Groovy
  1. Groovy
  2. GROOVY-2318

Lexer fails on forward slash used in division

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1-rc-2
    • Fix Version/s: None
    • Component/s: lexer
    • Labels:
      None
    • Environment:
      OS X Tiger 10.4.11

      Description

      This simple test is failing (I have groovy-all on classpath):

      import groovyjarjarantlr.*;
      import java.io.*;
      import org.codehaus.groovy.antlr.parser.GroovyLexer;
      public class Main {
          public static void main(String[] args) throws TokenStreamException {
              String exp = "println 4 / 2 + 3";
              InputStream inputStream = new ByteArrayInputStream(exp.getBytes());
              GroovyLexer lexer = new GroovyLexer(inputStream);
              while (true) {
                  Token token = lexer.nextToken();
                  if (token.getType() == Token.EOF_TYPE) return;
                  System.out.println("token = " + token);
              }
          }
      }
      

      with error:

      token = ["println",<84>,line=1,col=1]
      token = ["4",<194>,line=1,col=9]
      Exception in thread "main" line 1:18: unexpected char: 0xFFFF
              at org.codehaus.groovy.antlr.parser.GroovyLexer.nextToken(GroovyLexer.java:687)
              at Main.main(Main.java:14)
      Java Result: 1
      

      If I replace '/' character with '*' or something else it works fine.

        Activity

        Mark Thomas made changes -
        Workflow jira [ 12969524 ] Default workflow, editable Closed status [ 12977275 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12731384 ] Default workflow, editable Closed status [ 12743304 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Jochen Theodorou made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Resolution Fixed [ 1 ]
        Assignee Jochen Theodorou [ blackdrag ] Roshan Dawrani [ roshandawrani ]
        Paul King made changes -
        Field Original Value New Value
        Description This simple test is failing (I have groovy-all on classpath):

        import groovyjarjarantlr.*;
        import java.io.*;
        import org.codehaus.groovy.antlr.parser.GroovyLexer;
        public class Main {
            public static void main(String[] args) throws TokenStreamException {
                String exp = "println 4 / 2 + 3";
                InputStream inputStream = new ByteArrayInputStream(exp.getBytes());
                GroovyLexer lexer = new GroovyLexer(inputStream);
                while (true) {
                    Token token = lexer.nextToken();
                    if (token.getType() == Token.EOF_TYPE) return;
                    System.out.println("token = " + token);
                }
            }
        }

        with error:

        token = ["println",<84>,line=1,col=1]
        token = ["4",<194>,line=1,col=9]
        Exception in thread "main" line 1:18: unexpected char: 0xFFFF
                at org.codehaus.groovy.antlr.parser.GroovyLexer.nextToken(GroovyLexer.java:687)
                at Main.main(Main.java:14)
        Java Result: 1

        If I replace '/' character with '*' or something else it works fine.
        This simple test is failing (I have groovy-all on classpath):

        {code}
        import groovyjarjarantlr.*;
        import java.io.*;
        import org.codehaus.groovy.antlr.parser.GroovyLexer;
        public class Main {
            public static void main(String[] args) throws TokenStreamException {
                String exp = "println 4 / 2 + 3";
                InputStream inputStream = new ByteArrayInputStream(exp.getBytes());
                GroovyLexer lexer = new GroovyLexer(inputStream);
                while (true) {
                    Token token = lexer.nextToken();
                    if (token.getType() == Token.EOF_TYPE) return;
                    System.out.println("token = " + token);
                }
            }
        }
        {code}

        with error:

        {code}
        token = ["println",<84>,line=1,col=1]
        token = ["4",<194>,line=1,col=9]
        Exception in thread "main" line 1:18: unexpected char: 0xFFFF
                at org.codehaus.groovy.antlr.parser.GroovyLexer.nextToken(GroovyLexer.java:687)
                at Main.main(Main.java:14)
        Java Result: 1
        {code}

        If I replace '/' character with '*' or something else it works fine.
        Martin Adamek created issue -

          People

          • Assignee:
            Roshan Dawrani
            Reporter:
            Martin Adamek
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development