contents

# styx Language Reference

## Regular Grammar

( legend )

     Character Set

let

Byte

::

'\00' .. '\ff'

     all extended ascii

let

Control

::

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

     control

     DEL

     space-like extended ascii

     Basic elements of tokens

let

Printable

::

Byte - Control

ign

Space

::

" "

     ASCII - Space

ign

Line

::

"\n" | "\r\n" | "\r"

     UNIX / CPM / DOS

     Mac

ign

Page

::

"\p"

     weak separation convention

ign

Etx

::

"\1a" { Byte }

     CPM / older DOS Versions

     Definitions and simple tokens

let

Letter

::

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

let

HexDigit

::

'0' .. '9' | Letter

let

Digit

::

'0' .. '9'

let

Normal

::

Letter | Digit | Space

let

Quote

::

'\'\"\`\\'

tok

Parenthesis

::

'()[]{}'

     one character tokens

let

Special

::

Printable - Normal - Parenthesis - Quote

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

let

LitChar

::

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

     Comments et al

com

Comment

::

';' { Printable }

     Complex tokens

tok

Ide

::

Letter { Letter } { Digit }

     Identifier

tok

Nat

::

Digit +

     Natural

tok

Opr

::

( Special - ';=<>' ) + | '=<>'

     Operator

tok

Set

::

'\'' { LitChar } '\''

     CharacterSet

tok

Seq

::

'\"' { LitChar } '\"'

     CharacterSequence (String)

     Macro tokens

let

White

::

Space | Line | Page

let

Name

::

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

let

MPar

::

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

tok

MacInc

::

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

     Include

tok

MacDel

::

"#undefine" White { White } Name

     undefine Macro

tok

MacDfn

::

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

     Macro definition

tok

MacSep

::

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

     End of parameter

tok

MacCond

::

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

     Conditionals

## Context-free Grammar

( legend )

start

Source

::

Language [ Nat ] Ide [ Regular Grammar { QlxDfn } ] [ Context Free Grammar { Dfn } { Context State . Token : reduce Ide . Ide { reduce Ide . Ide } } ]

let

QlxCat

::

com | ind | let | tok | lan | ign

     QlxCategory

let

QlxGrp

::

!+ | !- | ! | ! Ide | !+ Ide

     switch to QlxGroup

let

Exp

::

     Expression prio 0

|

Exp / Exp

|

Set

|

Ide

|

Seq

|

Exp Exp

|

Exp | Exp

|

Exp - Exp

|

( Exp )

|

Exp .. Exp

|

< Exp > Exp < Exp >

|

< ? Exp > Ide < Exp >

|

< = Exp > Set < Exp >

|

Exp +

|

Exp Limit

|

Exp *

|

[ Exp ]

|

{ Exp }

let

Limit

::

Nat , [ Nat ] | Nat

     occurance limit

let

QlxDfn

::

tok < Ide >

     Qlx-Definition

|

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

|

InGroup Ide

|

ExGroup Ide [ tok ]

|

Group Ide = Ide { Ide }

|

ExGroup Ide

let

Cat

::

let | start | xtop

     Category

let

Lay

::

! | ? | :

     Layouting: PrettyPrinter Hint

let

Mbr

::

[ { Seq } Mbr { Seq } ]

     single byte literals or literals, encoded in us-ascii

|

Ide < Ide >

|

( { Seq } Mbr { Seq } ... { Seq } )

|

Ide

|

[ { Seq } Mbr { Seq } ... { Seq } ]

|

[ other ]

|

Seq

let

Dfn

::

Cat [ [ err ] ] Ide { Lay Ide : { Mbr } }

     Definition

let

State

::

Nat | Ide | Seq

     Conflict state

let

Token

::

Seq | Ide

     Conflict token