Multi Purpose P.K. Syntax Analyzer Generator...

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:
.NOSKIPLINEEnd of Line is part of the language (ex BASIC).
.SKIPLINEEnd of Line is not significative (ex C) (default value).
.NOSKIPSPACESpace character is significative.
.SKIPSPACESpace character non significative (default value).


For Tests :
.IDIdentifier.
.LINEEnd of Line Test.
.REELFloating Point.
.NUMBERNumber.
.STRINGString.
.EOFEnd of File Test.
.EMPTYNothing.


For language operators:
$0 or n times.
< >postponed code generation.
( )parenthesis.
*Last recognized lexeme.
{ }In-Line C code generation.
|OR.
=StringString Test.
-StringNot String Test.
!testSucces 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.
.RETURNCan be used within the $ "loops".
.BREAKCan be used within the $ "loops".
.CONTINUECan be used within the $ "loops".
.ERR StringError Message.
.INCLUDE FileNameSource code Inclusion.


Postponed code generation example:
  • Modulo ::= <expression> ‘%’ <expression> .OUT ( #1 "- (" #1 "/" #2 ") *" #2 ) ;



Site has been updated on Wednesday, February 03 2016 - 19:15:29