doc: syntax of terms

parent 275deafa
......@@ -61,6 +61,11 @@ and syntax = parse
print_string s;
print_string "} \\sep{}";
syntax lexbuf }
| ";" ([^ '\n']* as s) "%\n" {
print_string "& \\textrm{";
print_string s;
print_string "}";
syntax lexbuf }
| ";" ([^ '\n']* as s) '\n' {
print_string "& \\textrm{";
print_string s;
......
......@@ -3,7 +3,7 @@
This chapter gives the grammar for the input files
\input{./term_bnf.tex}
\framebox{\input{./term_bnf.tex}}
%%% Local Variables:
%%% mode: latex
......
\begin{syntax}
bin-op ::= "+" | "-" | "*" | "/" | "%" ;
| "==" | "!=" | "<=" | ">=" | ">" | "<" ;
| "&&" | "||" | ; boolean operations
| "&" | "|" | "-->" ;
| "<-->" | "^"; bitwise operations
\
unary-op ::= "+" | "-" ; unary plus and minus
| "!" ; boolean negation
| "~" ; bitwise complementation
| "*" ; pointer dereferencing
| "&" ; address-of operator
\
term ::= "\true" | "\false" ;
| integer ; integer constants
| real ; real constants
| id ; variables
| unary-op term ;
| term bin-op term ;
| term "[" term "]" ; array access
| "{" term "\with" "[" term "]" "=" term "}" ; array functional modifier
| term "." id ; structure field access
| "{" term "\with" "."id "=" term "}" ; field functional modifier
| term "->" id ;
| "(" type-expr ")" term ; cast
| id "(" term ("," term)* ")" ; function application
| "(" term ")" ; parentheses
| term "?" term ":" term ; ternary condition
| "\let" id "=" term ";" term ; local binding
| "sizeof" "(" term ")" ;
| "sizeof" "(" C-type-expr ")" ;
| id ":" term ; syntactic naming
term ::= integer ; integer constant
| real ; real constant
| qualid ; symbol
| prefix-op term ;
| term infix-op term ;
| lqualid term+ ; function application
| "if" formula "then" term "else" term ; conditional
| "let" pattern "=" term "in" term ; local binding
| "match" ("," term)+ "with" "|"? match-cases "end" ;
| "(" term ("," term)* ")" ; tuple
| term ":" type ; cast
| label term ; label
| "(" term ")" ; parentheses%
\end{syntax}
......@@ -4,6 +4,10 @@ theory List
type list 'a = Nil | Cons 'a (list 'a)
use import bool.Bool
logic x : int = if true then 1 else 3
end
theory Length
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment