Skip to content

Commit 7fc0cf9

Browse files
[aslspec][asl reference] imported the syntax and AST builders to aslspec
1 parent 921f92b commit 7fc0cf9

23 files changed

Lines changed: 2754 additions & 909 deletions

asllib/doc/ASLFormal.tex

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,20 +1070,9 @@ \section{Conventionally-used Judgments and Notations\label{sec:ConventionallyUse
10701070
We now present functions used conventionally in this reference.
10711071

10721072
\subsection{Checked Transitions\label{sec:Checked Transitions}}
1073-
\hypertarget{relation-becheck}{}
10741073
\hypertarget{type-builderror}{}
1075-
The function
1076-
\[
1077-
\becheck(\overname{\Bool}{\vb}, \overname{\Strings}{\vcode}) \aslto \{\True\}
1078-
\cup\ \overname{\TBuildError}{\BuildErrorConfig}
1079-
\]
1080-
takes a Boolean value $\vb$ and an error code $\vcode$
1081-
and returns $\True$ when $\vb$ is $\True$ and a build error \configurationterm{} for $\vcode$, otherwise.
1082-
\begin{mathpar}
1083-
\inferrule[be\_check\_true]{}{ \becheck(\True, \vcode) \astarrow \True }
1084-
\hva\and
1085-
\inferrule[be\_check\_false]{}{ \becheck(\False, \vcode) \astarrow \BuildError(\vcode) }
1086-
\end{mathpar}
1074+
\RenderRelation{be_check}
1075+
\RenderProseAndFormally{be_check}
10871076

10881077
We define a similar function for type errors.
10891078
\RenderRelation{te_check}

asllib/doc/ASLmacros.tex

Lines changed: 26 additions & 113 deletions
Large diffs are not rendered by default.

asllib/doc/AbstractSyntax.tex

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,13 +422,14 @@ \section{Building Parameterized Productions\label{sec:BuildingParameterizedProdu
422422
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
423423
This section defines builder relations for the
424424
subset of macro productions in \secref{ParametricProductions}
425-
that are not inlined:
425+
that are not inlined as well as helper builder relations:
426426
\begin{itemize}
427427
\item \ASTRuleRef{List}
428428
\item \ASTRuleRef{CList}
429429
\item \ASTRuleRef{PList}
430430
\item \ASTRuleRef{NTCList}
431431
\item \ASTRuleRef{Option}
432+
\item \ASTRuleRef{Identifier}
432433
\end{itemize}
433434

434435
We also define \ASTRuleRef{Identity},
@@ -584,6 +585,10 @@ \section{Building Parameterized Productions\label{sec:BuildingParameterizedProdu
584585
}
585586
\end{mathpar}
586587

588+
\ASTRuleDef{Identifier}
589+
\RenderRelation{build_identifier_token}
590+
\RenderProseAndFormally{build_identifier_token}
591+
587592
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
588593
\section{Transforming Assignable Expressions\label{sec:LeftToRight}}
589594
\RenderRelation{rexpr}

asllib/doc/AssignableExpressions.tex

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,7 @@ \chapter{Assignable Expressions\label{chap:AssignableExpressions}}
124124
\end{flalign*}
125125

126126
\ASTRuleDef{LExpr}
127-
\hypertarget{build-lexpr}{}
128-
The function
129-
\[
130-
\buildlexpr(\overname{\parsenode{\Nlexpr}}{\vparsednode}) \;\aslto\; \overname{\lexpr}{\vastnode}
131-
\]
132-
transforms a parse node $\vparsednode$ into an AST node $\vastnode$.
127+
\RenderRelation{build_lexpr}
133128

134129
\begin{mathpar}
135130
\inferrule[discard]{}{
@@ -187,12 +182,7 @@ \chapter{Assignable Expressions\label{chap:AssignableExpressions}}
187182
\end{mathpar}
188183

189184
\ASTRuleDef{BasicLexpr}
190-
\hypertarget{build-basiclexpr}{}
191-
The function
192-
\[
193-
\buildbasiclexpr(\overname{\parsenode{\Nbasiclexpr}}{\vparsednode}) \;\aslto\; (\overname{\Identifier}{\vbase} \aslsep \overname{\lhsaccess}{\vlhsaccess})
194-
\]
195-
transforms a parse node $\vparsednode$ into a pair of AST nodes, $\vbase$ and $\vlhsaccess$.
185+
\RenderRelation{build_basic_lexpr}
196186

197187
\begin{mathpar}
198188
\inferrule[no\_slices]{
@@ -229,14 +219,7 @@ \chapter{Assignable Expressions\label{chap:AssignableExpressions}}
229219
\end{mathpar}
230220

231221
\ASTRuleDef{Access}
232-
233-
\hypertarget{build-access}{}
234-
The function
235-
\[
236-
\buildaccess(\overname{\parsenode{\Naccess}}{\vparsednode}) \;\aslto
237-
\overname{\KleeneStar{\fieldorarrayaccess}}{\vastnode}
238-
\]
239-
transforms a parse node $\vparsednode$ into an AST node $\vastnode$.
222+
\RenderRelation{build_access}
240223

241224
\begin{mathpar}
242225
\inferrule[empty]{}{
@@ -259,15 +242,7 @@ \chapter{Assignable Expressions\label{chap:AssignableExpressions}}
259242
\end{mathpar}
260243

261244
\ASTRuleDef{DiscardOrBasicLexpr}
262-
\hypertarget{build-discardorbasiclexpr}{}
263-
The function
264-
\[
265-
\begin{array}{r}
266-
\builddiscardorbasiclexpr(\overname{\parsenode{\Ndiscardorbasiclexpr}}{\vparsednode}) \;\aslto\\
267-
\overname{\Option{(\Identifier, \lhsaccess)}}{\vastnode}
268-
\end{array}
269-
\]
270-
transforms a parse node $\vparsednode$ into an AST node $\vastnode$.
245+
\RenderRelation{build_discard_or_basic_lexpr}
271246

272247
\begin{mathpar}
273248
\inferrule[discard]{}{
@@ -287,15 +262,7 @@ \chapter{Assignable Expressions\label{chap:AssignableExpressions}}
287262
\end{mathpar}
288263

289264
\ASTRuleDef{DiscardOrIdentifier}
290-
\hypertarget{build-discardoridentifier}{}
291-
The function
292-
\[
293-
\begin{array}{r}
294-
\builddiscardoridentifier(\overname{\parsenode{\Ndiscardoridentifier}}{\vparsednode}) \;\aslto
295-
\overname{\Option{\Identifier}}{\vastnode}
296-
\end{array}
297-
\]
298-
transforms a parse node $\vparsednode$ into an AST node $\vastnode$.
265+
\RenderRelation{build_discard_or_identifier}
299266

300267
\begin{mathpar}
301268
\inferrule[none]{}{

asllib/doc/Bitfields.tex

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,7 @@ \section{Nested Bitfields\label{sec:Nested Bitfields}}
124124
\RenderType[remove_hypertargets]{bitfield}
125125

126126
\ASTRuleDef{Bitfields}
127-
\NotImportedToASLSpecYet{
128-
\hypertarget{build-bitfields}{}
129-
The function
130-
\[
131-
\buildbitfields(\overname{\parsenode{\Nbitfields}}{\vparsednode}) \;\aslto\; \overname{\KleeneStar{\bitfield}}{\vastnode}
132-
\]
133-
transforms a parse node $\vparsednode$ into an AST node $\vastnode$.
134-
} % END_OF_UNIMPORTED_RELATION
127+
\RenderRelation{build_bitfields}
135128

136129

137130
\begin{mathpar}
@@ -148,14 +141,7 @@ \section{Nested Bitfields\label{sec:Nested Bitfields}}
148141
\end{mathpar}
149142

150143
\ASTRuleDef{Bitfield}
151-
\NotImportedToASLSpecYet{
152-
\hypertarget{build-bitfield}{}
153-
The function
154-
\[
155-
\buildbitfield(\overname{\parsenode{\Nbitfield}}{\vparsednode}) \;\aslto\; \overname{\bitfield}{\vastnode}
156-
\]
157-
transforms a parse node $\vparsednode$ into an AST node $\vastnode$.
158-
} % END_OF_UNIMPORTED_RELATION
144+
\RenderRelation{build_bitfield}
159145

160146

161147
\begin{mathpar}

asllib/doc/CatchingExceptions.tex

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,7 @@ \chapter{Catching Exceptions\label{chap:CatchingExceptions}}
5050
\RenderType[remove_hypertargets]{catcher}
5151

5252
\ASTRuleDef{Catcher}
53-
\NotImportedToASLSpecYet{
54-
\hypertarget{build-catcher}{}
55-
The function
56-
\[
57-
\buildcatcher(\overname{\parsenode{\Ncatcher}}{\vparsednode}) \;\aslto\; \overname{\catcher}{\vastnode}
58-
\]
59-
transforms a parse node $\vparsednode$ into an AST node $\vastnode$.
60-
} % END_OF_UNIMPORTED_RELATION
53+
\RenderRelation{build_catcher}
6154

6255
\begin{mathpar}
6356
\inferrule[named]{}{

asllib/doc/Expressions.tex

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,7 @@ \chapter{Expressions\label{chap:Expressions}}
4646

4747
\paragraph{Abstract Syntax:} Expressions are derived in the abstract syntax from $\expr$,
4848
and generated by $\buildexpr$.
49-
\NotImportedToASLSpecYet{
50-
\hypertarget{build-expr}{}
51-
The function
52-
\[
53-
\buildexpr(\overname{\parsenode{\Nexpr}}{\vparsednode}) \;\aslto\; \overname{\expr}{\vastnode}
54-
\cup \overname{\TBuildError}{\BuildErrorConfig}
55-
\]
56-
transforms an expression parse node $\vparsednode$ into an expression AST node $\vastnode$.
57-
\ProseOtherwiseBuildError
58-
} % END_OF_UNIMPORTED_RELATION
49+
\RenderRelation{build_expr}
5950

6051

6152
\paragraph{Typing:}
@@ -290,18 +281,7 @@ \subsection{Abstract Syntax}
290281
}
291282
\end{mathpar}
292283

293-
\NotImportedToASLSpecYet{
294-
\hypertarget{build-checknotsameprec}{}
295-
The function
296-
\[
297-
\checknotsameprec(\overname{\binop}{\op} \aslsep \overname{\expr}{\ve})
298-
\aslto \{\True\} \cup \overname{\TBuildError}{\BuildErrorConfig}
299-
\]
300-
checks whether the expression AST node $\ve$ is a binary operator, either with a different operator to $\op$ but the same \emph{precedence}, or the same non-associative operator $\op$.
301-
In either case, it is considered an error.
302-
Surrounding $\ve$ by parenthesis fixes the error.
303-
} % END_OF_UNIMPORTED_RELATION
304-
284+
\RenderRelation{check_not_same_prec}
305285

306286
For example, \texttt{a + b + c} is considered legal, since the same binary operator (\texttt{+})
307287
is used, whereas \texttt{a - b - c} and \texttt{a + b - c} are considered illegal.
@@ -633,13 +613,7 @@ \subsection{Abstract Syntax}
633613
\RenderTypes[remove_hypertargets]{expr_call}
634614

635615
\ASTRuleDef{Call}
636-
\texthypertarget{build-call}
637-
The function
638-
\[
639-
\buildcall(\overname{\parsenode{\Ncall}}{\vparsednode}) \astarrow \overname{\call}{\vastnode} \cup \overname{\TBuildError}{\BuildErrorConfig}
640-
\]
641-
constructs a call expression AST from a parse tree for a subprogram call.
642-
\ProseOtherwiseBuildError
616+
\RenderRelation{build_call}
643617

644618
\begin{mathpar}
645619
\inferrule{
@@ -1460,14 +1434,7 @@ \subsection{Abstract Syntax}
14601434
\end{mathpar}
14611435

14621436
\ASTRuleDef{FieldAssign}
1463-
\NotImportedToASLSpecYet{
1464-
\hypertarget{build-fieldassign}{}
1465-
The function
1466-
\[
1467-
\buildfieldassign(\overname{\parsenode{\Nfieldassign}}{\vparsednode}) \;\aslto\; \overname{(\Identifier, \expr)}{\vastnode}
1468-
\]
1469-
transforms a parse node $\vparsednode$ into an AST node $\vastnode$.
1470-
} % END_OF_UNIMPORTED_RELATION
1437+
\RenderRelation{build_field_assign}
14711438

14721439

14731440
\begin{mathpar}

asllib/doc/GlobalStorageDeclarations.tex

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -229,17 +229,7 @@ \section{Configurable Global Storage Declarations\label{sec:ConfigurableGlobalSt
229229
\end{mathpar}
230230

231231
\ASTRuleDef{GlobalDeclKeywordNonConfig}
232-
\NotImportedToASLSpecYet{
233-
\hypertarget{build-globaldeclkeywordnonconfig}{}
234-
The function
235-
\[
236-
\begin{array}{r}
237-
\buildglobaldeclkeywordnonconfig(\overname{\parsenode{\Nglobaldeclkeywordnonconfig}}{\vparsednode}) \aslto \\
238-
\overname{\globaldeclkeyword}{\vastnode}
239-
\end{array}
240-
\]
241-
transforms a parse node $\vparsednode$ into an AST node $\vastnode$.
242-
} % END_OF_UNIMPORTED_RELATION
232+
\RenderRelation{build_global_decl_keyword_non_config}
243233

244234

245235
\begin{mathpar}
@@ -273,17 +263,7 @@ \section{Configurable Global Storage Declarations\label{sec:ConfigurableGlobalSt
273263
\end{mathpar}
274264

275265
\ASTRuleDef{GlobalDeclKeyword}
276-
\NotImportedToASLSpecYet{
277-
\hypertarget{build-globaldeclkeyword}{}
278-
The function
279-
\[
280-
\begin{array}{r}
281-
\buildglobaldeclkeyword(\overname{\parsenode{\Nglobaldeclkeyword}}{\vparsednode}) \aslto \\
282-
\overname{\globaldeclkeyword}{\vastnode}
283-
\end{array}
284-
\]
285-
transforms a parse node $\vparsednode$ into an AST node $\vastnode$.
286-
} % END_OF_UNIMPORTED_RELATION
266+
\RenderRelation{build_global_decl_keyword}
287267

288268

289269
\begin{mathpar}

asllib/doc/Literals.tex

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,9 @@ \chapter{Literals\label{chap:Literals}}
4949
\RenderType[remove_hypertargets]{literal}
5050

5151
\subsection{ASTRule.Value \label{sec:ASTRule.Value}}
52-
\NotImportedToASLSpecYet{
53-
\hypertarget{build-value}{}
54-
The function
55-
\[
56-
\buildvalue(\overname{\parsenode{\Nvalue}}{\vparsednode}) \;\aslto\; \overname{\literal}{\vastnode}
57-
\]
58-
transforms a parse node $\vparsednode$ for $\Nvalue$, except for enumeration labels,
59-
into an AST node $\vastnode$ for $\literal$.
60-
} % END_OF_UNIMPORTED_RELATION
52+
\RenderRelation{build_value}
6153

54+
\BackupRule{
6255
\begin{mathpar}
6356
\inferrule[integer]{}{
6457
\buildvalue(\Nvalue(\Tintlit(\vi))) \astarrow
@@ -93,6 +86,8 @@ \subsection{ASTRule.Value \label{sec:ASTRule.Value}}
9386
\overname{\LString(\vs)}{\vastnode}
9487
}
9588
\end{mathpar}
89+
} % END_OF_BACKUP
90+
\RenderProseAndFormally{build_value}
9691

9792
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9893
\TypeRulesDef{Literals}

asllib/doc/LocalStorageDeclarations.tex

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,7 @@ \chapter{Local Storage Declarations\label{chap:LocalStorageDeclarations}}
7474
\ASLListing{Illegal local storage declarations that discard all storage elements}{local-storage-discards}{\syntaxtests/GuideRule.DiscardingLocalStorageDeclarations.asl}
7575

7676
\ASTRuleDef{LocalDeclKeyword}
77-
\NotImportedToASLSpecYet{
78-
\hypertarget{build-localdeclkeyword}{}
79-
The function
80-
\[
81-
\buildlocaldeclkeyword(\overname{\parsenode{\Nlocaldeclkeyword}}{\vparsednode}) \;\aslto\;
82-
\overname{\localdeclkeyword}{\vastnode}
83-
\]
84-
transforms a parse node $\vparsednode$ into an AST node $\vastnode$.
85-
} % END_OF_UNIMPORTED_RELATION
77+
\RenderRelation{build_local_decl_keyword}
8678

8779

8880
% Transliteration note: simplify this when `--allow-local-constants' is removed.
@@ -100,14 +92,7 @@ \chapter{Local Storage Declarations\label{chap:LocalStorageDeclarations}}
10092
\end{mathpar}
10193

10294
\ASTRuleDef{DeclItem}
103-
\NotImportedToASLSpecYet{
104-
\hypertarget{build-declitem}{}
105-
The function
106-
\[
107-
\builddeclitem(\overname{\parsenode{\Ndeclitem}}{\vparsednode}) \;\aslto\; \overname{\localdeclitem}{\vastnode}
108-
\]
109-
transforms a parse node $\vparsednode$ into an AST node $\vastnode$.
110-
} % END_OF_UNIMPORTED_RELATION
95+
\RenderRelation{build_decl_item}
11196

11297

11398
\begin{mathpar}
@@ -133,15 +118,7 @@ \chapter{Local Storage Declarations\label{chap:LocalStorageDeclarations}}
133118
\end{mathpar}
134119

135120
\ASTRuleDef{IgnoredOrIdentifier}
136-
\NotImportedToASLSpecYet{
137-
\hypertarget{build-ignoredoridentifier}{}
138-
The relation
139-
\[
140-
\buildfuncargs(\overname{\parsenode{\Nignoredoridentifier}}{\vparsednode}) \;\aslrel\;
141-
\overname{\Identifier}{\vastnode}
142-
\]
143-
transforms a parse node $\vparsednode$ into an AST node $\vastnode$.
144-
} % END_OF_UNIMPORTED_RELATION
121+
\RenderRelation{build_ignored_or_identifier}
145122

146123

147124
\begin{mathpar}

0 commit comments

Comments
 (0)