You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is Madhav from Bangalore, India. I am using ANTLR3-ObjC2.0-Runtime
library from the URL(https://github.com/muggins/ANTLR3-ObjC2.0-Runtime) for generating code in Objective-C. I needed your help to debug the problem i am facing which is explained below.
My input would be some thing like this:-
abc1 = new abc(100) // abc1 is an object of class abc...something like this
xyz22 = new xyz(30)
abc1
xyz22 and so on...
For this the grammar file looks like:-
/*****************************************************************************************************/
options{
output=AST;
language=ObjC;
ASTLabelType=CommonTree;
}
stat : ID {
NSString *v = [dict objectForKey:$ID.text];
NSLog(@"id=%@\n",v);
} |
ID '=' NEW WORD LPARN NUMBER RPARN NEWLINE
{
[dict setObject:$WORD.text forKey:$ID.text];
NSLog(@"new= \%@\n",$NEW.text);
NSLog(@"word= \%@\n",$WORD.text);
}
| NEWLINE
;
/*****************************************************************************************************/
For the above mentioned grammar and input file, build/compilation everything is success, but while i run i get something like:-
missing NEW at 'new' (even though there is new in the input)
and
extraneous input 'abc' expecting LPARN
So i needed help in debugging above statements and in the NSLog print iam getting new=(null) but i expect new=new and word=abc.
But strange aspect is, in the above grammar file if i re-order the lexer tokens by moving the NUMBER:'0'..'9'+ token to after the WORD token, everything works perfectly. This is really strange.
Please point the mistakes i am doing or is this a bug in the antlr3/library. Awaiting your response. Thank you.
The text was updated successfully, but these errors were encountered:
This is Madhav from Bangalore, India. I am using ANTLR3-ObjC2.0-Runtime
library from the URL(https://github.com/muggins/ANTLR3-ObjC2.0-Runtime) for generating code in Objective-C. I needed your help to debug the problem i am facing which is explained below.
My input would be some thing like this:-
abc1 = new abc(100) // abc1 is an object of class abc...something like this
xyz22 = new xyz(30)
abc1
xyz22 and so on...
For this the grammar file looks like:-
/*****************************************************************************************************/
options{
output=AST;
language=ObjC;
ASTLabelType=CommonTree;
}
@Header {
}
@lexer::header {
}
@members {
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
}
@memVars {
NSMutableDictionary *dict;
}
@init {
dict = [[NSMutableDictionary alloc] init];
}
prog: stat+;
stat : ID {
NSString *v = [dict objectForKey:$ID.text];
NSLog(@"id=%@\n",v);
} |
NEW : ('n''e''w');
NUMBER: '0'..'9'+;
WORD: ('a'..'z'| 'A'..'Z')+;
ID: ('a'..'z'| 'A'..'Z')+('0'..'9')+;
LPARN : '(';
RPARN : ')';
COMMA : ',';
NEWLINE:'\r'? '\n' ;
WS : (' ' | '\t') {$channel=HIDDEN;} ;
/*****************************************************************************************************/
For the above mentioned grammar and input file, build/compilation everything is success, but while i run i get something like:-
missing NEW at 'new' (even though there is new in the input)
and
extraneous input 'abc' expecting LPARN
So i needed help in debugging above statements and in the NSLog print iam getting new=(null) but i expect new=new and word=abc.
But strange aspect is, in the above grammar file if i re-order the lexer tokens by moving the NUMBER:'0'..'9'+ token to after the WORD token, everything works perfectly. This is really strange.
Please point the mistakes i am doing or is this a bug in the antlr3/library. Awaiting your response. Thank you.
The text was updated successfully, but these errors were encountered: