Parsing dates/tenors in ANTLR
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Dave_Davies
Posted On:   Tuesday, February 26, 2002 06:35 AM

I need to parse a statement of the form: from '0d' to '23-aug-2003' or from '0d' to '1y' Where 0d, 1y etc are tenors and anything else should be a date . This is part of a (simple) language that also contains integer/float constants if statements, function calls etc, but in the ways I have tried so far, I keep getting conflicts between the int/float and the tenor, or I can parse a tenor, but not a date. I think I've just gone down the wrong path and can't think my way out of it (it doesn't help that I haven't really done this before), so any help would be greatly appreciated.    More>>

I need to parse a statement of the form:

			
from '0d' to '23-aug-2003'

or
			
from '0d' to '1y'

Where 0d, 1y etc are tenors and anything else should be a date .
This is part of a (simple) language that also contains integer/float constants if statements, function calls etc, but in the ways I have tried
so far, I keep getting conflicts between the int/float and the tenor, or I can parse a tenor, but not a date.
I think I've just gone down the wrong path and can't think my way out of it (it doesn't help that I haven't
really done this before), so any help would be greatly appreciated.    <<Less

Re: Parsing dates/tenors in ANTLR

Posted By:   Monty_Zukowski  
Posted On:   Wednesday, February 27, 2002 06:19 AM

Think about how you would do this by hand to get an idea of how you might best do this with antlr. How do you know if something is a tenor or date? Looks like both can have numbers and letters. Most likely the same lexer rule will have to handle both because of the common prefix. In that rule you will explicitly set the type based on the format. See, for instance, the NUM_INT rule in the example java grammar.
About | Sitemap | Contact