00001 %{
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00044
00045 #include <sys/fcntl.h>
00046 #include <sys/stat.h>
00047 #include <getopt.h>
00048 #include <string.h>
00049 #include <stdlib.h>
00050 #include <stdio.h>
00051 #include <unistd.h>
00052 #include <assert.h>
00053 #include <dirent.h>
00054 #include <iostream>
00055
00056 #include <string>
00057
00058 #include "Version.hxx"
00059 #include "AST.hxx"
00060 #include "ParseType.hxx"
00061 #include "UocInfo.hxx"
00062 #include "Options.hxx"
00063
00064 using namespace boost;
00065 using namespace sherpa;
00066 using namespace std;
00067
00068 #define YYSTYPE ParseType
00069 #define YYLEX_PARAM (TransitionLexer *)lexer
00070
00071
00072
00073
00074
00075
00076
00077
00078 #undef yyerror
00079 #define yyerror(lexer, s) lexer->showNextError = true
00080
00081 #include "TransitionLexer.hxx"
00082
00083 #define SHOWPARSE(s) \
00084 do { \
00085 if (Options::showParse) \
00086 lexer->errStream << (s) << std::endl; \
00087 } while (false);
00088
00089 #define SHOWPARSE1(s,x) \
00090 do { \
00091 if (Options::showParse) \
00092 lexer->errStream << (s) << " " << (x) << std::endl; \
00093 } while (false);
00094
00095 static void PrintSyntaxError(TransitionLexer *lexer, const char *s);
00096 #define syntaxError(s) PrintSyntaxError(lexer, (s))
00097
00098 inline int
00099 transition_lex(YYSTYPE *lvalp, TransitionLexer *lexer)
00100 {
00101 extern int yydebug;
00102
00103
00104 return lexer->lex(lvalp);
00105 }
00106
00107
00108
00109
00110 static shared_ptr<AST>
00111 stripDocString(shared_ptr<AST> exprSeq)
00112 {
00113 if (exprSeq->children.size() > 1 &&
00114 exprSeq->child(0)->astType == at_stringLiteral)
00115 exprSeq->disown(0);
00116
00117 return exprSeq;
00118 }
00119
00120 static unsigned VersionMajor(const std::string s)
00121 {
00122 std::string::size_type dotPos = s.find('.');
00123 return strtoul(s.substr(0, dotPos).c_str(), 0, 10);
00124 }
00125
00126 static unsigned VersionMinor(const std::string s)
00127 {
00128 std::string::size_type dotPos = s.find('.');
00129 return strtoul(s.substr(dotPos+1, s.size()).c_str(), 0, 10);
00130 }
00131
00132 %}
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160 %pure-parser
00161 %token-table
00162 %parse-param {TransitionLexer *lexer}
00163
00164
00165 %nonassoc <tok> prec_PreferShift
00166
00167 %nonassoc <tok> tk_ReservedWord
00168
00169
00170 %nonassoc <tok> tk_BlkIdent
00171 %nonassoc <tok> tk_NotApply
00172
00173 %token <tok> tk_TypeVar
00174 %token <tok> tk_EffectVar
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185 %token <tok> tk_NegativeInt
00186 %token <tok> tk_Nat
00187 %token <tok> tk_Float
00188 %token <tok> tk_Char
00189 %token <tok> tk_String
00190 %token <tok> tk_VersionNumber
00191
00192 %nonassoc <tok> '('
00193 %nonassoc <tok> ':'
00194 %nonassoc <tok> ')'
00195 %right <tok> ','
00196 %nonassoc <tok> '{' '}' ';'
00197 %nonassoc <tok> '[' ']'
00198 %left <tok> '.'
00199 %nonassoc <tok> tk_ASSIGN
00200
00201
00202 %token <tok> tk_AS
00203 %token <tok> tk_BOOL
00204 %token <tok> tk_TRUE
00205 %token <tok> tk_FALSE
00206 %token <tok> tk_CHAR
00207 %token <tok> tk_STRING
00208 %token <tok> tk_FLOAT
00209 %token <tok> tk_DOUBLE
00210 %token <tok> tk_DUP
00211 %token <tok> tk_QUAD
00212 %token <tok> tk_INT8
00213 %token <tok> tk_INT16
00214 %token <tok> tk_INT32
00215 %token <tok> tk_INT64
00216 %token <tok> tk_UINT8
00217 %token <tok> tk_UINT16
00218 %token <tok> tk_UINT32
00219 %token <tok> tk_UINT64
00220 %token <tok> tk_WORD
00221
00222 %token <tok> tk_MIXFIX
00223
00224 %token <tok> tk_SIZEOF
00225 %token <tok> tk_BITSIZEOF
00226
00227 %token <tok> tk_BITFIELD
00228 %token <tok> tk_FILL
00229 %token <tok> tk_RESERVED
00230 %token <tok> tk_WHERE
00231 %token <tok> tk_IS
00232
00233 %token <tok> tk_BITC
00234 %token <tok> tk_VERSION
00235
00236 %token <tok> tk_PURE
00237 %token <tok> tk_IMPURE
00238 %token <tok> tk_CONST
00239
00240
00241
00242
00243 %token <tok> tk_IF
00244 %nonassoc <tok> tk_THEN
00245 %nonassoc <tok> tk_ELSE
00246
00247
00248
00249 %token <tok> tk_WHEN tk_UNLESS
00250 %token <tok> tk_COND
00251 %token <tok> tk_SWITCH
00252 %token <tok> tk_TYPECASE
00253 %left <tok> tk_CASE
00254 %nonassoc <tok> tk_OTHERWISE
00255
00256
00257
00258
00259 %left <tok> tk_AND tk_OR
00260 %left <tok> tk_EQUALS
00261
00262
00263 %left <tok> '='
00264
00265 %token <tok> tk_LABEL
00266 %token <tok> tk_RETURN tk_FROM tk_CONTINUE
00267
00268
00269 %token <tok> tk_PAIR
00270 %token <tok> tk_VECTOR
00271 %token <tok> tk_ARRAY
00272 %token <tok> tk_MAKE_VECTOR
00273
00274
00275 %token <tok> tk_STRUCT
00276 %token <tok> tk_OBJECT
00277 %token <tok> tk_UNION
00278 %token <tok> tk_REPR
00279 %token <tok> tk_EXCEPTION
00280 %token <tok> tk_TRAIT
00281 %token <tok> tk_INSTANCE
00282 %token <tok> tk_DEF
00283
00284
00285 %token <tok> tk_DEFTHM
00286 %token <tok> tk_DECLARE
00287
00288 %token <tok> tk_EXTERNAL
00289 %token <tok> tk_TAG
00290
00291 %token <tok> tk_MUTABLE
00292 %token <tok> tk_DEREF
00293 %token <tok> tk_INNER_REF
00294 %token <tok> tk_UNBOXED
00295 %token <tok> tk_BOXED
00296 %left <tok> tk_PTR
00297 %token <tok> tk_OPAQUE
00298 %token <tok> tk_CLOSED
00299 %token <tok> tk_MEMBER
00300 %token <tok> tk_LAMBDA
00301 %token <tok> tk_LET
00302 %token <tok> tk_LETREC
00303 %token <tok> tk_IN
00304 %token <tok> tk_FN
00305 %token <tok> tk_FNARROW
00306 %token <tok> tk_BEGIN
00307 %token <tok> tk_LOOP
00308 %token <tok> tk_DO
00309 %token <tok> tk_UNTIL
00310 %token <tok> tk_APPLY
00311 %token <tok> tk_BY_REF
00312 %token <tok> tk_ARRAY_REF
00313
00314 %token <tok> tk_TRY
00315 %token <tok> tk_CATCH
00316 %token <tok> tk_HANDLE
00317 %token <tok> tk_THROW
00318
00319 %token <tok> tk_METHOD
00320 %token <tok> tk_FORALL
00321
00322 %token <tok> tk_INTERFACE
00323 %token <tok> tk_MODULE
00324
00325
00326 %token <tok> tk_IMPORT
00327 %token <tok> tk_PROVIDE
00328
00329
00330 %token <tok> tk_SUSPEND
00331 %type <tok> blk_ifident
00332
00333
00334
00335 %type <ast> trn_module trn_implicit_module trn_module_seq
00336 %type <ast> trn_interface
00337 %type <ast> blk_defpattern
00338 %type <ast> blk_mod_definition
00339 %type <ast> trn_mod_definitions trn_mod_definition
00340 %type <ast> trn_if_definitions trn_if_definition
00341 %type <ast> blk_common_definition
00342 %type <ast> blk_value_declaration
00343 %type <ast> blk_val blk_optval
00344 %type <ast> blk_openclosed
00345 %type <ast> blk_ptype_name
00346 %type <ast> blk_typeapp
00347 %type <ast> blk_type_definition blk_type_decl
00348 %type <ast> blk_externals
00349 %type <ast> blk_importList blk_provideList
00350 %type <ast> blk_alias
00351 %type <ast> blk_type_cpair
00352 %type <ast> blk_value_definition blk_fndef_tail
00353 %type <ast> blk_tc_definition blk_ti_definition
00354 %type <ast> blk_import_definition blk_provide_definition
00355 %type <ast> blk_tc_decls
00356 %type <ast> blk_opt_declares blk_declares blk_declare blk_decl
00357 %type <ast> blk_constructors blk_constructor
00358 %type <ast> blk_repr_constructors blk_repr_constructor
00359 %type <ast> blk_repr_reprs blk_repr_repr
00360 %type <ast> blk_bindingpattern blk_lambdapatterns blk_lambdapattern
00361 %type <ast> blk_actual_params blk_nonempty_params
00362 %type <ast> blk_iblock
00363 %type <ast> blk_expr_seq
00364
00365
00366
00367 %type <ast> blk_expr_primary
00368 %type <ast> blk_expr_apply
00369
00370 %type <ast> blk_expr
00371
00372 %type <ast> blk_expr_mixfix blk_mixfix_elem
00373 %type <ast> blk_mixfix_arglist
00374
00375 %type <ast> blk_expr_if_then_else blk_expr_when blk_expr_unless
00376 %type <ast> blk_expr_switch
00377 %type <ast> blk_expr_try
00378 %type <ast> blk_expr_let blk_expr_letrec
00379 %type <ast> blk_expr_loop
00380 %type <ast> blk_expr_return blk_expr_from_return
00381 %type <ast> blk_expr_throw
00382 %type <ast> blk_expr_lambda
00383 %type <ast> blk_expr_continue
00384
00385
00386 %type <ast> blk_method_decls blk_method_decl
00387
00388 %type <ast> blk_method_bindings blk_method_binding
00389 %type <ast> blk_constraints blk_constraint_seq blk_constraint
00390
00391
00392 %type <ast> blk_type
00393 %type <ast> blk_postfix_type
00394 %type <ast> blk_prefix_type
00395 %type <ast> primary_type
00396 %type <ast> blk_primary_type
00397
00398 %type <ast> blk_type_args blk_bitfieldtype
00399 %type <ast> blk_field_type blk_type_pl_byref blk_type_args_pl_byref
00400 %type <ast> int_type uint_type any_int_type float_type bool_type
00401 %type <ast> blk_tvlist
00402 %type <ast> blk_fields blk_field
00403 %type <ast> blk_fields_and_methods blk_methods_only blk_methdecl
00404 %type <ast> trn_literal typevar
00405 %type <ast> blk_expr_switch_matches blk_expr_switch_match
00406 %type <ast> blk_exident
00407 %type <ast> blk_fntype blk_method_type
00408 %type <ast> trn_fneffect
00409 %type <ast> blk_sw_legs blk_sw_leg
00410 %type <ast> blk_otherwise blk_opt_otherwise
00411 %type <ast> blk_letbindings blk_letbinding
00412 %type <ast> blk_loopbindings blk_nonempty_loopbindings blk_expr_loopbinding
00413 %type <ast> blk_type_val_definition
00414 %type <ast> blk_ident blk_defident blk_useident
00415 %type <ast> intLit natLit floatLit charLit strLit boolLit
00416
00417 %type <tok> ILCB IRCB
00418 %type <tok> OptRCB
00419 %type <tok> IsILCB
00420
00421 %%
00422
00423
00424
00425
00426
00427
00428
00429
00430 start: ILCB blk_version ';' trn_uoc_body IRCB {
00431 SHOWPARSE("start -> ILCB blk_version SC trn_uoc_body IRCB");
00432 return 0;
00433 };
00434
00435 start: error {
00436 syntaxError("input");
00437 return -1;
00438 }
00439
00440 trn_uoc_body: trn_interface {
00441 SHOWPARSE("trn_uoc_body -> trn_interface");
00442 }
00443
00444 trn_uoc_body: trn_implicit_module {
00445 SHOWPARSE("trn_uoc_body -> trn_implicit_module");
00446 }
00447
00448 trn_uoc_body: trn_module_seq {
00449 SHOWPARSE("trn_uoc_body -> trn_module_seq");
00450 }
00451
00452
00453 blk_version: tk_BITC {
00454 lexer->currentLang |= TransitionLexer::lf_version;
00455 } tk_VERSION {
00456 lexer->currentLang |= TransitionLexer::lf_version;
00457 } tk_VersionNumber {
00458 SHOWPARSE("blk_version -> BITC VERSION VersionNumber");
00459 shared_ptr<AST> version = AST::makeStringLit($5);
00460
00461 if ((VersionMajor(version->s) == 0) && (VersionMinor(version->s) < 11)) {
00462 std::string s = ": Error: block syntax is supported in versions 0.11 and above.";
00463 lexer->ReportParseError(version->loc, s);
00464 }
00465 };
00466
00467
00468 trn_interface: tk_INTERFACE blk_ifident {
00469 if ($2.str.find("bitc.") == 0)
00470 lexer->isRuntimeUoc = true;
00471 }
00472 IsILCB {
00473 lexer->layoutStack->precedingToken = tk_INTERFACE;
00474 } trn_if_definitions IRCB {
00475 SHOWPARSE("trn_interface -> INTERFACE blk_ifident IS { trn_if_definitions }");
00476 shared_ptr<AST> ifIdent = AST::make(at_ident, $2);
00477 $$ = AST::make(at_interface, $1.loc, ifIdent);
00478 $$->addChildrenFrom($6);
00479
00480 if (lexer->isCommandLineInput) {
00481 const char *s =
00482 ": Warning: interface units of compilation should no longer\n"
00483 " be given on the command line.\n";
00484 lexer->ReportParseWarning($$->loc, s);
00485 }
00486
00487 std::string uocName = ifIdent->s;
00488 shared_ptr<UocInfo> uoc =
00489 UocInfo::make(uocName, lexer->here.origin, $$);
00490
00491 if (uocName == "bitc.prelude")
00492 uoc->flags |= UOC_IS_PRELUDE;
00493
00494 shared_ptr<UocInfo> existingUoc = UocInfo::findInterface(uocName);
00495
00496 if (existingUoc) {
00497 std::string s = "Error: This sxp_interface has already been loaded from "
00498 + existingUoc->uocAst->loc.asString();
00499 lexer->ReportParseError($$->loc, s);
00500
00501 }
00502 else {
00503
00504
00505 UocInfo::ifList[uocName] = uoc;
00506 }
00507
00508
00509
00510 uoc->Compile();
00511 };
00512
00513
00514
00515 blk_ifident: {
00516 lexer->setIfIdentMode(true);
00517 } blk_ident {
00518 lexer->setIfIdentMode(false);
00519 $$ = LToken(tk_BlkIdent, $2->loc, $2->endLoc(), $2->s);
00520 };
00521 blk_ifident: blk_ifident '.' {
00522 lexer->setIfIdentMode(true);
00523 } tk_BlkIdent {
00524 lexer->setIfIdentMode(false);
00525 $$ = LToken(tk_BlkIdent, $1.loc, $4.endLoc, $1.str + "." + $4.str);
00526 };
00527
00528
00529 trn_module_seq: trn_module {
00530 SHOWPARSE("trn_module_seq -> trn_module");
00531 }
00532
00533 trn_module_seq: trn_module_seq SC trn_module {
00534 SHOWPARSE("trn_module_seq -> trn_module_seq SC trn_module");
00535 }
00536
00537 trn_implicit_module: trn_mod_definitions {
00538 SHOWPARSE("trn_implicit_module -> trn_mod_definitions");
00539 $$ = $1;
00540 $$->astType = at_module;
00541 $$->printVariant = pf_IMPLIED;
00542
00543
00544 string uocName =
00545 UocInfo::UocNameFromSrcName(lexer->here.origin, lexer->nModules);
00546
00547 shared_ptr<UocInfo> uoc = UocInfo::make(uocName, lexer->here.origin, $$);
00548 lexer->nModules++;
00549
00550 uoc->Compile();
00551 UocInfo::srcList[uocName] = uoc;
00552 };
00553
00554 trn_module: tk_MODULE IsILCB {
00555 lexer->layoutStack->precedingToken = tk_INTERFACE;
00556 } trn_mod_definitions IRCB {
00557 SHOWPARSE("trn_module -> tk_MODULE IS { trn_mod_definitions }");
00558 $$ = $4;
00559 $$->astType = at_module;
00560
00561 string uocName =
00562 UocInfo::UocNameFromSrcName(lexer->here.origin, lexer->nModules);
00563
00564
00565 shared_ptr<UocInfo> uoc = UocInfo::make(uocName, lexer->here.origin, $$);
00566 lexer->nModules++;
00567 uoc->Compile();
00568 UocInfo::srcList[uocName] = uoc;
00569 };
00570
00571 trn_module: tk_MODULE blk_ifident IsILCB {
00572 lexer->layoutStack->precedingToken = tk_INTERFACE;
00573 } trn_mod_definitions IRCB {
00574 SHOWPARSE("trn_module -> tk_MODULE blk_ifident trn_optdocstring IS { trn_mod_definitions }");
00575 $$ = $5;
00576 $$->astType = at_module;
00577
00578
00579
00580
00581 string uocName =
00582 UocInfo::UocNameFromSrcName(lexer->here.origin, lexer->nModules);
00583
00584 shared_ptr<UocInfo> uoc = UocInfo::make(uocName, lexer->here.origin, $$);
00585 lexer->nModules++;
00586 uoc->Compile();
00587 UocInfo::srcList[uocName] = uoc;
00588 };
00589
00590
00591 trn_if_definitions: trn_if_definition {
00592 SHOWPARSE("trn_if_definitions -> trn_if_definition");
00593 $$ = AST::make(at_Null, $1->loc, $1);
00594 };
00595
00596 trn_if_definitions: trn_if_definitions SC trn_if_definition {
00597 SHOWPARSE("trn_if_definitions -> trn_if_definitions SC trn_if_definition");
00598 $$ = $1;
00599 $$->addChild($3);
00600 };
00601
00602 trn_if_definition: blk_common_definition {
00603 SHOWPARSE("trn_if_definition -> blk_common_definition");
00604 $$ = $1;
00605 };
00606
00607
00608
00609
00610 trn_mod_definitions: trn_mod_definition {
00611 SHOWPARSE("trn_mod_definitions -> trn_mod_definition");
00612 $$ = AST::make(at_Null, $1->loc, $1);
00613 };
00614
00615 trn_mod_definitions: trn_mod_definitions SC trn_mod_definition {
00616 SHOWPARSE("trn_mod_definitions -> trn_mod_definitions SC trn_mod_definition");
00617 $$ = $1;
00618 $$->addChild($3);
00619 };
00620
00621 trn_mod_definition: blk_mod_definition {
00622 SHOWPARSE("trn_mod_definition -> blk_mod_defintion");
00623 $$ = $1;
00624 };
00625
00626 blk_mod_definition: blk_provide_definition {
00627 SHOWPARSE("blk_mod_definition -> blk_provide_definition");
00628 $$ = $1;
00629 };
00630
00631 blk_mod_definition: blk_common_definition {
00632 SHOWPARSE("blk_mod_definition -> blk_common_definition");
00633 $$ = $1;
00634 };
00635
00636 blk_common_definition: blk_import_definition {
00637 SHOWPARSE("blk_common_definition -> blk_import_definition");
00638 $$ = $1;
00639 }
00640
00641 blk_common_definition: blk_type_val_definition {
00642 SHOWPARSE("blk_common_definition -> blk_type_val_definition");
00643 $$ = $1;
00644 };
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654 blk_type_val_definition: blk_type_decl {
00655 SHOWPARSE("blk_type_val_definition -> blk_type_decl");
00656 $$ = $1;
00657 };
00658
00659 blk_type_val_definition: blk_type_definition {
00660 SHOWPARSE("blk_type_val_definition -> blk_type_definition");
00661 $$ = $1;
00662 };
00663
00664 blk_type_val_definition: blk_value_definition {
00665 SHOWPARSE("blk_type_val_definition -> blk_value_definition");
00666 $$ = $1;
00667 };
00668
00669 blk_type_val_definition: blk_value_declaration {
00670 SHOWPARSE("blk_type_val_definition -> blk_value_declaration");
00671 $$ = $1;
00672 };
00673
00674 blk_type_val_definition: blk_tc_definition {
00675 SHOWPARSE("blk_type_val_definition -> blk_tc_definition");
00676 $$ = $1;
00677 };
00678
00679 blk_type_val_definition: blk_ti_definition {
00680 SHOWPARSE("blk_type_val_definition -> blk_ti_definition");
00681 $$ = $1;
00682 };
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692 blk_constraints: {
00693 $$ = AST::make(at_constraints);
00694 }
00695
00696 blk_constraints: tk_WHERE blk_constraint_seq SC {
00697 SHOWPARSE("blk_constraints -> FORALL blk_constraint_seq SC");
00698 $$ = $2;
00699 }
00700
00701 blk_constraint_seq: blk_constraint_seq ',' blk_constraint {
00702 SHOWPARSE("blk_constraint_seq -> blk_constraint_seq , blk_constraint");
00703 $$ = $1;
00704 $$->addChild($3);
00705 };
00706
00707 blk_constraint_seq: blk_constraint {
00708 SHOWPARSE("blk_constraint_seq -> blk_constraint");
00709 $$ = AST::make(at_constraints, $1->loc, $1);
00710 };
00711
00712 blk_constraint: blk_typeapp {
00713 $1->astType = at_tcapp;
00714 $$ = $1;
00715 }
00716
00717 blk_constraint: blk_useident %prec prec_PreferShift {
00718 SHOWPARSE("blk_constraint -> blk_useident");
00719 $$ = AST::make(at_tcapp, $1->loc, $1);
00720 };
00721
00722
00723
00724
00725
00726
00727
00728 blk_ptype_name: blk_defident %prec prec_PreferShift {
00729 SHOWPARSE("blk_ptype_name -> blk_defident");
00730 shared_ptr<AST> tvlist = AST::make(at_tvlist, $1->loc);
00731
00732
00733
00734
00735
00736
00737
00738 $$ = AST::make(at_Null, $1->loc, $1, tvlist);
00739 };
00740
00741 blk_ptype_name: blk_defident '(' blk_tvlist ')' %prec '(' {
00742 SHOWPARSE("blk_ptype_name -> blk_defident ( blk_tvlist )");
00743
00744
00745
00746
00747
00748
00749 $$ = AST::make(at_Null, $1->loc, $1, $3);
00750 };
00751
00752
00753 blk_type_definition: blk_constraints blk_val tk_STRUCT blk_ptype_name blk_opt_declares IsILCB blk_fields_and_methods IRCB {
00754 SHOWPARSE("blk_type_definition -> blk_constraints blk_val STRUCT blk_ptype_name "
00755 "blk_declares { blk_fields }");
00756 $$ = AST::make(at_defstruct, $3.loc, $4->child(0), $4->child(1), $2,
00757 $5, $7, $1);
00758 $$->child(0)->defForm = $$;
00759 };
00760
00761
00762 blk_type_definition: blk_constraints blk_val tk_UNION blk_ptype_name blk_opt_declares IsILCB blk_constructors IRCB {
00763 SHOWPARSE("blk_type_definition -> blk_constraints blk_val UNION blk_ptype_name "
00764 "trn_optdocstring blk_opt_declares { blk_constructors }");
00765 $$ = AST::make(at_defunion, $3.loc,
00766 $4->child(0),
00767 $4->child(1),
00768 $2,
00769 $5,
00770 $7,
00771 $1);
00772 $$->child(0)->defForm = $$;
00773 }
00774
00775
00776 blk_type_definition: blk_constraints blk_val tk_REPR blk_defident blk_opt_declares IsILCB blk_repr_constructors IRCB {
00777 SHOWPARSE("blk_type_definition -> blk_constraints blk_val REPR blk_defident "
00778 "blk_opt_declares { blk_repr_constructors }");
00779 if ($1->children.size() != 0) {
00780 std::string s = ": Error: Repr declarations cannot be quantified.";
00781 lexer->ReportParseError($1->loc, s);
00782 }
00783 $$ = AST::make(at_defrepr, $3.loc, $4,
00784 AST::make(at_tvlist),
00785 $2, $5, $7,
00786 $1);
00787 $$->child(0)->defForm = $$;
00788 }
00789
00790 blk_repr_constructors: blk_repr_constructor {
00791 SHOWPARSE("blk_repr_constructors -> blk_repr_constructor");
00792 $$ = AST::make(at_reprctrs, $1->loc, $1);
00793 }
00794
00795 blk_repr_constructors: blk_repr_constructors SC blk_repr_constructor {
00796 SHOWPARSE("blk_repr_constructors -> blk_repr_constructors SC blk_repr_constructor");
00797 $$ = $1;
00798 $$->addChild($3);
00799 }
00800
00801 blk_repr_constructor: blk_ident IsILCB blk_fields OptRCB tk_WHERE blk_repr_reprs {
00802 SHOWPARSE("blk_repr_constructor -> blk_ident { sxp_fields } WHERE blk_repr_reprs");
00803 $1->flags |= (ID_IS_GLOBAL);
00804 shared_ptr<AST> ctr = AST::make(at_constructor, $1->loc, $1);
00805 ctr->addChildrenFrom($3);
00806 $$ = AST::make(at_reprctr, $1->loc, ctr);
00807 $$->addChildrenFrom($6);
00808 }
00809
00810 blk_repr_reprs: blk_repr_repr {
00811 SHOWPARSE("blk_repr_reprs -> blk_repr_repr");
00812 $$ = AST::make(at_Null, $1->loc, $1);
00813 };
00814 blk_repr_reprs: blk_repr_reprs ',' blk_repr_repr {
00815 SHOWPARSE("blk_repr_reprs -> blk_repr_reprs ',' blk_repr_repr");
00816 $$ = $1;
00817 $$->addChild($3);
00818 };
00819
00820 blk_repr_repr: blk_ident tk_EQUALS intLit {
00821 SHOWPARSE("blk_repr_repr -> sxp_ident == intLit");
00822
00823 $$ = AST::make(at_reprrepr, $2.loc, $1, $3);
00824 };
00825
00826
00827
00828 blk_externals: {
00829 SHOWPARSE("blk_externals -> ");
00830 yyerrok;
00831 lexer->showNextError = false;
00832
00833 $$ = AST::make(at_Null);
00834 $$->flags = NO_FLAGS;
00835 };
00836
00837 blk_externals: tk_EXTERNAL {
00838 SHOWPARSE("blk_externals -> EXTERNAL");
00839 $$ = AST::make(at_Null, $1.loc);
00840 $$->flags = DEF_IS_EXTERNAL;
00841 };
00842
00843 blk_externals: tk_EXTERNAL blk_exident {
00844 SHOWPARSE("blk_externals -> EXTERNAL blk_exident");
00845 $$ = AST::make(at_Null, $1.loc);
00846 $$->flags = DEF_IS_EXTERNAL;
00847 $$->externalName = $2->s;
00848 };
00849
00850
00851 blk_type_definition: blk_constraints tk_OBJECT blk_ptype_name blk_opt_declares IsILCB blk_methods_only IRCB {
00852 SHOWPARSE("blk_type_definition -> blk_constraints OBJECT blk_ptype_name "
00853 "blk_opt_declares blk_methods_only )");
00854
00855
00856 shared_ptr<AST> valCat =
00857 AST::make(at_unboxedCat, LToken(tk_UNBOXED, "unboxed"));
00858
00859 $$ = AST::make(at_defobject, $2.loc, $3->child(0), $3->child(1),
00860 valCat,
00861 $4, $6, $1);
00862 $$->child(0)->defForm = $$;
00863 };
00864
00865
00866 blk_type_decl: blk_constraints blk_val tk_STRUCT blk_ptype_name blk_externals {
00867 SHOWPARSE("blk_type_decl -> blk_constraints blk_val STRUCT blk_ptype_name blk_externals '");
00868 $$ = AST::make(at_declstruct, $3.loc,
00869 $4->child(0),
00870 $4->child(1),
00871 $2,
00872 AST::make(at_declares),
00873 AST::make(at_fields),
00874 $1);
00875 $$->child(0)->defForm = $$;
00876 $$->flags |= $5->flags;
00877 $$->getID()->flags |= $5->flags;
00878 $$->getID()->externalName = $5->externalName;
00879 };
00880
00881
00882 blk_type_decl: blk_constraints blk_val tk_UNION blk_ptype_name blk_externals {
00883 SHOWPARSE("blk_type_decl -> blk_constraints blk_val UNION blk_ptype_name blk_externals");
00884 $$ = AST::make(at_declunion, $3.loc,
00885 $4->child(0),
00886 $4->child(1),
00887 $2,
00888 AST::make(at_declares),
00889 AST::make(at_constructors),
00890 $1);
00891 $$->child(0)->defForm = $$;
00892 $$->flags |= $5->flags;
00893 $$->getID()->flags |= $5->flags;
00894 $$->getID()->externalName = $5->externalName;
00895 };
00896
00897
00898 blk_type_decl: blk_constraints blk_val tk_REPR blk_defident blk_externals {
00899 SHOWPARSE("blk_type_decl -> blk_val REPR blk_defident blk_externals )");
00900 if ($1->children.size() != 0) {
00901 std::string s = ": Error: Repr declarations cannot be quantified.";
00902 lexer->ReportParseError($1->loc, s);
00903 }
00904
00905 $$ = AST::make(at_declrepr, $3.loc, $4,
00906 AST::make(at_tvlist),
00907 $2,
00908 AST::make(at_declares),
00909 AST::make(at_reprctrs),
00910 $1);
00911 $$->child(0)->defForm = $$;
00912 $$->flags |= $5->flags;
00913 $$->getID()->flags |= $5->flags;
00914 $$->getID()->externalName = $5->externalName;
00915 };
00916
00917
00918
00919 blk_optval: {
00920 SHOWPARSE("blk_optval ->");
00921 $$ = AST::make(at_boxedCat);
00922 $$->printVariant = pf_IMPLIED;
00923 }
00924 blk_optval: blk_val {
00925 SHOWPARSE("blk_optval -> blk_val");
00926 $$ = $1;
00927 }
00928
00929 blk_val: tk_BOXED {
00930 SHOWPARSE("blk_val -> BOXED");
00931 $$ = AST::make(at_boxedCat);
00932 }
00933
00934 blk_val: tk_UNBOXED {
00935 SHOWPARSE("blk_val -> UNBOXED");
00936 $$ = AST::make(at_unboxedCat, $1);
00937 };
00938
00939 blk_val: tk_OPAQUE {
00940 SHOWPARSE("blk_val -> tk_OPAQUE");
00941 $$ = AST::make(at_opaqueCat, $1);
00942 };
00943
00944 blk_openclosed: {
00945 SHOWPARSE("blk_closed -> <empty>");
00946 $$ = AST::make(at_oc_open);
00947 $$->printVariant = pf_IMPLIED;
00948 };
00949
00950 blk_openclosed: tk_CLOSED {
00951 SHOWPARSE("blk_closed -> CLOSED");
00952 $$ = AST::make(at_oc_closed, $1);
00953 };
00954
00955
00956 blk_type_definition: blk_constraints blk_optval tk_EXCEPTION blk_ident {
00957 SHOWPARSE("blk_type_definition -> blk_constraints optval EXCEPTION blk_ident");
00958 if ($1->children.size() != 0) {
00959 std::string s = ": Error: Exception declarations cannot be quantified.";
00960 lexer->ReportParseError($1->loc, s);
00961 }
00962 $4->flags |= ID_IS_GLOBAL;
00963 $$ = AST::make(at_defexception, $3.loc,
00964 $4,
00965 AST::make(at_tvlist),
00966 $2,
00967 AST::make(at_declares),
00968 AST::make(at_fields),
00969 $1);
00970 $$->child(0)->defForm = $$;
00971 };
00972
00973 blk_type_definition: blk_constraints blk_optval tk_EXCEPTION blk_ident IsILCB blk_fields IRCB {
00974 SHOWPARSE("blk_type_definition -> blk_constraints exception blk_ident IS { blk_fields }");
00975 if ($1->children.size() != 0) {
00976 std::string s = ": Error: Exception declarations cannot be quantified.";
00977 lexer->ReportParseError($1->loc, s);
00978 }
00979 $4->flags |= ID_IS_GLOBAL;
00980 $$ = AST::make(at_defexception, $3.loc,
00981 $4,
00982 AST::make(at_tvlist),
00983 $2,
00984 AST::make(at_declares),
00985 $6,
00986 $1);
00987 $$->child(0)->defForm = $$;
00988 };
00989
00990
00991
00992
00993 blk_tc_definition: blk_constraints blk_openclosed tk_TRAIT blk_ptype_name blk_tc_decls IsILCB blk_method_decls IRCB {
00994 SHOWPARSE("blk_tc_definition -> blk_constraints blk_openclosed TRAIT blk_ptype_name "
00995 "blk_tc_decls blk_method_decls)");
00996 $$ = AST::make(at_deftypeclass, $3.loc, $4->child(0),
00997 $4->child(1), $5, $2, $7, $1);
00998 $$->child(0)->defForm = $$;
00999 };
01000
01001 blk_tc_decls: {
01002 SHOWPARSE("blk_tc_decls -> <empty>");
01003 $$ = AST::make(at_tcdecls);
01004 };
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024 blk_method_decls: {
01025 SHOWPARSE("blk_method_decls -> ");
01026 LexLoc loc;
01027 $$ = AST::make(at_method_decls, loc);
01028 };
01029
01030 blk_method_decls: blk_method_decls SC blk_method_decl {
01031 SHOWPARSE("blk_method_decls -> blk_method_decls SC blk_method_decl");
01032 $$ = $1;
01033 $$->addChild($3);
01034 };
01035
01036 blk_method_decl: blk_ident ':' blk_fntype {
01037 SHOWPARSE("blk_method_decl -> blk_ident : blk_fntype");
01038 $1->flags |= ID_IS_GLOBAL;
01039 $1->identType = id_tcmethod;
01040 $$ = AST::make(at_method_decl, $1->loc, $1, $3);
01041 };
01042
01043
01044 blk_ti_definition: blk_constraints tk_INSTANCE blk_constraint {
01045 SHOWPARSE("blk_ti_definition -> blk_constraints INSTANCE blk_constraint)");
01046 $$ = AST::make(at_definstance, $2.loc, $3,
01047 AST::make(at_tcmethods, $2.loc), $1);
01048 };
01049 blk_ti_definition: blk_constraints tk_INSTANCE blk_constraint IsILCB blk_method_bindings IRCB {
01050 SHOWPARSE("blk_ti_definition -> blk_constraints INSTANCE blk_constraint IS { blk_method_bindings }");
01051 $$ = AST::make(at_definstance, $2.loc, $3, $5, $1);
01052 };
01053
01054 blk_method_bindings: blk_method_binding {
01055 SHOWPARSE("blk_method_bindings -> blk_method_binding");
01056 $$ = AST::make(at_tcmethods, $1->loc, $1);
01057 };
01058 blk_method_bindings: blk_method_bindings SC blk_method_binding {
01059 SHOWPARSE("blk_method_bindings -> blk_method_bindings SC blk_method_binding");
01060 $$ = $1;
01061 $$->addChild($3);
01062 };
01063
01064 blk_method_binding: blk_ident '=' blk_expr {
01065 SHOWPARSE("blk_method_binding -> blk_ident = blk_expr");
01066
01067 $$ = AST::make(at_tcmethod_binding, $1->loc, $1, $3);
01068 };
01069
01070
01071
01072
01073
01074
01075
01076 blk_value_definition: blk_constraints tk_DEF blk_defpattern '=' blk_expr {
01077 SHOWPARSE("blk_value_definition -> blk_constraints DEF blk_defpattern = blk_expr");
01078 $$ = AST::make(at_define, $2.loc, $3, $5, $1);
01079 };
01080 blk_value_definition: blk_constraints tk_DEF blk_defident '(' ')' blk_fndef_tail {
01081 SHOWPARSE("blk_value_definition -> blk_constraints DEF blk_defident () blk_expr");
01082 shared_ptr<AST> iRetBlock =
01083 AST::make(at_labeledBlock, $2.loc,
01084 AST::make(at_ident, LToken(tk_BlkIdent, "__return")), $6);
01085 shared_ptr<AST> iLambda =
01086 AST::make(at_lambda, $2.loc, AST::make(at_argVec, $4.loc), iRetBlock);
01087 iLambda->printVariant = pf_IMPLIED;
01088 shared_ptr<AST> iP = AST::make(at_identPattern, $3->loc, $3);
01089 $$ = AST::make(at_recdef, $2.loc, iP, iLambda, $1);
01090 }
01091
01092 blk_value_definition: blk_constraints tk_DEF blk_defident '(' blk_lambdapatterns ')' blk_fndef_tail {
01093 SHOWPARSE("blk_value_definition -> blk_constraints DEF blk_defident () blk_expr");
01094
01095 shared_ptr<AST> iRetBlock =
01096 AST::make(at_labeledBlock, $2.loc,
01097 AST::make(at_ident, LToken(tk_BlkIdent, "__return")), $7);
01098 shared_ptr<AST> iLambda = AST::make(at_lambda, $2.loc, $5, iRetBlock);
01099 iLambda->printVariant = pf_IMPLIED;
01100 shared_ptr<AST> iP = AST::make(at_identPattern, $3->loc, $3);
01101 $$ = AST::make(at_recdef, $2.loc, iP, iLambda, $1);
01102 }
01103
01104 blk_fndef_tail: '=' blk_expr {
01105 SHOWPARSE("blk_fndef_tail -> '=' blk_expr");
01106 $$ = $2;
01107 }
01108 blk_fndef_tail: tk_IN blk_iblock {
01109 SHOWPARSE("blk_fndef_tail -> IN blk_iblock");
01110 $$ = $2;
01111 }
01112 blk_fndef_tail: '{' blk_expr_seq '}' {
01113 SHOWPARSE("blk_fndef_tail -> '{' blk_expr_seq '}'");
01114 $$ = $2;
01115 }
01116
01117
01118 blk_value_declaration: blk_constraints tk_DEF blk_defpattern blk_externals {
01119 SHOWPARSE("blk_value_declaration -> blk_constraints DEF blk_defpattern blk_externals");
01120
01121
01122
01123 if ($3->children.size() == 1)
01124 lexer->ReportParseError($3->loc, "Declaration forms require a type");
01125
01126 shared_ptr<AST> declIdent = $3->child(0);
01127 shared_ptr<AST> declType = $3->child(1);
01128
01129 $$ = AST::make(at_proclaim, $2.loc, declIdent, declType, $1);
01130 $$->flags |= $4->flags;
01131 $$->getID()->flags |= $4->flags;
01132 $$->getID()->externalName = $4->externalName;
01133 };
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147 blk_import_definition: tk_IMPORT blk_ifident tk_AS blk_ident {
01148 SHOWPARSE("blk_import_definition -> IMPORT blk_ifident AS blk_ident;");
01149 shared_ptr<AST> ifIdent = AST::make(at_ifident, $2);
01150 if (!UocInfo::importInterface(lexer->errStream, $2.loc, $2.str)) {
01151 std::string err = "Unable to import " + $2.str;
01152 lexer->ReportParseError($1.loc, err);
01153 }
01154
01155 $$ = AST::make(at_importAs, $1.loc, ifIdent, $4);
01156 }
01157
01158 blk_import_definition: tk_IMPORT blk_ifident {
01159 SHOWPARSE("blk_import_definition -> IMPORT blk_ifident;");
01160 shared_ptr<AST> ifIdent = AST::make(at_ifident, $2);
01161 if (!UocInfo::importInterface(lexer->errStream, $2.loc, $2.str)) {
01162 std::string err = "Unable to import " + $2.str;
01163 lexer->ReportParseError($1.loc, err);
01164 }
01165 $$ = AST::make(at_import, $1.loc, ifIdent);
01166 };
01167
01168 blk_import_definition: tk_IMPORT blk_ifident blk_importList {
01169 SHOWPARSE("blk_import_definition -> IMPORT blk_ifident blk_importList;");
01170 shared_ptr<AST> ifIdent = AST::make(at_ifident, $2);
01171 if (!UocInfo::importInterface(lexer->errStream, $2.loc, $2.str)) {
01172 std::string err = "Unable to import " + $2.str;
01173 lexer->ReportParseError($1.loc, err);
01174 }
01175 $$ = AST::make(at_import, $1.loc, ifIdent);
01176 $$->addChildrenFrom($3);
01177 };
01178
01179 blk_importList: blk_alias {
01180 SHOWPARSE("blk_importList -> blk_alias");
01181 $$ = AST::make(at_Null, $1->loc, $1);
01182 };
01183 blk_importList: blk_importList ',' blk_alias {
01184 SHOWPARSE("blk_importList -> blk_importList blk_alias");
01185 $$ = $1;
01186 $$->addChild($3);
01187 };
01188
01189 blk_alias: blk_ident {
01190 SHOWPARSE("blk_alias -> blk_ident");
01191
01192
01193 $$ = AST::make(at_ifsel, $1->loc, $1, $1->getDeepCopy());
01194 };
01195 blk_alias: blk_ident '=' blk_ident {
01196 SHOWPARSE("blk_alias -> blk_ident '=' blk_ident");
01197
01198 $$ = AST::make(at_ifsel, $1->loc, $1, $3);
01199 };
01200
01201
01202 blk_provide_definition: tk_PROVIDE blk_ifident blk_provideList {
01203 SHOWPARSE("blk_provide_definition -> PROVIDE blk_ifident blk_provideList;");
01204 shared_ptr<AST> ifIdent = AST::make(at_ifident, $2);
01205 UocInfo::importInterface(lexer->errStream, $2.loc, $2.str);
01206 $$ = AST::make(at_provide, $1.loc, ifIdent);
01207 $$->addChildrenFrom($3);
01208 };
01209
01210 blk_provideList: blk_ident {
01211 SHOWPARSE("blk_provideList -> blk_ident");
01212 $$ = AST::make(at_Null, $1->loc, $1);
01213 };
01214
01215 blk_provideList: blk_provideList ',' blk_ident {
01216 SHOWPARSE("blk_provideList -> blk_provideList , blk_ident");
01217 $$ = $1;
01218 $$->addChild($3);
01219 };
01220
01221 blk_opt_declares: {
01222 SHOWPARSE("blk_opt_declares -> <empty>");
01223 yyerrok;
01224 lexer->showNextError = false;
01225 $$ = AST::make(at_declares);
01226 };
01227 blk_opt_declares: blk_declares {
01228 SHOWPARSE("blk_opt_declares -> blk_declares");
01229 $$ = $1;
01230 };
01231
01232 blk_declares: blk_declare {
01233 SHOWPARSE("blk_declares -> blk_declare");
01234 $$ = AST::make(at_declares, $1->loc, $1);
01235 };
01236
01237 blk_declares: blk_declares SC blk_declare {
01238 SHOWPARSE("blk_declares -> blk_declares blk_declare");
01239 $$ = $1;
01240 $$->addChildrenFrom($3);
01241 };
01242
01243 blk_declare: tk_DECLARE blk_decl {
01244 SHOWPARSE("blk_declare -> DECLARE blk_decl");
01245 $$ = $2;
01246 };
01247
01248
01249 blk_decl: blk_ident tk_AS blk_field_type {
01250 SHOWPARSE("blk_decl -> blk_ident AS blk_field_type");
01251 $$ = AST::make(at_declare, $1->loc, $1, $3);
01252 };
01253
01254
01255
01256
01257
01258 blk_decl: blk_ident {
01259 SHOWPARSE("blk_decl -> blk_ident");
01260 $$ = AST::make(at_declare, $1->loc, $1);
01261 };
01262
01263
01264
01265 blk_constructors: blk_constructor {
01266 SHOWPARSE("blk_constructors -> blk_constructor");
01267 $$ = AST::make(at_constructors, $1->loc, $1);
01268 };
01269 blk_constructors: blk_constructors SC blk_constructor {
01270 SHOWPARSE("blk_constructors -> blk_constructors SC blk_constructor");
01271 $$ = $1;
01272 $$->addChild($3);
01273 };
01274
01275 blk_constructor: blk_ident {
01276 SHOWPARSE("blk_constructor -> blk_ident");
01277 $1->flags |= (ID_IS_GLOBAL);
01278 $$ = AST::make(at_constructor, $1->loc, $1);
01279 };
01280
01281
01282
01283
01284
01285 blk_constructor: blk_ident IsILCB blk_fields IRCB {
01286 SHOWPARSE("blk_constructor -> blk_ident { blk_fields }");
01287 $1->flags |= (ID_IS_GLOBAL);
01288 $$ = AST::make(at_constructor, $1->loc, $1);
01289 $$->addChildrenFrom($3);
01290 };
01291
01292
01293 blk_fields: blk_field {
01294 SHOWPARSE("blk_fields -> blk_field");
01295 $$ = AST::make(at_fields, $1->loc, $1);
01296 };
01297
01298 blk_fields: blk_fields SC blk_field {
01299 SHOWPARSE("sxp_fields -> sxp_fields SC sxp_field ");
01300 $$ = $1;
01301 $$->addChild($3);
01302 };
01303
01304 blk_field: blk_ident ':' blk_field_type {
01305 SHOWPARSE("blk_field -> blk_ident : blk_field_type");
01306 $$ = AST::make(at_field, $1->loc, $1, $3);
01307 };
01308
01309
01310 blk_field: tk_FILL ':' blk_bitfieldtype {
01311 SHOWPARSE("blk_field -> FILL : blk_bitfieldtype");
01312 $$ = AST::make(at_fill, $1.loc, $3);
01313 };
01314
01315
01316
01317 blk_field: tk_RESERVED ':' blk_bitfieldtype '=' natLit {
01318 SHOWPARSE("blk_field -> RESERVED ':' blk_bitfieldtype = natLit");
01319 $$ = AST::make(at_fill, $1.loc, $3, $5);
01320 };
01321
01322 blk_methods_only: blk_methdecl {
01323 SHOWPARSE("blk_methods_only -> blk_methdecl");
01324 $$ = AST::make(at_fields, $1->loc, $1);
01325 };
01326
01327 blk_methods_only: blk_methods_only SC blk_methdecl {
01328 SHOWPARSE("blk_methods_only -> blk_methods_only SC blk_methdecl");
01329 $$ = $1;
01330 $$->addChild($3);
01331 };
01332
01333 blk_methdecl: blk_ident ':' blk_method_type {
01334 SHOWPARSE("blk_methdecl -> blk_ident : blk_method_type");
01335 $$ = AST::make(at_methdecl, $1->loc, $1, $3);
01336 };
01337
01338 blk_fields_and_methods: blk_methdecl {
01339 SHOWPARSE("blk_fields_and_methods -> blk_methdecl");
01340 $$ = AST::make(at_fields, $1->loc, $1);
01341 };
01342
01343 blk_fields_and_methods: blk_field {
01344 SHOWPARSE("blk_fields_and_methods -> blk_field");
01345 $$ = AST::make(at_fields, $1->loc, $1);
01346 };
01347
01348 blk_fields_and_methods: blk_fields_and_methods SC blk_methdecl {
01349 SHOWPARSE("blk_fields_and_methods -> blk_fields_and_methods SC blk_methdecl ");
01350 $$ = $1;
01351 $$->addChild($3);
01352 };
01353
01354 blk_fields_and_methods: blk_fields_and_methods SC blk_field {
01355 SHOWPARSE("blk_fields_and_methods -> blk_fields_and_methods SC blk_field ");
01356 $$ = $1;
01357 $$->addChild($3);
01358 };
01359
01360
01361
01362
01363 blk_tvlist: typevar {
01364 SHOWPARSE("blk_tvlist -> typevar");
01365 $$ = AST::make(at_tvlist, $1->loc, $1);
01366 };
01367 blk_tvlist: blk_tvlist ',' typevar {
01368 SHOWPARSE("blk_tvlist -> blk_tvlist , typevar");
01369 $$ = $1;
01370 $1->addChild($3);
01371 };
01372
01373
01374
01375
01376
01377
01378
01379
01380
01381
01382
01383
01384
01385
01386
01387
01388
01389
01390
01391
01392
01393
01394
01395
01396
01397
01398
01399
01400 blk_prefix_type: blk_primary_type {
01401 SHOWPARSE("blk_prefix_type -> blk_primary_type");
01402 $$ = $1;
01403 }
01404
01405 blk_prefix_type: tk_MUTABLE blk_prefix_type {
01406 SHOWPARSE("blk_prefix_type -> MUTABLE blk_prefix_type");
01407 $$ = AST::make(at_mutableType, $1.loc, $2);
01408 }
01409 blk_prefix_type: tk_CONST blk_prefix_type {
01410 SHOWPARSE("blk_prefix_type -> CONST blk_prefix_type");
01411 $$ = AST::make(at_constType, $1.loc, $2);
01412 }
01413
01414 blk_postfix_type: blk_prefix_type {
01415 SHOWPARSE("blk_postfix_type -> blk_prefix_type");
01416 $$ = $1;
01417 }
01418
01419 blk_type: blk_postfix_type %prec prec_PreferShift {
01420 SHOWPARSE("blk_type -> blk_postfix_type");
01421 $$ = $1;
01422 }
01423
01424 blk_primary_type: primary_type {
01425 SHOWPARSE("blk_primary_type -> primary_type");
01426 $$ = $1;
01427 }
01428 blk_primary_type: '(' blk_type ')' {
01429 SHOWPARSE("blk_primary_type -> '(' blk_type ')'");
01430 $$ = $2;
01431
01432 $2->printVariant |= pf_PARENWRAP;
01433 }
01434 blk_primary_type: '(' blk_type_cpair ')' {
01435 SHOWPARSE("blk_primary_type -> (blk_type_cpair)");
01436 $$ = $2;
01437 };
01438
01439
01440
01441 blk_primary_type: tk_BOXED '(' blk_type ')' {
01442 SHOWPARSE("blk_primary_type -> tk_BOXED ( blk_type )");
01443 $$ = AST::make(at_boxedType, $1.loc, $3);
01444
01445 }
01446 blk_primary_type: tk_UNBOXED '(' blk_type ')' {
01447 SHOWPARSE("blk_type -> UNBOXED ( blk_type )");
01448 $$ = AST::make(at_unboxedType, $1.loc, $3);
01449 };
01450 blk_primary_type: tk_ARRAY '(' blk_type ',' natLit ')' {
01451 SHOWPARSE("blk_primary_type -> tk_ARRAY ( blk_type, natLit )");
01452 $$ = AST::make(at_arrayType, $1.loc, $3, $5);
01453
01454 }
01455 blk_primary_type: tk_VECTOR '(' blk_type ')' {
01456 SHOWPARSE("blk_primary_type -> tk_VECTOR ( blk_type )");
01457 $$ = AST::make(at_vectorType, $1.loc, $3);
01458
01459 }
01460
01461 blk_primary_type: blk_useident %prec prec_PreferShift {
01462 SHOWPARSE("blk_primary_type -> blk_useident");
01463 $$ = $1;
01464 };
01465
01466 primary_type: '(' ')' {
01467 SHOWPARSE("primary_type -> ( )");
01468 $$ = AST::make(at_primaryType, $1.loc);
01469 $$->s = "unit";
01470 };
01471
01472
01473
01474
01475
01476
01477
01478
01479 bool_type: tk_BOOL {
01480 SHOWPARSE("bool_type -> BOOL");
01481 $$ = AST::make(at_primaryType, $1);
01482 };
01483
01484 primary_type: bool_type {
01485 SHOWPARSE("primary_type -> bool_type");
01486 $$ = $1;
01487 };
01488
01489 primary_type: tk_CHAR {
01490 SHOWPARSE("primary_type -> CHAR");
01491 $$ = AST::make(at_primaryType, $1);
01492 };
01493 primary_type: tk_STRING {
01494 SHOWPARSE("primary_type -> STRING");
01495 $$ = AST::make(at_primaryType, $1);
01496 };
01497
01498 int_type: tk_INT8 {
01499 SHOWPARSE("int_type -> INT8");
01500 $$ = AST::make(at_primaryType, $1);
01501 };
01502 int_type: tk_INT16 {
01503 SHOWPARSE("int_type -> INT16");
01504 $$ = AST::make(at_primaryType, $1);
01505 };
01506 int_type: tk_INT32 {
01507 SHOWPARSE("int_type -> INT32");
01508 $$ = AST::make(at_primaryType, $1);
01509 };
01510 int_type: tk_INT64 {
01511 SHOWPARSE("int_type -> INT64");
01512 $$ = AST::make(at_primaryType, $1);
01513 };
01514 uint_type: tk_UINT8 {
01515 SHOWPARSE("uint_type -> UINT8");
01516 $$ = AST::make(at_primaryType, $1);
01517 };
01518 uint_type: tk_UINT16 {
01519 SHOWPARSE("uint_type -> UINT16");
01520 $$ = AST::make(at_primaryType, $1);
01521 };
01522 uint_type: tk_UINT32 {
01523 SHOWPARSE("uint_type -> UINT32");
01524 $$ = AST::make(at_primaryType, $1);
01525 };
01526 uint_type: tk_UINT64 {
01527 SHOWPARSE("uint_type -> UINT64");
01528 $$ = AST::make(at_primaryType, $1);
01529 };
01530
01531 any_int_type: int_type {
01532 SHOWPARSE("any_int_type -> int_type");
01533 $$ = $1;
01534 };
01535 any_int_type: uint_type {
01536 SHOWPARSE("any_int_type -> uint_type");
01537 $$ = $1;
01538 };
01539 any_int_type: tk_WORD {
01540 SHOWPARSE("any_int_type -> WORD");
01541 $$ = AST::make(at_primaryType, $1);
01542 };
01543
01544 float_type: tk_FLOAT {
01545 SHOWPARSE("float_type -> FLOAT");
01546 $$ = AST::make(at_primaryType, $1);
01547 };
01548 float_type: tk_DOUBLE {
01549 SHOWPARSE("float_type -> DOUBLE");
01550 $$ = AST::make(at_primaryType, $1);
01551 };
01552 float_type: tk_QUAD {
01553 SHOWPARSE("float_type -> QUAD");
01554 $$ = AST::make(at_primaryType, $1);
01555 };
01556
01557 primary_type: any_int_type {
01558 SHOWPARSE("primary_type -> any_int_type");
01559 $$ = $1;
01560 };
01561 primary_type: float_type {
01562 SHOWPARSE("primary_type -> float_type");
01563 $$ = $1;
01564 };
01565
01566
01567 primary_type: tk_EXCEPTION {
01568 SHOWPARSE("primary_type -> EXCEPTION");
01569 $$ = AST::make(at_exceptionType, $1.loc);
01570 };
01571
01572
01573 primary_type: typevar {
01574 SHOWPARSE("primary_type -> typevar");
01575 $$ = $1;
01576 };
01577
01578
01579 blk_postfix_type: blk_postfix_type tk_PTR %prec tk_PTR {
01580 SHOWPARSE("blk_postfix_type -> blk_postfix_type PTR");
01581 $$ = AST::make(at_boxedType, $2.loc, $1);
01582 };
01583
01584
01585 blk_type: blk_fntype {
01586 SHOWPARSE("blk_type -> blk_fntype");
01587 $$ = $1;
01588 }
01589
01590 trn_fneffect: {
01591 SHOWPARSE("trn_fneffect -> <empty>");
01592 $$ = AST::make(at_ident, LToken(tk_IMPURE, "impure"));
01593 };
01594
01595 trn_fneffect: tk_PURE {
01596 SHOWPARSE("trn_fneffect -> PURE");
01597 $$ = AST::make(at_ident, $1);
01598 };
01599
01600 trn_fneffect: tk_IMPURE {
01601 SHOWPARSE("trn_fneffect -> IMPURE");
01602 $$ = AST::make(at_ident, $1);
01603 };
01604
01605 trn_fneffect: tk_EffectVar {
01606 SHOWPARSE("trn_fneffect -> <EffectVar=" + $1.str + ">");
01607 $$ = AST::make(at_ident, $1);
01608 };
01609
01610 blk_type_args: blk_type {
01611 SHOWPARSE("blk_type_args -> blk_type");
01612 $$ = AST::make(at_Null);
01613 $$->addChild($1);
01614 };
01615 blk_type_args: blk_type_args ',' blk_type {
01616 SHOWPARSE("blk_type_args -> blk_type_args, blk_type");
01617 $$ = $1;
01618 $1->addChild($3);
01619 };
01620
01621
01622 blk_fntype: trn_fneffect tk_FN '(' ')' tk_FNARROW blk_type {
01623 SHOWPARSE("blk_fntype -> trn_fneffect FN () -> blk_type )");
01624 shared_ptr<AST> fnargVec = AST::make(at_fnargVec, $5.loc);
01625 $$ = AST::make(at_fn, $1->loc, fnargVec, $6);
01626 };
01627
01628 blk_fntype: trn_fneffect tk_FN '(' blk_type_args_pl_byref ')' tk_FNARROW blk_type {
01629 SHOWPARSE("blk_fntype -> trn_fneffect FN ( blk_type_args_pl_byref ) -> blk_type )");
01630 $$ = AST::make(at_fn, $1->loc, $4, $7);
01631 };
01632
01633
01634 blk_method_type: trn_fneffect tk_METHOD '(' ')' tk_FNARROW blk_type {
01635 SHOWPARSE("blk_method_type -> trn_fneffect METHOD () -> blk_type )");
01636 shared_ptr<AST> fnargVec = AST::make(at_fnargVec, $5.loc);
01637 $$ = AST::make(at_methType, $1->loc, fnargVec, $6);
01638 };
01639
01640 blk_method_type: trn_fneffect tk_METHOD '(' blk_type_args_pl_byref ')' tk_FNARROW blk_type {
01641 SHOWPARSE("blk_method_type -> trn_fneffect METHOD ( blk_type_args_pl_byref ) -> blk_type )");
01642 $$ = AST::make(at_fn, $1->loc, $4, $7);
01643 };
01644
01645 blk_type_cpair: blk_type ',' blk_type {
01646 SHOWPARSE("blk_type_cpair -> blk_type ',' blk_type");
01647 $$ = AST::make(at_typeapp, $2.loc,
01648 AST::make(at_ident, LToken(tk_PAIR, $2.loc, $2.endLoc, "pair")),
01649 $1, $3);
01650 $$->printVariant = pf_IMPLIED;
01651 };
01652 blk_type_cpair: blk_type ',' blk_type_cpair {
01653 SHOWPARSE("blk_type_cpair -> blk_type ',' blk_type_cpair");
01654 $$ = AST::make(at_typeapp, $2.loc,
01655 AST::make(at_ident, LToken(tk_PAIR, $2.loc, $2.endLoc, "pair")),
01656 $1, $3);
01657 $$->printVariant = pf_IMPLIED;
01658 };
01659
01660
01661 blk_postfix_type: blk_postfix_type '[' natLit ']' %prec '[' {
01662 SHOWPARSE("blk_postfix_type -> blk_postfix_type '[' natLit ']'");
01663 $$ = AST::make(at_arrayType, $1->loc, $1, $3);
01664 };
01665
01666 blk_postfix_type: blk_postfix_type '[' ']' %prec '[' {
01667 SHOWPARSE("blk_postfix_type -> blk_postfix_type '[' ']'");
01668 $$ = AST::make(at_vectorType, $1->loc, $1);
01669 };
01670
01671
01672
01673
01674
01675
01676
01677 blk_primary_type: blk_typeapp {
01678 SHOWPARSE("blk_primary_type -> blk_typeapp");
01679 $$ = $1;
01680 };
01681
01682 blk_typeapp: blk_useident '(' blk_type_args ')' %prec '(' {
01683 SHOWPARSE("blk_typeapp -> blk_useident (blk_type_args)");
01684 $$ = AST::make(at_typeapp, $1->loc, $1);
01685 $$->addChildrenFrom($3);
01686 };
01687
01688
01689 blk_bitfieldtype: any_int_type '(' natLit ')' {
01690 SHOWPARSE("blk_bitfieldtype -> any_int_type ( natLit )");
01691 $$ = AST::make(at_bitfieldType, $1->loc, $1, $3);
01692 };
01693 blk_bitfieldtype: bool_type '(' natLit ')' {
01694 SHOWPARSE("blk_bitfieldtype -> bool_type ( natLit )");
01695 $$ = AST::make(at_bitfieldType, $1->loc, $1, $3);
01696 };
01697
01698
01699 blk_field_type: blk_bitfieldtype {
01700 SHOWPARSE("blk_field_type -> blk_bitfieldtype");
01701 $$ = $1;
01702 };
01703
01704 blk_field_type: blk_type {
01705 SHOWPARSE("blk_field_type -> blk_type");
01706 $$ = $1;
01707 };
01708
01709
01710
01711
01712 blk_type_pl_byref: blk_type {
01713 SHOWPARSE("blk_type_pl_byref -> blk_type");
01714 $$ = $1;
01715 };
01716
01717 blk_type_pl_byref: tk_BY_REF blk_type {
01718 SHOWPARSE("blk_type_pl_byref -> BY-REF blk_type");
01719 $$ = AST::make(at_byRefType, $1.loc, $2);
01720 };
01721
01722 blk_type_pl_byref: tk_ARRAY_REF blk_type {
01723 SHOWPARSE("blk_type_pl_byref -> ARRAY-REF blk_type");
01724 $$ = AST::make(at_arrayRefType, $1.loc, $2);
01725 };
01726
01727 blk_type_args_pl_byref: blk_type_pl_byref {
01728 SHOWPARSE("blk_type_args_pl_byref -> blk_type_pl_byref");
01729 $$ = AST::make(at_fnargVec);
01730 $$->addChild($1);
01731 };
01732 blk_type_args_pl_byref: blk_type_args_pl_byref ',' blk_type_pl_byref {
01733 SHOWPARSE("blk_type_args_pl_byref -> blk_type_args_pl_byref blk_type_pl_byref");
01734 $$ = $1;
01735 $1->addChild($3);
01736 };
01737
01738
01739 blk_bindingpattern: blk_ident {
01740 SHOWPARSE("blk_bindingpattern -> blk_ident");
01741 $$ = AST::make(at_identPattern, $1->loc, $1);
01742 };
01743
01744 blk_bindingpattern: blk_ident ':' blk_type {
01745 SHOWPARSE("blk_bindingpattern -> blk_ident : blk_type");
01746 $$ = AST::make(at_identPattern, $1->loc, $1, $3);
01747 };
01748
01749
01750
01751
01752 blk_defpattern: blk_defident %prec prec_PreferShift {
01753 SHOWPARSE("blk_defpattern -> blk_defident");
01754 $$ = AST::make(at_identPattern, $1->loc, $1);
01755 };
01756 blk_defpattern: blk_defident ':' blk_type %prec ':' {
01757 SHOWPARSE("blk_defpattern -> blk_defident : blk_qual_type");
01758 $$ = AST::make(at_identPattern, $1->loc, $1, $3);
01759 };
01760
01761
01762 blk_lambdapatterns: blk_lambdapattern {
01763 SHOWPARSE("blk_lambdapatterns -> blk_lambdapattern");
01764 $$ = AST::make(at_argVec, $1->loc);
01765 $$->addChild($1);
01766 };
01767 blk_lambdapatterns: blk_lambdapatterns ',' blk_lambdapattern {
01768 SHOWPARSE("blk_lambdapatterns -> blk_lambdapatterns , blk_lambdapattern");
01769 $$ = $1;
01770 $$->addChild($3);
01771 };
01772
01773 blk_lambdapattern: blk_ident {
01774 SHOWPARSE("blk_lambdapattern -> blk_ident");
01775 $$ = AST::make(at_identPattern, $1->loc, $1);
01776 };
01777
01778 blk_lambdapattern: blk_ident ':' blk_type_pl_byref {
01779 SHOWPARSE("blk_lambdapattern -> blk_ident : blk_type_pl_byref");
01780 $$ = AST::make(at_identPattern, $1->loc, $1, $3);
01781 if ($3->astType == at_byRefType)
01782 $1->flags |= ARG_BYREF;
01783 };
01784
01785
01786
01787
01788
01789
01790
01791
01792
01793
01794
01795
01796
01797
01798
01799
01800
01801
01802
01803
01804
01805
01806
01807
01808
01809
01810
01811
01812
01813
01814
01815
01816
01817
01818
01819
01820
01821
01822
01823
01824
01825
01826
01827
01828
01829
01830
01831
01832
01833
01834
01835
01836
01837
01838
01839
01840
01841
01842
01843
01844
01845
01846
01847
01848
01849
01850
01851
01852
01853
01854
01855
01856
01857
01858
01859
01860
01861
01862
01863 blk_expr_primary: blk_iblock {
01864 SHOWPARSE("blk_expr_primary -> blk_iblock");
01865 $$ = $1;
01866 }
01867
01868
01869
01870
01871
01872
01873
01874
01875 blk_expr_apply: blk_expr_primary {
01876 SHOWPARSE("blk_expr_apply -> blk_expr_primary");
01877 $$ = $1;
01878 }
01879 blk_expr_apply: tk_SIZEOF '(' blk_type ')' {
01880 SHOWPARSE("blk_expr_apply -> SIZEOF (blk_type)");
01881 $$ = AST::make(at_sizeof, $1.loc, $3);
01882 };
01883 blk_expr_apply: tk_BITSIZEOF '(' blk_type ')' {
01884 SHOWPARSE("blk_expr_apply -> BITSIZEOF (blk_type)");
01885 $$ = AST::make(at_bitsizeof, $1.loc, $3);
01886 };
01887
01888 blk_expr_apply: tk_DUP '(' blk_expr ')' {
01889 SHOWPARSE("blk_expr_apply -> DUP ( blk_expr )");
01890 $$ = AST::make(at_dup, $1.loc, $3);
01891 };
01892 blk_expr_apply: tk_DEREF '(' blk_expr ')' {
01893 SHOWPARSE("blk_expr_apply -> DEREF ( blk_expr )");
01894 $$ = AST::make(at_deref, $1.loc, $3);
01895 };
01896 blk_expr_apply: tk_MAKE_VECTOR '(' blk_expr ',' blk_expr ')' {
01897 SHOWPARSE("blk_expr_apply -> MAKE-VECTOR ( blk_expr , blk_expr )");
01898 $$ = AST::make(at_MakeVector, $1.loc, $3, $5);
01899 };
01900 blk_expr_apply: tk_VECTOR '(' blk_actual_params ')' {
01901 SHOWPARSE("blk_expr_apply -> VECTOR (blk_actual_params)");
01902 $$ = $3;
01903 $$->astType = at_vector;
01904 $$->loc = $1.loc;
01905 };
01906 blk_expr_apply: tk_ARRAY '(' blk_nonempty_params ')' {
01907
01908 SHOWPARSE("blk_expr_apply -> (ARRAY blk_nonempty_params)");
01909 $$ = $3;
01910 $$->astType = at_array;
01911 $$->loc = $1.loc;
01912 };
01913
01914 blk_expr_mixfix: blk_mixfix_elem %prec prec_PreferShift {
01915 SHOWPARSE("blk_expr_mixfix -> blk_mixfix_elem");
01916 $$ = $1;
01917 }
01918
01919 blk_expr_mixfix: blk_expr_mixfix blk_mixfix_elem {
01920 SHOWPARSE("blk_expr_mixfix -> blk_expr_mixfix blk_mixfix_elem");
01921 $1->addChildrenFrom($2);
01922 $$ = $1;
01923 }
01924
01925
01926
01927
01928
01929
01930
01931
01932 blk_mixfix_elem: blk_expr_apply {
01933 SHOWPARSE("blk_mixfix_elem -> blk_expr_apply");
01934 $$ = AST::make(at_mixfix, $1->loc, $1);
01935 }
01936
01937
01938
01939
01940
01941
01942
01943
01944
01945
01946
01947
01948
01949
01950
01951
01952
01953
01954 blk_mixfix_elem: '.' blk_ident {
01955 SHOWPARSE("blk_mixfix_elem -> '.' <Ident " + $1.str + "> blk_ident");
01956 $$ = AST::make(at_mixfix, $1.loc, AST::make(at_ident, $1), $2);
01957 };
01958
01959 blk_mixfix_arglist: blk_expr {
01960 SHOWPARSE("blk_mixfix_arglist -> blk_expr");
01961 $$ = AST::make(at_mixfix, $1->loc, $1);
01962 }
01963
01964 blk_mixfix_arglist: blk_mixfix_arglist ',' blk_expr {
01965 SHOWPARSE("blk_mixfix_arglist -> blk_mixfix_arglist , blk_expr");
01966 $$ = $1;
01967 $$->addChild(AST::make(at_ident, $2));
01968 $$->addChild(AST::make(at_mixfix, $3->loc, $3));
01969 }
01970
01971
01972
01973 blk_mixfix_elem: '(' blk_mixfix_arglist ')' {
01974 SHOWPARSE("blk_mixfix_elem -> ( blk_mixfix_arglist )");
01975 $$ = AST::make(at_mixfix, $1.loc, AST::make(at_ident, $1));
01976 $$->addChildrenFrom($2);
01977 $$->addChild(AST::make(at_ident, $3));
01978 }
01979
01980 blk_mixfix_elem: '(' ')' {
01981 SHOWPARSE("blk_mixfix_elem -> ( )");
01982 $$ = AST::make(at_mixfix, $1.loc, AST::make(at_ident, $1));
01983 $$->addChild(AST::make(at_ident, $2));
01984 }
01985
01986 blk_mixfix_elem: '[' blk_mixfix_arglist ']' {
01987 SHOWPARSE("blk_mixfix_elem -> [ blk_mixfix_arglist ]");
01988 $$ = AST::make(at_mixfix, $1.loc, AST::make(at_ident, $1));
01989 $$->addChildrenFrom($2);
01990 $$->addChild(AST::make(at_ident, $3));
01991 }
01992
01993
01994
01995
01996 blk_expr: blk_expr_mixfix %prec prec_PreferShift {
01997 SHOWPARSE("blk_expr -> blk_expr_mixfix");
01998 $$ = $1;
01999 }
02000 blk_expr: blk_expr_mixfix ':' blk_type {
02001 SHOWPARSE("blk_expr -> blk_expr_mixfix : blk_type");
02002 $$ = AST::make(at_typeAnnotation, $2.loc, $1, $3);
02003 }
02004
02005 blk_iblock: ILCB IRCB {
02006 SHOWPARSE("blk_block -> { }");
02007
02008 $$ = AST::make(at_begin, $1.loc);
02009 }
02010 blk_iblock: ILCB blk_expr_seq IRCB {
02011 SHOWPARSE("blk_block -> { blk_expr_seq }");
02012
02013
02014 if ($2->children.size() == 1 && $2->child(0)->astType == at_begin)
02015 $2 = $2->child(0);
02016 $$ = $2;
02017 }
02018
02019 blk_expr_seq: blk_expr {
02020 SHOWPARSE("blk_expr_seq -> blk_expr");
02021 $$ = AST::make(at_begin, $1->loc, $1);
02022 };
02023 blk_expr_seq: blk_value_definition {
02024 SHOWPARSE("blk_expr_seq -> blk_value_definition");
02025 $$ = AST::make(at_begin, $1->loc, $1);
02026 };
02027 blk_expr_seq: blk_expr_seq ';' blk_expr {
02028 SHOWPARSE("blk_expr_seq -> blk_expr_seq ; blk_expr");
02029 $$ = $1;
02030 $$->addChild($3);
02031 };
02032 blk_expr_seq: blk_expr_seq ';' blk_value_definition {
02033 SHOWPARSE("blk_expr_seq -> blk_expr_seq ; blk_value_definition");
02034 $$ = $1;
02035 $$->addChild($3);
02036 };
02037
02038 blk_actual_params: {
02039 SHOWPARSE("blk_actual_params -> ");
02040 $$ = AST::make(at_Null);
02041 };
02042 blk_actual_params: blk_nonempty_params {
02043 SHOWPARSE("blk_actual_params -> blk_nonempty_params");
02044 $$ = $1;
02045 };
02046 blk_nonempty_params: blk_expr {
02047 SHOWPARSE("blk_nonempty_params -> blk_expr");
02048 $$ = AST::make(at_Null, $1->loc, $1);
02049 };
02050 blk_nonempty_params: blk_nonempty_params ',' blk_expr {
02051 SHOWPARSE("blk_nonempty_params -> blk_nonempty_params , blk_expr");
02052 $$ = $1;
02053 $$->addChild($3);
02054 };
02055
02056
02057 blk_expr_primary: trn_literal {
02058 SHOWPARSE("blk_expr_primary -> Literal");
02059 $$ = $1;
02060 };
02061
02062
02063
02064
02065
02066
02067
02068
02069
02070
02071
02072
02073
02074
02075
02076
02077
02078
02079 blk_expr_primary: blk_ident {
02080 SHOWPARSE("blk_expr_primary -> blk_ident");
02081 $$ = $1;
02082 };
02083
02084
02085
02086
02087
02088
02089
02090
02091
02092
02093
02094
02095
02096
02097
02098
02099
02100
02101
02102
02103
02104
02105
02106
02107
02108
02109
02110
02111
02112
02113
02114
02115
02116
02117
02118
02119
02120
02121
02122
02123
02124
02125
02126
02127
02128
02129
02130
02131
02132
02133
02134
02135
02136
02137
02138
02139
02140
02141 blk_expr_primary: tk_LABEL tk_BlkIdent tk_IN blk_iblock {
02142 SHOWPARSE("blk_expr_primary -> LABEL ident in blk_iblock");
02143 $$ = AST::make(at_labeledBlock, $1.loc,
02144 AST::make(at_ident, $2),
02145 $4);
02146 }
02147
02148 blk_expr: blk_expr_continue {
02149 SHOWPARSE("blk_expr -> blk_continue");
02150 $$ = $1;
02151 }
02152 blk_expr_continue: tk_CONTINUE {
02153 SHOWPARSE("blk_expr_continue -> CONTINUE");
02154 $$ = AST::make(at_return_from, $1.loc,
02155 AST::make(at_ident, LToken(tk_BlkIdent, "__continue")),
02156 AST::make(at_unit, $1.loc));
02157 }
02158
02159 blk_expr: blk_expr_from_return {
02160 SHOWPARSE("blk_expr -> blk_expr_from_return");
02161 $$ = $1;
02162 }
02163 blk_expr_from_return: tk_FROM blk_ident tk_RETURN blk_expr {
02164 SHOWPARSE("blk_expr_from_return -> FROM blk_ident RETURN blk_expr");
02165 $$ = AST::make(at_return_from, $1.loc, $2, $4);
02166 }
02167
02168
02169
02170
02171
02172
02173 blk_expr: blk_expr_lambda {
02174 SHOWPARSE("blk_expr -> blk_expr_lambda");
02175 $$ = $1;
02176 }
02177 blk_expr_lambda: tk_LAMBDA '(' ')' blk_expr {
02178 SHOWPARSE("blk_expr_lambda -> LAMBDA () blk_expr");
02179 shared_ptr<AST> argVec = AST::make(at_argVec, $2.loc);
02180 shared_ptr<AST> iRetBlock =
02181 AST::make(at_labeledBlock, $1.loc,
02182 AST::make(at_ident, LToken(tk_BlkIdent, "__return")), $4);
02183 $$ = AST::make(at_lambda, $1.loc, argVec, iRetBlock);
02184 };
02185
02186 blk_expr_lambda: tk_LAMBDA '(' blk_lambdapatterns ')' blk_expr {
02187 SHOWPARSE("blk_expr_lambda -> LAMBDA (blk_lambdapatterns) blk_expr");
02188 shared_ptr<AST> iRetBlock =
02189 AST::make(at_labeledBlock, $1.loc,
02190 AST::make(at_ident, LToken(tk_BlkIdent, "__return")), $5);
02191 $$ = AST::make(at_lambda, $1.loc, $3, iRetBlock);
02192 };
02193
02194
02195 blk_expr: blk_expr_return {
02196 SHOWPARSE("blk_expr -> blk_expr_return");
02197 $$ = $1;
02198 }
02199 blk_expr_return: tk_RETURN blk_expr {
02200 SHOWPARSE("blk_expr_return -> RETURN blk_expr");
02201 $$ = AST::make(at_return_from, $1.loc,
02202 AST::make(at_ident, LToken(tk_BlkIdent, "__return")), $2);
02203 }
02204
02205
02206 blk_expr: blk_expr_if_then_else {
02207 SHOWPARSE("blk_expr -> blk_expr_if_then_else");
02208 $$ = $1;
02209 }
02210
02211 blk_expr_if_then_else: tk_IF blk_expr tk_THEN ILCB blk_expr_seq OptRCB tk_ELSE blk_iblock {
02212 SHOWPARSE("blk_expr_if_then_else -> IF blk_expr THEN blk_ieblock ELSE blk_iblock");
02213 $$ = AST::make(at_if, $1.loc, $2, $5, $8);
02214 };
02215 blk_expr: tk_IF blk_expr error {
02216 SHOWPARSE("blk_expr -> IF blk_expr error");
02217 LToken lastTok = lexer->getLastToken();
02218 lexer->ReportParseError($1.loc,
02219 "Expected 'then' following 'if', got " + lastTok.str
02220 + " at " + lastTok.loc.asString());
02221 $$ = AST::make(at_unit, $1.loc);
02222 };
02223 blk_expr: tk_IF blk_expr tk_THEN ILCB blk_expr_seq OptRCB error {
02224 SHOWPARSE("blk_expr -> IF blk_expr error");
02225 LToken lastTok = lexer->getLastToken();
02226 lexer->ReportParseError($1.loc,
02227 "if/then/else missing else clause at "
02228 + lastTok.loc.asString() +
02229 ", assuming unit. Consider when or unless?");
02230
02231
02232
02233
02234 assert(yychar != YYEMPTY);
02235 yylval.tok.flags |= TF_REPROCESS;
02236 lexer->pushTokenBack(yylval.tok, true);
02237 yyclearin;
02238
02239 lexer->showNextError = false;
02240
02241 $$ = AST::make(at_if, $1.loc, $2, $5,
02242 AST::make(at_unit, $1.loc));
02243 };
02244
02245
02246 blk_expr: blk_expr_when {
02247 SHOWPARSE("blk_expr -> blk_expr_when");
02248 $$ = $1;
02249 }
02250 blk_expr_when: tk_WHEN blk_expr tk_DO blk_expr {
02251 SHOWPARSE("blk_expr -> WHEN blk_expr DO blk_expr");
02252 $$ = AST::make(at_when, $1.loc, $2, $4);
02253 };
02254 blk_expr_when: tk_WHEN blk_expr tk_THEN blk_expr {
02255
02256 SHOWPARSE("blk_expr -> WHEN blk_expr THEN blk_expr");
02257 lexer->ReportParseError($3.loc,
02258 "when/then has been replaced by when/do.");
02259 $$ = AST::make(at_when, $1.loc, $2, $4);
02260 };
02261 blk_expr: blk_expr_unless {
02262 SHOWPARSE("blk_expr -> blk_expr_unless");
02263 $$ = $1;
02264 }
02265 blk_expr_unless: tk_UNLESS blk_expr tk_DO blk_expr {
02266 SHOWPARSE("blk_expr -> UNLESS blk_expr DO blk_expr");
02267 $$ = AST::make(at_unless, $1.loc, $2, $4);
02268 };
02269
02270
02271 blk_expr: blk_expr_mixfix tk_ASSIGN blk_expr %prec tk_ASSIGN {
02272
02273
02274
02275
02276
02277
02278 SHOWPARSE("blk_assignment -> blk_expr_mixfix := blk_expr");
02279 $$ = AST::make(at_setbang, $2.loc, $1, $3);
02280 };
02281
02282
02283
02284
02285
02286
02287
02288
02289
02290
02291
02292
02293 blk_expr: blk_expr_switch {
02294 SHOWPARSE("blk_expr -> blk_expr_switch");
02295 $$ = $1;
02296 }
02297 blk_expr_switch: tk_SWITCH ILCB blk_ident '=' blk_expr OptRCB blk_sw_legs blk_opt_otherwise {
02298 SHOWPARSE("blk_expr_switch -> SWITCH { blk_letbinding } blk_sw_legs blk_opt_otherwise");
02299
02300 $$ = AST::make(at_uswitch, $1.loc, $3, $5, $7, $8);
02301
02302
02303 for (size_t c =0; c < $7->children.size(); c++) {
02304 shared_ptr<AST> sw_leg = $7->child(c);
02305 sw_leg->children.insert(sw_leg->children.begin(),
02306 $3->getDeepCopy());
02307 }
02308 if ($8->astType == at_otherwise) {
02309 shared_ptr<AST> ow = $8;
02310 ow->children.insert(ow->children.begin(),
02311 $3->getDeepCopy());
02312 }
02313 }
02314
02315 blk_sw_legs: blk_sw_legs blk_sw_leg {
02316 SHOWPARSE("blk_sw_legs -> blk_sw_legs blk_sw_leg");
02317 $$ = $1;
02318 $1->addChild($2);
02319 }
02320 blk_sw_legs: blk_sw_leg {
02321 SHOWPARSE("blk_sw_legs -> blk_sw_leg");
02322 $$ = AST::make(at_usw_legs, $1->loc, $1);
02323 }
02324
02325
02326
02327
02328 blk_sw_leg: tk_CASE blk_expr_switch_matches tk_IN blk_iblock {
02329 SHOWPARSE("blk_sw_leg -> CASE blk_expr_switch_matches IN blk_iblock");
02330 $$ = AST::make(at_usw_leg, $1.loc, $4);
02331 $$->addChildrenFrom($2);
02332 }
02333
02334 blk_expr_switch_matches: blk_expr_switch_match {
02335 SHOWPARSE("blk_expr_switch_matches -> blk_expr_switch_match");
02336 $$ = AST::make(at_Null, $1->loc, $1);
02337 }
02338
02339 blk_expr_switch_matches: blk_expr_switch_matches ',' blk_expr_switch_match {
02340 SHOWPARSE("blk_expr_switch_matches -> blk_expr_switch_matches ',' blk_expr_switch_match");
02341 $$ = $1;
02342 $$->addChild($3);
02343 }
02344
02345
02346
02347
02348
02349
02350
02351
02352
02353 blk_expr_switch_match: blk_ident {
02354 SHOWPARSE("blk_expr_switch_match -> blk_ident");
02355 $$ = $1;
02356 };
02357
02358 blk_expr_switch_match: blk_ident '.' blk_ident {
02359 SHOWPARSE("blk_expr_switch_match -> blk_ident . blk_ident");
02360 $$ = AST::make(at_select, $1->loc, $1, $3);
02361 };
02362
02363 blk_expr_switch_match: blk_ident '.' blk_ident '.' blk_ident {
02364 SHOWPARSE("blk_expr_switch_match -> blk_ident '.' blk_ident '.' blk_ident");
02365 shared_ptr<AST> usesel = AST::make(at_usesel, $1->loc, $1, $3);
02366 usesel->s = $1->s + "." + $3->s;
02367 $$ = AST::make(at_select, $1->loc, usesel, $5);
02368 };
02369
02370
02371 blk_opt_otherwise: blk_otherwise {
02372 SHOWPARSE("blk_opt_otherwise -> blk_otherwise");
02373 $$ = $1;
02374 };
02375 blk_opt_otherwise: %prec prec_PreferShift {
02376 SHOWPARSE("blk_opt_otherwise -> ");
02377 $$ = AST::make(at_Null);
02378 };
02379 blk_otherwise: tk_OTHERWISE blk_iblock %prec tk_OTHERWISE {
02380 SHOWPARSE("blk_otherwise -> OTHERWISE blk_expr");
02381 $$ = AST::make(at_otherwise, $1.loc, $2);
02382 };
02383
02384
02385 blk_expr: blk_expr_try {
02386 SHOWPARSE("blk_expr -> blk_expr_try");
02387 $$ = $1;
02388 }
02389 blk_expr_try: tk_TRY blk_iblock tk_CATCH blk_ident blk_sw_legs blk_opt_otherwise {
02390 SHOWPARSE("blk_expr -> TRY blk_iblock CATCH blk_ident blk_sw_legs blk_opt_otherwise");
02391 $$ = AST::make(at_try, $1.loc, $2,
02392 AST::make(at_ident, LToken(tk_BlkIdent, "__dummy")),
02393 $5, $6);
02394
02395 for (size_t c =0; c < $5->children.size(); c++) {
02396 shared_ptr<AST> sw_leg = $5->child(c);
02397 sw_leg->children.insert(sw_leg->children.begin(),
02398 $4->getDeepCopy());
02399 }
02400 if ($6->astType == at_otherwise) {
02401 shared_ptr<AST> ow = $6;
02402 ow->children.insert(ow->children.begin(),
02403 $4->getDeepCopy());
02404 }
02405 }
02406
02407 blk_expr_try: tk_TRY blk_iblock tk_CATCH blk_ident blk_otherwise {
02408 SHOWPARSE("blk_expr_try -> TRY blk_expr tk_CATCH blk_ident blk_otherwise");
02409 shared_ptr<AST> dummyID =
02410 AST::make(at_ident, LToken(tk_BlkIdent, "__dummy"));
02411
02412 $$ = AST::make(at_try, $1.loc, $2, dummyID,
02413 AST::make(at_usw_legs, $5->loc),
02414 $5);
02415
02416 shared_ptr<AST> ow = $5;
02417 ow->children.insert(ow->children.begin(), $4->getDeepCopy());
02418 }
02419
02420
02421
02422
02423
02424
02425
02426
02427
02428
02429
02430
02431
02432
02433
02434
02435
02436
02437
02438 blk_expr: blk_expr_throw {
02439 SHOWPARSE("blk_expr -> blk_expr_throw");
02440 $$ = $1;
02441 }
02442 blk_expr_throw: tk_THROW blk_expr {
02443 SHOWPARSE("blk_expr_throw -> THROW blk_expr");
02444 $$ = AST::make(at_throw, $1.loc, $2);
02445 }
02446
02447
02448 blk_expr: blk_expr_let {
02449 SHOWPARSE("blk_expr -> blk_expr_let");
02450 $$ = $1;
02451 }
02452 blk_expr_let: tk_LET ILCB blk_letbindings OptRCB tk_IN blk_iblock {
02453 SHOWPARSE("blk_expr_let -> LET { blk_letbindings } IN blk_iblock");
02454
02455 $$ = AST::make(at_let, $1.loc, $3, $6);
02456 $$->addChild(AST::make(at_constraints));
02457 }
02458 blk_letbinding: blk_bindingpattern '=' blk_expr {
02459 SHOWPARSE("blk_letbinding -> blk_bindingpattern '=' blk_expr");
02460 $$ = AST::make(at_letbinding, $1->loc, $1, $3);
02461 };
02462
02463 blk_letbindings: blk_letbinding {
02464 SHOWPARSE("blk_letbindings -> blk_letbinding");
02465 $$ = AST::make(at_letbindings, $1->loc, $1);
02466 };
02467 blk_letbindings: blk_letbindings SC blk_letbinding {
02468 SHOWPARSE("blk_letbindings -> blk_letbindings SC blk_letbinding");
02469 $$ = $1;
02470 $$->addChild($3);
02471 };
02472
02473
02474 blk_expr: blk_expr_letrec {
02475 SHOWPARSE("blk_expr -> blk_expr_letrec");
02476 $$ = $1;
02477 }
02478 blk_expr_letrec: tk_LETREC ILCB blk_letbindings OptRCB tk_IN blk_iblock {
02479 SHOWPARSE("blk_expr_letrec -> LETREC { blk_letbindings } IN blk_iblock");
02480
02481 shared_ptr<AST> lbs = $3;
02482 for (size_t c=0; c < lbs->children.size(); c++)
02483 lbs->child(c)->flags |= LB_REC_BIND;
02484
02485 $$ = AST::make(at_letrec, $1.loc, lbs, $6, AST::make(at_constraints));
02486 }
02487
02488
02489
02490
02491
02492 blk_expr: blk_expr_loop {
02493 SHOWPARSE("blk_expr -> blk_expr_loop");
02494 $$ = $1;
02495 }
02496 blk_expr_loop: tk_LOOP ILCB blk_loopbindings OptRCB tk_UNTIL blk_expr tk_IN blk_iblock {
02497 SHOWPARSE("blk_expr -> LOOP blk_loopbindings UNTIL blk_expr IN blk_iblock");
02498
02499
02500
02501
02502
02503
02504 shared_ptr<AST> iTest =
02505 AST::make(at_looptest, $6->loc, $6, AST::make(at_unit, $6->loc));
02506
02507 shared_ptr<AST> iBody =
02508 AST::make(at_begin, $8->loc, $8, AST::make(at_unit, $8->loc));
02509
02510 shared_ptr<AST> iContinueBlock =
02511 AST::make(at_labeledBlock, $1.loc,
02512 AST::make(at_ident, LToken(tk_BlkIdent, "__continue")),
02513 iBody);
02514
02515 $$ = AST::make(at_loop, $1.loc, $3, iTest, iContinueBlock);
02516 }
02517
02518 blk_loopbindings: {
02519 SHOWPARSE("blk_loopbindings -> <empty>");
02520 $$ = AST::make(at_loopbindings);
02521 };
02522 blk_loopbindings: blk_nonempty_loopbindings {
02523 SHOWPARSE("blk_loopbindings -> blk_nonempty_loopbindings");
02524 $$ = $1;
02525 };
02526 blk_nonempty_loopbindings: blk_expr_loopbinding {
02527 SHOWPARSE("blk_nonempty_loopbindings -> blk_expr_loopbinding");
02528 $$ = AST::make(at_loopbindings, $1->loc, $1);
02529 };
02530 blk_nonempty_loopbindings: blk_nonempty_loopbindings SC blk_expr_loopbinding {
02531 SHOWPARSE("blk_nonempty_loopbindings -> blk_nonempty_loopbindings SC blk_expr_loopbinding");
02532 $$ = $1;
02533 $$->addChild($3);
02534 };
02535
02536
02537
02538
02539 blk_expr_loopbinding: blk_bindingpattern '=' blk_expr tk_THEN blk_iblock {
02540 SHOWPARSE("blk_expr_loopbinding -> blk_bindingpattern = blk_expr THEN blk_iblock");
02541 $$ = AST::make(at_loopbinding, $1->loc, $1, $3, $5);
02542 };
02543
02544
02545
02546 trn_literal: boolLit {
02547 SHOWPARSE("trn_literal -> boolLit");
02548 $$ = $1;
02549 };
02550
02551 trn_literal: intLit {
02552 SHOWPARSE("trn_literal -> intLit");
02553 $$ = $1;
02554 };
02555
02556
02557 trn_literal: floatLit {
02558 SHOWPARSE("trn_literal -> floatLit");
02559 $$ = $1;
02560 };
02561
02562 trn_literal: charLit {
02563 SHOWPARSE("trn_literal -> CharLit");
02564 $$ = $1;
02565 };
02566
02567 trn_literal: strLit {
02568 SHOWPARSE("trn_literal -> strLit");
02569 $$ = $1;
02570 };
02571
02572
02573 blk_exident: tk_BlkIdent {
02574 SHOWPARSE("blk_exident -> <Ident " + $1.str + ">");
02575 $$ = AST::make(at_ident, $1);
02576 };
02577
02578 blk_exident: tk_ReservedWord {
02579 SHOWPARSE("blk_exident -> <Reserved " + $1.str + ">");
02580 $$ = AST::make(at_ident, $1);
02581 };
02582
02583
02584 blk_ident: tk_BlkIdent {
02585 SHOWPARSE("blk_ident -> <Ident " + $1.str + ">");
02586 $$ = AST::make(at_ident, $1);
02587 };
02588 blk_ident: tk_EQUALS {
02589 SHOWPARSE("blk_ident -> <Ident \"" + $1.str + "\">");
02590 $$ = AST::make(at_ident, $1);
02591 };
02592
02593 blk_ident: tk_AND {
02594 SHOWPARSE("blk_ident -> <Ident " + $1.str + ">");
02595 $$ = AST::make(at_ident, $1);
02596 };
02597 blk_ident: tk_OR {
02598 SHOWPARSE("blk_ident -> <Ident " + $1.str + ">");
02599 $$ = AST::make(at_ident, $1);
02600 };
02601 blk_ident: tk_ReservedWord {
02602 SHOWPARSE("blk_ident -> <RESERVED=" + $1.str + ">");
02603 cerr << $1.loc.asString() << ": The token \"" << $1.str
02604 << "\" is reserved for future use.\n";
02605 lexer->num_errors++;
02606 $$ = AST::make(at_ident, $1);
02607 };
02608
02609 blk_useident: blk_ident %prec prec_PreferShift {
02610 SHOWPARSE("blk_useident -> blk_ident");
02611 $$ = $1;
02612 };
02613
02614 blk_useident: blk_useident '.' blk_ident %prec '.' {
02615 SHOWPARSE("blk_useident -> blk_useident . blk_ident");
02616 shared_ptr<AST> usesel = AST::make(at_usesel, $2.loc, $1, $3);
02617 usesel->s = $1->s + "." + $3->s;
02618 $$ = usesel;
02619 };
02620
02621 blk_defident: blk_useident {
02622 SHOWPARSE("blk_defident -> blk_useident");
02623 $1->flags |= (ID_IS_GLOBAL);
02624 $$ = $1;
02625 };
02626
02627
02628 typevar: tk_TypeVar {
02629 SHOWPARSE("typevar -> <TypeVar=" + $1.str + ">");
02630 $$ = AST::make(at_ident, $1);
02631 $$->identType = id_tvar;
02632 };
02633
02634
02635
02636 boolLit: tk_TRUE {
02637 SHOWPARSE("boolLit -> <Bool=" + $1.str +">");
02638 $$ = AST::makeBoolLit($1);
02639 };
02640 boolLit: tk_FALSE {
02641 SHOWPARSE("boolLit -> <Bool=" + $1.str +">");
02642 $$ = AST::makeBoolLit($1);
02643 };
02644
02645 charLit: tk_Char {
02646 SHOWPARSE("charLit -> <Char=" + $1.str +">");
02647 $$ = AST::makeCharLit($1);
02648 };
02649
02650 intLit: tk_NegativeInt {
02651 SHOWPARSE("intLit -> <Int=" + $1.str +">");
02652 $$ = AST::makeIntLit($1);
02653 };
02654
02655 intLit: tk_Nat {
02656 SHOWPARSE("intLit -> <Nat=" + $1.str +">");
02657 $$ = AST::makeIntLit($1);
02658 };
02659
02660 natLit: tk_Nat {
02661 SHOWPARSE("natLit -> <Nat=" + $1.str +">");
02662 $$ = AST::makeIntLit($1);
02663 };
02664
02665 floatLit: tk_Float {
02666 SHOWPARSE("floatLit -> <Float=" + $1.str +">");
02667 $$ = AST::makeFloatLit($1);
02668 };
02669
02670 strLit: tk_String {
02671 SHOWPARSE("strLit -> <String=" + $1.str +">");
02672 $$ = AST::makeStringLit($1);
02673 };
02674
02675
02676 ILCB: '{' {
02677 $$ = $1;
02678 }
02679 IRCB: '}' {
02680 $$ = $1;
02681 }
02682
02683
02684
02685
02686
02687
02688
02689
02690
02691
02692
02693
02694 OptRCB: {
02695 assert(yychar != YYEMPTY);
02696
02697 yylval.tok.flags |= TF_REPROCESS;
02698
02699 LToken tok = LToken('}', yylval.tok.loc, yylval.tok.loc, "}");
02700 tok.prevTokType = yylval.tok.prevTokType;
02701 yylval.tok.prevTokType = '}';
02702 tok.flags |= (TF_INSERTED|TF_BY_PARSER);
02703
02704 lexer->pushTokenBack(yylval.tok, true);
02705 lexer->pushTokenBack(tok, true);
02706 lexer->lex(&yylval);
02707
02708
02709
02710 if (yychar != YYEMPTY)
02711 yyclearin;
02712
02713 $$ = tok;
02714 }
02715 OptRCB: IRCB {
02716 $$ = $1;
02717 }
02718
02719 IsILCB: tk_IS ILCB {
02720 $$ = $2;
02721 }
02722
02723 IsILCB: '{' {
02724 $$ = $1;
02725 }
02726
02727
02728
02729
02730
02731
02732
02733
02734
02735
02736
02737
02738
02739
02740
02741
02742
02743
02744
02745
02746
02747
02748
02749
02750
02751
02752
02753
02754
02755 SC: {
02756 SHOWPARSE("SC -> ");
02757 }
02758 SC: ';' {
02759 SHOWPARSE("SC -> ;");
02760 }
02761 %%
02762 static void
02763 PrintSyntaxError(TransitionLexer *lexer, const char *s)
02764 {
02765 std::stringstream ss;
02766 LToken tok = lexer->getLastToken();
02767
02768 if (!lexer->showNextError)
02769 return;
02770
02771 ss << "Syntax error in " << s << ": unexpected ";
02772
02773 switch(tok.tokType) {
02774 case '{':
02775 case '}':
02776 case ';':
02777 {
02778 ss << '\'' << tok.str << '\'' << " (possibly inserted by layout)";
02779 break;
02780 }
02781 case ':':
02782 {
02783 ss << '\'' << tok.str << '\'';
02784 break;
02785 }
02786 case tk_TypeVar:
02787 ss << "type variable '" << tok.str;
02788 break;
02789
02790 case EOF:
02791 ss << tok.str;
02792 break;
02793
02794 default:
02795 ss << '"' << tok.str << '"';
02796 break;
02797 }
02798
02799 lexer->ReportParseError(ss.str());
02800 lexer->showNextError = false;
02801 }
02802
02805 const char *TransitionTokenName(int lexTokenNumber)
02806 {
02807 if (lexTokenNumber == -1)
02808 return "EOF";
02809
02810 int bisonSymbolNumber = YYTRANSLATE(lexTokenNumber);
02811 const char * bisonTokenName = yytname[bisonSymbolNumber];
02812
02813 return bisonTokenName;
02814 }