antlr - How to lex 0 .. 255? -


I want to accept a decimal number from 0 to 255. This is the best I can come up with:

 Piece my_token: ('0' .. '9'). // 0 -> 9 ('1' .. '9' '0' .. '9'). // 0 -> 99 ('1' '0' .. '9' '0' .. '9'). // 100-> 199 ('2' '0' .. '4' '0' .. '9'). // 200 -> 24 9 ('25' '0' .. '5'); // 250 -> 255 

But Surelry is a better way I am just an NGN00b?

If you lexer relax and defer later check Lex NUMBER , then when If you convert it later, the value is out of bounds, you can provide a very specific error message if you enter a strong and powerful 256 error message, which results in any ambiguity for the first Grammar has not been created.

  Number: '0' .. '9';  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

jquery - SimpleModal Confirm fails to submit form -