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

Unable to Build #1

Open
xhwhis opened this issue Sep 18, 2023 · 1 comment
Open

Unable to Build #1

xhwhis opened this issue Sep 18, 2023 · 1 comment

Comments

@xhwhis
Copy link

xhwhis commented Sep 18, 2023

I am really interested in this project. However, I'm having trouble understanding how to build it from source. Could you kindly guide me through the build process, or perhaps update the README with build instructions?

@sqmedeiros
Copy link
Owner

Hi, @xhwhis .

Thanks for the interest. I should warn you that the project is not mature enough to be used, as I'm still playing with some transformations.

First you need to install ANTLR, to generate a lexer and a parser from the files ANTLRv4Lexer.g4 and ANTLRv4Parser.g4. In my machine, I achieve this by typing the following commands in the terminal:

antlr4 ANTLRv4Lexer.g4
antlr4 ANTLRv4Parser.g4

Then you should compile all the .java files generated by ANTLR plus the files ANTLR2Peg.java and MainListener.java. I type this in the terminal:
javac *.java

Without some extra settings, you would probably get an error related to the Java Classpath. Something like this:
ANTLRv4Lexer.java:12: error: cannot find symbol

public class ANTLRv4Lexer extends LexerAdaptor {
                                  ^
  symbol: class LexerAdaptor
ANTLRv4Lexer.java:120: error: method does not override or implement a method from a supertype
	@Override
	^
ANTLRv4Lexer.java:126: error: method does not override or implement a method from a supertype
	@Override
	^
ANTLRv4Lexer.java:135: error: cannot find symbol
		_interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
		^
  symbol:   variable _interp
  location: class ANTLRv4Lexer
...
MainListener.java:24: error: incompatible types: ANTLRv4Lexer cannot be converted to TokenSource
    CommonTokenStream tokens = new CommonTokenStream(lexer);
                                                     ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
17 errors

I solved this issue by adding the subfolder ./Java, which has code related to the implementation of the lexer, to the CLASSPATH through the following command:
export CLASSPATH=$CLASSPATH:./Java

Now, if you try javac *.java everything should work.

Then, you can convert a .g4 file to a format that is recognized by the tool pegparser, which is based on Parsing Expression Grammars.

To convert the DOT.g4 grammar, we can type:
java MainListener grammars/dot/DOT.g4 > DOTPeg.lua

File DOTPeg.lua is Lua file with a PEG that is a naive translation of the ANTLR grammar plus some code to perform extra transformation onto this PEG in order to make the behavior the of PEG parser more similar to the ANTLR one.

So, you need to execute this Lua file. Now you should install Lua and some Lua libraries. After this, you should tyr:
lua DOTPeg.lua

Probably, you will get an error about some missing library. Please, tell me when you arrive at this point, so I can give you some help related to the installation of the Lua libraries.

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

2 participants