grammar reference
This commit is contained in:
@@ -32,6 +32,7 @@ html_theme = 'alabaster'
|
|||||||
imgmath_latex_preamble = r'''
|
imgmath_latex_preamble = r'''
|
||||||
\usepackage{amsmath}
|
\usepackage{amsmath}
|
||||||
\usepackage{tabularray}
|
\usepackage{tabularray}
|
||||||
|
\usepackage{syntax}
|
||||||
|
|
||||||
\newcommand{\transrule}[2]
|
\newcommand{\transrule}[2]
|
||||||
{\begin{tblr}{|rrrlc|}
|
{\begin{tblr}{|rrrlc|}
|
||||||
|
|||||||
67
doc/src/references/rlp-grammar.rst
Normal file
67
doc/src/references/rlp-grammar.rst
Normal file
@@ -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}
|
||||||
|
<Decl> ::= <InfixDecl>
|
||||||
|
\alt <DataDecl>
|
||||||
|
\alt <TypeSig>
|
||||||
|
\alt <FunDef>
|
||||||
|
|
||||||
|
<InfixDecl> ::= <InfixWord> `litint' <Name>
|
||||||
|
<InfixWord> ::= `infix'
|
||||||
|
\alt `infixl'
|
||||||
|
\alt `infixr'
|
||||||
|
|
||||||
|
<DataDecl> ::= `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' ')'
|
||||||
|
|
||||||
Reference in New Issue
Block a user