Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static rule creates broken parser #29

Open
akirschbaum opened this issue May 30, 2015 · 1 comment
Open

Static rule creates broken parser #29

akirschbaum opened this issue May 30, 2015 · 1 comment
Assignees
Labels

Comments

@akirschbaum
Copy link

A rule that is declared "static" causes a "java.lang.VerifyError" during parser generation. Instead Grappa should either support this or else should generate a proper error message.

$ gradle
:compileJava
Download http://repo1.maven.org/maven2/com/github/fge/grappa/2.0.0/grappa-2.0.0.jar
:processResources UP-TO-DATE
:classes
:run
Exception in thread "main" java.lang.VerifyError: Bad local variable type
Exception Details:
  Location:
    app/Main$Parser$$grappa.rule()Lcom/github/fge/grappa/rules/Rule; @0: aload_0
  Reason:
    Type top (current frame, locals[0]) is not assignable to reference type
  Current Frame:
    bci: @0
    flags: { }
    locals: { }
    stack: { }
  Bytecode:
    0x0000000: 2ab4 01a1 59c6 0004 b057 bb00 3059 b700
    0x0000010: 3459 2a5f b501 a12a b701 a359 c600 0b13
    0x0000020: 01a4 b900 4702 005a c000 49b6 004d 592a
    0x0000030: 5fb5 01a1 b0
  Stackmap Table:
    same_locals_1_stack_item_frame(@9,Object[#67])
    full_frame(@39,{},{Object[#48],Object[#67]})

        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Class.java:2663)
        at java.lang.Class.getConstructors(Class.java:1643)
        at com.github.fge.grappa.Grappa.findConstructor(Grappa.java:111)
        at com.github.fge.grappa.Grappa.createParser(Grappa.java:67)
        at app.Main.main(Main.java:12)
:run FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> Process 'command '/usr/local/java/64/jdk1.8.0_31/bin/java'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 7.967 secs
$ cat build.gradle
defaultTasks 'run'

apply plugin: 'application'
apply plugin: 'java'

sourceCompatibility = 1.8
mainClassName = 'app.Main'

dependencies {
    compile 'com.github.fge:grappa:2.0.0'
}

repositories {
    mavenCentral()
}
$ cat src/main/java/app/Main.java
package app;

import com.github.fge.grappa.Grappa;
import com.github.fge.grappa.buffers.CharSequenceInputBuffer;
import com.github.fge.grappa.parsers.BaseParser;
import com.github.fge.grappa.rules.Rule;
import com.github.fge.grappa.run.ListeningParseRunner;

public class Main {

    public static void main(final String[] args) {
        new ListeningParseRunner<>(Grappa.createParser(Parser.class).rule()).run(new CharSequenceInputBuffer("a"));
    }

    public static class Parser extends BaseParser<Object> {

        public static Rule rule() {
            return ANY;
        }

    }

}
@fge
Copy link
Owner

fge commented May 30, 2015

Uuh... OK, fair point.

This is the first usage ever I have seen of static rules to be honest :)

@fge fge self-assigned this May 30, 2015
@fge fge added the bug label May 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants