|
Orbital library | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object orbital.moon.logic.LogicParser
public class LogicParser
It parses a concrete syntax (usually respecting the notation of symbols
).
This class implements a parser for logic and mathematical formulas that can be used
for every logic after being bound to it. This parser calls ExpressionBuilder
on every connection point (which specify the parser actions).
Most ExpressionBuilders will simply construct a tree of Expressions (usually Formulas)
whose implementation depends on the logic.
Although this distinction may sometimes sound artificial, we will - for the moment - distinguish three types of syntactic expressions:
This parser can be used by implementations of ExpressionSyntax. So there
is no need to interface with this parser directly. Instead, it
is sufficient to call the ExpressionSyntax.createExpression(String)
implementation of the specific logic - which could in turn invoke this parser.
ExpressionSyntax.createExpression(String)
,
parseFormula()
,
parseFormulas()
,
parseTerm()
Field Summary | |
---|---|
Token |
jj_nt
|
boolean |
lookingAhead
|
protected orbital.moon.logic.LogicParser.Scope |
root
The root scope, containing only the core signature. |
protected orbital.moon.logic.LogicParser.Scope |
scope
The current scope. |
protected ExpressionSyntax |
syntax
Delegate to the current syntax implementation that is used for building expressions. |
Token |
token
|
LogicParserTokenManager |
token_source
|
Fields inherited from interface orbital.moon.logic.LogicParserConstants |
---|
AND, BOX, DECIMAL_LITERAL, DECLARE_FREE, DEFAULT, DIAMOND, DIGIT, DIGIT_OR_ALIKE, DIVIDE, EOF, EOL, EQUAL, EQUIV, EXISTS, EXPONENT, FLOATING_POINT_LITERAL, FORALL, FORMAL_COMMENT, GREATER, GREATER_EQUAL, IDENTIFIER, IMPLY, INTEGER_LITERAL, LAMBDA, LESS, LESS_EQUAL, LETTER, MINUS, MULTI_LINE_COMMENT, NOT, OR, PI, PLUS, PRODUCT, SINGLE_LINE_COMMENT, STRING_LITERAL, TIMES, tokenImage, UNEQUAL, XOR |
Constructor Summary | |
---|---|
LogicParser(java.io.InputStream stream)
|
|
LogicParser(java.io.InputStream stream,
java.lang.String encoding)
|
|
LogicParser(LogicParserTokenManager tm)
|
|
LogicParser(java.io.Reader stream)
|
Method Summary | |
---|---|
Expression |
AndExpression()
|
protected Expression |
apply(Token optok,
Expression[] a,
Type reqResult)
n-ary predicates or functions. |
Expression[] |
Argument_list()
|
Expression[] |
Arguments()
|
protected Type |
asType(Expression f)
Converts an expression to the type it represents. |
Expression |
Atom()
A formula that is a logical atom. |
Expression |
AtomicTerm()
Parse an atomic term (function application, number or string) for the current logic. |
protected Expression |
combine(Token optok,
Expression[] a)
|
protected Expression |
combine(Token optok,
Symbol x,
Expression a)
quantifiers. |
Expression |
CompoundFormula()
Parse a compound predicate formula for the current logic. |
Expression |
CompoundTerm()
Parse a compound function term for the current logic. |
Expression |
CompoundType()
A compound type. |
Symbol |
ConstantOrVariable()
Parses a constant or a variable atomic term, depending upon known symbols in context. |
void |
disable_tracing()
|
void |
enable_tracing()
|
Expression |
EqualityExpression()
|
Expression |
EquivalenceExpression()
|
Expression |
ExclusiveOrExpression()
|
Expression |
expression()
Central expression parsing production. |
Expression |
FreeDeclarationExpression()
free scope "quantifier" A "quantifier" with a purely syntactic function of declaring a variable. |
ParseException |
generateParseException()
|
Token |
getNextToken()
|
Token |
getToken(int index)
|
Expression |
ImplicationExpression()
|
Expression |
InclusiveOrExpression()
|
Expression |
LambdaAbstraction()
λ-abstraction term. |
Expression |
LambdaAbstractionPredicate()
λ-abstraction predicate. |
Symbol |
LiteralValue()
atomic term literal value (in the sense of constant primitive type), f.ex. |
Expression |
MapType()
|
Expression |
ModalExpression()
|
Symbol |
NumberLiteralValue()
purely numeric atomic term literal value (in the sense of constant primitive type). |
Expression |
parseFormula()
Start production parsing a logic formula with the current syntax. |
Expression |
parseFormulas()
Start production parsing a set of logic formulas with the current syntax. |
Expression |
parseTerm()
Start production parsing an arithmetic formula expression. |
Type |
parseType()
Start production parsing a type expression with the current syntax. |
Expression |
PiAbstractionType()
|
Expression |
PowerTerm()
|
Expression |
PrimaryExpression()
Final expression parsing production (in addition to Atom() ). |
Expression |
PrimaryTerm()
Final term parsing production (in addition to AtomicTerm() ). |
Expression |
PrimaryType()
A primary type. |
Expression |
ProductTerm()
|
Expression |
ProductType()
|
Expression |
QuantifiedExpression()
|
static Substitution |
readTRS(java.io.Reader reader,
ExpressionSyntax syntax)
Reads a term-rewrite system from a stream. |
static Substitution |
readTRS(java.io.Reader reader,
ExpressionSyntax syntax,
Function expressionTransformation)
Reads a term-rewrite system from a stream. |
void |
ReInit(java.io.InputStream stream)
|
void |
ReInit(java.io.InputStream stream,
java.lang.String encoding)
|
void |
ReInit(LogicParserTokenManager tm)
|
void |
ReInit(java.io.Reader stream)
|
void |
setSyntax(ExpressionSyntax syntax)
Set the current syntax for parsing. |
Expression |
SumTerm()
|
Expression |
term()
Central term parsing production. |
Expression[] |
Type_list()
|
Expression |
type()
Central type parsing production. |
Expression[] |
Types()
|
Type |
typeUse()
A type use. |
Expression |
UnaryExpression()
|
Expression |
UnaryTerm()
|
Symbol |
Variable()
an atomic variable term. |
Symbol |
VariableDeclaration()
an atomic variable term with a type declaration. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ExpressionSyntax syntax
protected transient orbital.moon.logic.LogicParser.Scope root
protected orbital.moon.logic.LogicParser.Scope scope
public LogicParserTokenManager token_source
public Token token
public Token jj_nt
public boolean lookingAhead
Constructor Detail |
---|
public LogicParser(java.io.InputStream stream)
public LogicParser(java.io.InputStream stream, java.lang.String encoding)
public LogicParser(java.io.Reader stream)
public LogicParser(LogicParserTokenManager tm)
Method Detail |
---|
public void setSyntax(ExpressionSyntax syntax)
syntax
- the expression syntax to use for parsing expressions (formulas).protected Type asType(Expression f)
Expression* | → | Type |
f | ↦ | (Type) I0(f) |
protected Expression combine(Token optok, Expression[] a) throws ParseException
ParseException
protected Expression combine(Token optok, Symbol x, Expression a) throws ParseException
ParseException
protected Expression apply(Token optok, Expression[] a, Type reqResult) throws ParseException
reqResult
- specifies the required result type, as derived from the context.
Object.class for functions, and Boolean.class for predicates.
ParseException
ExpressionBuilder.compose(Expression,Expression[])
public static final Substitution readTRS(java.io.Reader reader, ExpressionSyntax syntax, Function expressionTransformation) throws java.io.IOException, ParseException
<matchingSide> |- <replacementSide> # <comment> <EOL> ...where
<matchingSide>
and <replacementSide>
are well-formed expressions of the (concrete) syntax
defined by syntax
.
reader
- the source for the TRS specification.syntax
- the syntax for parsing expressions.expressionTransformation
- the function Expression
→T used for transforming
the expressions parsed (<matchingSide>
and <replacementSide>
)
prior to constructing the substitution.
java.io.IOException
- when an error occurs while reading from the reader.
ParseException
- when a syntax error occurs in the source.ModernLogic#proveAll(Reader,ModernLogic,boolean)
public static final Substitution readTRS(java.io.Reader reader, ExpressionSyntax syntax) throws java.io.IOException, ParseException
java.io.IOException
ParseException
readTRS(Reader,ExpressionSyntax,Function)
public final Expression parseFormulas() throws ParseException
ParseException
parseFormula()
public final Expression parseFormula() throws ParseException
ParseException
parseFormulas()
public final Expression parseTerm() throws ParseException
ParseException
public final Type parseType() throws ParseException
ParseException
public final Expression expression() throws ParseException
ParseException
public final Expression FreeDeclarationExpression() throws ParseException
ParseException
public final Expression EquivalenceExpression() throws ParseException
ParseException
public final Expression ImplicationExpression() throws ParseException
ParseException
public final Expression InclusiveOrExpression() throws ParseException
ParseException
public final Expression ExclusiveOrExpression() throws ParseException
ParseException
public final Expression AndExpression() throws ParseException
ParseException
public final Expression UnaryExpression() throws ParseException
ParseException
public final Expression QuantifiedExpression() throws ParseException
ParseException
public final Expression ModalExpression() throws ParseException
ParseException
public final Expression PrimaryExpression() throws ParseException
Atom()
).
primary formulas that have truth values
ParseException
public final Expression Atom() throws ParseException
ParseException
public final Expression CompoundFormula() throws ParseException
ParseException
public final Expression EqualityExpression() throws ParseException
ParseException
public final Expression LambdaAbstractionPredicate() throws ParseException
ParseException
Substitutions.lambda
public final Expression term() throws ParseException
ParseException
public final Expression SumTerm() throws ParseException
ParseException
public final Expression ProductTerm() throws ParseException
ParseException
public final Expression PowerTerm() throws ParseException
ParseException
public final Expression UnaryTerm() throws ParseException
ParseException
public final Expression PrimaryTerm() throws ParseException
AtomicTerm()
).
ParseException
public final Expression CompoundTerm() throws ParseException
ParseException
public final Expression LambdaAbstraction() throws ParseException
ParseException
Substitutions.lambda
public final Expression AtomicTerm() throws ParseException
ParseException
public final Symbol LiteralValue() throws ParseException
ParseException
public final Symbol NumberLiteralValue() throws ParseException
ParseException
public final Symbol ConstantOrVariable() throws ParseException
ParseException
Variable()
public final Symbol Variable() throws ParseException
ParseException
ConstantOrVariable()
public final Symbol VariableDeclaration() throws ParseException
ParseException
public final Type typeUse() throws ParseException
ParseException
public final Expression type() throws ParseException
ParseException
public final Expression MapType() throws ParseException
ParseException
public final Expression ProductType() throws ParseException
ParseException
public final Expression PiAbstractionType() throws ParseException
ParseException
public final Expression PrimaryType() throws ParseException
ParseException
public final Expression CompoundType() throws ParseException
ParseException
public final Expression[] Arguments() throws ParseException
ParseException
public final Expression[] Argument_list() throws ParseException
ParseException
public final Expression[] Types() throws ParseException
ParseException
public final Expression[] Type_list() throws ParseException
ParseException
public void ReInit(java.io.InputStream stream)
public void ReInit(java.io.InputStream stream, java.lang.String encoding)
public void ReInit(java.io.Reader stream)
public void ReInit(LogicParserTokenManager tm)
public final Token getNextToken()
public final Token getToken(int index)
public ParseException generateParseException()
public final void enable_tracing()
public final void disable_tracing()
|
Orbital library 1.3.0: 11 Apr 2009 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |