| Get Going With WESCL: Language Documentation | ||
|---|---|---|
| Prev | ||
This appendix presents WESCL grammar description using Extended-BNF format taken from PCCTS Toolkit. For more information on PCCTS, see: ANTLR Website.
/**
wescl.grammar 2.07 (01.09.2000)
written by Damian Wrobel <dwrobel@ertel.com.pl>
WESCL - language description (Extended-BNF)
-*/
/*
EBNF - short description
------------------------
Rules: describes a portion of the input language and
consist of a list of alternatives.
A rule syntax:
rule : alternative1
| alternative2
;
where each of alternatives can by references to
next rules, subrules or tokens.
Subrules:
Form Example
plain subrule (...) (OUTPUT | MEMORY)
zero-or-more (...)* (statement)* "@"
optional {...} {NOT} input
Tokens:
Tokens are defined with #token. Token reference indicate the
token must be matched on the input file.
Examples:
#token OR "or"
#token AND "and"
#token XOR "xor"
#token Eof "@" // predefined end-of-file token
For more information see also: <http://www.antlr.org>
*/
wescl :
( statement )* "@"
;
statement :
expression COLON actionlist SEMICOLON
;
actionlist :
action ( COMMA action )*
;
action :
string
| assign
| var_name
;
string :
HTML ASSIGN ( STRING | HTML )
;
assign :
name ASSIGN expression
;
name :
( VALUE | INPUT | ADINPUT | OUTPUT | VMEMORY | MEMORY | STATUS | COUNTER )
;
input :
( name | TRUE_ | FALSE_ | BITVAL )
;
var_name :
{ NOT | MINUS } name
;
expr_list :
( BRA expression KET )
| input
;
operand :
{ NOT | MINUS } expr_list
;
multiplication :
operand ( MUL operand )*
;
division :
multiplication ( DIV multiplication )*
;
modulus :
division ( MOD division )*
;
plus :
modulus ( PLUS modulus )*
;
minus :
plus ( MINUS plus )*
;
relational :
minus ( ( LT | GT | LE | GE ) minus )*
;
equality :
relational ( ( NOT_EQUAL | EQUAL ) relational )*
;
and :
equality ( AND equality )*
;
expression :
and ( OR and )*
;
#token UNARY_MINUS
#token NOT "not|!"
#token MUL "\*"
#token DIV "/"
#token MOD "%"
#token PLUS "\+"
#token MINUS "\-"
#token LT "<"
#token GT ">"
#token LE "<="
#token GE ">="
#token NOT_EQUAL "xor|!="
#token EQUAL "=="
#token AND "and|&&"
#token OR "or|\|\|"
#token TRUE_ "true"
#token FALSE_ "false"
#token BRA "\("
#token KET "\)"
#token ASSIGN "="
#token COLON "\:|==>"
#token SEMICOLON ";"
#token COMMA ","
#token HTML "V|(A[0-9]{[0-9]})"
#token VMEMORY "B[0-9]{[0-9]}"
#token MEMORY "M[0-9]{[0-9]}"
#token STATUS "S[0-9]{[0-9]}"
#token COUNTER "C[0-9]{[0-9]}"
#token INPUT "I[0-9]{[0-9]}"
#token ADINPUT "D[0-9]|D[0-1]{[0-9]}"
#token OUTPUT "O[0-9]{[0-9]}"
#token BITVAL "ON|OFF"
#token VALUE "[0-9]{[0-9]}{[0-9]}{[0-9]}{[0-9]}" /* formally: SHRT_MIN .. SHRT_MAX */
#token STRING << full-formated C-String >>
|