[antlr-interest] ANTLR3.0b3, options filter=true, why actions
are not executed ?
David CROSSON
david.crosson at wanadoo.fr
Wed Aug 2 07:12:38 PDT 2006
So when I turn off filtering, actions are executed, but I was also
wondering why in the following code, the action which prints
"INSIDE" is only executed once although the DATA token appears
three times : ( DATA {System.out.println("INSIDE"); } )* {System.out.println("OUTSIDE"); }
A small test grammar, and a junit test :
//-----------------------------------------------------------------
grammar TryIt2Parser;
options {
filter=true;
output=AST;
}
go : (DATA {System.out.println("INSIDE"); })* {System.out.println("OUTSIDE"); }
;
DATA : 'DATA'
;
WS : ' ' | '\t' {channel=99;}
;
//-----------------------------------------------------------------
import junit.framework.*;
import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.CharStream;
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.RecognitionException;
import stackdumpparser.parsers.TryIt2Parser;
import stackdumpparser.parsers.TryIt2ParserLexer;
import stackdumpparser.parsers.TryItParser;
import stackdumpparser.parsers.TryItParserLexer;
public class AntlrTryItTest extends TestCase {
public AntlrTryItTest(String testName) {
super(testName);
}
protected void setUp() throws Exception {
}
protected void tearDown() throws Exception {
}
public void testActionExcecution() throws RecognitionException, InterruptedException {
CharStream in = new ANTLRStringStream("DATA DATA DATA");
TryIt2ParserLexer lexer = new TryIt2ParserLexer(in);
CommonTokenStream tokens = new CommonTokenStream(lexer);
TryIt2Parser parser = new TryIt2Parser(tokens);
parser.go();
}
}
//-----------------------------------------------------------------
regards,
David Crosson.
More information about the antlr-interest
mailing list