redferret / growdy Goto Github PK
View Code? Open in Web Editor NEWGRowdy provides lexical analysis and compiles grammars into parse trees
License: BSD 3-Clause "New" or "Revised" License
GRowdy provides lexical analysis and compiles grammars into parse trees
License: BSD 3-Clause "New" or "Revised" License
Pull from Rowdy the test utils to help with testing the grammar
GRowdy should be able to load in a grammar resource and build/compile source files defined for the grammar. Deserialization of the GRBuilder to grab the resources and tables should be built out. This resource would be packaged inside the JAR file of the user's language/interpreter.
Write Unit tests for all the current objects, GRBuilder, and GRowdy
For a production rule => NonTerm_1* NonTerm_2 | NonTerm3*;
The OR should give ids to the groups so that if one group is built out the other groups aren't expanded. This will force the user to improvise though on how to handle two nonterminals expanding on the same terminal
For example given
NonTerminal(ID) => NonTerm_1* NonTerm_2 | NonTerm3*;
NonTerm_1(ID) =>// This one will always take the token ID starving NonTerm3
NonTerm3(ID) =>
The fix for this is not easy and will require new language changes
Implement the parse tree so that a grammar can be constructed as a GRBuilder object containing all the data for Language, RowdyLexer, and RowdyBuilder to create a parse tree.
For users to identify terminals and non-terminals GRowdyGrammar will generate a Java file containing all the constants such as BOOL_TERM
to identify nodes.
Output file would be named <Grammar name>GrammarConstants.java
public class <Grammar Name>GrammarConstants {
public static final int <List of constants>;
}
A simple example:
public class RowdyGrammarConstants {
public static final int
ID = 0,
CONST = 1,
BOOL_TERM = 100,
BOOL_TERM_TAIL = 101;
}
GRowdy offers build methods that wraps the RowdyLexer and RowdyBuilder. You can build using the path to the source file with the file name or build with a String of code.
Similar to the builder you can get the program which wraps RowdyBuilder's get program method. It's possible that the builder will merge with GRowdy to flatten these calls out to just one method call
GRowdy gr = GRowdy.build(nameOfGrammarResource);
gr.build(programFilePathWithFileName)
gr.buildLine(code)
gr.getProgram()
Below is the grammar for building grammars.
Add the non terminals and PRules
GR => ID GRAMMAR
GRAMMAR(LEFTCARET) => TERMINAL_BODY GRAMMAR_BODY
TERMINAL_BODY(LEFTCARET) => LEFTCARET TERMINAL RIGHTCARET TERMINAL_DEFS SPECIAL_DEF(CONST)
SPECIAL_DEF(LEFTCARET) => LEFTCARET SPECIAL RIGHTCARET CONST SEMICOLON
TERMINAL_DEFS(ID) => TERMINAL_DEF SEMICOLON TERMINAL_DEFS
TERMINAL_DEF(ID) => ID IS ATOMIC
ATOMIC(id constant CONST) => id | constant | CONST
GRAMMAR_BODY(LEFTCARET) => LEFTCARET BEGIN RIGHTCARET NONTERMINAL_DEFS
NONTERMINAL_DEFS(ID) => NONTERMINAL_DEF SEMICOLON NONTERMINAL_DEFS
OR_OPT(OR) => OR ID OR_OPT
ID_LIST(ID) => ID ID_LIST
NONTERMINAL_DEF(ID) => ID NONTERMINAL_PARAMS IS ID_LIST OR_OPT
NONTERMINAL_PARAMS(LEFTPAREN) => LEFTPAREN TERMINAL_PARAMS RIGHTPAREN
TERMINAL_PARAMS(ID) => ID TERMINAL_PARAMS
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.