org.fraid.interpreter
Class Fraid
java.lang.Object
org.fraid.interpreter.Fraid
- All Implemented Interfaces:
- FraidConstants, FraidTreeConstants
public class Fraid
- extends java.lang.Object
- implements FraidTreeConstants, FraidConstants
Fields inherited from interface org.fraid.interpreter.FraidTreeConstants |
JJTADD, JJTAND, JJTASSIGNMENT, JJTDIVIDE, JJTEQUAL, JJTEXPRESSIONTOCALCULATE, JJTFUNCTIONCALL, JJTFUNCTIONDEF, JJTGREATER, JJTGREATEROREQUAL, JJTIFTHENEXPRESSION, JJTIMAGINARYNUMBER, JJTMETA, JJTMULTIPLY, JJTNEGATE, jjtNodeName, JJTNOT, JJTNOTEQUAL, JJTOR, JJTPOWER, JJTPROCESSSINGLELINE, JJTPROCESSSTREAM, JJTREALNUMBER, JJTSMALLER, JJTSMALLEROREQUAL, JJTSTRING, JJTSUBTRACT, JJTVARIABLE, JJTVOID, JJTXOR |
Fields inherited from interface org.fraid.interpreter.FraidConstants |
AND, ASSIGN, CLOSE_META, CLOSE_PAR, COMMA, DEFAULT, DIGITS, DIVIDE, ELSE, EOF, EOL, EQUAL, GREATER, GREATER_OR_EQ, ID, IF, IMAGINARY_NUMBER, IMAGINARY_ONE, INT_DIVIDE, MINUS, NOT, NOT_EQUAL, NUMBER, OPEN_META, OPEN_PAR, OR, PLUS, POWER, SIMPLE_NUMBER, SMALLER, SMALLER_OR_EQ, STRING, THEN, TIMES, tokenImage, XOR |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
jjtree
protected org.fraid.interpreter.JJTFraidState jjtree
token_source
public FraidTokenManager token_source
token
public Token token
jj_nt
public Token jj_nt
lookingAhead
public boolean lookingAhead
Fraid
public Fraid(java.io.InputStream stream)
Fraid
public Fraid(java.io.InputStream stream,
java.lang.String encoding)
Fraid
public Fraid(java.io.Reader stream)
Fraid
public Fraid(FraidTokenManager tm)
setNotifyListeners
public void setNotifyListeners(boolean aNotifyListeners)
isNotifyListeners
public boolean isNotifyListeners()
workWithConsole
public static void workWithConsole(IOStructure aIO,
boolean aIsMainApplication)
- Create a new interpreter and connect the IO with the aIO streams
and notification objects. Whenever the computed FrAid expression evaluates to null
it will break from the loop and will try to close the console (which implements CloseListener).
When the console closes it should send "exit;" through the input stream and this thread will close.
See FraidConsole for an example.
This is the "preffered" way for FrAid to
work with a console. See Fraid.main(...), Scripting.console(...) and
DemoApplet2 for examples.
This method can be used with any console and is not associated with FraidConsole in any way.
Start
public Complex Start()
throws ParseException
- Entry point for the interpreter. Wrapper around ProcessStream().
Process the whole stream (multiple FrAid lines).
Use when you do not need the individual lines' results.
- Returns:
- the result of the evaluation of the last expression in the stream.
- Throws:
ParseException
- if an error occurs
main
public static void main(java.lang.String[] args)
ProcessSingleLine
public final Complex ProcessSingleLine()
throws ParseException
- Entry point for the interpreter. Will process a single FrAid line (delimited by ';').
Use in a loop when you need (to print the) individual lines' results.
See the source of the main function ot this class for example.
- Returns:
- the result of the evaluation of the line, null if EOF was reached.
- Throws:
ParseException
- if an error occurs
ProcessStream
public final Complex ProcessStream()
throws ParseException
- Entry point for the interpreter. Process the whole stream (multiple FrAid lines).
Use when you do not need the individual lines' results.
- Returns:
- the result of the evaluation of the last expression in the stream.
- Throws:
ParseException
- if an error occurs
ExpressionToCalculate
public final SimpleNode ExpressionToCalculate()
throws ParseException
- Throws:
ParseException
Expression
public final void Expression()
throws ParseException
- Throws:
ParseException
IfThenExpression
public final void IfThenExpression()
throws ParseException
- Throws:
ParseException
Assignment
public final void Assignment()
throws ParseException
- Throws:
ParseException
FunctionDef
public final void FunctionDef()
throws ParseException
- Throws:
ParseException
ComparisonExpression
public final void ComparisonExpression()
throws ParseException
- Throws:
ParseException
OrXorExpression
public final void OrXorExpression()
throws ParseException
- Throws:
ParseException
LogicalAndExpression
public final void LogicalAndExpression()
throws ParseException
- Throws:
ParseException
AddSubtractExpression
public final void AddSubtractExpression()
throws ParseException
- Throws:
ParseException
MultiplyDivideExpression
public final void MultiplyDivideExpression()
throws ParseException
- Throws:
ParseException
PowerExpression
public final void PowerExpression()
throws ParseException,
java.lang.NumberFormatException
- Throws:
ParseException
java.lang.NumberFormatException
HighestPrecedenceExpression
public final void HighestPrecedenceExpression()
throws ParseException,
java.lang.NumberFormatException
- Throws:
ParseException
java.lang.NumberFormatException
AtomicExpression
public final void AtomicExpression()
throws ParseException
- Throws:
ParseException
Negate
public final void Negate()
throws ParseException
- Throws:
ParseException
Not
public final void Not()
throws ParseException
- Throws:
ParseException
ExpressionList
public final void ExpressionList()
throws ParseException
- Throws:
ParseException
FunctionCall
public final void FunctionCall()
throws ParseException
- Throws:
ParseException
Meta
public final void Meta()
throws ParseException
- Throws:
ParseException
Variable
public final void Variable()
throws ParseException
- Throws:
ParseException
ReInit
public void ReInit(java.io.InputStream stream)
ReInit
public void ReInit(java.io.InputStream stream,
java.lang.String encoding)
ReInit
public void ReInit(java.io.Reader stream)
ReInit
public void ReInit(FraidTokenManager tm)
getNextToken
public final Token getNextToken()
getToken
public final Token getToken(int index)
generateParseException
public ParseException generateParseException()
enable_tracing
public final void enable_tracing()
disable_tracing
public final void disable_tracing()
Fraid (system and language). (C) 2003-2007 Ivaylo Iliev
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.