Terminal Rule Bug? [message #804089] |
Wed, 22 February 2012 07:21 |
Heinz Huber Messages: 45 Registered: February 2012 |
Member |
|
|
Hi,
i'm trying to build my own language which will parse my Configuration Files.
Everything went fine, but now i stuck.
My Configuration Files got different Names for Clients in the network. I started to write checks (terminals) to approve that these conventions are okay.
The Clients got Names in the following formats:
Test_L_1_Sender
Test_Testclient_Sender
Statustest_Sender
TEST01_Sender
NULL_Sender
ABC_to_TEST2
My first Idea was to create a terminal rule like the following one:
terminal SENDERNAME:
('a'..'z'|'A'..'Z'|'_'|'0'..'9')+
;
Here i got the following Error "The following token definitions can never be matched because prior tokens match the same input: RULE_INT". Changing '0'..'9' into INT doesn't make it better.
After a long time with my best friend Google i found the Information, that terminal rules aren't as good as they seem. So i created a "normal" rule like the following:
SenderName:
(BUCHUNTER|INT)+
;
terminal BUCHUNTER:
('a'..'z'|'A'..'Z'|'_')+
;
This one works better, but he is expecting a number now oO
Names without a number work very fine ... but at the moment i add a number to my Name a error shows up again! The Error which is created in the editor plugin is the following: "required (...)+ loop did not match anything at input 'Test_L_1_Sender'"! Changing (BUCHUNTER|INT)+ to (INT|BUCHUNTER)+ in the rule doesn't change the situation.
I don't really know how i can locate the problem, so i can fix this!
The following Code is the way i used the rule/terminal. Maybe this is my mistake?
'Name' '=' name=SenderName
Hope someone can help!
[Updated on: Wed, 22 February 2012 07:29] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Terminal Rule Bug? [message #804552 is a reply to message #804347] |
Wed, 22 February 2012 19:14 |
Alexander Nittka Messages: 1193 Registered: July 2009 |
Senior Member |
|
|
Hi,
there are some nasty details about the names in your grammar. As already noted, most of your terminals overlap which causes the problem. Also, CONNECTION contains the # which marks the start of a single line comment, not very nice.
Test.Listener reuses the keyword Listener, a similar problem you will have with the single character keywords a, m, t etc.
Most urgent is the definition of a CONNECTION. Is it always "\{something\}" or is it just the example?
Are spaces allowed between the + and Listener at the beginning of a Listener? Usually I am all for splitting up keywords, but for you to get started '+Listener', '+Sender', '+QueueAddress' might be an option (otherwise you will have problems using Listener within a name; you will have to enumerate every keyword allowed in datatype rule like QueueName). Currently, I would suggest the following grammar to start with.
Model:
(elements += AbstractElement)*
;
AbstractElement:
Listener|Sender
;
Listener:
'+Listener' '%'
'Name' '=' name=ID
insert=Queueaddress
'-'
;
Sender:
'+Sender' '%'
'Name' '=' name=ID
('IgnoreQueueFull' '=' (ignoreQueueFull?='true' | 'false'))?
insert=Queueaddress
'-'
;
Queueaddress:
'+QueueAddress'
'Class' '=' class=ID
('+Connection'
'a' '=' a = Connection
'm' '=' m = Connection
't' '=' t = Connection
'h' '=' h = Connection
'p' '=' p = Connection
'c' '=' c = Connection
'-')? '+Queue'
('n' '=' n = QueueName)?
'-''-'
;
QueueName:
(ID|'.'|INT)+
;
terminal Connection: '\\{'->'\\}';
terminal SL_COMMENT :
'#' !('\n'|'\r')* ('\r'? '\n')?;
terminal ML_COMMENT:
'*' -> '*'
;
|
|
|
|
Re: Terminal Rule Bug? [message #808215 is a reply to message #804951] |
Mon, 27 February 2012 14:42 |
Heinz Huber Messages: 45 Registered: February 2012 |
Member |
|
|
Hi Guys,
the past days i got no problems while working on my project.
It is nearly finished now, but i found another problem.
In my configuration files it is necessary to have elements like "+Name". Name could be anything which is included in the terminal ID. (A-Z, a-z, _, 0-9). My first idea was to just do the following:
Destination:
'+'name=ID
'Sender' '=' sender=[Sender|ID]
'-'
;
Now he is expecting a whitespace between + and the specific name. But i don't really know why!
My next idea was to create a rule for this like the following one:
DestinationName:
'+' ID+;
This rule isn't solving my problem, too. I tried everything i could imagin, but nothing helped. The error messages are like: "Multiple markers at this line
- no viable alternative at character 'F' - mismatched input 'AFC' expecting '-'". And when i'm adding the whitespace between the + and the Name, the error is gone! But this kind of Tags isn't possible for my language.
The interesting thing about all this is, that there are 2 words which are correct (without the whitespace) for the parser. These ones are: "W*" (* stands for any possible insertion) and "Uninteresting". All other names are wrong!
Does anyone has a idea where the problem is?
I just want to create Elements like:
+Test
+Element
+Name
+Hello
+Whatever
Thanks in advance for helping me again ...
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03828 seconds