TOPICS ON XLANG
What is this ? || Language Specification || Sample Program
How to Compile the Compiler ? || Additional Documentation || Download
XLang : Language Specification
Contents
Language Implementation
Implementation Method
Operators
Data Types
Grammar
Exceptions
Sample Program
The language will be interpreted with the the input being a file with the extension "xml". The case could be of any combination. The input will be also a fully qualified name unless otherwise in the same directory as that of the language executable. The language implementation space is defined as below.
The implementation method is represented as under:
The operators defined in the language are as under
Multiplication <mul/>
Division <div/>
Addition <add/>
Subtraction <sub/>
Equal
<equals/>
Unary Plus <up/>
Unary Minus <um/>
The Precedence of the Operators is as under
Higher
<mul/> <div/>
<add/> <add/>
<up/> <um/>
<equals/>
Lower
The primitive data types will be restriced
to int and float and their
Range would be
int 10 e-31 to 10 e32 -1
float 10 e-63 to 10 e 63 -1
The type checking for primitive int and float would be such that upward casting from int to float will be permitted and also implicit. No downward casting is permitted.
The grammer for XLang is relatively hard to be expressed by pure EBNF due to the fact that we have <> being represented in the constructs. I have used a double << >> to represent the non terminals instead of a single <>.
begin => <program> <<expr1>></program>
<<expr1>>
=>
<decl>
<<expr2>></decl><code><<expr3>></code>
<<expr2>>
=>
{<var><<expr4>></var>}
<<expr4>>
=> <name><<expr5>></name><type><<expr6>>[<value><<expr7>><\value>]
<<expr5>>
=> Alphanumeric String
<<expr6>>
=> int | float
<<expr7>>
=>
A string representation of values for int and float data
<<expr3>>
=> <code> { <expr><<expr8>></expr>
}</code>
<<expr8>>
=> Expression for evaluation
The list of possible Exceptions that will be handled are
1) SAXException : For handling XML syntax errors
2) Throwable : General IO
problems with file handling
3) DataOverflowException. : Exceeds the Maximum Size
4) DataUnderflowException.: Less than minimum value that could be handled
5) DivisionException : Division by Zero
6) MalFormedExpressionException : Illegal syntax for expresions
7) InvalidTypeException : Errors due to bad data type selection
A sample program would be like this
<program>
<decl>
<var>
<name>quantity</name>
<type>int</type>
<value>100</value>
</var>
<var>
<name>price</name>
<type>float</type>
<value>10.110</value>
</var>
<var>
<name>total</name>
<type>float</type>
</var>
<var>
<name>tax</name>
<type>float</type>
<value>0.1</value>
</var>
</decl>
<code>
<expr>
<total/><equals/><quantity/><mul/><price/>
</expr>
<expr>
<total/><equals/><paran><total/><mul/><tax/></paran><add/><const>10</const>
</expr>
</code>
</program>
TOPICS ON XLANG
What is this ? || Language Specification || Sample Program
How to Compile the Compiler ? ||
Additional Documentation
|| Download
Who: Elango Sundaram ;
esundara at sign yahoo dot com