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

Cannot parse "iggy.json" correctly? #15

Open
paulzfm opened this issue Sep 19, 2019 · 0 comments
Open

Cannot parse "iggy.json" correctly? #15

paulzfm opened this issue Sep 19, 2019 · 0 comments

Comments

@paulzfm
Copy link

paulzfm commented Sep 19, 2019

Hi, I am planning to use your iguana parser to perform GLL parsing. I download the latest commit (5b7dce5) in master branch and build a jar (ignoring all test cases).

However, I have no idea how the CLI works (it seems only .json grammars are supported?), so I read the tutorial in this link and write my own test code (I have added a new file Main.java):

package org.iguana;

import org.iguana.grammar.Grammar;
import org.iguana.iggy.IggyParser;

import java.io.IOException;

public class Main {
    public static void main(String[] args) {
        try {
            Grammar g = IggyParser.getGrammar(PATH_TO_Simple.iggy); // Main.java:11
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

I create a iggy grammar file "Simple.iggy" according to the tutorial:

A ::= A 'a' 
   |  'a'

However, the program crashes:

Exception in thread "main" java.lang.RuntimeException: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "category" (class org.iguana.grammar.symbol.Terminal$Builder), not marked as ignorable (9 known properties: "label", "regex", "postConditions", "name", "nodeType", "object", "terminalPostConditions", "preConditions", "terminalPreConditions"])
 at [Source: (String)"{"kind":"Rule","head":{"kind":"Nonterminal","name":"Symbol","parameters":["p"]},"body":[{"kind":"Terminal","name":"ignore","category":"Keyword","regex":{"kind":"Seq","symbols":[{"kind":"Char","val":105},{"kind":"Char","val":103},{"kind":"Char","val":110},{"kind":"Char","val":111},{"kind":"Char","val":114},{"kind":"Char","val":101}]}},{"kind":"Nonterminal","name":"Layout"},{"kind":"Nonterminal","name":"Symbol","variable":"r","arguments":[{"kind":"Integer","value":3}]},{"kind":"Return","name":"{(r"[truncated 397 chars]; line: 1, column: 136] (through reference chain: org.iguana.grammar.symbol.Rule$Builder["body"]->java.util.ArrayList[0]->org.iguana.grammar.symbol.Terminal$Builder["category"])
	at org.iguana.iggy.IggyParser.iggyGrammar(IggyParser.java:29)
	at org.iguana.iggy.IggyParser.getGrammar(IggyParser.java:47)
	at org.iguana.Main.main(Main.java:11)
Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "category" (class org.iguana.grammar.symbol.Terminal$Builder), not marked as ignorable (9 known properties: "label", "regex", "postConditions", "name", "nodeType", "object", "terminalPostConditions", "preConditions", "terminalPreConditions"])
 at [Source: (String)"{"kind":"Rule","head":{"kind":"Nonterminal","name":"Symbol","parameters":["p"]},"body":[{"kind":"Terminal","name":"ignore","category":"Keyword","regex":{"kind":"Seq","symbols":[{"kind":"Char","val":105},{"kind":"Char","val":103},{"kind":"Char","val":110},{"kind":"Char","val":111},{"kind":"Char","val":114},{"kind":"Char","val":101}]}},{"kind":"Nonterminal","name":"Layout"},{"kind":"Nonterminal","name":"Symbol","variable":"r","arguments":[{"kind":"Integer","value":3}]},{"kind":"Return","name":"{(r"[truncated 397 chars]; line: 1, column: 136] (through reference chain: org.iguana.grammar.symbol.Rule$Builder["body"]->java.util.ArrayList[0]->org.iguana.grammar.symbol.Terminal$Builder["category"])
	at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:61)
	at com.fasterxml.jackson.databind.DeserializationContext.handleUnknownProperty(DeserializationContext.java:823)
	at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:1153)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1589)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1567)
// and so on

I tried to browse the code and I guess the problem is caused by a failure in parsing the json file IggyParser.class.getResourceAsStream("/iggy.json"), in file iguana/src/org/iguana/iggy/IggyParser.java.

I have no idea if I did the right thing to build a parser (for some customized grammar) using iguana? Or do you have clearer documents explaining the usage?

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant