Browse Source

Added support for 'switch' statements with C/C++ like fall-through to the next compound statement.

Supporting syntax such as:

a = 10;
switch(a)
{
  case 0: { print("a = 0"); }
  case 1:
  case 2:
  case 3:
  case 4:
  case 5: { print("a is a number between 1 and 5");  }
  case "test": { print("a is a string with a value of 'test'"); }
  default: { print("not handled by case"); }
};

Unlike C/C++ break isn't supported; the first fall-through compound statement is executed.
Oli Wilkinson 7 years ago
parent
commit
863d6169c2

+ 123 - 0
gmsrc/src/gm/gmCodeGen.cpp

@@ -94,6 +94,9 @@ public:
   bool GenStmtDoWhile(const gmCodeTreeNode * a_node, gmByteCodeGen * a_byteCode);
   bool GenStmtDoWhile(const gmCodeTreeNode * a_node, gmByteCodeGen * a_byteCode);
   bool GenStmtIf(const gmCodeTreeNode * a_node, gmByteCodeGen * a_byteCode);
   bool GenStmtIf(const gmCodeTreeNode * a_node, gmByteCodeGen * a_byteCode);
   bool GenStmtCompound(const gmCodeTreeNode * a_node, gmByteCodeGen * a_byteCode);
   bool GenStmtCompound(const gmCodeTreeNode * a_node, gmByteCodeGen * a_byteCode);
+#if GM_USE_SWITCH
+  bool GenStmtSwitch(const gmCodeTreeNode * a_node, gmByteCodeGen * a_byteCode);
+#endif //GM_USE_SWITCH
   bool GenExprOpDot(const gmCodeTreeNode * a_node, gmByteCodeGen * a_byteCode);
   bool GenExprOpDot(const gmCodeTreeNode * a_node, gmByteCodeGen * a_byteCode);
   bool GenExprOpUnary(const gmCodeTreeNode * a_node, gmByteCodeGen * a_byteCode);
   bool GenExprOpUnary(const gmCodeTreeNode * a_node, gmByteCodeGen * a_byteCode);
   #if GM_USE_INCDECOPERATORS
   #if GM_USE_INCDECOPERATORS
@@ -404,6 +407,18 @@ bool gmCodeGenPrivate::Generate(const gmCodeTreeNode * a_node, gmByteCodeGen * a
             return false;
             return false;
           }
           }
 #endif //GM_USE_FORK
 #endif //GM_USE_FORK
+#if GM_USE_SWITCH
+		  case CTNST_SWITCH: res = GenStmtSwitch(a_node, a_byteCode); break;
+#else //GM_USE_SWITCH
+		  case CTNST_SWITCH: // Unsupported, but tokens exist
+		  {
+			  if (m_log && m_currentFunction)
+			  {
+				  m_log->LogEntry("error (%d) 'switch' statement not supported", m_currentFunction->m_currentLine);
+			  }
+			  return false;
+		  }
+#endif //GM_USE_SWITCH
           default: 
           default: 
           {
           {
             GM_ASSERT(false);
             GM_ASSERT(false);
@@ -900,6 +915,114 @@ bool gmCodeGenPrivate::GenStmtDoWhile(const gmCodeTreeNode * a_node, gmByteCodeG
 }
 }
 
 
 
 
+#if GM_USE_SWITCH
+bool gmCodeGenPrivate::GenStmtSwitch(const gmCodeTreeNode * a_node, gmByteCodeGen * a_byteCode)
+{
+	GM_ASSERT(a_node->m_type == CTNT_STATEMENT && a_node->m_subType == CTNST_SWITCH);
+	const gmCodeTreeNode *switchexpr = a_node->m_children[0];
+	const gmCodeTreeNode *defaultstmt = NULL;
+
+	gmuint caseid = 0;
+	gmuint casestmtid = 0;
+	gmArraySimple<gmuint> casejumpfromlocs;
+	gmArraySimple<gmuint> casestmtjumpfromlocs;
+	const gmCodeTreeNode * casenode = a_node->m_children[1];
+
+	// Generate 'switch' part
+	if (!Generate(switchexpr, a_byteCode)) return false;
+
+	while (casenode)
+	{
+		GM_ASSERT(casenode->m_type == CTNT_STATEMENT);
+
+		if (casenode->m_subType == CTNST_CASE)
+		{
+			// Duplicate result of switch evaluation to save us having to do it ease case
+			a_byteCode->Emit(BC_DUP);
+			// Generate conditional code
+			if (!Generate(casenode->m_children[0], a_byteCode)) return false;
+			// Do 'equal' test & jump to body
+			a_byteCode->Emit(BC_OP_EQ);
+			gmuint jumpfromloc = a_byteCode->Skip(SIZEOF_BC_BRA);
+			casejumpfromlocs.InsertLast(jumpfromloc);
+			++caseid;
+		}
+		else
+		{
+			// Must be a default statement
+			if (!casenode->m_children[0])
+			{
+				if (m_log) m_log->LogEntry("default missing statement body", casenode->m_lineNumber);
+				return false;
+			}
+			if (casenode->m_sibling)
+			{
+				if (m_log) m_log->LogEntry("cannot have case after default", casenode->m_lineNumber);
+				return false;
+			}
+
+			defaultstmt = casenode->m_children[0];
+		}
+
+		if (casenode->m_children[1])	// This statement has a body
+		{
+			if (!defaultstmt)
+			{
+				// We have some code
+				// Emit placeholder for next case when this block have all failed
+				gmuint casefailloc = a_byteCode->Skip(SIZEOF_BC_BRA);
+				// Emit jump to next block of code
+				gmuint beforestmtloc = a_byteCode->Tell();
+				// Emit statement
+				if (!Generate(casenode->m_children[1], a_byteCode)) return false;
+				// Jump to 'end'
+				gmuint jumpfromstmtloc = a_byteCode->Skip(SIZEOF_BC_BRA);	// store loc
+				casestmtjumpfromlocs.InsertLast(jumpfromstmtloc);
+				++casestmtid;
+				// Go back and backfill ptrs to the jump to loc
+				for (caseid = 0; caseid < casejumpfromlocs.Count(); ++caseid)
+				{
+					// jump to position
+					a_byteCode->Seek(casejumpfromlocs[caseid]);
+					// emit jump (tell case to jump to jump just before the statement to exec it)
+					a_byteCode->Emit(BC_BRNZ, beforestmtloc);
+
+				}
+				// Remove all old locs
+				casejumpfromlocs.ResetAndFreeMemory();
+				gmuint end_of_stmt = a_byteCode->Tell();
+				a_byteCode->Seek(casefailloc);
+				a_byteCode->Emit(BC_BRA, jumpfromstmtloc + SIZEOF_BC_BRA);
+				// Jump back to where we were ready for next statement
+				a_byteCode->Seek(jumpfromstmtloc + SIZEOF_BC_BRA);
+				// reset case
+				caseid = 0;
+			}
+		}
+		// Move to next sibling
+		casenode = casenode->m_sibling;
+	}
+	gmuint default_loc = a_byteCode->Tell();
+	if (defaultstmt)
+	{
+		if (!Generate(defaultstmt, a_byteCode)) return false;
+	}
+	gmuint end_of_code = a_byteCode->Tell();
+	for (caseid = 0; caseid < casestmtjumpfromlocs.Count(); ++caseid)
+	{
+		gmuint loc = casestmtjumpfromlocs[caseid];
+		// jump to position
+		a_byteCode->Seek(loc);
+		// emit jump (tell case to jump to here)
+		a_byteCode->Emit(BC_BRA, end_of_code);
+	}
+	// Jump back to end
+	a_byteCode->Seek(end_of_code);
+	a_byteCode->Emit(BC_POP);
+	return true;
+}
+#endif //GM_USE_SWITCH
+
 
 
 bool gmCodeGenPrivate::GenStmtIf(const gmCodeTreeNode * a_node, gmByteCodeGen * a_byteCode)
 bool gmCodeGenPrivate::GenStmtIf(const gmCodeTreeNode * a_node, gmByteCodeGen * a_byteCode)
 {
 {

+ 5 - 0
gmsrc/src/gm/gmCodeTree.cpp

@@ -195,6 +195,11 @@ static void PrintRecursive(const gmCodeTreeNode * a_node, FILE * a_fp, bool a_fi
 #if GM_USE_FORK
 #if GM_USE_FORK
           case CTNST_FORK : fprintf(a_fp, "CTNST_FORK:%04d" GM_NL, a_node->m_lineNumber); break;
           case CTNST_FORK : fprintf(a_fp, "CTNST_FORK:%04d" GM_NL, a_node->m_lineNumber); break;
 #endif //GM_USE_FORK
 #endif //GM_USE_FORK
+#if GM_USE_SWITCH
+		  case CTNST_SWITCH: fprintf(a_fp, "CTNST_SWITCH:%04d" GM_NL, a_node->m_lineNumber); break;
+		  case CTNST_CASE: fprintf(a_fp, "CTNST_CASE:%04d" GM_NL, a_node->m_lineNumber); break;
+		  case CTNST_DEFAULT: fprintf(a_fp, "CTNST_DEFAULT:%04d" GM_NL, a_node->m_lineNumber); break;
+#endif //GM_USE_SWITCH
           default : fprintf(a_fp, "UNKNOWN STATEMENT:" GM_NL); break;
           default : fprintf(a_fp, "UNKNOWN STATEMENT:" GM_NL); break;
         }
         }
       }
       }

+ 3 - 0
gmsrc/src/gm/gmCodeTree.h

@@ -129,6 +129,9 @@ enum gmCodeTreeNodeStatementType
   CTNST_IF,
   CTNST_IF,
   CTNST_COMPOUND,
   CTNST_COMPOUND,
   CTNST_FORK,                                     // If GM_USE_FORK
   CTNST_FORK,                                     // If GM_USE_FORK
+  CTNST_SWITCH,									  // If GM_USE_SWITCH
+  CTNST_CASE,									  // If GM_USE_SWITCH
+  CTNST_DEFAULT									  // If GM_USE_SWITCH
 };
 };
 
 
 
 

+ 1 - 0
gmsrc/src/gm/gmConfig.h

@@ -107,5 +107,6 @@ enum gmEndian
 #define GM_USER_FOREACH             1         // Support foreach for user types
 #define GM_USER_FOREACH             1         // Support foreach for user types
 #define GM_USE_ENDON                1         // Support endon() to kill thread when signalled
 #define GM_USE_ENDON                1         // Support endon() to kill thread when signalled
 #define GM_USE_INCDECOPERATORS      1         // Support operator ++ and --
 #define GM_USE_INCDECOPERATORS      1         // Support operator ++ and --
+#define GM_USE_SWITCH				1	      // Support switch statements
 
 
 #endif // _GMCONFIG_H_
 #endif // _GMCONFIG_H_

File diff suppressed because it is too large
+ 516 - 403
gmsrc/src/gm/gmParser.cpp


+ 29 - 26
gmsrc/src/gm/gmParser.cpp.h

@@ -23,32 +23,35 @@
 #define	KEYWORD_TRUE	277
 #define	KEYWORD_TRUE	277
 #define	KEYWORD_FALSE	278
 #define	KEYWORD_FALSE	278
 #define	KEYWORD_FORK	279
 #define	KEYWORD_FORK	279
-#define	IDENTIFIER	280
-#define	CONSTANT_HEX	281
-#define	CONSTANT_BINARY	282
-#define	CONSTANT_INT	283
-#define	CONSTANT_CHAR	284
-#define	CONSTANT_FLOAT	285
-#define	CONSTANT_STRING	286
-#define	SYMBOL_ASGN_BSR	287
-#define	SYMBOL_ASGN_BSL	288
-#define	SYMBOL_ASGN_ADD	289
-#define	SYMBOL_ASGN_MINUS	290
-#define	SYMBOL_ASGN_TIMES	291
-#define	SYMBOL_ASGN_DIVIDE	292
-#define	SYMBOL_ASGN_REM	293
-#define	SYMBOL_ASGN_BAND	294
-#define	SYMBOL_ASGN_BOR	295
-#define	SYMBOL_ASGN_BXOR	296
-#define	SYMBOL_RIGHT_SHIFT	297
-#define	SYMBOL_LEFT_SHIFT	298
-#define	SYMBOL_INC	299
-#define	SYMBOL_DEC	300
-#define	SYMBOL_LTE	301
-#define	SYMBOL_GTE	302
-#define	SYMBOL_EQ	303
-#define	SYMBOL_NEQ	304
-#define	TOKEN_ERROR	305
+#define	KEYWORD_SWITCH	280
+#define	KEYWORD_CASE	281
+#define	KEYWORD_DEFAULT	282
+#define	IDENTIFIER	283
+#define	CONSTANT_HEX	284
+#define	CONSTANT_BINARY	285
+#define	CONSTANT_INT	286
+#define	CONSTANT_CHAR	287
+#define	CONSTANT_FLOAT	288
+#define	CONSTANT_STRING	289
+#define	SYMBOL_ASGN_BSR	290
+#define	SYMBOL_ASGN_BSL	291
+#define	SYMBOL_ASGN_ADD	292
+#define	SYMBOL_ASGN_MINUS	293
+#define	SYMBOL_ASGN_TIMES	294
+#define	SYMBOL_ASGN_DIVIDE	295
+#define	SYMBOL_ASGN_REM	296
+#define	SYMBOL_ASGN_BAND	297
+#define	SYMBOL_ASGN_BOR	298
+#define	SYMBOL_ASGN_BXOR	299
+#define	SYMBOL_RIGHT_SHIFT	300
+#define	SYMBOL_LEFT_SHIFT	301
+#define	SYMBOL_INC	302
+#define	SYMBOL_DEC	303
+#define	SYMBOL_LTE	304
+#define	SYMBOL_GTE	305
+#define	SYMBOL_EQ	306
+#define	SYMBOL_NEQ	307
+#define	TOKEN_ERROR	308
 
 
 
 
 extern YYSTYPE gmlval;
 extern YYSTYPE gmlval;

+ 74 - 0
gmsrc/src/gm/gmParser.y

@@ -90,6 +90,9 @@ gmCodeTreeNode * CreateAsignExpression(int a_subTypeType, gmCodeTreeNode * a_lef
 %token KEYWORD_TRUE
 %token KEYWORD_TRUE
 %token KEYWORD_FALSE
 %token KEYWORD_FALSE
 %token KEYWORD_FORK
 %token KEYWORD_FORK
+%token KEYWORD_SWITCH
+%token KEYWORD_CASE
+%token KEYWORD_DEFAULT
 %token IDENTIFIER
 %token IDENTIFIER
 %token CONSTANT_HEX
 %token CONSTANT_HEX
 %token CONSTANT_BINARY
 %token CONSTANT_BINARY
@@ -323,6 +326,77 @@ selection_statement
       $$ = gmCodeTreeNode::Create(CTNT_STATEMENT, CTNST_FORK, ($2) ? $2->m_lineNumber : gmlineno );
       $$ = gmCodeTreeNode::Create(CTNT_STATEMENT, CTNST_FORK, ($2) ? $2->m_lineNumber : gmlineno );
       $$->SetChild(0, $2 );
       $$->SetChild(0, $2 );
     }
     }
+  | KEYWORD_SWITCH '(' constant_expression ')' '{' case_selection_statement_list '}'
+    {
+      $$ = gmCodeTreeNode::Create(CTNT_STATEMENT, CTNST_SWITCH, ($3) ? $3->m_lineNumber : gmlineno);
+      $$->SetChild(0, $3);
+      $$->SetChild(1, $6);
+    }
+  ;
+
+case_selection_statement
+  : KEYWORD_CASE postfix_case_expression ':'
+    {
+      $$ = gmCodeTreeNode::Create(CTNT_STATEMENT, CTNST_CASE, ($2) ? $2->m_lineNumber : gmlineno);
+      $$->SetChild(0, $2);
+    }
+  | KEYWORD_CASE postfix_case_expression ':' compound_statement
+    {
+      $$ = gmCodeTreeNode::Create(CTNT_STATEMENT, CTNST_CASE, ($2) ? $2->m_lineNumber : gmlineno);
+      $$->SetChild(0, $2);
+      $$->SetChild(1, $4);
+    }
+   | KEYWORD_DEFAULT ':' compound_statement
+    {
+      $$ = gmCodeTreeNode::Create(CTNT_STATEMENT, CTNST_DEFAULT, ($3) ? $3->m_lineNumber : gmlineno);
+      $$->SetChild(0, $3);
+    }
+  ;
+  
+case_selection_statement_list
+  : case_selection_statement
+    {
+      $$ = $1;
+    }
+  | case_selection_statement_list case_selection_statement
+    {
+      ATTACH($$, $1, $2);
+    }
+  ;
+ 
+ postfix_case_expression
+  : case_expression
+    {
+      $$ = $1;
+    }
+  | postfix_case_expression '[' constant_expression ']'
+    {
+      $$ = CreateOperation(CTNOT_ARRAY_INDEX, $1, $3);
+    }
+  | postfix_case_expression '.' identifier
+    {
+      $$ = CreateOperation(CTNOT_DOT, $1, $3);
+    }
+  ;
+ 
+ case_expression
+  : identifier
+    {
+      $$ = $1;
+    }
+  | '.' identifier
+    {
+      $$ = $2;
+      $$->m_flags |= gmCodeTreeNode::CTN_MEMBER;
+    }
+  | KEYWORD_THIS
+    {
+      $$ = gmCodeTreeNode::Create(CTNT_EXPRESSION, CTNET_THIS, gmlineno);
+    }
+  | constant  
+    {
+      $$ = $1;
+    }
   ;
   ;
 
 
 iteration_statement
 iteration_statement

+ 263 - 238
gmsrc/src/gm/gmScanner.cpp

@@ -298,65 +298,71 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
    *yy_cp = '\0'; \
    *yy_cp = '\0'; \
    yy_c_buf_p = yy_cp;
    yy_c_buf_p = yy_cp;
 
 
-#define YY_NUM_RULES 81
-#define YY_END_OF_BUFFER 82
-static yyconst short int yy_acclist[284] =
+#define YY_NUM_RULES 84
+#define YY_END_OF_BUFFER 85
+static yyconst short int yy_acclist[304] =
     {   0,
     {   0,
-       82,   80,   81,   79,   80,   81,   79,   81,   65,   80,
-       81,   80,   81,   70,   80,   81,   73,   80,   81,   80,
-       81,   60,   80,   81,   61,   80,   81,   68,   80,   81,
-       67,   80,   81,   58,   80,   81,   66,   80,   81,   64,
-       80,   81,   69,   80,   81,   28,   80,   81,   28,   80,
-       81,   77,   78,   80,   81,   55,   80,   81,   71,   80,
-       81,   59,   80,   81,   72,   80,   81,   25,   80,   81,
-       62,   80,   81,   63,   80,   81,   75,   80,   81,   80,
-       81,   25,   80,   81,   25,   80,   81,   25,   80,   81,
-       25,   80,   81,   25,   80,   81,   25,   80,   81,   25,
-
-       80,   81,   25,   80,   81,   25,   80,   81,   25,   80,
-       81,   25,   80,   81,   25,   80,   81,   25,   80,   81,
-       25,   80,   81,   25,   80,   81,   56,   80,   81,   74,
-       80,   81,   57,   80,   81,   76,   80,   81,   54,   33,
-       43,   35,   44,   41,   49,   39,   50,   40,   31,    1,
-        2,   42,   32,   28,   48,   51,   53,   52,   47,   25,
-       46,   34,   25,   25,   25,   25,   25,   25,   25,   25,
-       25,    8,   25,   13,   25,   25,   25,   25,    7,   25,
-       25,   25,   25,   25,   25,   45,   36,   29,   31,    2,
-       31,   32,   32,   27,   30,   26,   38,   37,    6,   25,
-
-       25,   25,   25,   25,   25,   11,   25,   25,   25,   25,
-       25,   25,   25,   25,   25,   25,   25,   31,   31,   32,
-       32,   30,   25,   25,   25,    9,   25,   25,   25,   24,
-       25,   25,   25,   25,   25,   17,   25,   25,   25,   21,
-       25,   22,   25,   25,   31,   32,   15,   25,   25,   25,
-       23,   25,   25,   25,   25,    3,   25,   25,   25,   20,
-       25,   10,   25,   25,   25,   25,   25,    4,   25,    5,
-       25,   18,   25,   25,   14,   25,   12,   25,   25,   16,
-       25,   19,   25
+       85,   83,   84,   82,   83,   84,   82,   84,   68,   83,
+       84,   83,   84,   73,   83,   84,   76,   83,   84,   83,
+       84,   63,   83,   84,   64,   83,   84,   71,   83,   84,
+       70,   83,   84,   61,   83,   84,   69,   83,   84,   67,
+       83,   84,   72,   83,   84,   31,   83,   84,   31,   83,
+       84,   80,   81,   83,   84,   58,   83,   84,   74,   83,
+       84,   62,   83,   84,   75,   83,   84,   28,   83,   84,
+       65,   83,   84,   66,   83,   84,   78,   83,   84,   83,
+       84,   28,   83,   84,   28,   83,   84,   28,   83,   84,
+       28,   83,   84,   28,   83,   84,   28,   83,   84,   28,
+
+       83,   84,   28,   83,   84,   28,   83,   84,   28,   83,
+       84,   28,   83,   84,   28,   83,   84,   28,   83,   84,
+       28,   83,   84,   28,   83,   84,   28,   83,   84,   59,
+       83,   84,   77,   83,   84,   60,   83,   84,   79,   83,
+       84,   57,   36,   46,   38,   47,   44,   52,   42,   53,
+       43,   34,    1,    2,   45,   35,   31,   51,   54,   56,
+       55,   50,   28,   49,   37,   28,   28,   28,   28,   28,
+       28,   28,   28,   28,   28,   28,    8,   28,   13,   28,
+       28,   28,   28,    7,   28,   28,   28,   28,   28,   28,
+       28,   48,   39,   32,   34,    2,   34,   35,   35,   30,
+
+       33,   29,   41,   40,    6,   28,   28,   28,   28,   28,
+       28,   28,   28,   11,   28,   28,   28,   28,   28,   28,
+       28,   28,   28,   28,   28,   28,   34,   34,   35,   35,
+       33,   28,   26,   28,   28,   28,   28,    9,   28,   28,
+       28,   24,   28,   28,   28,   28,   28,   17,   28,   28,
+       28,   28,   21,   28,   22,   28,   28,   34,   35,   15,
+       28,   28,   28,   28,   23,   28,   28,   28,   28,    3,
+       28,   28,   28,   28,   20,   28,   10,   28,   28,   28,
+       28,   28,   28,    4,   28,    5,   28,   18,   28,   25,
+       28,   28,   27,   28,   14,   28,   12,   28,   28,   16,
+
+       28,   19,   28
     } ;
     } ;
 
 
-static yyconst short int yy_accept[188] =
+static yyconst short int yy_accept[203] =
     {   0,
     {   0,
         1,    1,    1,    2,    4,    7,    9,   12,   14,   17,
         1,    1,    1,    2,    4,    7,    9,   12,   14,   17,
        20,   22,   25,   28,   31,   34,   37,   40,   43,   46,
        20,   22,   25,   28,   31,   34,   37,   40,   43,   46,
        49,   52,   56,   59,   62,   65,   68,   71,   74,   77,
        49,   52,   56,   59,   62,   65,   68,   71,   74,   77,
        80,   82,   85,   88,   91,   94,   97,  100,  103,  106,
        80,   82,   85,   88,   91,   94,   97,  100,  103,  106,
       109,  112,  115,  118,  121,  124,  127,  130,  133,  136,
       109,  112,  115,  118,  121,  124,  127,  130,  133,  136,
-      139,  140,  140,  141,  141,  142,  143,  144,  144,  144,
-      145,  146,  147,  148,  149,  150,  151,  152,  153,  154,
-      155,  155,  155,  155,  156,  157,  158,  159,  160,  161,
-      162,  162,  163,  164,  165,  166,  167,  168,  169,  170,
-      171,  172,  174,  176,  177,  178,  179,  181,  182,  183,
-
-      184,  185,  186,  187,  188,  189,  189,  190,  191,  193,
-      193,  194,  195,  195,  196,  197,  198,  199,  201,  202,
-      203,  204,  205,  206,  208,  209,  210,  211,  212,  213,
-      214,  215,  216,  217,  218,  218,  219,  219,  221,  221,
-      222,  223,  224,  225,  226,  228,  229,  230,  232,  233,
-      234,  235,  236,  238,  239,  240,  242,  244,  245,  245,
-      247,  249,  250,  251,  253,  254,  255,  256,  258,  259,
-      260,  262,  264,  265,  266,  267,  268,  270,  272,  274,
-      275,  277,  279,  280,  282,  284,  284
+      139,  142,  143,  143,  144,  144,  145,  146,  147,  147,
+      147,  148,  149,  150,  151,  152,  153,  154,  155,  156,
+      157,  158,  158,  158,  158,  159,  160,  161,  162,  163,
+      164,  165,  165,  166,  167,  168,  169,  170,  171,  172,
+      173,  174,  175,  176,  177,  179,  181,  182,  183,  184,
+
+      186,  187,  188,  189,  190,  191,  192,  193,  194,  195,
+      195,  196,  197,  199,  199,  200,  201,  201,  202,  203,
+      204,  205,  207,  208,  209,  210,  211,  212,  213,  214,
+      216,  217,  218,  219,  220,  221,  222,  223,  224,  225,
+      226,  227,  227,  228,  228,  230,  230,  231,  232,  233,
+      235,  236,  237,  238,  240,  241,  242,  244,  245,  246,
+      247,  248,  250,  251,  252,  253,  255,  257,  258,  258,
+      260,  262,  263,  264,  265,  267,  268,  269,  270,  272,
+      273,  274,  275,  277,  279,  280,  281,  282,  283,  284,
+      286,  288,  290,  292,  293,  295,  297,  299,  300,  302,
+
+      304,  304
     } ;
     } ;
 
 
 static yyconst int yy_ec[256] =
 static yyconst int yy_ec[256] =
@@ -401,102 +407,105 @@ static yyconst int yy_meta[59] =
         5,    5,    5,    5,    1,    1,    1,    1
         5,    5,    5,    5,    1,    1,    1,    1
     } ;
     } ;
 
 
-static yyconst short int yy_base[193] =
+static yyconst short int yy_base[208] =
     {   0,
     {   0,
-        0,    0,  295,  296,  296,  296,  271,   54,  270,   53,
-      260,  296,  296,  268,   49,  296,   48,   46,   57,   72,
-       66,  296,  296,   44,  267,   46,    0,  296,  296,  266,
-      253,  239,  236,  236,  235,  237,   39,  236,   53,  232,
-      240,  226,  228,  237,   60,  233,  296,   51,  296,  296,
-      296,   72,  296,  272,  296,  296,  296,   87,   97,  296,
-      296,  296,  296,  296,   96,  296,    0,  296,   99,  114,
-       61,  130,    0,  251,  296,  296,  296,  250,    0,  296,
-      237,  236,  231,  229,  220,  213,  215,  219,  214,  215,
-      213,    0,    0,  223,  213,  210,    0,  193,  199,  191,
-
-      181,  189,  296,  296,  296,  138,  296,    0,  141,  153,
-      296,  103,  144,  156,    0,  296,  296,    0,  196,  179,
-      187,  189,  177,   85,  189,  189,  187,  185,  175,  167,
-      173,  167,  177,  170,  159,  168,  176,  296,  181,  184,
-      296,  166,  166,  164,    0,  167,  156,    0,  139,  153,
-      137,  140,    0,  129,  126,    0,    0,  124,  187,  196,
-        0,  105,  105,    0,  108,  101,   97,    0,   88,   87,
-        0,    0,   81,   88,   79,   62,    0,    0,    0,   68,
-        0,    0,   49,    0,    0,  296,  237,  242,  244,  249,
-      254,   78
-
+        0,    0,  309,  310,  310,  310,  285,   54,  284,   53,
+      274,  310,  310,  282,   49,  310,   48,   46,   57,   72,
+       66,  310,  310,   44,  281,   46,    0,  310,  310,  280,
+      267,  253,  250,   39,   52,  253,   58,  252,   55,  248,
+      256,  242,  244,  253,  238,   72,  248,  310,   54,  310,
+      310,  310,   73,  310,  287,  310,  310,  310,   87,   71,
+      310,  310,  310,  310,  310,   99,  310,    0,  310,  106,
+      126,   96,  118,    0,  266,  310,  310,  310,  265,    0,
+      310,  252,  251,  246,  244,  232,  234,  240,  226,  228,
+      232,  227,  228,  226,    0,    0,  236,  226,  226,    0,
+
+      219,  226,  232,  224,  214,  222,  310,  310,  310,  137,
+      310,    0,  140,  157,  310,  103,  143,  160,    0,  310,
+      310,    0,  229,  224,  211,  226,  218,  220,  208,  125,
+      220,  220,  217,  205,  187,  179,  179,  184,  178,  188,
+      181,  165,  168,  180,  310,  172,  185,  310,  180,    0,
+      180,  170,  178,    0,  180,  183,    0,  166,  181,  170,
+      175,    0,  164,  170,  160,    0,    0,  155,  188,  193,
+        0,  145,  127,  126,    0,  126,  119,  106,    0,  100,
+      100,   99,    0,    0,   85,   79,   89,   85,   55,    0,
+        0,    0,    0,   60,    0,    0,    0,   49,    0,    0,
+
+      310,  234,  239,  241,  246,  251,   78
     } ;
     } ;
 
 
-static yyconst short int yy_def[193] =
+static yyconst short int yy_def[208] =
     {   0,
     {   0,
-      186,    1,  186,  186,  186,  186,  186,  187,  186,  186,
-      188,  186,  186,  186,  186,  186,  186,  186,  186,  186,
-      186,  186,  186,  186,  186,  186,  189,  186,  186,  186,
-      190,  189,  189,  189,  189,  189,  189,  189,  189,  189,
-      189,  189,  189,  189,  189,  189,  186,  186,  186,  186,
-      186,  187,  186,  187,  186,  186,  186,  188,  188,  186,
-      186,  186,  186,  186,  186,  186,  191,  186,  186,  186,
-      186,  186,  192,  186,  186,  186,  186,  186,  189,  186,
-      190,  186,  189,  189,  189,  189,  189,  189,  189,  189,
-      189,  189,  189,  189,  189,  189,  189,  189,  189,  189,
-
-      189,  189,  186,  186,  186,  186,  186,  191,  186,  186,
-      186,  186,  186,  186,  192,  186,  186,  189,  189,  189,
-      189,  189,  189,  189,  189,  189,  189,  189,  189,  189,
-      189,  189,  189,  189,  186,  186,  186,  186,  186,  186,
-      186,  189,  189,  189,  189,  189,  189,  189,  189,  189,
-      189,  189,  189,  189,  189,  189,  189,  189,  186,  186,
-      189,  189,  189,  189,  189,  189,  189,  189,  189,  189,
-      189,  189,  189,  189,  189,  189,  189,  189,  189,  189,
-      189,  189,  189,  189,  189,    0,  186,  186,  186,  186,
-      186,  186
-
+      201,    1,  201,  201,  201,  201,  201,  202,  201,  201,
+      203,  201,  201,  201,  201,  201,  201,  201,  201,  201,
+      201,  201,  201,  201,  201,  201,  204,  201,  201,  201,
+      205,  204,  204,  204,  204,  204,  204,  204,  204,  204,
+      204,  204,  204,  204,  204,  204,  204,  201,  201,  201,
+      201,  201,  202,  201,  202,  201,  201,  201,  203,  203,
+      201,  201,  201,  201,  201,  201,  201,  206,  201,  201,
+      201,  201,  201,  207,  201,  201,  201,  201,  201,  204,
+      201,  205,  201,  204,  204,  204,  204,  204,  204,  204,
+      204,  204,  204,  204,  204,  204,  204,  204,  204,  204,
+
+      204,  204,  204,  204,  204,  204,  201,  201,  201,  201,
+      201,  206,  201,  201,  201,  201,  201,  201,  207,  201,
+      201,  204,  204,  204,  204,  204,  204,  204,  204,  204,
+      204,  204,  204,  204,  204,  204,  204,  204,  204,  204,
+      204,  201,  201,  201,  201,  201,  201,  201,  204,  204,
+      204,  204,  204,  204,  204,  204,  204,  204,  204,  204,
+      204,  204,  204,  204,  204,  204,  204,  204,  201,  201,
+      204,  204,  204,  204,  204,  204,  204,  204,  204,  204,
+      204,  204,  204,  204,  204,  204,  204,  204,  204,  204,
+      204,  204,  204,  204,  204,  204,  204,  204,  204,  204,
+
+        0,  201,  201,  201,  201,  201,  201
     } ;
     } ;
 
 
-static yyconst short int yy_nxt[355] =
+static yyconst short int yy_nxt[369] =
     {   0,
     {   0,
         4,    5,    6,    7,    8,    9,   10,   11,   12,   13,
         4,    5,    6,    7,    8,    9,   10,   11,   12,   13,
        14,   15,   16,   17,   18,   19,   20,   21,   21,   22,
        14,   15,   16,   17,   18,   19,   20,   21,   21,   22,
        23,   24,   25,   26,   27,   27,   27,   27,   27,   27,
        23,   24,   25,   26,   27,   27,   27,   27,   27,   27,
        28,    4,   29,   30,   31,   32,   33,   34,   35,   36,
        28,    4,   29,   30,   31,   32,   33,   34,   35,   36,
        37,   38,   27,   39,   27,   40,   41,   42,   43,   44,
        37,   38,   27,   39,   27,   40,   41,   42,   43,   44,
-       27,   45,   27,   46,   47,   48,   49,   50,   53,   56,
-       61,   63,   65,   65,   65,   74,   75,   66,   77,   78,
-       64,   62,   67,  103,   88,   57,   53,  112,  112,   68,
-       69,  115,   70,   70,   70,   54,   69,   89,   70,   70,
-       70,   90,   72,   92,  105,   99,  185,   71,   72,  186,
-
-       93,   73,  100,   54,   58,   72,  104,  184,   71,  101,
-      183,   72,   65,   65,   65,  109,  109,  109,   59,  112,
-      112,  182,  106,  107,  147,  110,  111,  181,   69,  148,
-       70,   70,   70,  180,  179,  106,  107,  178,  110,  111,
-       72,  113,  177,  113,  176,  175,  114,  114,  114,  135,
-      174,  135,  173,   72,  136,  136,  136,  109,  109,  109,
-      114,  114,  114,  172,  139,  171,  139,  137,  138,  140,
-      140,  140,  114,  114,  114,  136,  136,  136,  170,  169,
-      137,  138,  168,  141,  136,  136,  136,  159,  167,  159,
-      166,  165,  160,  160,  160,  107,  141,  140,  140,  140,
-
-      140,  140,  140,  160,  160,  160,  164,  163,  107,  162,
-      161,  111,  160,  160,  160,  158,  157,  156,  155,  154,
-      153,  152,  151,  138,  111,  150,  149,  146,  145,  144,
-      143,  142,  134,  133,  132,  131,  138,   52,   52,   52,
-       52,   52,   58,   58,  130,   58,   58,   79,   79,   81,
-       81,   81,   81,   81,  108,  129,  108,  108,  108,  128,
-      127,  126,  125,  124,  123,  122,  121,  120,  119,  118,
-       81,   82,  117,  116,  186,  102,   98,   97,   96,   95,
-       94,   91,   87,   86,   85,   84,   83,   82,   80,   76,
-       60,   59,   55,   51,  186,    3,  186,  186,  186,  186,
-
-      186,  186,  186,  186,  186,  186,  186,  186,  186,  186,
-      186,  186,  186,  186,  186,  186,  186,  186,  186,  186,
-      186,  186,  186,  186,  186,  186,  186,  186,  186,  186,
-      186,  186,  186,  186,  186,  186,  186,  186,  186,  186,
-      186,  186,  186,  186,  186,  186,  186,  186,  186,  186,
-      186,  186,  186,  186
+       45,   46,   27,   47,   48,   49,   50,   51,   54,   57,
+       62,   64,   66,   66,   66,   75,   76,   67,   78,   79,
+       65,   63,   68,  201,   86,   58,  107,   54,   59,   69,
+       70,  119,   71,   71,   71,   55,   70,   87,   71,   71,
+       71,   88,   73,   91,  109,   95,  200,   72,   73,  199,
+
+       89,   74,   96,  198,   55,   73,   92,  103,   72,  108,
+       93,   73,  116,  116,  104,   66,   66,   66,   60,  116,
+      116,  105,  113,  113,  113,  110,  111,  197,  196,  117,
+      195,  117,  114,  115,  118,  118,  118,  194,  110,  111,
+       70,  193,   71,   71,   71,  114,  115,  192,  142,  191,
+      142,  190,   73,  143,  143,  143,  113,  113,  113,  118,
+      118,  118,  189,  188,  156,   73,  144,  145,  146,  157,
+      146,  187,  186,  147,  147,  147,  118,  118,  118,  144,
+      145,  143,  143,  143,  143,  143,  143,  148,  147,  147,
+      147,  169,  185,  169,  184,  111,  170,  170,  170,  183,
+
+      148,  147,  147,  147,  170,  170,  170,  182,  111,  170,
+      170,  170,  115,  181,  180,  179,  178,  177,  176,  175,
+      145,  174,  173,  172,  171,  115,  168,  167,  166,  165,
+      164,  163,  162,  145,   53,   53,   53,   53,   53,   59,
+       59,  161,   59,   59,   80,   80,   82,   82,   82,   82,
+       82,  112,  160,  112,  112,  112,  159,  158,  155,  154,
+      153,  152,  151,  150,  149,  141,  140,  139,  138,  137,
+      136,  135,  134,  133,  132,  131,  130,  129,  128,  127,
+      126,  125,  124,  123,  122,   82,   83,  121,  120,  201,
+      106,  102,  101,  100,   99,   98,   97,   94,   90,   85,
+
+       84,   83,   81,   77,   61,   60,   56,   52,  201,    3,
+      201,  201,  201,  201,  201,  201,  201,  201,  201,  201,
+      201,  201,  201,  201,  201,  201,  201,  201,  201,  201,
+      201,  201,  201,  201,  201,  201,  201,  201,  201,  201,
+      201,  201,  201,  201,  201,  201,  201,  201,  201,  201,
+      201,  201,  201,  201,  201,  201,  201,  201,  201,  201,
+      201,  201,  201,  201,  201,  201,  201,  201
     } ;
     } ;
 
 
-static yyconst short int yy_chk[355] =
+static yyconst short int yy_chk[369] =
     {   0,
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
@@ -505,38 +514,39 @@ static yyconst short int yy_chk[355] =
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    8,   10,
         1,    1,    1,    1,    1,    1,    1,    1,    8,   10,
        15,   17,   18,   18,   18,   24,   24,   19,   26,   26,
        15,   17,   18,   18,   18,   24,   24,   19,   26,   26,
-       17,   15,   19,   48,   37,   10,   52,   71,   71,   19,
-       21,  192,   21,   21,   21,    8,   20,   37,   20,   20,
-       20,   37,   21,   39,   58,   45,  183,   20,   20,   59,
-
-       39,   20,   45,   52,   59,   21,   48,  180,   20,   45,
-      176,   20,   65,   65,   65,   69,   69,   69,   58,  112,
-      112,  175,   65,   65,  124,   69,   69,  174,   70,  124,
-       70,   70,   70,  173,  170,   65,   65,  169,   69,   69,
-       70,   72,  167,   72,  166,  165,   72,   72,   72,  106,
-      163,  106,  162,   70,  106,  106,  106,  109,  109,  109,
-      113,  113,  113,  158,  110,  155,  110,  109,  109,  110,
-      110,  110,  114,  114,  114,  135,  135,  135,  154,  152,
-      109,  109,  151,  114,  136,  136,  136,  137,  150,  137,
-      149,  147,  137,  137,  137,  136,  114,  139,  139,  139,
-
-      140,  140,  140,  159,  159,  159,  146,  144,  136,  143,
-      142,  140,  160,  160,  160,  134,  133,  132,  131,  130,
-      129,  128,  127,  160,  140,  126,  125,  123,  122,  121,
-      120,  119,  102,  101,  100,   99,  160,  187,  187,  187,
-      187,  187,  188,  188,   98,  188,  188,  189,  189,  190,
-      190,  190,  190,  190,  191,   96,  191,  191,  191,   95,
-       94,   91,   90,   89,   88,   87,   86,   85,   84,   83,
-       82,   81,   78,   74,   54,   46,   44,   43,   42,   41,
-       40,   38,   36,   35,   34,   33,   32,   31,   30,   25,
-       14,   11,    9,    7,    3,  186,  186,  186,  186,  186,
-
-      186,  186,  186,  186,  186,  186,  186,  186,  186,  186,
-      186,  186,  186,  186,  186,  186,  186,  186,  186,  186,
-      186,  186,  186,  186,  186,  186,  186,  186,  186,  186,
-      186,  186,  186,  186,  186,  186,  186,  186,  186,  186,
-      186,  186,  186,  186,  186,  186,  186,  186,  186,  186,
-      186,  186,  186,  186
+       17,   15,   19,   60,   34,   10,   49,   53,   60,   19,
+       21,  207,   21,   21,   21,    8,   20,   34,   20,   20,
+       20,   35,   21,   37,   59,   39,  198,   20,   20,  194,
+
+       35,   20,   39,  189,   53,   21,   37,   46,   20,   49,
+       37,   20,   72,   72,   46,   66,   66,   66,   59,  116,
+      116,   46,   70,   70,   70,   66,   66,  188,  187,   73,
+      186,   73,   70,   70,   73,   73,   73,  185,   66,   66,
+       71,  182,   71,   71,   71,   70,   70,  181,  110,  180,
+      110,  178,   71,  110,  110,  110,  113,  113,  113,  117,
+      117,  117,  177,  176,  130,   71,  113,  113,  114,  130,
+      114,  174,  173,  114,  114,  114,  118,  118,  118,  113,
+      113,  142,  142,  142,  143,  143,  143,  118,  146,  146,
+      146,  144,  172,  144,  168,  143,  144,  144,  144,  165,
+
+      118,  147,  147,  147,  169,  169,  169,  164,  143,  170,
+      170,  170,  147,  163,  161,  160,  159,  158,  156,  155,
+      170,  153,  152,  151,  149,  147,  141,  140,  139,  138,
+      137,  136,  135,  170,  202,  202,  202,  202,  202,  203,
+      203,  134,  203,  203,  204,  204,  205,  205,  205,  205,
+      205,  206,  133,  206,  206,  206,  132,  131,  129,  128,
+      127,  126,  125,  124,  123,  106,  105,  104,  103,  102,
+      101,   99,   98,   97,   94,   93,   92,   91,   90,   89,
+       88,   87,   86,   85,   84,   83,   82,   79,   75,   55,
+       47,   45,   44,   43,   42,   41,   40,   38,   36,   33,
+
+       32,   31,   30,   25,   14,   11,    9,    7,    3,  201,
+      201,  201,  201,  201,  201,  201,  201,  201,  201,  201,
+      201,  201,  201,  201,  201,  201,  201,  201,  201,  201,
+      201,  201,  201,  201,  201,  201,  201,  201,  201,  201,
+      201,  201,  201,  201,  201,  201,  201,  201,  201,  201,
+      201,  201,  201,  201,  201,  201,  201,  201,  201,  201,
+      201,  201,  201,  201,  201,  201,  201,  201
     } ;
     } ;
 
 
 static yy_state_type yy_state_buf[YY_BUF_SIZE + 2], *yy_state_ptr;
 static yy_state_type yy_state_buf[YY_BUF_SIZE + 2], *yy_state_ptr;
@@ -570,7 +580,7 @@ char *yytext;
 #include "gmConfig.h"
 #include "gmConfig.h"
 #include "gmParser.cpp.h"
 #include "gmParser.cpp.h"
 
 
-#line 574 "gmScanner.cpp"
+#line 584 "gmScanner.cpp"
 
 
 /* Macros after this point can all be overridden by user definitions in
 /* Macros after this point can all be overridden by user definitions in
  * section 1.
  * section 1.
@@ -742,7 +752,7 @@ YY_DECL
 #line 29 "gmScanner.l"
 #line 29 "gmScanner.l"
 
 
 
 
-#line 746 "gmScanner.cpp"
+#line 756 "gmScanner.cpp"
 
 
    if ( yy_init )
    if ( yy_init )
       {
       {
@@ -790,14 +800,14 @@ yy_match:
 			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 				{
 				{
 				yy_current_state = (int) yy_def[yy_current_state];
 				yy_current_state = (int) yy_def[yy_current_state];
-				if ( yy_current_state >= 187 )
+				if ( yy_current_state >= 202 )
 					yy_c = yy_meta[(unsigned int) yy_c];
 					yy_c = yy_meta[(unsigned int) yy_c];
 				}
 				}
 			yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
 			yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
 			*yy_state_ptr++ = yy_current_state;
 			*yy_state_ptr++ = yy_current_state;
 			++yy_cp;
 			++yy_cp;
 			}
 			}
-		while ( yy_base[yy_current_state] != 296 );
+		while ( yy_base[yy_current_state] != 310 );
 
 
 yy_find_action:
 yy_find_action:
 		yy_current_state = *--yy_state_ptr;
 		yy_current_state = *--yy_state_ptr;
@@ -968,290 +978,305 @@ YY_RULE_SETUP
 	YY_BREAK
 	YY_BREAK
 case 25:
 case 25:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 71 "gmScanner.l"
-{ return(IDENTIFIER);         }
+#line 70 "gmScanner.l"
+{ return(KEYWORD_SWITCH);     }
 	YY_BREAK
 	YY_BREAK
 case 26:
 case 26:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 73 "gmScanner.l"
-{ return(CONSTANT_HEX);       }
+#line 71 "gmScanner.l"
+{ return(KEYWORD_CASE);       }
 	YY_BREAK
 	YY_BREAK
 case 27:
 case 27:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 74 "gmScanner.l"
-{ return(CONSTANT_BINARY);    }
+#line 72 "gmScanner.l"
+{ return(KEYWORD_DEFAULT);    }
 	YY_BREAK
 	YY_BREAK
 case 28:
 case 28:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 75 "gmScanner.l"
-{ return(CONSTANT_INT);       }
+#line 74 "gmScanner.l"
+{ return(IDENTIFIER);         }
 	YY_BREAK
 	YY_BREAK
 case 29:
 case 29:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 76 "gmScanner.l"
 #line 76 "gmScanner.l"
-{ return(CONSTANT_CHAR);      }
+{ return(CONSTANT_HEX);       }
 	YY_BREAK
 	YY_BREAK
 case 30:
 case 30:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 77 "gmScanner.l"
 #line 77 "gmScanner.l"
-{ return(CONSTANT_FLOAT);     }
+{ return(CONSTANT_BINARY);    }
 	YY_BREAK
 	YY_BREAK
 case 31:
 case 31:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 78 "gmScanner.l"
 #line 78 "gmScanner.l"
-{ return(CONSTANT_FLOAT);     }
+{ return(CONSTANT_INT);       }
 	YY_BREAK
 	YY_BREAK
 case 32:
 case 32:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 79 "gmScanner.l"
 #line 79 "gmScanner.l"
-{ return(CONSTANT_FLOAT);     }
+{ return(CONSTANT_CHAR);      }
 	YY_BREAK
 	YY_BREAK
 case 33:
 case 33:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 80 "gmScanner.l"
 #line 80 "gmScanner.l"
-{ return(CONSTANT_STRING);    }
+{ return(CONSTANT_FLOAT);     }
 	YY_BREAK
 	YY_BREAK
 case 34:
 case 34:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 81 "gmScanner.l"
 #line 81 "gmScanner.l"
-{ return(CONSTANT_STRING);    }
+{ return(CONSTANT_FLOAT);     }
 	YY_BREAK
 	YY_BREAK
 case 35:
 case 35:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 83 "gmScanner.l"
-{ return(KEYWORD_AND);        }
+#line 82 "gmScanner.l"
+{ return(CONSTANT_FLOAT);     }
 	YY_BREAK
 	YY_BREAK
 case 36:
 case 36:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 84 "gmScanner.l"
-{ return(KEYWORD_OR);         }
+#line 83 "gmScanner.l"
+{ return(CONSTANT_STRING);    }
 	YY_BREAK
 	YY_BREAK
 case 37:
 case 37:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 85 "gmScanner.l"
-{ return(SYMBOL_ASGN_BSR);    }
+#line 84 "gmScanner.l"
+{ return(CONSTANT_STRING);    }
 	YY_BREAK
 	YY_BREAK
 case 38:
 case 38:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 86 "gmScanner.l"
 #line 86 "gmScanner.l"
-{ return(SYMBOL_ASGN_BSL);    }
+{ return(KEYWORD_AND);        }
 	YY_BREAK
 	YY_BREAK
 case 39:
 case 39:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 87 "gmScanner.l"
 #line 87 "gmScanner.l"
-{ return(SYMBOL_ASGN_ADD);    }
+{ return(KEYWORD_OR);         }
 	YY_BREAK
 	YY_BREAK
 case 40:
 case 40:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 88 "gmScanner.l"
 #line 88 "gmScanner.l"
-{ return(SYMBOL_ASGN_MINUS);  }
+{ return(SYMBOL_ASGN_BSR);    }
 	YY_BREAK
 	YY_BREAK
 case 41:
 case 41:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 89 "gmScanner.l"
 #line 89 "gmScanner.l"
-{ return(SYMBOL_ASGN_TIMES);  }
+{ return(SYMBOL_ASGN_BSL);    }
 	YY_BREAK
 	YY_BREAK
 case 42:
 case 42:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 90 "gmScanner.l"
 #line 90 "gmScanner.l"
-{ return(SYMBOL_ASGN_DIVIDE); }
+{ return(SYMBOL_ASGN_ADD);    }
 	YY_BREAK
 	YY_BREAK
 case 43:
 case 43:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 91 "gmScanner.l"
 #line 91 "gmScanner.l"
-{ return(SYMBOL_ASGN_REM);    }
+{ return(SYMBOL_ASGN_MINUS);  }
 	YY_BREAK
 	YY_BREAK
 case 44:
 case 44:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 92 "gmScanner.l"
 #line 92 "gmScanner.l"
-{ return(SYMBOL_ASGN_BAND);   }
+{ return(SYMBOL_ASGN_TIMES);  }
 	YY_BREAK
 	YY_BREAK
 case 45:
 case 45:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 93 "gmScanner.l"
 #line 93 "gmScanner.l"
-{ return(SYMBOL_ASGN_BOR);    }
+{ return(SYMBOL_ASGN_DIVIDE); }
 	YY_BREAK
 	YY_BREAK
 case 46:
 case 46:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 94 "gmScanner.l"
 #line 94 "gmScanner.l"
-{ return(SYMBOL_ASGN_BXOR);   }
+{ return(SYMBOL_ASGN_REM);    }
 	YY_BREAK
 	YY_BREAK
 case 47:
 case 47:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 95 "gmScanner.l"
 #line 95 "gmScanner.l"
-{ return(SYMBOL_RIGHT_SHIFT); }
+{ return(SYMBOL_ASGN_BAND);   }
 	YY_BREAK
 	YY_BREAK
 case 48:
 case 48:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 96 "gmScanner.l"
 #line 96 "gmScanner.l"
-{ return(SYMBOL_LEFT_SHIFT);  }
+{ return(SYMBOL_ASGN_BOR);    }
 	YY_BREAK
 	YY_BREAK
 case 49:
 case 49:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 97 "gmScanner.l"
 #line 97 "gmScanner.l"
-{ return(SYMBOL_INC);         }
+{ return(SYMBOL_ASGN_BXOR);   }
 	YY_BREAK
 	YY_BREAK
 case 50:
 case 50:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 98 "gmScanner.l"
 #line 98 "gmScanner.l"
-{ return(SYMBOL_DEC);         }
+{ return(SYMBOL_RIGHT_SHIFT); }
 	YY_BREAK
 	YY_BREAK
 case 51:
 case 51:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 99 "gmScanner.l"
 #line 99 "gmScanner.l"
-{ return(SYMBOL_LTE);         }
+{ return(SYMBOL_LEFT_SHIFT);  }
 	YY_BREAK
 	YY_BREAK
 case 52:
 case 52:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 100 "gmScanner.l"
 #line 100 "gmScanner.l"
-{ return(SYMBOL_GTE);         }
+{ return(SYMBOL_INC);         }
 	YY_BREAK
 	YY_BREAK
 case 53:
 case 53:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 101 "gmScanner.l"
 #line 101 "gmScanner.l"
-{ return(SYMBOL_EQ);          }
+{ return(SYMBOL_DEC);         }
 	YY_BREAK
 	YY_BREAK
 case 54:
 case 54:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 102 "gmScanner.l"
 #line 102 "gmScanner.l"
-{ return(SYMBOL_NEQ);         }
+{ return(SYMBOL_LTE);         }
 	YY_BREAK
 	YY_BREAK
 case 55:
 case 55:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 103 "gmScanner.l"
 #line 103 "gmScanner.l"
-{ return(';');                }
+{ return(SYMBOL_GTE);         }
 	YY_BREAK
 	YY_BREAK
 case 56:
 case 56:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 104 "gmScanner.l"
 #line 104 "gmScanner.l"
-{ return('{');                }
+{ return(SYMBOL_EQ);          }
 	YY_BREAK
 	YY_BREAK
 case 57:
 case 57:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 105 "gmScanner.l"
 #line 105 "gmScanner.l"
-{ return('}');                }
+{ return(SYMBOL_NEQ);         }
 	YY_BREAK
 	YY_BREAK
 case 58:
 case 58:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 106 "gmScanner.l"
 #line 106 "gmScanner.l"
-{ return(',');                }
+{ return(';');                }
 	YY_BREAK
 	YY_BREAK
 case 59:
 case 59:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 107 "gmScanner.l"
 #line 107 "gmScanner.l"
-{ return('=');                }
+{ return('{');                }
 	YY_BREAK
 	YY_BREAK
 case 60:
 case 60:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 108 "gmScanner.l"
 #line 108 "gmScanner.l"
-{ return('(');                }
+{ return('}');                }
 	YY_BREAK
 	YY_BREAK
 case 61:
 case 61:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 109 "gmScanner.l"
 #line 109 "gmScanner.l"
-{ return(')');                }
+{ return(',');                }
 	YY_BREAK
 	YY_BREAK
 case 62:
 case 62:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 110 "gmScanner.l"
 #line 110 "gmScanner.l"
-{ return('[');                }
+{ return('=');                }
 	YY_BREAK
 	YY_BREAK
 case 63:
 case 63:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 111 "gmScanner.l"
 #line 111 "gmScanner.l"
-{ return(']');                }
+{ return('(');                }
 	YY_BREAK
 	YY_BREAK
 case 64:
 case 64:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 112 "gmScanner.l"
 #line 112 "gmScanner.l"
-{ return('.');                }
+{ return(')');                }
 	YY_BREAK
 	YY_BREAK
 case 65:
 case 65:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 113 "gmScanner.l"
 #line 113 "gmScanner.l"
-{ return('!');                }
+{ return('[');                }
 	YY_BREAK
 	YY_BREAK
 case 66:
 case 66:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 114 "gmScanner.l"
 #line 114 "gmScanner.l"
-{ return('-');                }
+{ return(']');                }
 	YY_BREAK
 	YY_BREAK
 case 67:
 case 67:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 115 "gmScanner.l"
 #line 115 "gmScanner.l"
-{ return('+');                }
+{ return('.');                }
 	YY_BREAK
 	YY_BREAK
 case 68:
 case 68:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 116 "gmScanner.l"
 #line 116 "gmScanner.l"
-{ return('*');                }
+{ return('!');                }
 	YY_BREAK
 	YY_BREAK
 case 69:
 case 69:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 117 "gmScanner.l"
 #line 117 "gmScanner.l"
-{ return('/');                }
+{ return('-');                }
 	YY_BREAK
 	YY_BREAK
 case 70:
 case 70:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 118 "gmScanner.l"
 #line 118 "gmScanner.l"
-{ return('%');                }
+{ return('+');                }
 	YY_BREAK
 	YY_BREAK
 case 71:
 case 71:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 119 "gmScanner.l"
 #line 119 "gmScanner.l"
-{ return('<');                }
+{ return('*');                }
 	YY_BREAK
 	YY_BREAK
 case 72:
 case 72:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 120 "gmScanner.l"
 #line 120 "gmScanner.l"
-{ return('>');                }
+{ return('/');                }
 	YY_BREAK
 	YY_BREAK
 case 73:
 case 73:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 121 "gmScanner.l"
 #line 121 "gmScanner.l"
-{ return('&');                }
+{ return('%');                }
 	YY_BREAK
 	YY_BREAK
 case 74:
 case 74:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 122 "gmScanner.l"
 #line 122 "gmScanner.l"
-{ return('|');                }
+{ return('<');                }
 	YY_BREAK
 	YY_BREAK
 case 75:
 case 75:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 123 "gmScanner.l"
 #line 123 "gmScanner.l"
-{ return('^');                }
+{ return('>');                }
 	YY_BREAK
 	YY_BREAK
 case 76:
 case 76:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 124 "gmScanner.l"
 #line 124 "gmScanner.l"
-{ return('~');                }
+{ return('&');                }
 	YY_BREAK
 	YY_BREAK
 case 77:
 case 77:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 125 "gmScanner.l"
 #line 125 "gmScanner.l"
-{ return(':');                }
+{ return('|');                }
 	YY_BREAK
 	YY_BREAK
 case 78:
 case 78:
 YY_RULE_SETUP
 YY_RULE_SETUP
 #line 126 "gmScanner.l"
 #line 126 "gmScanner.l"
-{ return(':');                }
+{ return('^');                }
 	YY_BREAK
 	YY_BREAK
 case 79:
 case 79:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 128 "gmScanner.l"
-{                             }
+#line 127 "gmScanner.l"
+{ return('~');                }
 	YY_BREAK
 	YY_BREAK
 case 80:
 case 80:
 YY_RULE_SETUP
 YY_RULE_SETUP
-#line 129 "gmScanner.l"
-{ return(TOKEN_ERROR);        }
+#line 128 "gmScanner.l"
+{ return(':');                }
 	YY_BREAK
 	YY_BREAK
 case 81:
 case 81:
 YY_RULE_SETUP
 YY_RULE_SETUP
+#line 129 "gmScanner.l"
+{ return(':');                }
+	YY_BREAK
+case 82:
+YY_RULE_SETUP
 #line 131 "gmScanner.l"
 #line 131 "gmScanner.l"
+{                             }
+	YY_BREAK
+case 83:
+YY_RULE_SETUP
+#line 132 "gmScanner.l"
+{ return(TOKEN_ERROR);        }
+	YY_BREAK
+case 84:
+YY_RULE_SETUP
+#line 134 "gmScanner.l"
 ECHO;
 ECHO;
 	YY_BREAK
 	YY_BREAK
-#line 1255 "gmScanner.cpp"
+#line 1280 "gmScanner.cpp"
 			case YY_STATE_EOF(INITIAL):
 			case YY_STATE_EOF(INITIAL):
 				yyterminate();
 				yyterminate();
 
 
@@ -1545,7 +1570,7 @@ static yy_state_type yy_get_previous_state()
 		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 			{
 			{
 			yy_current_state = (int) yy_def[yy_current_state];
 			yy_current_state = (int) yy_def[yy_current_state];
-			if ( yy_current_state >= 187 )
+			if ( yy_current_state >= 202 )
 				yy_c = yy_meta[(unsigned int) yy_c];
 				yy_c = yy_meta[(unsigned int) yy_c];
 			}
 			}
 		yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
 		yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1575,12 +1600,12 @@ yy_state_type yy_current_state;
 	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 		{
 		{
 		yy_current_state = (int) yy_def[yy_current_state];
 		yy_current_state = (int) yy_def[yy_current_state];
-		if ( yy_current_state >= 187 )
+		if ( yy_current_state >= 202 )
 			yy_c = yy_meta[(unsigned int) yy_c];
 			yy_c = yy_meta[(unsigned int) yy_c];
 		}
 		}
 	yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
 	yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
 	*yy_state_ptr++ = yy_current_state;
 	*yy_state_ptr++ = yy_current_state;
-	yy_is_jam = (yy_current_state == 186);
+	yy_is_jam = (yy_current_state == 201);
 
 
    return yy_is_jam ? 0 : yy_current_state;
    return yy_is_jam ? 0 : yy_current_state;
    }
    }
@@ -2118,7 +2143,7 @@ int main()
    return 0;
    return 0;
    }
    }
 #endif
 #endif
-#line 131 "gmScanner.l"
+#line 134 "gmScanner.l"
 
 
 
 
 // yywrap
 // yywrap

+ 3 - 0
gmsrc/src/gm/gmScanner.l

@@ -67,6 +67,9 @@ FL		    (f|F)
 "true"                            { return(KEYWORD_TRUE);       }
 "true"                            { return(KEYWORD_TRUE);       }
 "false"                           { return(KEYWORD_FALSE);      }
 "false"                           { return(KEYWORD_FALSE);      }
 "fork"                            { return(KEYWORD_FORK);       }
 "fork"                            { return(KEYWORD_FORK);       }
+"switch"                          { return(KEYWORD_SWITCH);     }
+"case"                            { return(KEYWORD_CASE);       }
+"default"                         { return(KEYWORD_DEFAULT);    }
 
 
 {LETTER}({LETTER}|{DIGIT})*       { return(IDENTIFIER);         }
 {LETTER}({LETTER}|{DIGIT})*       { return(IDENTIFIER);         }
                                                                 
                                                                 

Some files were not shown because too many files changed in this diff