styx Language Reference



Regular Grammar


The regular grammar defines the basic language elements i.e. tokens as certain classes of character sequences like numbers, identifiers, operators and strings.

Each rule defining such a class of character sequences has the following structure: <Class Type> <Class Identifier> :: <Regular Expression>

We distinguish four types of classes:
 


A regular expression spezifies the character sequences belonging to the class. Such a description usually consists of the following elements and operators:
 

Case ignore character classes can be spezified with an [I] behind the class identifier.
 
 

 Character Set
letByte  :: 

'\00' .. '\ff'

 all extended ascii
     
letControl  :: 

( '\00' .. '\1f' | '\7f' ) | '\ff'

 control

 DEL

 space-like extended ascii
     
 Basic elements of tokens
letPrintable  :: 

Byte - Control




     
ignSpace  :: 

" "

 ASCII - Space
     
ignLine  :: 

"\n" | "\r\n"

 UNIX / CPM / DOS
     
ignPage  :: 

"\p"

 weak separation convention
     
ignEtx  :: 

"\1a" { Byte }

 CPM / older DOS Versions
     
 Definitions and simple tokens
letLetter  :: 

'A' .. 'Z' | 'a' .. 'z'




     
letHexDigit  :: 

'0' .. '9' | 'a' .. 'f'




     
letDigit  :: 

'0' .. '9'




     
letNormal  :: 

( Letter | Digit ) | Space




     
letQuote  :: 

'\'\"\`\\'




     
tokParenthesis  :: 

'()[]{}'

 one character tokens
     
letSpecial  :: 

( ( Printable - Normal ) - Parenthesis ) - Quote




     
 single byte literals or literals, encoded in us-ascii, ISO 8859-1 Latin-1 or ucs4 hex values
letLitChar  :: 

( Printable - Quote ) | ( '\\' ( ( ( Quote | 'prnt' ) | ( HexDigit HexDigit ) ) | ( ( ( ( ( ( ( ( 'xX' HexDigit ) HexDigit ) HexDigit ) HexDigit ) HexDigit ) HexDigit ) HexDigit ) HexDigit ) ) )




     
 Comments et al
comComment  :: 

';' { Printable }




     
 Complex tokens
tokIde  :: 

( Letter { Letter } ) { Digit }

 Identifier
     
tokNat  :: 

Digit +

 Natural
     
tokOpr  :: 

( Special - ';' ) +

 Operator
     
tokSet  :: 

( '\'' { LitChar } ) '\''

 CharacterSet
     
tokSeq  :: 

( '\"' { LitChar } ) '\"'

 CharacterSequence (String)
     
 Macro tokens
letWhite  :: 

( Space | Line ) | Page




     
letName  :: 

( Letter | "_" ) { ( Letter | Digit ) | "_" }




     
letMPar  :: 

( Printable - ( ( ( White | ',' ) | ')' ) | '=' ) ) { Printable - ( ( ( White | ',' ) | ')' ) | '=' ) }




     
tokMacInc  :: 

( ( ( "#include" White ) { White } ) ( Printable - White ) ) { Printable - White }

 Include
     
tokMacDfn  :: 

( ( ( ( ( "#macro" White ) { White } ) Name ) { White } ) [ ( ( ( ( ( "(" { White } ) MPar ) { ( ( { White } "," ) { White } ) MPar } ) { White } ) ")" ) { White } ] ) [ ( "=" ( { Byte } - ( ( { Byte } ( "#macro" | "#end" ) ) { Byte } ) ) ) "#end" ]

 Macro definition
     
tokMacSep  :: 

( '\'' ( Byte - '\'' ) ) [ '-' ]

 End of parameter
     
tokMacCond  :: 

( ( ( ( ( "#ifdef" | "#ifndef" ) White ) { White } ) Name ) | "#else" ) | "#end"

 Conditionals



Context-free Grammar


The syntax rules are described in EBNF ( Extended Backus-Naur-Form ). A startsymbol must exist for each source file type. That means the syntax within each file has to be conform to the corresponding start rule. The other are internal helper rules.

Each rule is structured as follows: <Rule Type: start or let <Rule Identifier> :: <EBNF-konform Expression>
An EBNF-konform expression defines a part of the language syntax. It consists of a set of alternative productions i.e. partial expressions, separated by the character '|'.

A production can be spezified with the help of the following elements and operators:
 


startSource  :: 

Language Ide Regular Grammar { QlxCat [ [ ica ] ] Ide = Exp } [ Context Free Grammar { Cat [ [ err ] ] Ide { Lay Ide : { Mbr } } } ]




     
letQlxCat  :: 

tok | let | lan | com | ign

 QlxCategory
     
letExp  :: 

Exp Exp

 Expression prio 0
     
   | 

Exp | Exp

 
     
   | 

Exp - Exp

 
     
   | 

Seq

 
     
   | 

Set

 
     
   | 

Ide

 
     
   | 

( Exp )

 
     
   | 

Exp .. Exp

 
     
   | 

[ Exp ]

 
     
   | 

{ Exp }

 
     
   | 

Exp +

 
     
letCat  :: 

xtop | start | let

 Category
     
letLay  :: 

! | ? | :

 Layouting: PrettyPrinter Hint
     
letMbr  :: 

Ide | Seq | [ other ]

 Member