|
|
ParCinJParCinJ is a Java™ library for constructing parsers. It stands for Parser Constructor in Java.
(a, b, (c1, c2, ()), d)In an EBNF-like grammar language (like ANTLR) you would write
list: '(' (element (',' element)*)? ')';
element: ATOM | list;
With ParCinJ's fluent interface API you write following Java code:
NonTerminalSymbol<P> list = new NonTerminalSymbol<P>("list")
NonTerminalSymbol<P> element = new NonTerminalSymbol<P>("element");
TerminalSymbol<P> atom = new TerminalSymbolByType<P>(NormalToken.NORMAL_TOKEN);
TerminalSymbol<P> open = new TerminalSymbolByText<P>("(");
TerminalSymbol<P> comma = new TerminalSymbolByText<P>(",");
TerminalSymbol<P> close = new TerminalSymbolByText<P>(")");
list.definedBy(open
.followedBy(element.followedBy(comma.followedBy(element).zeroOrMoreTimes()).optional())
.followedBy(close));
element.definedBy(atom.or(list));
and
are classes implementing the interface .
It provides the method process which does the actual parsing.
To do the job it needs a
and a .
The TokenIterator is provided by a
which turns a stream of
characters into a stream of .
Processor is only a marker interface of classes which implement
particular methods for processing Tokens in certain steps of the
parsing process. All symbols are generic classes for a particular processor.
For details see the User Guide or study the examples
in ParCinJ 0.7This is a major release from 7/3/2009.
ParCinJ 0.6This is a major release from 5/5/2009.
ParCinJ 0.5This is the initial release from 4/21/2009. |
|
(C) 2009 Franz-Josef Elmer. All rights reserved. Last modified: 2009-07-03 |
|