Backward Compatibility

81 views
Skip to first unread message

Byungjun Yu

unread,
Jul 4, 2013, 9:27:31 PM7/4/13
to antlr-di...@googlegroups.com

Hi

Are there any references I can look up for translating ANTLR 3.X grammar to 4.X grammar?

I'm trying to modify an existing grammar, which was written by ANTLR 3.3, to comply with ANTLR 4.1.

And when I compile the grammar(ANTLR 3.3) with ANTLR 4.1, there are lots of errors and warning.

Thanks, BJ.

Jim Idle

unread,
Jul 4, 2013, 11:10:07 PM7/4/13
to antlr-di...@googlegroups.com
Just start by taking out all the syntactic predicates. It should pretty much just work at that point. 

So:

(rule)=>rule      change to just rule

(TOKEN)=>TOKEN     change to token

See how many errors you have left after that.

Jim


--
You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussi...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Byungjun Yu

unread,
Jul 4, 2013, 11:46:01 PM7/4/13
to antlr-di...@googlegroups.com
Thank you for reply.

Though, after removing all the syntactic predicates, there are still some errors. 

Below are examples.
e.g. 
error message: 
action in lexer rule 'PP_EQUALITY_EXPRESSION' must be last element of single outermost alt.

related grammar:
fragment
PP_PRIMARY_EXPRESSION:
IDENTIFIER
Returns.Push(MacroDefines.ContainsKey($IDENTIFIER.Text));
}
| '('   PP_EXPRESSION   ')'
;


error message:
redefinition of 'members' action 

related grammar:
@lexer::members {
// Preprocessor Data Structures - see lexer section below and PreProcessor.cs
protected Dictionary<string,string> MacroDefines = new Dictionary<string,string>();
protected Stack<bool> Processing = new Stack<bool>();

// Uggh, lexer rules don't return values, so use a stack to return values.
protected Stack<bool> Returns = new Stack<bool>();
}

@members
{
protected bool is_class_modifier() 
{
return false;
}
}


Thank you. 
BJ




2013년 7월 5일 금요일 오후 12시 10분 7초 UTC+9, Jim Idle 님의 말:
Reply all
Reply to author
Forward
0 new messages