contents
 

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> < [Member group :] Class Identifier [! Next group to activate]> :: <Regular Expression>

We distinguish five 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" | "\r"


UNIX / CPM / DOS Mac

 
     
ignPage  :: 

"\p"


weak separation convention

 
     
ignEtx  :: 

"\1a" { Byte }


CPM / older DOS Versions

 
     
 Definitions and simple tokens
letLetter  :: 

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


 
     
letHexDigit  :: 

'0' .. '9' | Letter


 
     
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

 
     
tokMacDel  :: 

"#undefine" White { White } Name


undefine Macro

 
     
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 { QlxDfn } ] [ Context Free Grammar { Cat [ [ err ] ] Ide { Lay Ide : { Mbr } } } ]


 
     
letQlxCat  :: 

let | ind | ign | com | lan | tok


QlxCategory

 
     
letQlxGrp1  :: 

! | ! Ide


switch to QlxGroup

 
     
letExp  :: 


Expression prio 0

 
     
   | 

Exp - Exp

 

 
     
   | 

Exp | Exp

 

 
     
   | 

Ide

 

 
     
   | 

Set

 

 
     
   | 

Seq

 

 
     
   | 

Exp .. Exp

 

 
     
   | 

( Exp )

 

 
     
   | 

< Exp > Exp < Exp >

 

 
     
   | 

Exp Exp

 

 
     
   | 

[ Exp ]

 

 
     
   | 

Exp +

 

 
     
   | 

{ Exp }

 

 
     
letQlxDfn  :: 

ExGroup Ide


Qlx-Definition

 
     
   | 

InGroup Ide

 

 
     
   | 

QlxCat [ [ ica ] ] [ : Ide : ] Ide [ QlxGrp1 ] = Exp

 

 
     
letCat  :: 

xtop | let | start


Category

 
     
letLay  :: 

: | ? | !


Layouting: PrettyPrinter Hint

 
     
letMbr  :: 

[ other ] | Ide | Seq


Member