X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/24d84dd26c24a33adf1ae4ba245c53901507e650..3e75a2c92b12766add442d00a86d5ec1c67ce560:/tests/java.at diff --git a/tests/java.at b/tests/java.at index b3e79e9c..b6ea1636 100644 --- a/tests/java.at +++ b/tests/java.at @@ -781,3 +781,69 @@ AT_CHECK([[$EGREP -v ' */?\*' YYParser.java | grep 'Position']], [1], [ignore]) AT_CHECK([[$EGREP -v ' */?\*' YYParser.java | grep 'Location']], [1], [ignore]) AT_CLEANUP + + +# ----------------------------------------------- # +# Java syntax error handling without error token. # +# ----------------------------------------------- # + +AT_SETUP([Java syntax error handling without error token]) + +AT_DATA([[YYParser.y]], [[%language "Java" + +%lex-param { String s } + +%code imports { + import java.io.IOException; +} + +%code lexer { + String Input; + int Position; + + public YYLexer (String s) + { + Input = s; + Position = 0; + } + + public void yyerror (String s) + { + System.err.println (s); + } + + public Object getLVal () + { + return null; + } + + public int yylex () throws IOException + { + if (Position >= Input.length ()) + return EOF; + else + return Input.charAt (Position++); + } +} + +%code { + public static void main (String args []) throws IOException + { + YYParser p = new YYParser (args [0]); + p.parse (); + } +} +%% +input: + 'a' 'a' +; +]]) +AT_BISON_CHECK([[YYParser.y]]) +AT_JAVA_COMPILE([[YYParser.java]]) +AT_JAVA_PARSER_CHECK([[YYParser aa]], [[0]], [[]], [[]]) +AT_JAVA_PARSER_CHECK([[YYParser ab]], [[0]], [[]], [[syntax error +]]) +AT_JAVA_PARSER_CHECK([[YYParser ba]], [[0]], [[]], [[syntax error +]]) + +AT_CLEANUP