[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem with sablecc4.beta2



We have a problem with the new beta version of sablecc with the following rules (also attached to message).
The parser throws a ParserException:

Exception in thread "main" language_testcase.ParserException: unexpected token '  IDENTIFICATION
 ' on line 1, pos 1
    at language_testcase.L_0.getTarget(Parser.java:151)
    at language_testcase.Parser.shift(Parser.java:51)
    at language_testcase.L_0.apply(Parser.java:132)
    at language_testcase.Parser.parse(Parser.java:22)
    at TestCase.main(TestCase.java:13)

But if we remove the token "line" and its references, the problem disappears.

Note that the same grammar adapted to version 3.2 of sablecc produces the same behaviour.

What erroneous rule are we setting that causes this problem?. What can we do to make sablecc to take the tokens "tag_identification" and "ignorable" instead of "line" token.

-----------------------------------------------------------------------------------------------

The grammar rules:

Language testcase;

Lexer

   unicode_input_character = #0..#xffff;
   tb  = #x0009;
   lf  = #x000a;
   cr  = #x000d;
   sp  = ' ';

   tag_identification = 'IDENTIFICATION';
   line = (#x0000..#xffff)* cr? lf;
     
   ignorable = (sp | cr | lf | tb)+;

Token
   tag_identification,
   line;
       
Ignored
   ignorable;
     
Priority

   line > ignorable;

Parser

  source =
    identification;
   
  identification =
    tag_identification;




 The test case source file:

  IDENTIFICATION
 

The java Walker:

 
import java.io.FileReader;

import language_testcase.Node;
import language_testcase.Parser;
import language_testcase.Walker;

public class TestCase extends Walker
{
  public static void main(String args[]) throws Exception
  {
    TestCase tc = new TestCase();
    Parser parser = new Parser(new FileReader(args[0]));
    Node ast = parser.parse();
          
    ast.apply(tc);
        
  }
}

Attachment: testcase.sablecc
Description: Binary data

Attachment: example.testcase
Description: Binary data

Attachment: TestCase.java
Description: Binary data