diff --git a/doc/src/conf.py b/doc/src/conf.py index d344334..533296a 100644 --- a/doc/src/conf.py +++ b/doc/src/conf.py @@ -32,6 +32,7 @@ html_theme = 'alabaster' imgmath_latex_preamble = r''' \usepackage{amsmath} \usepackage{tabularray} +\usepackage{syntax} \newcommand{\transrule}[2] {\begin{tblr}{|rrrlc|} diff --git a/doc/src/references/rlp-grammar.rst b/doc/src/references/rlp-grammar.rst new file mode 100644 index 0000000..c81fea7 --- /dev/null +++ b/doc/src/references/rlp-grammar.rst @@ -0,0 +1,67 @@ +The Complete Syntax of rl' +========================== + +WIP. + +Provided is the complete syntax of rl' in (pseudo) EBNF. {A} represents zero or +more A's, [A] means optional A, and terminals are wrapped in 'single-quotes'. + +.. math + :nowrap: + + \setlength{\grammarparsep}{20pt plus 1pt minus 1pt} + \setlength{\grammarindent}{12em} + \begin{grammar} + ::= + \alt + \alt + \alt + + ::= `litint' + ::= `infix' + \alt `infixl' + \alt `infixr' + + ::= `data' `conname' {} + + \end{grammar} + +.. code-block:: bnf + + Decl ::= InfixDecl + | DataDecl + | TypeSig + | FunDef + + InfixDecl ::= InfixWord 'litint' Operator + InfixWord ::= 'infix' + | 'infixl' + | 'infixr' + + DataDecl ::= 'data' 'conname' {'name'} '=' Data + DataCons ::= 'conname' {Type1} ['|' DataCons] + + TypeSig ::= Var '::' Type + FunDef ::= Var {Pat1} '=' Expr + + Type ::= Type1 {Type1} + -- note that (->) is right-associative, + -- and extends as far as possible + | Type '->' Type + Type1 ::= '(' Type ')' + | 'conname' + + Pat ::= 'conname' Pat1 {Pat1} + | Pat 'consym' Pat + + Pat1 ::= Literal + | 'conname' + | '(' Pat ')' + + Literal ::= 'litint' + + Var ::= 'varname' + | '(' 'varsym' ')' + Con ::= 'conname' + | '(' 'consym' ')' +