Changeset 81bb114


Ignore:
Timestamp:
Apr 16, 2018, 9:51:02 AM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
Children:
32cab5b, 6040e67d, 9181f1d, f38e7d7
Parents:
0a89a8f
Message:

update to support more bison directives

Location:
tools/prettyprinter
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • tools/prettyprinter/Makefile.am

    r0a89a8f r81bb114  
    1111## Created On       : Wed Jun 28 12:07:10 2017
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Wed Jun 28 23:11:56 2017
    14 ## Update Count     : 15
     13## Last Modified On : Mon Apr 16 09:43:23 2018
     14## Update Count     : 20
    1515###############################################################################
    1616
  • tools/prettyprinter/lex.ll

    r0a89a8f r81bb114  
    1010 * Created On       : Sat Dec 15 11:45:59 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Tue Aug 29 17:33:36 2017
    13  * Update Count     : 268
     12 * Last Modified On : Sun Apr 15 21:28:33 2018
     13 * Update Count     : 271
    1414 */
    1515
     
    5050<INITIAL,C_CODE>"/*" {                                                                  // C style comments */
    5151#if defined(DEBUG_ALL) | defined(DEBUG_COMMENT)
    52     cerr << "\"/*\" : " << yytext << endl;
     52                cerr << "\"/*\" : " << yytext << endl;
    5353#endif
    54     if ( YYSTATE == C_CODE ) code_str += yytext;
    55     else comment_str += yytext;
    56     yy_push_state(C_COMMENT);
     54                if ( YYSTATE == C_CODE ) code_str += yytext;
     55                else comment_str += yytext;
     56                yy_push_state(C_COMMENT);
    5757}
    5858<C_COMMENT>(.|"\n")     {                                                                       // C style comments
    5959#if defined(DEBUG_ALL) | defined(DEBUG_COMMENT)
    60     cerr << "<C_COMMENT>(.|\\n) : " << yytext << endl;
     60                cerr << "<C_COMMENT>(.|\\n) : " << yytext << endl;
    6161#endif
    62     if ( yy_top_state() == C_CODE ) code_str += yytext;
    63     else comment_str += yytext;
     62                if ( yy_top_state() == C_CODE ) code_str += yytext;
     63                else comment_str += yytext;
    6464}
    6565<C_COMMENT>"*/" {                                                                               // C style comments
     
    123123<C_CODE>"%}"    { RETURN_TOKEN( RCURL ) }
    124124
    125 ^"%union"       { RETURN_TOKEN( UNION ) }
    126 ^"%start"       { RETURN_TOKEN( START ) }
    127 ^"%token"       { RETURN_TOKEN( TOKEN ) }
    128 ^"%type"            { RETURN_TOKEN( TYPE ) }
    129 ^"%left"            { RETURN_TOKEN( LEFT ) }
    130 ^"%right"           { RETURN_TOKEN( RIGHT ) }
    131 ^"%nonassoc"    { RETURN_TOKEN( NONASSOC ) }
    132 ^"%precedence"  { RETURN_TOKEN( PRECEDENCE ) }
     125^"%define"[^\n]*"\n" { RETURN_TOKEN( DEFINE ) }
     126^"%expect"              { RETURN_TOKEN( EXPECT ) }
     127^"%left"                { RETURN_TOKEN( LEFT ) }
     128^"%locations"   { RETURN_TOKEN( LOCATIONS ) }
     129^"%nonassoc"    { RETURN_TOKEN( NONASSOC ) }
     130^"%precedence"  { RETURN_TOKEN( PRECEDENCE ) }
    133131^"%pure_parser" { RETURN_TOKEN( PURE_PARSER ) }
     132^"%right"               { RETURN_TOKEN( RIGHT ) }
    134133^"%semantic_parser"     { RETURN_TOKEN( SEMANTIC_PARSER ) }
    135 ^"%expect"      { RETURN_TOKEN( EXPECT ) }
    136 ^"%thong"               { RETURN_TOKEN( THONG ) }
     134^"%start"               { RETURN_TOKEN( START ) }
     135^"%thong"               { RETURN_TOKEN( THONG ) }
     136^"%token"               { RETURN_TOKEN( TOKEN ) }
     137^"%type"                { RETURN_TOKEN( TYPE ) }
     138^"%union"               { RETURN_TOKEN( UNION ) }
    137139
    138 "%prec"                 { RETURN_TOKEN( PREC ) }
     140"%prec"                 { RETURN_TOKEN( PREC ) }
    139141
    140 {integer}           { RETURN_TOKEN( INTEGER ); }
    141 [']{c_char}[']  { RETURN_TOKEN( CHARACTER ); }
    142 {identifier}    { RETURN_TOKEN( IDENTIFIER ); }
     142{integer}               { RETURN_TOKEN( INTEGER ); }
     143[']{c_char}[']  { RETURN_TOKEN( CHARACTER ); }
     144{identifier}    { RETURN_TOKEN( IDENTIFIER ); }
    143145
    144146<C_CODE>["]{s_char}*["] {                                                               // hide braces "{}" in strings
     
    160162%%
    161163void lexC(void) {
    162     BEGIN(C_CODE);
     164        BEGIN(C_CODE);
    163165}
    164166
    165167string lexYacc(void) {
    166     BEGIN(INITIAL);
    167     //cerr << "CODE: " << endl << code_str << endl;
    168     string temp( code_str );
    169     code_str = "";
    170     return temp;
     168        BEGIN(INITIAL);
     169        //cerr << "CODE: " << endl << code_str << endl;
     170        string temp( code_str );
     171        code_str = "";
     172        return temp;
    171173}
    172174
  • tools/prettyprinter/parser.yy

    r0a89a8f r81bb114  
    1010// Created On       : Sat Dec 15 13:44:21 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Aug 29 16:34:10 2017
    13 // Update Count     : 1047
     12// Last Modified On : Sun Apr 15 21:40:30 2018
     13// Update Count     : 1052
    1414//
    1515
     
    6161%token<tokenp>  CODE                                                                    // C code
    6262
    63 %token<tokenp>  START                                                                   // %start
    64 %token<tokenp>  UNION                                                                   // %union
    65 %token<tokenp>  TOKEN                                                                   // %token
     63%token<tokenp>  DEFINE                                                                  // %define
     64%token<tokenp>  EXPECT                                                                  // %expect
    6665%token<tokenp>  LEFT                                                                    // %left
    67 %token<tokenp>  RIGHT                                                                   // %right
     66%token<tokenp>  LOCATIONS                                                               // %locations
    6867%token<tokenp>  NONASSOC                                                                // %nonassoc
    6968%token<tokenp>  PRECEDENCE                                                              // %precedence
     69%token<tokenp>  PURE_PARSER                                                             // %pure_parser
     70%token<tokenp>  RIGHT                                                                   // %right
     71%token<tokenp>  SEMANTIC_PARSER                                                 // %semantic_parser
     72%token<tokenp>  START                                                                   // %start
     73%token<tokenp>  THONG                                                                   // %thong
     74%token<tokenp>  TOKEN                                                                   // %token
    7075%token<tokenp>  TYPE                                                                    // %type
    71 %token<tokenp>  PURE_PARSER                                                             // %pure_parser
    72 %token<tokenp>  SEMANTIC_PARSER                                                 // %semantic_parser
    73 %token<tokenp>  EXPECT                                                                  // %expect
    74 %token<tokenp>  THONG                                                                   // %thong
     76%token<tokenp>  UNION                                                                   // %union
    7577
    7678%token<tokenp>  PREC                                                                    // %prec
    7779
    78 %token          END_TERMINALS                                                           // ALL TERMINAL TOKEN NAMES MUST APPEAR BEFORE THIS
     80%token                  END_TERMINALS                                                   // ALL TERMINAL TOKEN NAMES MUST APPEAR BEFORE THIS
    7981
    8082%type<tokenp>   sections
    81 %token          _SECTIONS
     83%token                  _SECTIONS
    8284%type<tokenp>   mark
    8385%type<tokenp>   defsection_opt
    84 %token          _DEFSECTION_OPT
     86%token                  _DEFSECTION_OPT
    8587%type<tokenp>   declarations
    8688%type<tokenp>   literalblock
    87 %token          _LITERALBLOCK
     89%token                  _LITERALBLOCK
    8890%type<tokenp>   declaration
    89 %token          _DECLARATION
     91%token                  _DECLARATION
    9092%type<tokenp>   union
    9193%type<tokenp>   rword
    9294%type<tokenp>   tag_opt
    93 %token          _TAG_OPT
     95%token                  _TAG_OPT
    9496%type<tokenp>   namenolist
    95 %token          _NAMENOLIST
     97%token                  _NAMENOLIST
    9698%type<tokenp>   nameno
    97 %token          _NAMENO
     99%token                  _NAMENO
    98100%type<tokenp>   namelist
    99 %token          _NAMELIST
     101%token                  _NAMELIST
    100102%type<tokenp>   name
    101103%type<tokenp>   rulesection
    102 %token          _RULESECTION
     104%token                  _RULESECTION
    103105%type<tokenp>   rules
    104 %token          _RULE
     106%token                  _RULE
    105107%type<tokenp>   lhs
    106 %token          _LHS
     108%token                  _LHS
    107109%type<tokenp>   rhs
    108 %token          _RHS
     110%token                  _RHS
    109111%type<tokenp>   prod
    110112%type<tokenp>   prec
    111 %token          _PREC
     113%token                  _PREC
    112114%type<tokenp>   action
    113 %token          _ACTION
     115%token                  _ACTION
    114116%type<tokenp>   usersection_opt
    115 %token          _USERSECTION_OPT
     117%token                  _USERSECTION_OPT
    116118%type<tokenp>   ccode_opt
    117119%type<tokenp>   blocks
     
    234236                    $$ = $1;
    235237                }
     238        | DEFINE                                                                                        // bison
     239        | LOCATIONS
    236240        | THONG                                                                                         // bison
    237241        ;
  • tools/prettyprinter/test.y

    r0a89a8f r81bb114  
    66
    77/* adsad2 */
    8 
     8%locations
     9%define parse.error verbose
    910%%
    1011
Note: See TracChangeset for help on using the changeset viewer.