[antlr-interest] rules for ASCII
Ric Klaren
klaren at cs.utwente.nl
Mon Jun 23 02:51:04 PDT 2003
On Sun, Jun 22, 2003 at 09:54:19PM +0200, berserksangr wrote:
> In my parser created for c++, I need to parse a file that contains
> some national signs. They have ASCII codes, i.e. 161, 198, 202, 163. How can
> I write a lexer rule for accepting only chains made of this signs?
>
> NATIONAL_CHAIN: (SIGN_161|SIGN_198|SIGN_202|SIGN_163)+;
>
> My question can be treat more generally: What are the relations
> between ASCII code and its ANTLR grammar representation in C++
> ANTLR-related code?
Directly one on one. so 161 -> '\241', 198 -> '\306', 202 -> '\312' and 163
-> '\243'.
NATIONAL_CHAIN: ('\241'|'\306'|'\312'|'\243')+;
Cheers,
Ric
PS those are technically not ASCII but extended ASCII (or what it's called)
--
-----+++++*****************************************************+++++++++-------
---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893722 ----
-----+++++*****************************************************+++++++++-------
Wo das Chaos auf die Ordnung trifft, gewinnt meist das Chaos, weil es
besser organisiert ist. --- Friedrich Nietzsche
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list