| 1 |
structure |
| 2 |
Tokens = struct |
| 3 |
|
| 4 |
datatype token = EOF |
| 5 |
| REAL of Real.real |
| 6 |
| INT of IntInf.int |
| 7 |
| ID of string |
| 8 |
| MULOP of string |
| 9 |
| ADDOP of string |
| 10 |
| RELOP of string |
| 11 |
| MINUS |
| 12 |
| RP |
| 13 |
| LP |
| 14 |
| RSB |
| 15 |
| LSB |
| 16 |
| DOT |
| 17 |
| SEMI |
| 18 |
| COLON |
| 19 |
| COMMA |
| 20 |
| ASSIGNOP |
| 21 |
| KW_not |
| 22 |
| KW_do |
| 23 |
| KW_while |
| 24 |
| KW_else |
| 25 |
| KW_then |
| 26 |
| KW_if |
| 27 |
| KW_end |
| 28 |
| KW_begin |
| 29 |
| KW_procedure |
| 30 |
| KW_function |
| 31 |
| KW_real |
| 32 |
| KW_integer |
| 33 |
| KW_of |
| 34 |
| KW_array |
| 35 |
| KW_var |
| 36 |
| KW_program |
| 37 |
|
| 38 |
val allToks = [EOF, ID("bogus"), MINUS, RP, LP, RSB, LSB, DOT, SEMI, COLON, COMMA, ASSIGNOP, KW_not, KW_do, KW_while, KW_else, KW_then, KW_if, KW_end, KW_begin, KW_procedure, KW_function, KW_real, KW_integer, KW_of, KW_array, KW_var, KW_program] |
| 39 |
|
| 40 |
fun toString tok = |
| 41 |
(case (tok) |
| 42 |
of (EOF) => "EOF" |
| 43 |
| (REAL(_)) => "REAL" |
| 44 |
| (INT(_)) => "INT" |
| 45 |
| (ID(_)) => "ID" |
| 46 |
| (MULOP(_)) => "MULOP" |
| 47 |
| (ADDOP(_)) => "ADDOP" |
| 48 |
| (RELOP(_)) => "RELOP" |
| 49 |
| (MINUS) => "-" |
| 50 |
| (RP) => ")" |
| 51 |
| (LP) => "(" |
| 52 |
| (RSB) => "]" |
| 53 |
| (LSB) => "[" |
| 54 |
| (DOT) => "." |
| 55 |
| (SEMI) => ";" |
| 56 |
| (COLON) => ":" |
| 57 |
| (COMMA) => "," |
| 58 |
| (ASSIGNOP) => ":=" |
| 59 |
| (KW_not) => "not" |
| 60 |
| (KW_do) => "do" |
| 61 |
| (KW_while) => "while" |
| 62 |
| (KW_else) => "else" |
| 63 |
| (KW_then) => "then" |
| 64 |
| (KW_if) => "if" |
| 65 |
| (KW_end) => "end" |
| 66 |
| (KW_begin) => "begin" |
| 67 |
| (KW_procedure) => "procedure" |
| 68 |
| (KW_function) => "function" |
| 69 |
| (KW_real) => "real" |
| 70 |
| (KW_integer) => "integer" |
| 71 |
| (KW_of) => "of" |
| 72 |
| (KW_array) => "array" |
| 73 |
| (KW_var) => "var" |
| 74 |
| (KW_program) => "program" |
| 75 |
(* end case *)) |
| 76 |
fun isKW tok = |
| 77 |
(case (tok) |
| 78 |
of (EOF) => false |
| 79 |
| (REAL(_)) => false |
| 80 |
| (INT(_)) => false |
| 81 |
| (ID(_)) => false |
| 82 |
| (MULOP(_)) => false |
| 83 |
| (ADDOP(_)) => false |
| 84 |
| (RELOP(_)) => false |
| 85 |
| (MINUS) => false |
| 86 |
| (RP) => false |
| 87 |
| (LP) => false |
| 88 |
| (RSB) => false |
| 89 |
| (LSB) => false |
| 90 |
| (DOT) => false |
| 91 |
| (SEMI) => false |
| 92 |
| (COLON) => false |
| 93 |
| (COMMA) => false |
| 94 |
| (ASSIGNOP) => false |
| 95 |
| (KW_not) => true |
| 96 |
| (KW_do) => true |
| 97 |
| (KW_while) => true |
| 98 |
| (KW_else) => true |
| 99 |
| (KW_then) => true |
| 100 |
| (KW_if) => true |
| 101 |
| (KW_end) => true |
| 102 |
| (KW_begin) => true |
| 103 |
| (KW_procedure) => true |
| 104 |
| (KW_function) => true |
| 105 |
| (KW_real) => true |
| 106 |
| (KW_integer) => true |
| 107 |
| (KW_of) => true |
| 108 |
| (KW_array) => true |
| 109 |
| (KW_var) => true |
| 110 |
| (KW_program) => true |
| 111 |
(* end case *)) |
| 112 |
val changes = [] |
| 113 |
|
| 114 |
|
| 115 |
fun isEOF EOF = true |
| 116 |
| isEOF _ = false |
| 117 |
|
| 118 |
end |
| 119 |
|
| 120 |
functor ParseFn(Lex : ANTLR_LEXER) = struct |
| 121 |
|
| 122 |
local |
| 123 |
structure Tok = |
| 124 |
Tokens |
| 125 |
structure UserCode = |
| 126 |
struct |
| 127 |
|
| 128 |
val cat = String.concat |
| 129 |
val catSp = String.concatWith " " |
| 130 |
val catNl = String.concatWith "\n" |
| 131 |
val catNlNl = String.concatWith "\n\n" |
| 132 |
val catCm = String.concatWith ", " |
| 133 |
val catSemi = String.concatWith "; " |
| 134 |
val catSemiNl = String.concatWith ";\n" |
| 135 |
|
| 136 |
fun program_PROD_1_ACT (ID, LP, RP, DOT, SR1, SR2, SEMI, compound_statement, id_list, KW_program, ID_SPAN : (Lex.pos * Lex.pos), LP_SPAN : (Lex.pos * Lex.pos), RP_SPAN : (Lex.pos * Lex.pos), DOT_SPAN : (Lex.pos * Lex.pos), SR1_SPAN : (Lex.pos * Lex.pos), SR2_SPAN : (Lex.pos * Lex.pos), SEMI_SPAN : (Lex.pos * Lex.pos), compound_statement_SPAN : (Lex.pos * Lex.pos), id_list_SPAN : (Lex.pos * Lex.pos), KW_program_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 137 |
( catNl [ |
| 138 |
cat ["program ", ID, "(", id_list, ");"], |
| 139 |
catNl SR1, catNlNl SR2, |
| 140 |
compound_statement ^ "." |
| 141 |
]) |
| 142 |
fun id_list_PROD_1_ACT (ID, SR, ID_SPAN : (Lex.pos * Lex.pos), SR_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 143 |
( catCm (ID::SR) ) |
| 144 |
fun declaration_PROD_1_ACT (SEMI, id_list_type, KW_var, SEMI_SPAN : (Lex.pos * Lex.pos), id_list_type_SPAN : (Lex.pos * Lex.pos), KW_var_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 145 |
( cat ["var ", id_list_type, ";"] ) |
| 146 |
fun compound_type_PROD_2_ACT (LSB, RSB, DOT1, DOT2, INT1, INT2, KW_array, standard_type, KW_of, LSB_SPAN : (Lex.pos * Lex.pos), RSB_SPAN : (Lex.pos * Lex.pos), DOT1_SPAN : (Lex.pos * Lex.pos), DOT2_SPAN : (Lex.pos * Lex.pos), INT1_SPAN : (Lex.pos * Lex.pos), INT2_SPAN : (Lex.pos * Lex.pos), KW_array_SPAN : (Lex.pos * Lex.pos), standard_type_SPAN : (Lex.pos * Lex.pos), KW_of_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 147 |
( cat ["array [", IntInf.toString INT1, "..", IntInf.toString INT2, "] of ", standard_type] ) |
| 148 |
fun standard_type_PROD_1_ACT (KW_integer, KW_integer_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 149 |
( "integer" ) |
| 150 |
fun standard_type_PROD_2_ACT (KW_real, KW_real_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 151 |
( "real" ) |
| 152 |
fun id_list_type_PROD_1_ACT (compound_type, COLON, id_list, compound_type_SPAN : (Lex.pos * Lex.pos), COLON_SPAN : (Lex.pos * Lex.pos), id_list_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 153 |
( catSp [id_list, ":", compound_type] ) |
| 154 |
fun subprogram_declaration_PROD_1_ACT (SR, SEMI, compound_statement, subprogram_head, SR_SPAN : (Lex.pos * Lex.pos), SEMI_SPAN : (Lex.pos * Lex.pos), compound_statement_SPAN : (Lex.pos * Lex.pos), subprogram_head_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 155 |
( catNl [subprogram_head, catNl SR, compound_statement ^ ";"] ) |
| 156 |
fun subprogram_head_PROD_1_ACT (ID, SEMI, standard_type, COLON, arguments, KW_function, ID_SPAN : (Lex.pos * Lex.pos), SEMI_SPAN : (Lex.pos * Lex.pos), standard_type_SPAN : (Lex.pos * Lex.pos), COLON_SPAN : (Lex.pos * Lex.pos), arguments_SPAN : (Lex.pos * Lex.pos), KW_function_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 157 |
( cat ["function ", ID, arguments, " : ", standard_type, ";"] ) |
| 158 |
fun subprogram_head_PROD_2_ACT (ID, SEMI, KW_procedure, arguments, ID_SPAN : (Lex.pos * Lex.pos), SEMI_SPAN : (Lex.pos * Lex.pos), KW_procedure_SPAN : (Lex.pos * Lex.pos), arguments_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 159 |
( cat ["procedure ", ID, arguments, ";"] ) |
| 160 |
fun arguments_PROD_1_ACT (LP, RP, parameter_list, LP_SPAN : (Lex.pos * Lex.pos), RP_SPAN : (Lex.pos * Lex.pos), parameter_list_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 161 |
( "(" ^ parameter_list ^ ")" ) |
| 162 |
fun arguments_PROD_2_ACT (FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 163 |
( "" ) |
| 164 |
fun parameter_list_PROD_1_ACT (SR, id_list_type, SR_SPAN : (Lex.pos * Lex.pos), id_list_type_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 165 |
( catSemi (id_list_type::SR) ) |
| 166 |
fun compound_statement_PROD_1_SUBRULE_1_PROD_1_ACT (SR, KW_begin, statement, SR_SPAN : (Lex.pos * Lex.pos), KW_begin_SPAN : (Lex.pos * Lex.pos), statement_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 167 |
( catSemiNl (statement::SR) ) |
| 168 |
fun compound_statement_PROD_1_ACT (SR, KW_begin, KW_end, SR_SPAN : (Lex.pos * Lex.pos), KW_begin_SPAN : (Lex.pos * Lex.pos), KW_end_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 169 |
( catNl ["begin", getOpt(SR, ""), "end"] ) |
| 170 |
fun statement_PROD_1_ACT (exp, variable, ASSIGNOP, exp_SPAN : (Lex.pos * Lex.pos), variable_SPAN : (Lex.pos * Lex.pos), ASSIGNOP_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 171 |
( cat [variable, " := ", exp] ) |
| 172 |
fun statement_PROD_4_ACT (exp, KW_else, KW_then, statement1, statement2, KW_if, exp_SPAN : (Lex.pos * Lex.pos), KW_else_SPAN : (Lex.pos * Lex.pos), KW_then_SPAN : (Lex.pos * Lex.pos), statement1_SPAN : (Lex.pos * Lex.pos), statement2_SPAN : (Lex.pos * Lex.pos), KW_if_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 173 |
( cat ["if ", exp, " then ", statement1, " else ", statement2] ) |
| 174 |
fun statement_PROD_5_ACT (exp, KW_while, KW_do, statement, exp_SPAN : (Lex.pos * Lex.pos), KW_while_SPAN : (Lex.pos * Lex.pos), KW_do_SPAN : (Lex.pos * Lex.pos), statement_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 175 |
( cat ["while ", exp, " do ", statement] ) |
| 176 |
fun variable_PROD_2_ACT (ID, LSB, RSB, exp, ID_SPAN : (Lex.pos * Lex.pos), LSB_SPAN : (Lex.pos * Lex.pos), RSB_SPAN : (Lex.pos * Lex.pos), exp_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 177 |
( cat [ID, "[", exp, "]"] ) |
| 178 |
fun procedure_statement_PROD_2_ACT (ID, LP, RP, SR, exp, ID_SPAN : (Lex.pos * Lex.pos), LP_SPAN : (Lex.pos * Lex.pos), RP_SPAN : (Lex.pos * Lex.pos), SR_SPAN : (Lex.pos * Lex.pos), exp_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 179 |
( cat [ID, "(", catCm (exp::SR), ")" ] ) |
| 180 |
fun exp_PROD_1_SUBRULE_1_PROD_1_ACT (simple_exp, RELOP, simple_exp_SPAN : (Lex.pos * Lex.pos), RELOP_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 181 |
( RELOP ^ " " ^ simple_exp ) |
| 182 |
fun exp_PROD_1_ACT (SR, simple_exp, SR_SPAN : (Lex.pos * Lex.pos), simple_exp_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 183 |
( catSp [simple_exp, getOpt(SR, "")] ) |
| 184 |
fun simple_exp_PROD_1_SUBRULE_1_PROD_1_ACT (signed_term, ADDOP, signed_term_SPAN : (Lex.pos * Lex.pos), ADDOP_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 185 |
( ADDOP ^ " " ^signed_term ) |
| 186 |
fun simple_exp_PROD_1_ACT (SR, signed_term, SR_SPAN : (Lex.pos * Lex.pos), signed_term_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 187 |
( catSp (signed_term::SR) ) |
| 188 |
fun signed_term_PROD_1_ACT (term, MINUS, term_SPAN : (Lex.pos * Lex.pos), MINUS_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 189 |
( "-" ^ term ) |
| 190 |
fun term_PROD_1_SUBRULE_1_PROD_1_ACT (factor, MULOP, factor_SPAN : (Lex.pos * Lex.pos), MULOP_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 191 |
( MULOP ^ " " ^ factor ) |
| 192 |
fun term_PROD_1_ACT (SR, factor, SR_SPAN : (Lex.pos * Lex.pos), factor_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 193 |
( catSp (factor::SR) ) |
| 194 |
fun factor_PROD_2_ACT (ID, LP, RP, SR, exp, ID_SPAN : (Lex.pos * Lex.pos), LP_SPAN : (Lex.pos * Lex.pos), RP_SPAN : (Lex.pos * Lex.pos), SR_SPAN : (Lex.pos * Lex.pos), exp_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 195 |
( cat [ID, "(", catCm (exp::SR), ")" ] ) |
| 196 |
fun factor_PROD_3_ACT (INT, INT_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 197 |
( IntInf.toString INT ) |
| 198 |
fun factor_PROD_4_ACT (REAL, REAL_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 199 |
( Real.toString REAL ) |
| 200 |
fun factor_PROD_5_ACT (LP, RP, exp, LP_SPAN : (Lex.pos * Lex.pos), RP_SPAN : (Lex.pos * Lex.pos), exp_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 201 |
( "(" ^ exp ^ ")" ) |
| 202 |
fun factor_PROD_6_ACT (factor, KW_not, factor_SPAN : (Lex.pos * Lex.pos), KW_not_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)) = |
| 203 |
( "not " ^ factor ) |
| 204 |
end (* UserCode *) |
| 205 |
|
| 206 |
structure Err = AntlrErrHandler( |
| 207 |
structure Tok = Tok |
| 208 |
structure Lex = Lex) |
| 209 |
structure EBNF = AntlrEBNF( |
| 210 |
struct |
| 211 |
type strm = Err.wstream |
| 212 |
val getSpan = Err.getSpan |
| 213 |
end) |
| 214 |
|
| 215 |
fun mk lexFn = let |
| 216 |
fun getS() = {} |
| 217 |
fun putS{} = () |
| 218 |
fun unwrap (ret, strm, repairs) = (ret, strm, repairs) val (eh, lex) = Err.mkErrHandler {get = getS, put = putS} |
| 219 |
fun fail() = Err.failure eh |
| 220 |
fun tryProds (strm, prods) = let |
| 221 |
fun try [] = fail() |
| 222 |
| try (prod :: prods) = |
| 223 |
(Err.whileDisabled eh (fn() => prod strm)) |
| 224 |
handle Err.ParseError => try (prods) |
| 225 |
in try prods end |
| 226 |
fun matchEOF strm = (case (lex(strm)) |
| 227 |
of (Tok.EOF, span, strm') => ((), span, strm') |
| 228 |
| _ => fail() |
| 229 |
(* end case *)) |
| 230 |
fun matchREAL strm = (case (lex(strm)) |
| 231 |
of (Tok.REAL(x), span, strm') => (x, span, strm') |
| 232 |
| _ => fail() |
| 233 |
(* end case *)) |
| 234 |
fun matchINT strm = (case (lex(strm)) |
| 235 |
of (Tok.INT(x), span, strm') => (x, span, strm') |
| 236 |
| _ => fail() |
| 237 |
(* end case *)) |
| 238 |
fun matchID strm = (case (lex(strm)) |
| 239 |
of (Tok.ID(x), span, strm') => (x, span, strm') |
| 240 |
| _ => fail() |
| 241 |
(* end case *)) |
| 242 |
fun matchMULOP strm = (case (lex(strm)) |
| 243 |
of (Tok.MULOP(x), span, strm') => (x, span, strm') |
| 244 |
| _ => fail() |
| 245 |
(* end case *)) |
| 246 |
fun matchADDOP strm = (case (lex(strm)) |
| 247 |
of (Tok.ADDOP(x), span, strm') => (x, span, strm') |
| 248 |
| _ => fail() |
| 249 |
(* end case *)) |
| 250 |
fun matchRELOP strm = (case (lex(strm)) |
| 251 |
of (Tok.RELOP(x), span, strm') => (x, span, strm') |
| 252 |
| _ => fail() |
| 253 |
(* end case *)) |
| 254 |
fun matchMINUS strm = (case (lex(strm)) |
| 255 |
of (Tok.MINUS, span, strm') => ((), span, strm') |
| 256 |
| _ => fail() |
| 257 |
(* end case *)) |
| 258 |
fun matchRP strm = (case (lex(strm)) |
| 259 |
of (Tok.RP, span, strm') => ((), span, strm') |
| 260 |
| _ => fail() |
| 261 |
(* end case *)) |
| 262 |
fun matchLP strm = (case (lex(strm)) |
| 263 |
of (Tok.LP, span, strm') => ((), span, strm') |
| 264 |
| _ => fail() |
| 265 |
(* end case *)) |
| 266 |
fun matchRSB strm = (case (lex(strm)) |
| 267 |
of (Tok.RSB, span, strm') => ((), span, strm') |
| 268 |
| _ => fail() |
| 269 |
(* end case *)) |
| 270 |
fun matchLSB strm = (case (lex(strm)) |
| 271 |
of (Tok.LSB, span, strm') => ((), span, strm') |
| 272 |
| _ => fail() |
| 273 |
(* end case *)) |
| 274 |
fun matchDOT strm = (case (lex(strm)) |
| 275 |
of (Tok.DOT, span, strm') => ((), span, strm') |
| 276 |
| _ => fail() |
| 277 |
(* end case *)) |
| 278 |
fun matchSEMI strm = (case (lex(strm)) |
| 279 |
of (Tok.SEMI, span, strm') => ((), span, strm') |
| 280 |
| _ => fail() |
| 281 |
(* end case *)) |
| 282 |
fun matchCOLON strm = (case (lex(strm)) |
| 283 |
of (Tok.COLON, span, strm') => ((), span, strm') |
| 284 |
| _ => fail() |
| 285 |
(* end case *)) |
| 286 |
fun matchCOMMA strm = (case (lex(strm)) |
| 287 |
of (Tok.COMMA, span, strm') => ((), span, strm') |
| 288 |
| _ => fail() |
| 289 |
(* end case *)) |
| 290 |
fun matchASSIGNOP strm = (case (lex(strm)) |
| 291 |
of (Tok.ASSIGNOP, span, strm') => ((), span, strm') |
| 292 |
| _ => fail() |
| 293 |
(* end case *)) |
| 294 |
fun matchKW_not strm = (case (lex(strm)) |
| 295 |
of (Tok.KW_not, span, strm') => ((), span, strm') |
| 296 |
| _ => fail() |
| 297 |
(* end case *)) |
| 298 |
fun matchKW_do strm = (case (lex(strm)) |
| 299 |
of (Tok.KW_do, span, strm') => ((), span, strm') |
| 300 |
| _ => fail() |
| 301 |
(* end case *)) |
| 302 |
fun matchKW_while strm = (case (lex(strm)) |
| 303 |
of (Tok.KW_while, span, strm') => ((), span, strm') |
| 304 |
| _ => fail() |
| 305 |
(* end case *)) |
| 306 |
fun matchKW_else strm = (case (lex(strm)) |
| 307 |
of (Tok.KW_else, span, strm') => ((), span, strm') |
| 308 |
| _ => fail() |
| 309 |
(* end case *)) |
| 310 |
fun matchKW_then strm = (case (lex(strm)) |
| 311 |
of (Tok.KW_then, span, strm') => ((), span, strm') |
| 312 |
| _ => fail() |
| 313 |
(* end case *)) |
| 314 |
fun matchKW_if strm = (case (lex(strm)) |
| 315 |
of (Tok.KW_if, span, strm') => ((), span, strm') |
| 316 |
| _ => fail() |
| 317 |
(* end case *)) |
| 318 |
fun matchKW_end strm = (case (lex(strm)) |
| 319 |
of (Tok.KW_end, span, strm') => ((), span, strm') |
| 320 |
| _ => fail() |
| 321 |
(* end case *)) |
| 322 |
fun matchKW_begin strm = (case (lex(strm)) |
| 323 |
of (Tok.KW_begin, span, strm') => ((), span, strm') |
| 324 |
| _ => fail() |
| 325 |
(* end case *)) |
| 326 |
fun matchKW_procedure strm = (case (lex(strm)) |
| 327 |
of (Tok.KW_procedure, span, strm') => ((), span, strm') |
| 328 |
| _ => fail() |
| 329 |
(* end case *)) |
| 330 |
fun matchKW_function strm = (case (lex(strm)) |
| 331 |
of (Tok.KW_function, span, strm') => ((), span, strm') |
| 332 |
| _ => fail() |
| 333 |
(* end case *)) |
| 334 |
fun matchKW_real strm = (case (lex(strm)) |
| 335 |
of (Tok.KW_real, span, strm') => ((), span, strm') |
| 336 |
| _ => fail() |
| 337 |
(* end case *)) |
| 338 |
fun matchKW_integer strm = (case (lex(strm)) |
| 339 |
of (Tok.KW_integer, span, strm') => ((), span, strm') |
| 340 |
| _ => fail() |
| 341 |
(* end case *)) |
| 342 |
fun matchKW_of strm = (case (lex(strm)) |
| 343 |
of (Tok.KW_of, span, strm') => ((), span, strm') |
| 344 |
| _ => fail() |
| 345 |
(* end case *)) |
| 346 |
fun matchKW_array strm = (case (lex(strm)) |
| 347 |
of (Tok.KW_array, span, strm') => ((), span, strm') |
| 348 |
| _ => fail() |
| 349 |
(* end case *)) |
| 350 |
fun matchKW_var strm = (case (lex(strm)) |
| 351 |
of (Tok.KW_var, span, strm') => ((), span, strm') |
| 352 |
| _ => fail() |
| 353 |
(* end case *)) |
| 354 |
fun matchKW_program strm = (case (lex(strm)) |
| 355 |
of (Tok.KW_program, span, strm') => ((), span, strm') |
| 356 |
| _ => fail() |
| 357 |
(* end case *)) |
| 358 |
|
| 359 |
val (program_NT) = |
| 360 |
let |
| 361 |
fun exp_NT (strm) = let |
| 362 |
val (simple_exp_RES, simple_exp_SPAN, strm') = simple_exp_NT(strm) |
| 363 |
fun exp_PROD_1_SUBRULE_1_NT (strm) = let |
| 364 |
val (RELOP_RES, RELOP_SPAN, strm') = matchRELOP(strm) |
| 365 |
val (simple_exp_RES, simple_exp_SPAN, strm') = simple_exp_NT(strm') |
| 366 |
val FULL_SPAN = (#1(RELOP_SPAN), #2(simple_exp_SPAN)) |
| 367 |
in |
| 368 |
(UserCode.exp_PROD_1_SUBRULE_1_PROD_1_ACT (simple_exp_RES, RELOP_RES, simple_exp_SPAN : (Lex.pos * Lex.pos), RELOP_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 369 |
FULL_SPAN, strm') |
| 370 |
end |
| 371 |
fun exp_PROD_1_SUBRULE_1_PRED (strm) = (case (lex(strm)) |
| 372 |
of (Tok.RELOP(_), _, strm') => true |
| 373 |
| _ => false |
| 374 |
(* end case *)) |
| 375 |
val (SR_RES, SR_SPAN, strm') = EBNF.optional(exp_PROD_1_SUBRULE_1_PRED, exp_PROD_1_SUBRULE_1_NT, strm') |
| 376 |
val FULL_SPAN = (#1(simple_exp_SPAN), #2(SR_SPAN)) |
| 377 |
in |
| 378 |
(UserCode.exp_PROD_1_ACT (SR_RES, simple_exp_RES, SR_SPAN : (Lex.pos * Lex.pos), simple_exp_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 379 |
FULL_SPAN, strm') |
| 380 |
end |
| 381 |
and simple_exp_NT (strm) = let |
| 382 |
val (signed_term_RES, signed_term_SPAN, strm') = signed_term_NT(strm) |
| 383 |
fun simple_exp_PROD_1_SUBRULE_1_NT (strm) = let |
| 384 |
val (ADDOP_RES, ADDOP_SPAN, strm') = matchADDOP(strm) |
| 385 |
val (signed_term_RES, signed_term_SPAN, strm') = signed_term_NT(strm') |
| 386 |
val FULL_SPAN = (#1(ADDOP_SPAN), #2(signed_term_SPAN)) |
| 387 |
in |
| 388 |
(UserCode.simple_exp_PROD_1_SUBRULE_1_PROD_1_ACT (signed_term_RES, ADDOP_RES, signed_term_SPAN : (Lex.pos * Lex.pos), ADDOP_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 389 |
FULL_SPAN, strm') |
| 390 |
end |
| 391 |
fun simple_exp_PROD_1_SUBRULE_1_PRED (strm) = (case (lex(strm)) |
| 392 |
of (Tok.ADDOP(_), _, strm') => true |
| 393 |
| _ => false |
| 394 |
(* end case *)) |
| 395 |
val (SR_RES, SR_SPAN, strm') = EBNF.closure(simple_exp_PROD_1_SUBRULE_1_PRED, simple_exp_PROD_1_SUBRULE_1_NT, strm') |
| 396 |
val FULL_SPAN = (#1(signed_term_SPAN), #2(SR_SPAN)) |
| 397 |
in |
| 398 |
(UserCode.simple_exp_PROD_1_ACT (SR_RES, signed_term_RES, SR_SPAN : (Lex.pos * Lex.pos), signed_term_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 399 |
FULL_SPAN, strm') |
| 400 |
end |
| 401 |
and signed_term_NT (strm) = let |
| 402 |
fun signed_term_PROD_1 (strm) = let |
| 403 |
val (MINUS_RES, MINUS_SPAN, strm') = matchMINUS(strm) |
| 404 |
val (term_RES, term_SPAN, strm') = term_NT(strm') |
| 405 |
val FULL_SPAN = (#1(MINUS_SPAN), #2(term_SPAN)) |
| 406 |
in |
| 407 |
(UserCode.signed_term_PROD_1_ACT (term_RES, MINUS_RES, term_SPAN : (Lex.pos * Lex.pos), MINUS_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 408 |
FULL_SPAN, strm') |
| 409 |
end |
| 410 |
fun signed_term_PROD_2 (strm) = let |
| 411 |
val (term_RES, term_SPAN, strm') = term_NT(strm) |
| 412 |
val FULL_SPAN = (#1(term_SPAN), #2(term_SPAN)) |
| 413 |
in |
| 414 |
((term_RES), FULL_SPAN, strm') |
| 415 |
end |
| 416 |
in |
| 417 |
(case (lex(strm)) |
| 418 |
of (Tok.KW_not, _, strm') => signed_term_PROD_2(strm) |
| 419 |
| (Tok.LP, _, strm') => signed_term_PROD_2(strm) |
| 420 |
| (Tok.ID(_), _, strm') => signed_term_PROD_2(strm) |
| 421 |
| (Tok.INT(_), _, strm') => signed_term_PROD_2(strm) |
| 422 |
| (Tok.REAL(_), _, strm') => signed_term_PROD_2(strm) |
| 423 |
| (Tok.MINUS, _, strm') => signed_term_PROD_1(strm) |
| 424 |
| _ => fail() |
| 425 |
(* end case *)) |
| 426 |
end |
| 427 |
and term_NT (strm) = let |
| 428 |
val (factor_RES, factor_SPAN, strm') = factor_NT(strm) |
| 429 |
fun term_PROD_1_SUBRULE_1_NT (strm) = let |
| 430 |
val (MULOP_RES, MULOP_SPAN, strm') = matchMULOP(strm) |
| 431 |
val (factor_RES, factor_SPAN, strm') = factor_NT(strm') |
| 432 |
val FULL_SPAN = (#1(MULOP_SPAN), #2(factor_SPAN)) |
| 433 |
in |
| 434 |
(UserCode.term_PROD_1_SUBRULE_1_PROD_1_ACT (factor_RES, MULOP_RES, factor_SPAN : (Lex.pos * Lex.pos), MULOP_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 435 |
FULL_SPAN, strm') |
| 436 |
end |
| 437 |
fun term_PROD_1_SUBRULE_1_PRED (strm) = (case (lex(strm)) |
| 438 |
of (Tok.MULOP(_), _, strm') => true |
| 439 |
| _ => false |
| 440 |
(* end case *)) |
| 441 |
val (SR_RES, SR_SPAN, strm') = EBNF.closure(term_PROD_1_SUBRULE_1_PRED, term_PROD_1_SUBRULE_1_NT, strm') |
| 442 |
val FULL_SPAN = (#1(factor_SPAN), #2(SR_SPAN)) |
| 443 |
in |
| 444 |
(UserCode.term_PROD_1_ACT (SR_RES, factor_RES, SR_SPAN : (Lex.pos * Lex.pos), factor_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 445 |
FULL_SPAN, strm') |
| 446 |
end |
| 447 |
and factor_NT (strm) = let |
| 448 |
fun factor_PROD_1 (strm) = let |
| 449 |
val (variable_RES, variable_SPAN, strm') = variable_NT(strm) |
| 450 |
val FULL_SPAN = (#1(variable_SPAN), #2(variable_SPAN)) |
| 451 |
in |
| 452 |
((variable_RES), FULL_SPAN, strm') |
| 453 |
end |
| 454 |
fun factor_PROD_2 (strm) = let |
| 455 |
val (ID_RES, ID_SPAN, strm') = matchID(strm) |
| 456 |
val (LP_RES, LP_SPAN, strm') = matchLP(strm') |
| 457 |
val (exp_RES, exp_SPAN, strm') = exp_NT(strm') |
| 458 |
fun factor_PROD_2_SUBRULE_1_NT (strm) = let |
| 459 |
val (COMMA_RES, COMMA_SPAN, strm') = matchCOMMA(strm) |
| 460 |
val (exp_RES, exp_SPAN, strm') = exp_NT(strm') |
| 461 |
val FULL_SPAN = (#1(COMMA_SPAN), #2(exp_SPAN)) |
| 462 |
in |
| 463 |
((exp_RES), FULL_SPAN, strm') |
| 464 |
end |
| 465 |
fun factor_PROD_2_SUBRULE_1_PRED (strm) = (case (lex(strm)) |
| 466 |
of (Tok.COMMA, _, strm') => true |
| 467 |
| _ => false |
| 468 |
(* end case *)) |
| 469 |
val (SR_RES, SR_SPAN, strm') = EBNF.closure(factor_PROD_2_SUBRULE_1_PRED, factor_PROD_2_SUBRULE_1_NT, strm') |
| 470 |
val (RP_RES, RP_SPAN, strm') = matchRP(strm') |
| 471 |
val FULL_SPAN = (#1(ID_SPAN), #2(RP_SPAN)) |
| 472 |
in |
| 473 |
(UserCode.factor_PROD_2_ACT (ID_RES, LP_RES, RP_RES, SR_RES, exp_RES, ID_SPAN : (Lex.pos * Lex.pos), LP_SPAN : (Lex.pos * Lex.pos), RP_SPAN : (Lex.pos * Lex.pos), SR_SPAN : (Lex.pos * Lex.pos), exp_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 474 |
FULL_SPAN, strm') |
| 475 |
end |
| 476 |
fun factor_PROD_3 (strm) = let |
| 477 |
val (INT_RES, INT_SPAN, strm') = matchINT(strm) |
| 478 |
val FULL_SPAN = (#1(INT_SPAN), #2(INT_SPAN)) |
| 479 |
in |
| 480 |
(UserCode.factor_PROD_3_ACT (INT_RES, INT_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 481 |
FULL_SPAN, strm') |
| 482 |
end |
| 483 |
fun factor_PROD_4 (strm) = let |
| 484 |
val (REAL_RES, REAL_SPAN, strm') = matchREAL(strm) |
| 485 |
val FULL_SPAN = (#1(REAL_SPAN), #2(REAL_SPAN)) |
| 486 |
in |
| 487 |
(UserCode.factor_PROD_4_ACT (REAL_RES, REAL_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 488 |
FULL_SPAN, strm') |
| 489 |
end |
| 490 |
fun factor_PROD_5 (strm) = let |
| 491 |
val (LP_RES, LP_SPAN, strm') = matchLP(strm) |
| 492 |
val (exp_RES, exp_SPAN, strm') = exp_NT(strm') |
| 493 |
val (RP_RES, RP_SPAN, strm') = matchRP(strm') |
| 494 |
val FULL_SPAN = (#1(LP_SPAN), #2(RP_SPAN)) |
| 495 |
in |
| 496 |
(UserCode.factor_PROD_5_ACT (LP_RES, RP_RES, exp_RES, LP_SPAN : (Lex.pos * Lex.pos), RP_SPAN : (Lex.pos * Lex.pos), exp_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 497 |
FULL_SPAN, strm') |
| 498 |
end |
| 499 |
fun factor_PROD_6 (strm) = let |
| 500 |
val (KW_not_RES, KW_not_SPAN, strm') = matchKW_not(strm) |
| 501 |
val (factor_RES, factor_SPAN, strm') = factor_NT(strm') |
| 502 |
val FULL_SPAN = (#1(KW_not_SPAN), #2(factor_SPAN)) |
| 503 |
in |
| 504 |
(UserCode.factor_PROD_6_ACT (factor_RES, KW_not_RES, factor_SPAN : (Lex.pos * Lex.pos), KW_not_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 505 |
FULL_SPAN, strm') |
| 506 |
end |
| 507 |
in |
| 508 |
(case (lex(strm)) |
| 509 |
of (Tok.KW_not, _, strm') => factor_PROD_6(strm) |
| 510 |
| (Tok.REAL(_), _, strm') => factor_PROD_4(strm) |
| 511 |
| (Tok.ID(_), _, strm') => |
| 512 |
(case (lex(strm')) |
| 513 |
of (Tok.KW_end, _, strm') => factor_PROD_1(strm) |
| 514 |
| (Tok.KW_then, _, strm') => factor_PROD_1(strm) |
| 515 |
| (Tok.KW_else, _, strm') => factor_PROD_1(strm) |
| 516 |
| (Tok.KW_do, _, strm') => factor_PROD_1(strm) |
| 517 |
| (Tok.COMMA, _, strm') => factor_PROD_1(strm) |
| 518 |
| (Tok.SEMI, _, strm') => factor_PROD_1(strm) |
| 519 |
| (Tok.LSB, _, strm') => factor_PROD_1(strm) |
| 520 |
| (Tok.RSB, _, strm') => factor_PROD_1(strm) |
| 521 |
| (Tok.RP, _, strm') => factor_PROD_1(strm) |
| 522 |
| (Tok.RELOP(_), _, strm') => factor_PROD_1(strm) |
| 523 |
| (Tok.ADDOP(_), _, strm') => factor_PROD_1(strm) |
| 524 |
| (Tok.MULOP(_), _, strm') => factor_PROD_1(strm) |
| 525 |
| (Tok.LP, _, strm') => factor_PROD_2(strm) |
| 526 |
| _ => fail() |
| 527 |
(* end case *)) |
| 528 |
| (Tok.INT(_), _, strm') => factor_PROD_3(strm) |
| 529 |
| (Tok.LP, _, strm') => factor_PROD_5(strm) |
| 530 |
| _ => fail() |
| 531 |
(* end case *)) |
| 532 |
end |
| 533 |
and variable_NT (strm) = let |
| 534 |
fun variable_PROD_1 (strm) = let |
| 535 |
val (ID_RES, ID_SPAN, strm') = matchID(strm) |
| 536 |
val FULL_SPAN = (#1(ID_SPAN), #2(ID_SPAN)) |
| 537 |
in |
| 538 |
((ID_RES), FULL_SPAN, strm') |
| 539 |
end |
| 540 |
fun variable_PROD_2 (strm) = let |
| 541 |
val (ID_RES, ID_SPAN, strm') = matchID(strm) |
| 542 |
val (LSB_RES, LSB_SPAN, strm') = matchLSB(strm') |
| 543 |
val (exp_RES, exp_SPAN, strm') = exp_NT(strm') |
| 544 |
val (RSB_RES, RSB_SPAN, strm') = matchRSB(strm') |
| 545 |
val FULL_SPAN = (#1(ID_SPAN), #2(RSB_SPAN)) |
| 546 |
in |
| 547 |
(UserCode.variable_PROD_2_ACT (ID_RES, LSB_RES, RSB_RES, exp_RES, ID_SPAN : (Lex.pos * Lex.pos), LSB_SPAN : (Lex.pos * Lex.pos), RSB_SPAN : (Lex.pos * Lex.pos), exp_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 548 |
FULL_SPAN, strm') |
| 549 |
end |
| 550 |
in |
| 551 |
(case (lex(strm)) |
| 552 |
of (Tok.ID(_), _, strm') => |
| 553 |
(case (lex(strm')) |
| 554 |
of (Tok.KW_end, _, strm') => variable_PROD_1(strm) |
| 555 |
| (Tok.KW_then, _, strm') => variable_PROD_1(strm) |
| 556 |
| (Tok.KW_else, _, strm') => variable_PROD_1(strm) |
| 557 |
| (Tok.KW_do, _, strm') => variable_PROD_1(strm) |
| 558 |
| (Tok.ASSIGNOP, _, strm') => variable_PROD_1(strm) |
| 559 |
| (Tok.COMMA, _, strm') => variable_PROD_1(strm) |
| 560 |
| (Tok.SEMI, _, strm') => variable_PROD_1(strm) |
| 561 |
| (Tok.RSB, _, strm') => variable_PROD_1(strm) |
| 562 |
| (Tok.RP, _, strm') => variable_PROD_1(strm) |
| 563 |
| (Tok.RELOP(_), _, strm') => variable_PROD_1(strm) |
| 564 |
| (Tok.ADDOP(_), _, strm') => variable_PROD_1(strm) |
| 565 |
| (Tok.MULOP(_), _, strm') => variable_PROD_1(strm) |
| 566 |
| (Tok.LSB, _, strm') => variable_PROD_2(strm) |
| 567 |
| _ => fail() |
| 568 |
(* end case *)) |
| 569 |
| _ => fail() |
| 570 |
(* end case *)) |
| 571 |
end |
| 572 |
fun procedure_statement_NT (strm) = let |
| 573 |
fun procedure_statement_PROD_1 (strm) = let |
| 574 |
val (ID_RES, ID_SPAN, strm') = matchID(strm) |
| 575 |
val FULL_SPAN = (#1(ID_SPAN), #2(ID_SPAN)) |
| 576 |
in |
| 577 |
((ID_RES), FULL_SPAN, strm') |
| 578 |
end |
| 579 |
fun procedure_statement_PROD_2 (strm) = let |
| 580 |
val (ID_RES, ID_SPAN, strm') = matchID(strm) |
| 581 |
val (LP_RES, LP_SPAN, strm') = matchLP(strm') |
| 582 |
val (exp_RES, exp_SPAN, strm') = exp_NT(strm') |
| 583 |
fun procedure_statement_PROD_2_SUBRULE_1_NT (strm) = let |
| 584 |
val (COMMA_RES, COMMA_SPAN, strm') = matchCOMMA(strm) |
| 585 |
val (exp_RES, exp_SPAN, strm') = exp_NT(strm') |
| 586 |
val FULL_SPAN = (#1(COMMA_SPAN), #2(exp_SPAN)) |
| 587 |
in |
| 588 |
((exp_RES), FULL_SPAN, strm') |
| 589 |
end |
| 590 |
fun procedure_statement_PROD_2_SUBRULE_1_PRED (strm) = (case (lex(strm)) |
| 591 |
of (Tok.COMMA, _, strm') => true |
| 592 |
| _ => false |
| 593 |
(* end case *)) |
| 594 |
val (SR_RES, SR_SPAN, strm') = EBNF.closure(procedure_statement_PROD_2_SUBRULE_1_PRED, procedure_statement_PROD_2_SUBRULE_1_NT, strm') |
| 595 |
val (RP_RES, RP_SPAN, strm') = matchRP(strm') |
| 596 |
val FULL_SPAN = (#1(ID_SPAN), #2(RP_SPAN)) |
| 597 |
in |
| 598 |
(UserCode.procedure_statement_PROD_2_ACT (ID_RES, LP_RES, RP_RES, SR_RES, exp_RES, ID_SPAN : (Lex.pos * Lex.pos), LP_SPAN : (Lex.pos * Lex.pos), RP_SPAN : (Lex.pos * Lex.pos), SR_SPAN : (Lex.pos * Lex.pos), exp_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 599 |
FULL_SPAN, strm') |
| 600 |
end |
| 601 |
in |
| 602 |
(case (lex(strm)) |
| 603 |
of (Tok.ID(_), _, strm') => |
| 604 |
(case (lex(strm')) |
| 605 |
of (Tok.KW_end, _, strm') => procedure_statement_PROD_1(strm) |
| 606 |
| (Tok.KW_else, _, strm') => procedure_statement_PROD_1(strm) |
| 607 |
| (Tok.SEMI, _, strm') => procedure_statement_PROD_1(strm) |
| 608 |
| (Tok.LP, _, strm') => procedure_statement_PROD_2(strm) |
| 609 |
| _ => fail() |
| 610 |
(* end case *)) |
| 611 |
| _ => fail() |
| 612 |
(* end case *)) |
| 613 |
end |
| 614 |
fun compound_statement_NT (strm) = let |
| 615 |
val (KW_begin_RES, KW_begin_SPAN, strm') = matchKW_begin(strm) |
| 616 |
fun compound_statement_PROD_1_SUBRULE_1_NT (strm) = let |
| 617 |
val (statement_RES, statement_SPAN, strm') = statement_NT(strm) |
| 618 |
fun compound_statement_PROD_1_SUBRULE_1_PROD_1_SUBRULE_1_NT (strm) = let |
| 619 |
val (SEMI_RES, SEMI_SPAN, strm') = matchSEMI(strm) |
| 620 |
val (statement_RES, statement_SPAN, strm') = statement_NT(strm') |
| 621 |
val FULL_SPAN = (#1(SEMI_SPAN), #2(statement_SPAN)) |
| 622 |
in |
| 623 |
((statement_RES), FULL_SPAN, strm') |
| 624 |
end |
| 625 |
fun compound_statement_PROD_1_SUBRULE_1_PROD_1_SUBRULE_1_PRED (strm) = (case (lex(strm)) |
| 626 |
of (Tok.SEMI, _, strm') => true |
| 627 |
| _ => false |
| 628 |
(* end case *)) |
| 629 |
val (SR_RES, SR_SPAN, strm') = EBNF.closure(compound_statement_PROD_1_SUBRULE_1_PROD_1_SUBRULE_1_PRED, compound_statement_PROD_1_SUBRULE_1_PROD_1_SUBRULE_1_NT, strm') |
| 630 |
val FULL_SPAN = (#1(statement_SPAN), #2(SR_SPAN)) |
| 631 |
in |
| 632 |
(UserCode.compound_statement_PROD_1_SUBRULE_1_PROD_1_ACT (SR_RES, KW_begin_RES, statement_RES, SR_SPAN : (Lex.pos * Lex.pos), KW_begin_SPAN : (Lex.pos * Lex.pos), statement_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 633 |
FULL_SPAN, strm') |
| 634 |
end |
| 635 |
fun compound_statement_PROD_1_SUBRULE_1_PRED (strm) = (case (lex(strm)) |
| 636 |
of (Tok.KW_begin, _, strm') => true |
| 637 |
| (Tok.KW_if, _, strm') => true |
| 638 |
| (Tok.KW_while, _, strm') => true |
| 639 |
| (Tok.ID(_), _, strm') => true |
| 640 |
| _ => false |
| 641 |
(* end case *)) |
| 642 |
val (SR_RES, SR_SPAN, strm') = EBNF.optional(compound_statement_PROD_1_SUBRULE_1_PRED, compound_statement_PROD_1_SUBRULE_1_NT, strm') |
| 643 |
val (KW_end_RES, KW_end_SPAN, strm') = matchKW_end(strm') |
| 644 |
val FULL_SPAN = (#1(KW_begin_SPAN), #2(KW_end_SPAN)) |
| 645 |
in |
| 646 |
(UserCode.compound_statement_PROD_1_ACT (SR_RES, KW_begin_RES, KW_end_RES, SR_SPAN : (Lex.pos * Lex.pos), KW_begin_SPAN : (Lex.pos * Lex.pos), KW_end_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 647 |
FULL_SPAN, strm') |
| 648 |
end |
| 649 |
and statement_NT (strm) = let |
| 650 |
fun statement_PROD_1 (strm) = let |
| 651 |
val (variable_RES, variable_SPAN, strm') = variable_NT(strm) |
| 652 |
val (ASSIGNOP_RES, ASSIGNOP_SPAN, strm') = matchASSIGNOP(strm') |
| 653 |
val (exp_RES, exp_SPAN, strm') = exp_NT(strm') |
| 654 |
val FULL_SPAN = (#1(variable_SPAN), #2(exp_SPAN)) |
| 655 |
in |
| 656 |
(UserCode.statement_PROD_1_ACT (exp_RES, variable_RES, ASSIGNOP_RES, exp_SPAN : (Lex.pos * Lex.pos), variable_SPAN : (Lex.pos * Lex.pos), ASSIGNOP_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 657 |
FULL_SPAN, strm') |
| 658 |
end |
| 659 |
fun statement_PROD_2 (strm) = let |
| 660 |
val (procedure_statement_RES, procedure_statement_SPAN, strm') = procedure_statement_NT(strm) |
| 661 |
val FULL_SPAN = (#1(procedure_statement_SPAN), |
| 662 |
#2(procedure_statement_SPAN)) |
| 663 |
in |
| 664 |
((procedure_statement_RES), FULL_SPAN, strm') |
| 665 |
end |
| 666 |
fun statement_PROD_3 (strm) = let |
| 667 |
val (compound_statement_RES, compound_statement_SPAN, strm') = compound_statement_NT(strm) |
| 668 |
val FULL_SPAN = (#1(compound_statement_SPAN), |
| 669 |
#2(compound_statement_SPAN)) |
| 670 |
in |
| 671 |
((compound_statement_RES), FULL_SPAN, strm') |
| 672 |
end |
| 673 |
fun statement_PROD_4 (strm) = let |
| 674 |
val (KW_if_RES, KW_if_SPAN, strm') = matchKW_if(strm) |
| 675 |
val (exp_RES, exp_SPAN, strm') = exp_NT(strm') |
| 676 |
val (KW_then_RES, KW_then_SPAN, strm') = matchKW_then(strm') |
| 677 |
val (statement1_RES, statement1_SPAN, strm') = statement_NT(strm') |
| 678 |
val (KW_else_RES, KW_else_SPAN, strm') = matchKW_else(strm') |
| 679 |
val (statement2_RES, statement2_SPAN, strm') = statement_NT(strm') |
| 680 |
val FULL_SPAN = (#1(KW_if_SPAN), #2(statement2_SPAN)) |
| 681 |
in |
| 682 |
(UserCode.statement_PROD_4_ACT (exp_RES, KW_else_RES, KW_then_RES, statement1_RES, statement2_RES, KW_if_RES, exp_SPAN : (Lex.pos * Lex.pos), KW_else_SPAN : (Lex.pos * Lex.pos), KW_then_SPAN : (Lex.pos * Lex.pos), statement1_SPAN : (Lex.pos * Lex.pos), statement2_SPAN : (Lex.pos * Lex.pos), KW_if_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 683 |
FULL_SPAN, strm') |
| 684 |
end |
| 685 |
fun statement_PROD_5 (strm) = let |
| 686 |
val (KW_while_RES, KW_while_SPAN, strm') = matchKW_while(strm) |
| 687 |
val (exp_RES, exp_SPAN, strm') = exp_NT(strm') |
| 688 |
val (KW_do_RES, KW_do_SPAN, strm') = matchKW_do(strm') |
| 689 |
val (statement_RES, statement_SPAN, strm') = statement_NT(strm') |
| 690 |
val FULL_SPAN = (#1(KW_while_SPAN), #2(statement_SPAN)) |
| 691 |
in |
| 692 |
(UserCode.statement_PROD_5_ACT (exp_RES, KW_while_RES, KW_do_RES, statement_RES, exp_SPAN : (Lex.pos * Lex.pos), KW_while_SPAN : (Lex.pos * Lex.pos), KW_do_SPAN : (Lex.pos * Lex.pos), statement_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 693 |
FULL_SPAN, strm') |
| 694 |
end |
| 695 |
in |
| 696 |
(case (lex(strm)) |
| 697 |
of (Tok.KW_while, _, strm') => statement_PROD_5(strm) |
| 698 |
| (Tok.KW_begin, _, strm') => statement_PROD_3(strm) |
| 699 |
| (Tok.ID(_), _, strm') => |
| 700 |
(case (lex(strm')) |
| 701 |
of (Tok.ASSIGNOP, _, strm') => statement_PROD_1(strm) |
| 702 |
| (Tok.LSB, _, strm') => statement_PROD_1(strm) |
| 703 |
| (Tok.KW_end, _, strm') => statement_PROD_2(strm) |
| 704 |
| (Tok.KW_else, _, strm') => statement_PROD_2(strm) |
| 705 |
| (Tok.SEMI, _, strm') => statement_PROD_2(strm) |
| 706 |
| (Tok.LP, _, strm') => statement_PROD_2(strm) |
| 707 |
| _ => fail() |
| 708 |
(* end case *)) |
| 709 |
| (Tok.KW_if, _, strm') => statement_PROD_4(strm) |
| 710 |
| _ => fail() |
| 711 |
(* end case *)) |
| 712 |
end |
| 713 |
fun standard_type_NT (strm) = let |
| 714 |
fun standard_type_PROD_1 (strm) = let |
| 715 |
val (KW_integer_RES, KW_integer_SPAN, strm') = matchKW_integer(strm) |
| 716 |
val FULL_SPAN = (#1(KW_integer_SPAN), #2(KW_integer_SPAN)) |
| 717 |
in |
| 718 |
(UserCode.standard_type_PROD_1_ACT (KW_integer_RES, KW_integer_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 719 |
FULL_SPAN, strm') |
| 720 |
end |
| 721 |
fun standard_type_PROD_2 (strm) = let |
| 722 |
val (KW_real_RES, KW_real_SPAN, strm') = matchKW_real(strm) |
| 723 |
val FULL_SPAN = (#1(KW_real_SPAN), #2(KW_real_SPAN)) |
| 724 |
in |
| 725 |
(UserCode.standard_type_PROD_2_ACT (KW_real_RES, KW_real_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 726 |
FULL_SPAN, strm') |
| 727 |
end |
| 728 |
in |
| 729 |
(case (lex(strm)) |
| 730 |
of (Tok.KW_real, _, strm') => standard_type_PROD_2(strm) |
| 731 |
| (Tok.KW_integer, _, strm') => standard_type_PROD_1(strm) |
| 732 |
| _ => fail() |
| 733 |
(* end case *)) |
| 734 |
end |
| 735 |
fun compound_type_NT (strm) = let |
| 736 |
fun compound_type_PROD_1 (strm) = let |
| 737 |
val (standard_type_RES, standard_type_SPAN, strm') = standard_type_NT(strm) |
| 738 |
val FULL_SPAN = (#1(standard_type_SPAN), #2(standard_type_SPAN)) |
| 739 |
in |
| 740 |
((standard_type_RES), FULL_SPAN, strm') |
| 741 |
end |
| 742 |
fun compound_type_PROD_2 (strm) = let |
| 743 |
val (KW_array_RES, KW_array_SPAN, strm') = matchKW_array(strm) |
| 744 |
val (LSB_RES, LSB_SPAN, strm') = matchLSB(strm') |
| 745 |
val (INT1_RES, INT1_SPAN, strm') = matchINT(strm') |
| 746 |
val (DOT1_RES, DOT1_SPAN, strm') = matchDOT(strm') |
| 747 |
val (DOT2_RES, DOT2_SPAN, strm') = matchDOT(strm') |
| 748 |
val (INT2_RES, INT2_SPAN, strm') = matchINT(strm') |
| 749 |
val (RSB_RES, RSB_SPAN, strm') = matchRSB(strm') |
| 750 |
val (KW_of_RES, KW_of_SPAN, strm') = matchKW_of(strm') |
| 751 |
val (standard_type_RES, standard_type_SPAN, strm') = standard_type_NT(strm') |
| 752 |
val FULL_SPAN = (#1(KW_array_SPAN), #2(standard_type_SPAN)) |
| 753 |
in |
| 754 |
(UserCode.compound_type_PROD_2_ACT (LSB_RES, RSB_RES, DOT1_RES, DOT2_RES, INT1_RES, INT2_RES, KW_array_RES, standard_type_RES, KW_of_RES, LSB_SPAN : (Lex.pos * Lex.pos), RSB_SPAN : (Lex.pos * Lex.pos), DOT1_SPAN : (Lex.pos * Lex.pos), DOT2_SPAN : (Lex.pos * Lex.pos), INT1_SPAN : (Lex.pos * Lex.pos), INT2_SPAN : (Lex.pos * Lex.pos), KW_array_SPAN : (Lex.pos * Lex.pos), standard_type_SPAN : (Lex.pos * Lex.pos), KW_of_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 755 |
FULL_SPAN, strm') |
| 756 |
end |
| 757 |
in |
| 758 |
(case (lex(strm)) |
| 759 |
of (Tok.KW_array, _, strm') => compound_type_PROD_2(strm) |
| 760 |
| (Tok.KW_integer, _, strm') => compound_type_PROD_1(strm) |
| 761 |
| (Tok.KW_real, _, strm') => compound_type_PROD_1(strm) |
| 762 |
| _ => fail() |
| 763 |
(* end case *)) |
| 764 |
end |
| 765 |
fun id_list_NT (strm) = let |
| 766 |
val (ID_RES, ID_SPAN, strm') = matchID(strm) |
| 767 |
fun id_list_PROD_1_SUBRULE_1_NT (strm) = let |
| 768 |
val (COMMA_RES, COMMA_SPAN, strm') = matchCOMMA(strm) |
| 769 |
val (ID_RES, ID_SPAN, strm') = matchID(strm') |
| 770 |
val FULL_SPAN = (#1(COMMA_SPAN), #2(ID_SPAN)) |
| 771 |
in |
| 772 |
((ID_RES), FULL_SPAN, strm') |
| 773 |
end |
| 774 |
fun id_list_PROD_1_SUBRULE_1_PRED (strm) = (case (lex(strm)) |
| 775 |
of (Tok.COMMA, _, strm') => true |
| 776 |
| _ => false |
| 777 |
(* end case *)) |
| 778 |
val (SR_RES, SR_SPAN, strm') = EBNF.closure(id_list_PROD_1_SUBRULE_1_PRED, id_list_PROD_1_SUBRULE_1_NT, strm') |
| 779 |
val FULL_SPAN = (#1(ID_SPAN), #2(SR_SPAN)) |
| 780 |
in |
| 781 |
(UserCode.id_list_PROD_1_ACT (ID_RES, SR_RES, ID_SPAN : (Lex.pos * Lex.pos), SR_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 782 |
FULL_SPAN, strm') |
| 783 |
end |
| 784 |
fun id_list_type_NT (strm) = let |
| 785 |
val (id_list_RES, id_list_SPAN, strm') = id_list_NT(strm) |
| 786 |
val (COLON_RES, COLON_SPAN, strm') = matchCOLON(strm') |
| 787 |
val (compound_type_RES, compound_type_SPAN, strm') = compound_type_NT(strm') |
| 788 |
val FULL_SPAN = (#1(id_list_SPAN), #2(compound_type_SPAN)) |
| 789 |
in |
| 790 |
(UserCode.id_list_type_PROD_1_ACT (compound_type_RES, COLON_RES, id_list_RES, compound_type_SPAN : (Lex.pos * Lex.pos), COLON_SPAN : (Lex.pos * Lex.pos), id_list_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 791 |
FULL_SPAN, strm') |
| 792 |
end |
| 793 |
fun declaration_NT (strm) = let |
| 794 |
val (KW_var_RES, KW_var_SPAN, strm') = matchKW_var(strm) |
| 795 |
val (id_list_type_RES, id_list_type_SPAN, strm') = id_list_type_NT(strm') |
| 796 |
val (SEMI_RES, SEMI_SPAN, strm') = matchSEMI(strm') |
| 797 |
val FULL_SPAN = (#1(KW_var_SPAN), #2(SEMI_SPAN)) |
| 798 |
in |
| 799 |
(UserCode.declaration_PROD_1_ACT (SEMI_RES, id_list_type_RES, KW_var_RES, SEMI_SPAN : (Lex.pos * Lex.pos), id_list_type_SPAN : (Lex.pos * Lex.pos), KW_var_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 800 |
FULL_SPAN, strm') |
| 801 |
end |
| 802 |
fun parameter_list_NT (strm) = let |
| 803 |
val (id_list_type_RES, id_list_type_SPAN, strm') = id_list_type_NT(strm) |
| 804 |
fun parameter_list_PROD_1_SUBRULE_1_NT (strm) = let |
| 805 |
val (SEMI_RES, SEMI_SPAN, strm') = matchSEMI(strm) |
| 806 |
val (id_list_type_RES, id_list_type_SPAN, strm') = id_list_type_NT(strm') |
| 807 |
val FULL_SPAN = (#1(SEMI_SPAN), #2(id_list_type_SPAN)) |
| 808 |
in |
| 809 |
((id_list_type_RES), FULL_SPAN, strm') |
| 810 |
end |
| 811 |
fun parameter_list_PROD_1_SUBRULE_1_PRED (strm) = (case (lex(strm)) |
| 812 |
of (Tok.SEMI, _, strm') => true |
| 813 |
| _ => false |
| 814 |
(* end case *)) |
| 815 |
val (SR_RES, SR_SPAN, strm') = EBNF.closure(parameter_list_PROD_1_SUBRULE_1_PRED, parameter_list_PROD_1_SUBRULE_1_NT, strm') |
| 816 |
val FULL_SPAN = (#1(id_list_type_SPAN), #2(SR_SPAN)) |
| 817 |
in |
| 818 |
(UserCode.parameter_list_PROD_1_ACT (SR_RES, id_list_type_RES, SR_SPAN : (Lex.pos * Lex.pos), id_list_type_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 819 |
FULL_SPAN, strm') |
| 820 |
end |
| 821 |
fun arguments_NT (strm) = let |
| 822 |
fun arguments_PROD_1 (strm) = let |
| 823 |
val (LP_RES, LP_SPAN, strm') = matchLP(strm) |
| 824 |
val (parameter_list_RES, parameter_list_SPAN, strm') = parameter_list_NT(strm') |
| 825 |
val (RP_RES, RP_SPAN, strm') = matchRP(strm') |
| 826 |
val FULL_SPAN = (#1(LP_SPAN), #2(RP_SPAN)) |
| 827 |
in |
| 828 |
(UserCode.arguments_PROD_1_ACT (LP_RES, RP_RES, parameter_list_RES, LP_SPAN : (Lex.pos * Lex.pos), RP_SPAN : (Lex.pos * Lex.pos), parameter_list_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 829 |
FULL_SPAN, strm') |
| 830 |
end |
| 831 |
fun arguments_PROD_2 (strm) = let |
| 832 |
val FULL_SPAN = (Err.getPos(strm), Err.getPos(strm)) |
| 833 |
in |
| 834 |
(UserCode.arguments_PROD_2_ACT (FULL_SPAN : (Lex.pos * Lex.pos)), |
| 835 |
FULL_SPAN, strm) |
| 836 |
end |
| 837 |
in |
| 838 |
(case (lex(strm)) |
| 839 |
of (Tok.COLON, _, strm') => arguments_PROD_2(strm) |
| 840 |
| (Tok.SEMI, _, strm') => arguments_PROD_2(strm) |
| 841 |
| (Tok.LP, _, strm') => arguments_PROD_1(strm) |
| 842 |
| _ => fail() |
| 843 |
(* end case *)) |
| 844 |
end |
| 845 |
fun subprogram_head_NT (strm) = let |
| 846 |
fun subprogram_head_PROD_1 (strm) = let |
| 847 |
val (KW_function_RES, KW_function_SPAN, strm') = matchKW_function(strm) |
| 848 |
val (ID_RES, ID_SPAN, strm') = matchID(strm') |
| 849 |
val (arguments_RES, arguments_SPAN, strm') = arguments_NT(strm') |
| 850 |
val (COLON_RES, COLON_SPAN, strm') = matchCOLON(strm') |
| 851 |
val (standard_type_RES, standard_type_SPAN, strm') = standard_type_NT(strm') |
| 852 |
val (SEMI_RES, SEMI_SPAN, strm') = matchSEMI(strm') |
| 853 |
val FULL_SPAN = (#1(KW_function_SPAN), #2(SEMI_SPAN)) |
| 854 |
in |
| 855 |
(UserCode.subprogram_head_PROD_1_ACT (ID_RES, SEMI_RES, standard_type_RES, COLON_RES, arguments_RES, KW_function_RES, ID_SPAN : (Lex.pos * Lex.pos), SEMI_SPAN : (Lex.pos * Lex.pos), standard_type_SPAN : (Lex.pos * Lex.pos), COLON_SPAN : (Lex.pos * Lex.pos), arguments_SPAN : (Lex.pos * Lex.pos), KW_function_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 856 |
FULL_SPAN, strm') |
| 857 |
end |
| 858 |
fun subprogram_head_PROD_2 (strm) = let |
| 859 |
val (KW_procedure_RES, KW_procedure_SPAN, strm') = matchKW_procedure(strm) |
| 860 |
val (ID_RES, ID_SPAN, strm') = matchID(strm') |
| 861 |
val (arguments_RES, arguments_SPAN, strm') = arguments_NT(strm') |
| 862 |
val (SEMI_RES, SEMI_SPAN, strm') = matchSEMI(strm') |
| 863 |
val FULL_SPAN = (#1(KW_procedure_SPAN), #2(SEMI_SPAN)) |
| 864 |
in |
| 865 |
(UserCode.subprogram_head_PROD_2_ACT (ID_RES, SEMI_RES, KW_procedure_RES, arguments_RES, ID_SPAN : (Lex.pos * Lex.pos), SEMI_SPAN : (Lex.pos * Lex.pos), KW_procedure_SPAN : (Lex.pos * Lex.pos), arguments_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 866 |
FULL_SPAN, strm') |
| 867 |
end |
| 868 |
in |
| 869 |
(case (lex(strm)) |
| 870 |
of (Tok.KW_procedure, _, strm') => subprogram_head_PROD_2(strm) |
| 871 |
| (Tok.KW_function, _, strm') => subprogram_head_PROD_1(strm) |
| 872 |
| _ => fail() |
| 873 |
(* end case *)) |
| 874 |
end |
| 875 |
fun subprogram_declaration_NT (strm) = let |
| 876 |
val (subprogram_head_RES, subprogram_head_SPAN, strm') = subprogram_head_NT(strm) |
| 877 |
fun subprogram_declaration_PROD_1_SUBRULE_1_NT (strm) = let |
| 878 |
val (declaration_RES, declaration_SPAN, strm') = declaration_NT(strm) |
| 879 |
val FULL_SPAN = (#1(declaration_SPAN), #2(declaration_SPAN)) |
| 880 |
in |
| 881 |
((declaration_RES), FULL_SPAN, strm') |
| 882 |
end |
| 883 |
fun subprogram_declaration_PROD_1_SUBRULE_1_PRED (strm) = (case (lex(strm)) |
| 884 |
of (Tok.KW_var, _, strm') => true |
| 885 |
| _ => false |
| 886 |
(* end case *)) |
| 887 |
val (SR_RES, SR_SPAN, strm') = EBNF.closure(subprogram_declaration_PROD_1_SUBRULE_1_PRED, subprogram_declaration_PROD_1_SUBRULE_1_NT, strm') |
| 888 |
val (compound_statement_RES, compound_statement_SPAN, strm') = compound_statement_NT(strm') |
| 889 |
val (SEMI_RES, SEMI_SPAN, strm') = matchSEMI(strm') |
| 890 |
val FULL_SPAN = (#1(subprogram_head_SPAN), #2(SEMI_SPAN)) |
| 891 |
in |
| 892 |
(UserCode.subprogram_declaration_PROD_1_ACT (SR_RES, SEMI_RES, compound_statement_RES, subprogram_head_RES, SR_SPAN : (Lex.pos * Lex.pos), SEMI_SPAN : (Lex.pos * Lex.pos), compound_statement_SPAN : (Lex.pos * Lex.pos), subprogram_head_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 893 |
FULL_SPAN, strm') |
| 894 |
end |
| 895 |
fun program_NT (strm) = let |
| 896 |
val (KW_program_RES, KW_program_SPAN, strm') = matchKW_program(strm) |
| 897 |
val (ID_RES, ID_SPAN, strm') = matchID(strm') |
| 898 |
val (LP_RES, LP_SPAN, strm') = matchLP(strm') |
| 899 |
val (id_list_RES, id_list_SPAN, strm') = id_list_NT(strm') |
| 900 |
val (RP_RES, RP_SPAN, strm') = matchRP(strm') |
| 901 |
val (SEMI_RES, SEMI_SPAN, strm') = matchSEMI(strm') |
| 902 |
fun program_PROD_1_SUBRULE_1_NT (strm) = let |
| 903 |
val (declaration_RES, declaration_SPAN, strm') = declaration_NT(strm) |
| 904 |
val FULL_SPAN = (#1(declaration_SPAN), #2(declaration_SPAN)) |
| 905 |
in |
| 906 |
((declaration_RES), FULL_SPAN, strm') |
| 907 |
end |
| 908 |
fun program_PROD_1_SUBRULE_1_PRED (strm) = (case (lex(strm)) |
| 909 |
of (Tok.KW_var, _, strm') => true |
| 910 |
| _ => false |
| 911 |
(* end case *)) |
| 912 |
val (SR1_RES, SR1_SPAN, strm') = EBNF.closure(program_PROD_1_SUBRULE_1_PRED, program_PROD_1_SUBRULE_1_NT, strm') |
| 913 |
fun program_PROD_1_SUBRULE_2_NT (strm) = let |
| 914 |
val (subprogram_declaration_RES, subprogram_declaration_SPAN, strm') = subprogram_declaration_NT(strm) |
| 915 |
val FULL_SPAN = (#1(subprogram_declaration_SPAN), |
| 916 |
#2(subprogram_declaration_SPAN)) |
| 917 |
in |
| 918 |
((subprogram_declaration_RES), FULL_SPAN, strm') |
| 919 |
end |
| 920 |
fun program_PROD_1_SUBRULE_2_PRED (strm) = (case (lex(strm)) |
| 921 |
of (Tok.KW_function, _, strm') => true |
| 922 |
| (Tok.KW_procedure, _, strm') => true |
| 923 |
| _ => false |
| 924 |
(* end case *)) |
| 925 |
val (SR2_RES, SR2_SPAN, strm') = EBNF.closure(program_PROD_1_SUBRULE_2_PRED, program_PROD_1_SUBRULE_2_NT, strm') |
| 926 |
val (compound_statement_RES, compound_statement_SPAN, strm') = compound_statement_NT(strm') |
| 927 |
val (DOT_RES, DOT_SPAN, strm') = matchDOT(strm') |
| 928 |
val FULL_SPAN = (#1(KW_program_SPAN), #2(DOT_SPAN)) |
| 929 |
in |
| 930 |
(UserCode.program_PROD_1_ACT (ID_RES, LP_RES, RP_RES, DOT_RES, SR1_RES, SR2_RES, SEMI_RES, compound_statement_RES, id_list_RES, KW_program_RES, ID_SPAN : (Lex.pos * Lex.pos), LP_SPAN : (Lex.pos * Lex.pos), RP_SPAN : (Lex.pos * Lex.pos), DOT_SPAN : (Lex.pos * Lex.pos), SR1_SPAN : (Lex.pos * Lex.pos), SR2_SPAN : (Lex.pos * Lex.pos), SEMI_SPAN : (Lex.pos * Lex.pos), compound_statement_SPAN : (Lex.pos * Lex.pos), id_list_SPAN : (Lex.pos * Lex.pos), KW_program_SPAN : (Lex.pos * Lex.pos), FULL_SPAN : (Lex.pos * Lex.pos)), |
| 931 |
FULL_SPAN, strm') |
| 932 |
end |
| 933 |
in |
| 934 |
(program_NT) |
| 935 |
end |
| 936 |
val program_NT = fn s => unwrap (Err.launch (eh, lexFn, program_NT , true) s) |
| 937 |
|
| 938 |
in (program_NT) end |
| 939 |
in |
| 940 |
fun parse lexFn s = let val (program_NT) = mk lexFn in program_NT s end |
| 941 |
|
| 942 |
end |
| 943 |
|
| 944 |
end |