This has been covered in previous discussions (use the search), but basically
you create tokens that look for dates using code that is sensitive to the
locale, which leaves you with a single lexer with a code based match rather
than pattern based match.
DATE : '#' // Assuming that you delimit the dates somehow
{
setText(myDateFunctionThatReturnsString());
}
'#'
;
There are other approaches than returning the string but you should get the
picture?
Jim
From: [email protected]
[mailto:[email protected]] On Behalf Of Parambir Singh
Sent: Tuesday, October 20, 2009 7:06 PM
To: [email protected]
Subject: [antlr-interest] Using multiple grammars with a single parser
Hi
I am working on a project where I want to parse input in different locales
(e.g. english, french & german dates). I don't want to create multiple parsers,
since the semantics of the grammar don't change between locales. So probably
I'll need multiple lexers and a single parser. Moreover, I want to specify a
locale to the parser and the input should be matched against only that
particular locale (e.g. german dates should be invalid in english locale).
What would be the best approach to construct such a parser using ANTLR. I don't
have much experience with ANTLR but I read about grammar inheritance and think
it could be useful here.
Thanks
Param
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address