Grammar Syntax
It begins with
.SYNTAX and ends by
.END
Statements end is the
; character.
.SYNTAX may have several parameters:
- The first one, which is mandatory, is the main rule name.
- The others, optional, consist of declarations.
A grammar example :
.SYNTAX test
test ::= .NUMBER;
.END
Terminal Items of the grammar are:
For the declarative part:
.NOSKIPLINE | End of Line is part of the language (ex BASIC). |
.SKIPLINE | End of Line is not significative (ex C) (default value). |
.NOSKIPSPACE | Space character is significative. |
.SKIPSPACE | Space character non significative (default value). |
For Tests :
.ID | Identifier. |
.LINE | End of Line Test. |
.REEL | Floating Point. |
.NUMBER | Number. |
.STRING | String. |
.EOF | End of File Test. |
.EMPTY | Nothing. |
For language operators:
$ | 0 or n times. |
< > | postponed code generation. |
( ) | parenthesis. |
* | Last recognized lexeme. |
{ } | In-Line C code generation. |
| | OR. |
=String | String Test. |
-String | Not String Test. |
!test | Succes indicator state inversion. |
For actions:
.OUT (String | * | Number | , | #Number | :) |
Code Generation. |
.LABEL (String | Number) | Label Definition. |
- Number is an integer (for example: 1) which defines a label in a rule.
- #Number is a reference to a postponed code generation block.
- , generates an end of line (same for a closing parenthesis).
- : do not generate an end of line for the following closing parenthesis.
|
.SCAN [Nothing| UNTIL String| NUMBER [Number | * | #Numérique] ] | skip characters.... |
- Nothing: Until the end of the line.
- String: Until the first character of the string.
- Number : Number of characters to skip.
- * : The Number of characters to skip is given by the last recognized lexeme.
- #Number : The Number of characters to skip is given by the postponed code generation block.
|
.RETURN | Can be used within the $ "loops". |
.BREAK | Can be used within the $ "loops". |
.CONTINUE | Can be used within the $ "loops". |
.ERR String | Error Message. |
.INCLUDE FileName | Source code Inclusion. |
Postponed code generation example:
- Modulo ::= <expression> % <expression>
.OUT ( #1 "- (" #1 "/" #2 ") *" #2 ) ;