Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » mismatched input 'JaFirHug' expecting RULE_NAME(mismatched input 'JaFirHug' expecting RULE_NAME)
mismatched input 'JaFirHug' expecting RULE_NAME [message #1764831] Fri, 02 June 2017 14:05 Go to next message
Olaf Bigalk is currently offline Olaf BigalkFriend
Messages: 155
Registered: July 2009
Location: Berlin
Senior Member
I have the followind DSL definition:

fragment Personenname:
	sex=Sex anrede=Anrede? (titelList+=NAME '.')* (firstName+=Vornamen ('und' firstName+=Vornamen)?) adelsList+=LOWERNAME* lastName=Nachname
;

fragment Adresse:
	(adress=Adress | "bei" personRef=[Person|PID])
	(email=EMAIL) ?
;

Person:
	(
		('Firma' firma=Firmenname Personenname? name=PID
		Adresse
		(note=STRING)?)
	|
		('Person' Personenname name=PID
		Adresse
		(note=STRING)?)
		(jogger=Jogger)?
	) 
;

Adress:
	plz=PLZ city=CityName
	street=STRING
;

Vornamen:
	NAME (('-'|'+') NAME)*;

Nachname:
	NAME ((('-'|'+') NAME) | (E NAME))*;

PID:
	NAME NAME NAME
;

Firmenname:
	(LOWERNAME|NAME  (('+')? NAME)* (('+'|'&') Firmenform)*);

Firmenform:
	"gGbmH" | "GmbH" | "OHG" | "AG"  | "Co" | "KG"
;

CityName:
	(NAME '.')? NAME (('-'|'+') NAME)* ('/' NAME '.'?)?;

ACCOUNT:
	NAME (('_'|"."|"+") NAME)*
;

SITE:
	LOWERNAME ('.' LOWERNAME)+
;

EMAIL:
	ACCOUNT '@' SITE
;

terminal E:
	'e'
;

terminal PLZ:
	(('A'..'Z')+ "-")? '0'..'9' '0'..'9' '0'..'9' '0'..'9' ('0'..'9')?;

enum Anrede:
	 sie | du ;

Sex:
	"D&H" | "Mann" |  "Frau"| "Ehe"| "Familie" ;

terminal LOWERNAME:
	('a'..'z' | 'ß'..'ö' | 'ø'..'ý' | 'ÿ')+;

terminal UPPERNAME:
	('A'..'Z' | 'À'..'Ö' | 'Ø'..'Ý');

terminal NAME:
	UPPERNAME (LOWERNAME | '-')*;



And I have the following DSL text:

Firma Hugo+Boss+AG JaFirHug
99999 Nirgendwo
"Straße 99999"


And I get the error "mismatched input 'JaFirHug' expecting RULE_NAME".
I expected that 'JaFirHug' would be matched as name=PID in Person.
Why it does not ?

Thanks for an answer.
Re: mismatched input 'JaFirHug' expecting RULE_NAME [message #1764842 is a reply to message #1764831] Fri, 02 June 2017 14:57 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
JaFirHug is lexed as an ID not a NAME
you may override it with something like

	
@Override 
terminal ID: "@@@@@@@@@@@@@"; //something unlikely

or copy & paste the other rules from terminals and dont imherit from terminals
(modifying the lexer like the following helps to show this)

public class InternalMyDslLexer extends Lexer {
   
	@Override
	public Token nextToken() {
		Token token = super.nextToken();
		System.out.println(token);
		return token;
	}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Interfaces and classes / types are proposed where only interfaces should be proposed
Next Topic:Internal language parser is not found in xtext project
Goto Forum:
  


Current Time: Fri Mar 29 04:41:01 GMT 2024

Powered by FUDForum. Page generated in 0.05919 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top