Browse Source

add tail to C lang grammars

Jeremy Siek 2 năm trước cách đây
mục cha
commit
0c43b39ee8
1 tập tin đã thay đổi với 9 bổ sung9 xóa
  1. 9 9
      book.tex

+ 9 - 9
book.tex

@@ -8462,8 +8462,8 @@ in figure~\ref{fig:c1-syntax}.
      \MID \CUNIOP{\itm{unaryop}}{\Atm} \\
      &\MID& \CCMP{\itm{cmp}}{\Atm}{\Atm} \\
 \Stmt &::=& \CPRINT{\Atm} \MID \Exp \\
-     &\MID& \CASSIGN{\Var}{\Exp}  
-     \MID \CRETURN{\Exp} \MID \CGOTO{\itm{label}} \\
+      &\MID& \CASSIGN{\Var}{\Exp}  \\
+\Tail &::=& \CRETURN{\Exp} \MID \CGOTO{\itm{label}} \\
     &\MID& \CIFSTMT{\CCMP{\itm{cmp}}{\Atm}{\Atm}}{\CGOTO{\itm{label}}}{\CGOTO{\itm{label}}} 
 \end{array}
 }
@@ -8475,8 +8475,8 @@ in figure~\ref{fig:c1-syntax}.
      \MID \UNIOP{\itm{unaryop}}{\Atm} \\
      &\MID& \CMP{\Atm}{\itm{cmp}}{\Atm} \\
 \Stmt &::=& \PRINT{\Atm} \MID \EXPR{\Exp} \\
-     &\MID& \ASSIGN{\VAR{\Var}}{\Exp}  
-     \MID \RETURN{\Exp} \MID \GOTO{\itm{label}} \\
+     &\MID& \ASSIGN{\VAR{\Var}}{\Exp}  \\
+\Tail &::= & \RETURN{\Exp} \MID \GOTO{\itm{label}} \\
      &\MID& \IFSTMT{\CMP{\Atm}{\itm{cmp}}{\Atm}}{\LS\GOTO{\itm{label}}\RS}{\LS\GOTO{\itm{label}}\RS}
 \end{array}
 }
@@ -8500,7 +8500,7 @@ in figure~\ref{fig:c1-syntax}.
 \begin{array}{l}
   \CifGrammarPython \\
 \begin{array}{lcl}
-\LangCIfM{} & ::= & (\itm{label}\code{:}~\Stmt^{*}) \ldots
+\LangCIfM{} & ::= & (\itm{label}\code{:}~\Stmt^{*}\;\Tail) \ldots
 \end{array}
 \end{array}
 \]
@@ -8530,7 +8530,7 @@ in figure~\ref{fig:c1-syntax}.
 \begin{array}{l}
   \CifASTPython \\ 
 \begin{array}{lcl}
-\LangCIfM{} & ::= & \CPROGRAM{\itm{info}}{\LC\itm{label}\key{:}\,\Stmt^{*}, \ldots \RC}
+\LangCIfM{} & ::= & \CPROGRAM{\itm{info}}{\LC\itm{label}\key{:}\,\Stmt^{*}\;\Tail, \ldots \RC}
 \end{array}
 \end{array}
 \]
@@ -13152,7 +13152,7 @@ pass, which is \LangAlloc{} in monadic normal form.
   \gray{\CifASTPython} \\ \hline
   \CtupASTPython \\
 \begin{array}{lcl}
-\LangCVecM{} & ::= & \CPROGRAM{\itm{info}}{\LC\itm{label}\key{:}\,\Stmt^{*}, \ldots \RC}
+\LangCVecM{} & ::= & \CPROGRAM{\itm{info}}{\LC\itm{label}\key{:}\,\Stmt^{*}\;\Tail, \ldots \RC}
 \end{array}
 \end{array}
 \]
@@ -15670,9 +15670,9 @@ appropriate explicate functions for the various contexts.
 \newcommand{\CfunASTPython}{
 \begin{array}{lcl}
 \Exp &::= & \FUNREF{\itm{label}}{\Int} \MID \CALL{\Atm}{\Atm^{*}} \\
-\Stmt &::= & \TAILCALL{\Atm}{\Atm^{*}} \\
+\Tail &::= & \TAILCALL{\Atm}{\Atm^{*}} \\
 \Params &::=& \LS\LP\Var\key{,}\Type\RP\code{,}\ldots\RS \\
-\Block &::=& \itm{label}\key{:} \Stmt^{*} \\
+\Block &::=& \itm{label}\key{:} \Stmt^{*}\;\Tail \\
 \Blocks &::=& \LC\Block\code{,}\ldots\RC \\
 \Def &::=& \DEF{\itm{label}}{\Params}{\Blocks}{\key{None}}{\Type}{\key{None}} 
 \end{array}