Coder Social home page Coder Social logo

growdy's People

Contributors

redferret avatar

Watchers

 avatar  avatar

growdy's Issues

Implement GRowdy

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

Write Unit tests for all the current objects, GRBuilder, and GRowdy

Star and OR option for trimming nonterminals

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 Parse Tree

  • 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()

Build out the Grammar

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.