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

Getting Started - TRGEN #479

Open
johnholliday opened this issue Aug 22, 2024 · 5 comments
Open

Getting Started - TRGEN #479

johnholliday opened this issue Aug 22, 2024 · 5 comments

Comments

@johnholliday
Copy link

Followed the installation instructions, but getting this...
TRGEN-2024-08-22_18-57-40

@kaby76
Copy link
Owner

kaby76 commented Aug 23, 2024

Grammars have to follow a few rules, otherwise the tool can't figure out what to do.

  • Antlr4 grammars should be in files with a .g4 extension.
  • Split grammars need to end with Lexer.g4 and Parser.g4. For example, JavaLexer.g4 and JavaParser.g4. The "grammar name" for this combined grammar is Java.
  • There must be one or two "top-level" .g4 files but no more. A top-level .g4 is processed by the Antlr tool. Imported .g4's are not processed by the Antlr tool on the command line.
  • If you don't have a desc.xml file, you will need to tell what target to generate. E.g. "trgen -t Java" or "trgen -t CSharp", etc.

Given that, what .g4's do you have? What are they named?

@johnholliday
Copy link
Author

@kaby76 There is no .g4 in this case. I'm following the documentation for trgen:

"If the current directory is empty, trgen will create a parser for the Arithmetic.g4 grammar."

md test
cd test
trgen

This should create a parser, correct?

@kaby76
Copy link
Owner

kaby76 commented Aug 23, 2024

Sorry. The doc is off slightly here. I changed this code. Instead of trgen, it should be trgen --arithmetic -t *target*. It will then create an arithmetic example.

@kaby76
Copy link
Owner

kaby76 commented Aug 23, 2024

BTW, I think the reason I changed this is because I would type trgen just to see the help message (to check what options are available), and end up getting a ton of files spewed in the directory that I was working in.

@johnholliday
Copy link
Author

johnholliday commented Aug 26, 2024 via email

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