This project is no longer maintained. It was mostly a experiment to begin with. While it is in a useable state the performance of generic recursive decent parsers is already bad, that ontop of java not being c doen't make this project viable (which it wasn't intended to be)
Jain parse is a lib to create your own parsers (and writers).
Its main features are
- Custom functional parser building
- Defining parsers as files
- Stream/OnDemand Parsing (Sockets/InputStreams)
- Tokenization using REGEX
- Model Autogeneration
Use Maven (or Gradle) and add this as dependency
<dependency>
<groupId>com.niton</groupId>
<artifactId>jainparse</artifactId>
<version>1.0.4</version>
</dependency>
- Token: a single character or multiple characters of the same type (Letters/Numbers)
- Grammar: The "rule/s" how a string should be parsed -> The structural description
These steps are in the order you are most likely to do when you create a parser
-
GrammarReference ref = new GrammarReferenceMap() .map( Grammar.build("Number") .token(DefaultToken.NUMBER).add("value") ) .map( Grammar.build("calc_expression") .token(DefaultToken.BRACKET_OPEN).add() .grammar("expression").add("firstExpression") .tokens(DefaultToken.STAR, DefaultToken.PLUS, DefaultToken.MINUS, DefaultToken.SLASH).matchAny().add("calculationType") .grammar("expression").add("secondExpression") .token(DefaultToken.BRACKET_CLOSED).add() ) .map( Grammar.build("expression") .grammars(new String[]{"Number", "calc_expression"}).matchAny().add("content") );
- Changing onGet - Generation of the autogen classes to - build on constructor