dcsimg
How to implement flex's (...)?{1,n} construct ?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Alex_Ch
Posted On:   Monday, May 7, 2001 04:43 AM

Is there a simple way to realise lexer rule, which will match only given range of times?
In my case, I should recognise the numbers, which have 1--3 digits (but not more).

Thanks in advance
Alex

Re: How to implement flex's (...)?{1,n} construct ?

Posted By:   Terence_Parr  
Posted On:   Monday, May 7, 2001 10:55 PM

ANTLR currently does not have a {1,n} operator just ?, +, *. It is somewhat of a pain, but I usually just check the count during the semantic analysis or translation phase.



There is always a trade-off between how strict your grammar is, how easy it is to write, and how much work you have to do afterwards. For example, to parse C++ you usually are very loose in the parser and very strict in the analysis phase.
About | Sitemap | Contact