Skip to content

Commit c360fe1

Browse files
committed
[asl] Some minor lexer/parser tidying
Partly from suggestions by @acjf3 and @ldesnogu
1 parent e13921d commit c360fe1

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

asllib/Lexer.mll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,9 @@ let mask = (bit | 'x' | '(' bit+ ')')*
386386
let identifier = alpha_ (alpha_|digit)*
387387

388388
let forbidden_hex_first = '0' 'x' [^'a'-'f' 'A'-'F' '0'-'9']
389-
let forbidden_hex_remaining = '0' 'x' hex_digit hex_digit_* ['g'-'z' 'G'-'Z']
389+
let forbidden_hex_remaining = hex_lit ['g'-'z' 'G'-'Z']
390390
let forbidden_real_first = int_lit '.' [^'0'-'9' '.']
391-
let forbidden_real_remaining = int_lit '.' digit digit_* alpha
391+
let forbidden_real_remaining = int_lit '.' int_lit alpha
392392

393393
(*
394394
Lexing of string literals

asllib/Parser.mly

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -522,8 +522,6 @@ let global_keyword ==
522522
| global_keyword_non_config
523523
| CONFIG; { GDK_Config }
524524

525-
let pass == { S_Pass }
526-
let assign(x, y) == ~=x ; EQ ; ~=y ; < S_Assign >
527525
let direction := | TO; { AST.Up } | DOWNTO; { AST.Down }
528526

529527
let case_alt :=
@@ -562,8 +560,8 @@ let stmt :=
562560
| TRY; s=stmt_list; CATCH; c=list1(catcher); o=otherwise_opt; < S_Try >
563561
)
564562
| terminated_by(SEMI_COLON,
565-
| PASS; pass
566-
| RETURN; ~=option(expr); < S_Return >
563+
| PASS; { S_Pass }
564+
| RETURN; ~=option(expr); < S_Return >
567565
| ~=call; < s_call >
568566
| ASSERT; e=expr; < S_Assert >
569567
| ~=local_decl_keyword; ~=decl_item; ~=ty_opt; EQ; ~=some(expr); < S_Decl >
@@ -593,7 +591,7 @@ let stmt_list := ~ = list1(stmt) ; <stmt_from_list>
593591
let s_else :=
594592
annotated (
595593
| ELSIF; e=expr; THEN; s1=stmt_list; s2=s_else; <S_Cond>
596-
| pass
594+
| { S_Pass }
597595
)
598596
| ELSE; stmt_list
599597

asllib/doc/LexicalStructure.tex

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,7 @@ \section{Integer Literals\label{sec:Integer Literals}}
150150
$\REhexlit$ &$\triangleq$& \texttt{"0x"} (\REdigit\ \texttt{|} \REhexletter) \\
151151
& & $\wrappedline$ (\Underscore\ \texttt{|} \REdigit\ \texttt{|} \REhexletter)* \\
152152
$\REforbiddenhexfirst$ &$\triangleq$& \texttt{"0x"} ((\REchar\ \regexminus{} \REdigit) \regexminus{} \REhexletter) \\
153-
$\REforbiddenhexremaining$ &$\triangleq$& \texttt{"0x"} (\REdigit\ \texttt{|} \REhexletter) \\
154-
& & $\wrappedline$ (\Underscore\ \texttt{|} \REdigit\ \texttt{|} \REhexletter)* \\
155-
& & $\wrappedline$ (\REletter{} \regexminus{} \REhexletter) \\
153+
$\REforbiddenhexremaining$ &$\triangleq$& $\REhexlit$ (\REletter{} \regexminus{} \REhexletter) \\
156154
\end{tabular}
157155
\end{center}
158156

@@ -172,12 +170,9 @@ \section{Rational Number Literals\label{sec:Rational Number Literals}}
172170
This is formalized by the following lexical regular expression:
173171
\begin{center}
174172
\begin{tabular}{rcl}
175-
$\REreallit$ &$\triangleq$ & \texttt{\REdigit\ (\Underscore\ | \REdigit)* "." \REdigit} \\
176-
& & $\wrappedline$ \texttt{(\Underscore\ | \REdigit)*} \\
177-
$\REforbiddenrealfirst$ &$\triangleq$ & \texttt{\REdigit\ (\Underscore\ | \REdigit)* "."} \\
178-
& & $\wrappedline$ \texttt{ (\REchar\ \regexminus{} \anycharacter{\texttt{0123456789.}})} \\
179-
$\REforbiddenrealremaining$ &$\triangleq$& \texttt{\REdigit\ (\Underscore\ | \REdigit)* "." \REdigit} \\
180-
& & $\wrappedline$ \texttt{(\Underscore\ | \REdigit)* \REletter{}} \\
173+
$\REreallit$ &$\triangleq$ & $\REintlit$ \texttt{"."} $\REintlit$ \\
174+
$\REforbiddenrealfirst$ &$\triangleq$ & $\REintlit$ \texttt{ (\REchar\ \regexminus{} \anycharacter{\texttt{0123456789.}})} \\
175+
$\REforbiddenrealremaining$ &$\triangleq$& $\REintlit$ \texttt{"."} $\REintlit$ \REletter{} \\
181176
\end{tabular}
182177
\end{center}
183178

0 commit comments

Comments
 (0)