dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] pnet/cscc/csharp cs_grammar.y, 1.65, 1.66 cs_inter


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] pnet/cscc/csharp cs_grammar.y, 1.65, 1.66 cs_internal.h, 1.20, 1.21 cs_scanner.l, 1.12, 1.13
Date: Sun, 26 Oct 2003 02:47:47 +0000

Update of /cvsroot/dotgnu-pnet/pnet/cscc/csharp
In directory subversions:/tmp/cvs-serv31409/cscc/csharp

Modified Files:
        cs_grammar.y cs_internal.h cs_scanner.l 
Log Message:


Handle special C# keywords like "get", "set", "add", "remove", and
"where" in a slightly different way, to reduce the need for hacky flags and
scanner states.


Index: cs_scanner.l
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_scanner.l,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** cs_scanner.l        14 Jul 2003 09:41:12 -0000      1.12
--- cs_scanner.l        26 Oct 2003 02:47:45 -0000      1.13
***************
*** 32,36 ****
  #endif
  
- int       CSGetSetKeywords = 0;
  int             CSNoGenerics = 0;
  int       CSLatin1Charset = 0;
--- 32,35 ----
***************
*** 998,1001 ****
--- 997,1001 ----
  
  "abstract"                            { RETURNTOK(ABSTRACT); }
+ "add"                                 { RETURNTOK(ADD); }
  "__arglist"                           { RETURNTOK(ARGLIST); }
  "as"                                  { RETURNTOK(AS); }
***************
*** 1028,1031 ****
--- 1028,1032 ----
  "for"                                 { RETURNTOK(FOR); }
  "foreach"                             { RETURNTOK(FOREACH); }
+ "get"                                 { RETURNTOK(GET); }
  "goto"                                        { RETURNTOK(GOTO); }
  "if"                                  { RETURNTOK(IF); }
***************
*** 1056,1062 ****
--- 1057,1065 ----
  "__reftype"                           { RETURNTOK(REFTYPE); }
  "__refvalue"                  { RETURNTOK(REFVALUE); }
+ "remove"                              { RETURNTOK(REMOVE); }
  "return"                              { RETURNTOK(RETURN); }
  "sbyte"                                       { RETURNTOK(SBYTE); }
  "sealed"                              { RETURNTOK(SEALED); }
+ "set"                                 { RETURNTOK(SET); }
  "short"                                       { RETURNTOK(SHORT); }
  "sizeof"                              { RETURNTOK(SIZEOF); }
***************
*** 1080,1127 ****
  "void"                                        { RETURNTOK(VOID); }
  "volatile"                            { RETURNTOK(VOLATILE); }
! "where"                                       { 
!                                                       if(CSNoGenerics)
!                                                       {
!                                                               yylval.name = 
(ParseIdentifier(yytext)).string;
!                                                               
RETURNTOK(IDENTIFIER);
!                                                       }
!                                                       else
!                                                       {
!                                                               
RETURNTOK(WHERE); 
!                                                       }
!                                               }
  "while"                                       { RETURNTOK(WHILE); }
  
  {IDALPHA}({DIGIT}|{IDALPHA})*         {
!                       if(!CSGetSetKeywords)
!                       {
!                               yylval.name = (ParseIdentifier(yytext)).string;
!                               RETURNTOK(IDENTIFIER);
!                       }
!                       else if(!strcmp(yytext, "get"))
!                       {
!                               RETURNTOK(GET);
!                       }
!                       else if(!strcmp(yytext, "set"))
!                       {
!                               RETURNTOK(SET);
!                       }
!                       else if(!strcmp(yytext, "add"))
!                       {
!                               RETURNTOK(ADD);
!                       }
!                       else if(!strcmp(yytext, "remove"))
!                       {
!                               RETURNTOK(REMOVE);
!                       }
!                       else
!                       {
!                               yylval.name = (ParseIdentifier(yytext)).string;
!                               RETURNTOK(IDENTIFIER);
!                       }
                }
  "@"{IDALPHA}({DIGIT}|{IDALPHA})*      {
                        yylval.name = (ParseIdentifier(yytext + 1)).string;
!                       RETURNTOK(IDENTIFIER);
                }
  
--- 1083,1096 ----
  "void"                                        { RETURNTOK(VOID); }
  "volatile"                            { RETURNTOK(VOLATILE); }
! "where"                                       { RETURNTOK(WHERE); }
  "while"                                       { RETURNTOK(WHILE); }
  
  {IDALPHA}({DIGIT}|{IDALPHA})*         {
!                       yylval.name = (ParseIdentifier(yytext)).string;
!                       RETURNTOK(IDENTIFIER_LEXICAL);
                }
  "@"{IDALPHA}({DIGIT}|{IDALPHA})*      {
                        yylval.name = (ParseIdentifier(yytext + 1)).string;
!                       RETURNTOK(IDENTIFIER_LEXICAL);
                }
  

Index: cs_grammar.y
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_grammar.y,v
retrieving revision 1.65
retrieving revision 1.66
diff -C2 -d -r1.65 -r1.66
*** cs_grammar.y        14 Jul 2003 09:41:12 -0000      1.65
--- cs_grammar.y        26 Oct 2003 02:47:45 -0000      1.66
***************
*** 741,745 ****
  %token INTEGER_CONSTANT               "an integer value"
  %token CHAR_CONSTANT          "a character constant"
! %token IDENTIFIER                     "an identifier"
  %token STRING_LITERAL         "a string literal"
  %token FLOAT_CONSTANT         "a floating point value"
--- 741,745 ----
  %token INTEGER_CONSTANT               "an integer value"
  %token CHAR_CONSTANT          "a character constant"
! %token IDENTIFIER_LEXICAL     "an identifier"
  %token STRING_LITERAL         "a string literal"
  %token FLOAT_CONSTANT         "a floating point value"
***************
*** 869,873 ****
   * Define the yylval types of the various non-terminals.
   */
! %type <name>          IDENTIFIER
  %type <integer>               INTEGER_CONSTANT
  %type <charValue>     CHAR_CONSTANT
--- 869,873 ----
   * Define the yylval types of the various non-terminals.
   */
! %type <name>          IDENTIFIER IDENTIFIER_LEXICAL
  %type <integer>               INTEGER_CONSTANT
  %type <charValue>     CHAR_CONSTANT
***************
*** 965,969 ****
  %type <target>                AttributeTarget
  
! %expect 26
  
  %start CompilationUnit
--- 965,969 ----
  %type <target>                AttributeTarget
  
! %expect 31
  
  %start CompilationUnit
***************
*** 1099,1102 ****
--- 1099,1111 ----
        ;
  
+ IDENTIFIER
+       : IDENTIFIER_LEXICAL    { $$ = $1; }
+       | GET                                   { $$ = ILInternString("get", 
3).string; }
+       | SET                                   { $$ = ILInternString("set", 
3).string; }
+       | ADD                                   { $$ = ILInternString("add", 
3).string; }
+       | REMOVE                                { $$ = ILInternString("remove", 
6).string; }
+       | WHERE                                 { $$ = ILInternString("where", 
5).string; }
+       ;
+ 
  QualifiedIdentifier
        : QualifiedIdentifierPart                                               
        { $$ = $1; }
***************
*** 1414,1418 ****
        : LiteralExpression                             { $$ = $1; }
        | Identifier                                    { $$ = $1; }
-       | WHERE                                                 { $$ = 
ILQualIdentSimple("where"); }
        | '(' Expression ')'                    { $$ = $2; }
        | PrimaryExpression '.' Identifier      { MakeBinary(MemberAccess, $1, 
$3); }
--- 1423,1426 ----
***************
*** 2982,2991 ****
  
  StartAccessorBlock
!       : '{'   { CSGetSetKeywords = 1; }
        ;
  
  AccessorBlock
        : AccessorDeclarations '}'      {
-                               CSGetSetKeywords = 0;
                                $$ = $1;
                        }
--- 2990,2998 ----
  
  StartAccessorBlock
!       : '{'
        ;
  
  AccessorBlock
        : AccessorDeclarations '}'      {
                                $$ = $1;
                        }
***************
*** 2994,2998 ****
                                 * This production recovers from errors in 
accessor blocks.
                                 */
-                               CSGetSetKeywords = 0;
                                $$.item1 = 0;
                                $$.item2 = 0;
--- 3001,3004 ----
***************
*** 3018,3024 ****
  
  GetAccessorDeclaration
!       : OptAttributes GET TurnOffGetSet AccessorBody TurnOnGetSet             
{
                                $$ = ILNode_MethodDeclaration_create
!                                               ($1, 0, 0, 0, 0, $4);
                        #ifdef YYBISON
                                yysetlinenum($$, @2.first_line);
--- 3024,3030 ----
  
  GetAccessorDeclaration
!       : OptAttributes GET AccessorBody {
                                $$ = ILNode_MethodDeclaration_create
!                                               ($1, 0, 0, 0, 0, $3);
                        #ifdef YYBISON
                                yysetlinenum($$, @2.first_line);
***************
*** 3033,3039 ****
  
  SetAccessorDeclaration
!       : OptAttributes SET TurnOffGetSet AccessorBody TurnOnGetSet             
{
                                $$ = ILNode_MethodDeclaration_create
!                                               ($1, 0, 0, 0, 0, $4);
                        #ifdef YYBISON
                                yysetlinenum($$, @2.first_line);
--- 3039,3045 ----
  
  SetAccessorDeclaration
!       : OptAttributes SET AccessorBody {
                                $$ = ILNode_MethodDeclaration_create
!                                               ($1, 0, 0, 0, 0, $3);
                        #ifdef YYBISON
                                yysetlinenum($$, @2.first_line);
***************
*** 3047,3058 ****
        ;
  
- TurnOffGetSet
-       : /* empty */           { CSGetSetKeywords = 0; }
-       ;
- 
- TurnOnGetSet
-       : /* empty */           { CSGetSetKeywords = 1; }
-       ;
- 
  /*
   * Events.
--- 3053,3056 ----
***************
*** 3111,3115 ****
  EventAccessorBlock
        : EventAccessorDeclarations '}' {
-                               CSGetSetKeywords = 0;
                                $$ = $1;
                        }
--- 3109,3112 ----
***************
*** 3118,3122 ****
                                 * This production recovers from errors in 
accessor blocks.
                                 */
-                               CSGetSetKeywords = 0;
                                $$.item1 = 0;
                                $$.item2 = 0;
--- 3115,3118 ----
***************
*** 3137,3143 ****
  
  AddAccessorDeclaration
!       : OptAttributes ADD TurnOffGetSet AccessorBody TurnOnGetSet             
{
                                $$ = ILNode_MethodDeclaration_create
!                                               ($1, 0, 0, 0, 0, $4);
                        #ifdef YYBISION
                                yysetlinenum($$, @2.first_line);
--- 3133,3139 ----
  
  AddAccessorDeclaration
!       : OptAttributes ADD AccessorBody {
                                $$ = ILNode_MethodDeclaration_create
!                                               ($1, 0, 0, 0, 0, $3);
                        #ifdef YYBISION
                                yysetlinenum($$, @2.first_line);
***************
*** 3147,3153 ****
  
  RemoveAccessorDeclaration
!       : OptAttributes REMOVE TurnOffGetSet AccessorBody TurnOnGetSet  {
                                $$ = ILNode_MethodDeclaration_create
!                                               ($1, 0, 0, 0, 0, $4);
                        #ifdef YYBISION
                                yysetlinenum($$, @2.first_line);
--- 3143,3149 ----
  
  RemoveAccessorDeclaration
!       : OptAttributes REMOVE AccessorBody {
                                $$ = ILNode_MethodDeclaration_create
!                                               ($1, 0, 0, 0, 0, $3);
                        #ifdef YYBISION
                                yysetlinenum($$, @2.first_line);
***************
*** 3717,3726 ****
  
  StartInterfaceAccessorBody
!       : '{'           { CSGetSetKeywords = 1; }
        ;
  
  InterfaceAccessorBody
        : InterfaceAccessors '}'        {
-                               CSGetSetKeywords = 0;
                                $$ = $1;
                        }
--- 3713,3721 ----
  
  StartInterfaceAccessorBody
!       : '{'
        ;
  
  InterfaceAccessorBody
        : InterfaceAccessors '}'        {
                                $$ = $1;
                        }
***************
*** 3730,3734 ****
                                 * accessor declarations.
                                 */
-                               CSGetSetKeywords = 0;
                                $$ = 0;
                                yyerrok;
--- 3725,3728 ----

Index: cs_internal.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_internal.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** cs_internal.h       26 Jun 2003 23:55:50 -0000      1.20
--- cs_internal.h       26 Oct 2003 02:47:45 -0000      1.21
***************
*** 77,86 ****
  
  /*
-  * A flag that is set to 1 when "get" and "set" keywords
-  * should be recognized by the lexical analyser.
-  */
- extern int CSGetSetKeywords;
- 
- /*
   * A flag that is set to 1 for metadata-only compiles.
   */
--- 77,80 ----





reply via email to

[Prev in Thread] Current Thread [Next in Thread]