Can I write a rule where the initial token is partly fixed and partly generic?
rule: ID '=' NUMBER
;
ID: (A.. Z | a.. Z) +
NUMBER: (0 .. 9) +
But only if the token ID is in the form var* (var is fixed)
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Do you mean this?
Either way: when possible, do NOT use a strict lexer grammar for your error messages. They are slower and completely illegible to users. You should parse
IDin a relaxed form, then check later on if it’s in precisely the correct form.