]> git.lizzy.rs Git - metalua.git/blobdiff - doc/manual/ast.tex
fix CRLF
[metalua.git] / doc / manual / ast.tex
index 05a45adb449c1ba441cfbefadea0bf066f3dd27f..bf8b749e4bbe12447a3d91e06d883189501bcb2e 100755 (executable)
-% \documentclass{article}\r
-% \title{MetaLua Abstract Syntax Trees}\r
-% \setlength{\columnseprule}{1pt}\r
-\def\T#1{{\bf`#1}}\r
-\def\L#1{\{#1\}}\r
-\def\P#1{{\it #1}}\r
-\def\C#1{[\hspace{-.4em}[#1]\hspace{-.4em}]}\r
-\def\V#1{{\it #1}}\r
-\def\plus{\ensuremath{{}^{+}}}\r
-\def\star{\ensuremath{{}^{*}}}\r
-\def\TRANS{\ensuremath{\Longrightarrow}}\r
-% \usepackage{alltt}\r
-% \begin{document}\r
-% \maketitle\r
-\r
-\section{Abstract Syntax Tree grammar}\r
-\r
-\begin{alltt}\r
-\r
-block: \L{ stat\star }\r
-\r
-stat:\r
-| \T{Do}\L{ block }\r
-| \T{Set}\L{ \L{lhs\plus} \L{expr\plus} }\r
-| \T{While}\L{ expr block }\r
-| \T{Repeat}\L{ block expr }\r
-| \T{If}\L{ (expr block)\plus block? }\r
-| \T{Fornum}\L{ ident expr expr expr? block }\r
-| \T{Forin}\L{ \L{ident\plus} \L{expr\plus} block }\r
-| \T{Local}\L{ \L{ident\plus} \L{expr\plus}? }\r
-| \T{Localrec}\L{ \L{ident\plus} \L{expr\plus}? }\r
-| \T{Goto}\L{\P{string}}\r
-| \T{Label}\L{\P{string}}\r
-| \T{Return}\r
-| \T{Break}\r
-| apply\r
-\r
-expr:\r
-| \T{Nil} | \T{Dots} | \T{True} | \T{False}\r
-| \T{Number}\L{ \P{number} }\r
-| \T{String}\L{ \P{string} }\r
-| \T{Function}\L{ \L{ ident\star \T{Dots}? } block } \r
-| \T{Table}\L{ ( \T{Pair}\L{ expr expr } | expr )\star }\r
-| \T{Op}\L{ binopid expr expr } | \T{Op}\L{ unopid expr }\r
-| \T{Paren}\L{ expr }\r
-| \T{Stat}\L{ block expr }\r
-| apply\r
-| lhs\r
-\r
-apply:\r
-| \T{Call}\L{ expr expr\star }\r
-| \T{Invoke}\L{ expr \T{String}\L{ \P{string} } expr\star }\r
-\r
-lhs: ident | \T{Index}\L{ expr expr }\r
-\r
-ident: \T{Id}\L{ \P{string} }\r
-\r
-binopid: "add" | "sub" | "mul"    | "div"\r
-       | "mod" | "pow" | "concat" | "eq"\r
-       | "lt"  | "le"  | "and"    | "or"\r
-\r
-unopid:  "not" | "len" | "unm"\r
-\end{alltt}\r
-  \r
-% {\bf{}Relaxed forms:}\r
-\r
-% stat +=\r
-% | \L{ stat\star }\r
-% | \T{Let}\L{ (\L{lhs\plus}|lhs) (\L{expr\plus}|expr) }\r
-% | \T{Forin}\L{ (\L{ident\plus}|ident)  (\L{expr\plus}|expr) block }\r
-% | \T{Local}\L{ (\L{ident\plus}|ident)  (\L{expr\plus}|expr)? }\r
-\r
-% lhs += \T{Index}\L{ expr expr\plus }\r
-\r
-% expr += \r
-% | \T{Function}\L{ ident? block }\r
-% | \P{number}\r
-% | \P{string}\r
-\r
-% {\bf{}Translations:}\r
-% \C{do \V{foo}; \V{bar} end} \TRANS \T{Do}\L{ \C{\V{foo}}, \C{\V{bar}}}\r
-% \C{\V{v1},\V{v2},\V{v3} = \V{e1},\V{e2},\V{e3}} \TRANS \T{Let}\L{\L{\C{\V{v1}},\C{\V{v2}},\C{\V{v3}}}, \L{\C{\V{e1}},\C{\V{e2}},\C{\V{e3}}}}\r
-% \C{\V{foo}(\V{bar1}, \V{bar2})} \TRANS \T{Call}\L{\C{\V{foo}},\C{\V{bar1}},\C{\V{bar2}}}\r
-% \C{while \V{foo} do \V{bar}; \V{gna} end} \TRANS \T{While}\L{\C{\V{foo}},\T{Do}\L{\C{\V{bar}},\C{\V{gna}}}}\r
-% \C{repeat \V{foo}; \V{bar} until \V{gna}} \TRANS \T{Repeat}\L{\T{Do}\L{\C{\V{foo}},\C{\V{bar}}},\C{\V{gna}}}\r
-\r
-% \end{alltt}\r
-\r
-\r
-%\end{document}\r
-\r
-%stat:\r
-%| \T{Splice}\L{ expr }\r
-\r
-%expr:\r
-%| \T{Quote}\L{ \T{Exprr}, expr  }\r
-%| \T{Quote}\L{ \T{Stat}, stat }\r
-%| \T{Quote}\L{ \T{Id},   ident }\r
-%| \T{Splice}\L{ expr }\r
-\r
-%expr relaxed:\r
-%| \T{Quote}\L{ expr }\r
+% \documentclass{article}
+% \title{MetaLua Abstract Syntax Trees}
+% \setlength{\columnseprule}{1pt}
+\def\T#1{{\bf`#1}}
+\def\L#1{\{#1\}}
+\def\P#1{{\it #1}}
+\def\C#1{[\hspace{-.4em}[#1]\hspace{-.4em}]}
+\def\V#1{{\it #1}}
+\def\plus{\ensuremath{{}^{+}}}
+\def\star{\ensuremath{{}^{*}}}
+\def\TRANS{\ensuremath{\Longrightarrow}}
+% \usepackage{alltt}
+% \begin{document}
+% \maketitle
+
+\section{Abstract Syntax Tree grammar}
+
+\begin{alltt}
+
+block: \L{ stat\star }
+
+stat:
+| \T{Do}\L{ block }
+| \T{Set}\L{ \L{lhs\plus} \L{expr\plus} }
+| \T{While}\L{ expr block }
+| \T{Repeat}\L{ block expr }
+| \T{If}\L{ (expr block)\plus block? }
+| \T{Fornum}\L{ ident expr expr expr? block }
+| \T{Forin}\L{ \L{ident\plus} \L{expr\plus} block }
+| \T{Local}\L{ \L{ident\plus} \L{expr\plus}? }
+| \T{Localrec}\L{ \L{ident\plus} \L{expr\plus}? }
+| \T{Goto}\L{\P{string}}
+| \T{Label}\L{\P{string}}
+| \T{Return}
+| \T{Break}
+| apply
+
+expr:
+| \T{Nil} | \T{Dots} | \T{True} | \T{False}
+| \T{Number}\L{ \P{number} }
+| \T{String}\L{ \P{string} }
+| \T{Function}\L{ \L{ ident\star \T{Dots}? } block } 
+| \T{Table}\L{ ( \T{Pair}\L{ expr expr } | expr )\star }
+| \T{Op}\L{ binopid expr expr } | \T{Op}\L{ unopid expr }
+| \T{Paren}\L{ expr }
+| \T{Stat}\L{ block expr }
+| apply
+| lhs
+
+apply:
+| \T{Call}\L{ expr expr\star }
+| \T{Invoke}\L{ expr \T{String}\L{ \P{string} } expr\star }
+
+lhs: ident | \T{Index}\L{ expr expr }
+
+ident: \T{Id}\L{ \P{string} }
+
+binopid: "add" | "sub" | "mul"    | "div"
+       | "mod" | "pow" | "concat" | "eq"
+       | "lt"  | "le"  | "and"    | "or"
+
+unopid:  "not" | "len" | "unm"
+\end{alltt}
+  
+% {\bf{}Relaxed forms:}
+
+% stat +=
+% | \L{ stat\star }
+% | \T{Let}\L{ (\L{lhs\plus}|lhs) (\L{expr\plus}|expr) }
+% | \T{Forin}\L{ (\L{ident\plus}|ident)  (\L{expr\plus}|expr) block }
+% | \T{Local}\L{ (\L{ident\plus}|ident)  (\L{expr\plus}|expr)? }
+
+% lhs += \T{Index}\L{ expr expr\plus }
+
+% expr += 
+% | \T{Function}\L{ ident? block }
+% | \P{number}
+% | \P{string}
+
+% {\bf{}Translations:}
+% \C{do \V{foo}; \V{bar} end} \TRANS \T{Do}\L{ \C{\V{foo}}, \C{\V{bar}}}
+% \C{\V{v1},\V{v2},\V{v3} = \V{e1},\V{e2},\V{e3}} \TRANS \T{Let}\L{\L{\C{\V{v1}},\C{\V{v2}},\C{\V{v3}}}, \L{\C{\V{e1}},\C{\V{e2}},\C{\V{e3}}}}
+% \C{\V{foo}(\V{bar1}, \V{bar2})} \TRANS \T{Call}\L{\C{\V{foo}},\C{\V{bar1}},\C{\V{bar2}}}
+% \C{while \V{foo} do \V{bar}; \V{gna} end} \TRANS \T{While}\L{\C{\V{foo}},\T{Do}\L{\C{\V{bar}},\C{\V{gna}}}}
+% \C{repeat \V{foo}; \V{bar} until \V{gna}} \TRANS \T{Repeat}\L{\T{Do}\L{\C{\V{foo}},\C{\V{bar}}},\C{\V{gna}}}
+
+% \end{alltt}
+
+
+%\end{document}
+
+%stat:
+%| \T{Splice}\L{ expr }
+
+%expr:
+%| \T{Quote}\L{ \T{Exprr}, expr  }
+%| \T{Quote}\L{ \T{Stat}, stat }
+%| \T{Quote}\L{ \T{Id},   ident }
+%| \T{Splice}\L{ expr }
+
+%expr relaxed:
+%| \T{Quote}\L{ expr }