Nina: automata description language


Reference Top - PREV: Action part

Structure of class which generated by Nina

The Nina translator generates a class which can parse the input by described automata.
The generated class name is the input filename without .nina extension and the beginning character is capitalized.
In the automata part, you can use this(Java) or $this(C#, JavaScript) to access the fields and methods of the class.
In the action part, you can use this(Java,C#,JavaScript) to access.
The fields and methods which may affect to parsing are shown as follows.

Inner property

The fields which may affect are shown as follows.

name description type
Java C# JavaScript
STATE keeps current state. You can access and change it. int int number
$buffer(Java,JavaScript) / _buffer(C#) stores a string which is matching by a regex. StringBuffer StringBuilder string
$int(Java,JavaScript) / _int(C#) stores an integer which is matched by {%d}. int int number
$num(Java,JavaScript) / _num(C#) stores a double number which is matched by {%f}. Number double number
COMMENT You can suppress skipping comment by setting this to false.
If you evaluate strings or regexes, this property will be set to false.
boolean bool (boolean)

Inner methods

The methods which may affect to parsing are shown as follows.

Java

boolean parse(java.io.Reader rd) throws java.io.IOException
parses the input by Reader.
You must construct this class by the constructor without arguments.
This returns true if all inputs are read, otherwise false.
If you want to return the parsed result, you should return a field in which the result is stored.

void INCLUDE(String name) throws java.io.IOException
includes the file to the input.
Process like #include as C preprocessor can be available by this method.

void INCLUDE(java.io.Reader rd)
Same as the above method, you give a Reader instead of filename.

C#

bool Parse(System.IO.TextReader rd)
parses the input by TextReader.
You must construct this class by the constructor without arguments.
This returns true if all inputs are read, otherwise false.
If you want to return the parsed result, you should return a field in which the result is stored.

void INCLUDE(string name)
includes the file to the input.
Process like #include as C preprocessor can be available by this method.

void INCLUDE(System.IO.TextReader rd)
Same as the above method, you give a Reader instead of filename.

JavaScript

prototype.parse: function(arg)
parses the input by argument.
If the argument is string, parse the string as input.
If the argument is function, parse the input from the function
The function returns a character code by Unicode or null if the end of input is reached.
You must construct this class by the constructor without arguments.
This returns true if all inputs are read, otherwise false.
If you want to return the parsed result, you should return a field in which the result is stored.

Reference Top - PREV: Action part
Yuichiro Moriguchi
yuichiro-moriguchi´╝ánifty.com
SourceForge.JP