Dave Dutcher wrote: >> -----Original Message----- >> From: [email protected] >> >> The last line, b., doesn't match the MC_INCORRECT token >> because there's no newline after it. Is there an easy way to >> match this in ANTLR? > > > Do you need the newline in the text of the token? You could try removing > fragment from the NEWLINE rule and then setting it to the hidden channel. > Then have your lexer rules match everything except the new line characters.
That would remove the requirement that each thingy be on a separate line. You could consider various options. For one thing, I'm not sure you *really* want those to be huge lexer rules, rather than moving it up to the parsing stage. Then you could make newlines a separate rule but *don't* make them hidden, and account for them at parse-time. Otherwise, there's a non-antlr solution. Pre-cache the file (ie load it to a string buffer), check if the last character is a \n, if it isn't, append one. Then use a relevant reader to pass the buffer to the lexer, rather than the file. -- Sam Barnett-Cormack List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~----------~----~----~----~------~----~------~--~---
