[antlr-interest] Simple questions

Matthew Ford Matthew.Ford at forward.com.au
Sun Feb 24 09:39:22 PST 2002


----- Original Message -----
From: "elimesika" <elim at tti-telecom.com>
To: <antlr-interest at yahoogroups.com>
Sent: Monday, February 25, 2002 3:29 AM
Subject: [antlr-interest] Simple questions


> HI
>
> I have two simple questions:
>
> 1) my grammer should recognize the char '!', I have a "connect!"
> command that I should identify. I have tried to define it in the
> Tokens area :
>
> tokens {
> CONNECT = "connect!";
> }
>
> and got a run time error.
> Writing
> tokens {
> CONNECT = "connect\!";
> }
> gives an antlr compilation error.
> I am using (in the Lexer option section):
> charVocabulary = '\3'..'\377';
> How can I handle that ???

options {
 exportVocab=GAUSS_AD_LEXER;      // call the vocabulary "Gauss"
 caseSensitiveLiterals=false;
 caseSensitive=false;
 charVocabulary = '\3'..'\377';
 testLiterals=false;    // don't automatically test for literals
 k=4;                   // four characters of lookahead

}

tokens {
  IF = "if!";
  DLLCALL = "dllcall!";
}

works for me

>
> 2) I am reading a file written in a certain language.
>    I have to recognize only a subset of the language, but I want to
> keep the statements that I am not recognizing.
> I have tried to use the filter option and an IGNORE rule :
>
> options {
> k=2;
> filter=IGNORE;
> charVocabulary = '\3'..'\377';
> }
>
> protected
> IGNORE
> : c:.
> {System.out.println(c);}
> ;
>
> I don't get any printing when I type things that the parser don't
> recognize.
> Does anybody knows what's the problem or have a better way to do that?
>
> TIA
>      Eli
>

Have a look at the generated code to see what is happening.

You seem to trying to IGNORE every thing (.)

also try
{
 String text = $getText;
System.out.println(text);
}
 and
{System.out.println($getText);}
  might (should!) also work also

matthew

>
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list