Permalink
Browse files

Merge pull request #11 from cknadler/master

Adds tokens to grammar.
  • Loading branch information...
2 parents 0319e07 + e4a104e commit 736bf6c680a2107731bd2ecedf778cbdc1d600a6 @dasmoose dasmoose committed Sep 10, 2012
Showing with 96 additions and 0 deletions.
  1. +48 −0 src/lex.yy.l
  2. +48 −0 src/y.tab.y
View
@@ -20,6 +20,7 @@ extern int yyerror(const char* msg);
"while" return HKL_T_WHILE;
"end" return HKL_T_END;
"return" return HKL_T_RETURN;
+"break" return HKL_T_BREAK;
"class" return HKL_T_CLASS;
"function" return HKL_T_FUNCTION;
@@ -51,11 +52,25 @@ extern int yyerror(const char* msg);
"prototype" return HKL_T_PROTOTYPE;
"protected" return HKL_T_PROTECTED;
+"true" return HKL_T_TRUE;
+"false" return HKL_T_FALSE;
+
+"int" return HKL_T_TYPE_INT;
+"real" return HKL_T_TYPE_REAL;
+"string" return HKL_T_TYPE_STRING;
+"array" return HKL_T_TYPE_ARRAY;
+"hash" return HKL_T_TYPE_HASH;
+
"puts" return HKL_T_PUTS;
"gets" return HKL_T_GETS;
"include" return HKL_T_INCLUDE;
+"assert" return HKL_T_ASSERT;
+
+"typeof" return HKL_T_TYPE_OF;
+"instanceof" return HKL_T_INSTANCE_OF;
+
"(" return HKL_T_LPAREN;
")" return HKL_T_RPAREN;
"{" return HKL_T_LBRACE;
@@ -65,5 +80,38 @@ extern int yyerror(const char* msg);
"," return HKL_T_COMMA;
"." return HKL_T_DOT;
+"!" return HKL_T_NOT;
+"||" return HKL_T_OR;
+"&&" return HKL_T_AND;
+"<=" return HKL_T_LESS_EQUAL;
+">=" return HKL_T_GREATER_EQUAL;
+"<" return HKL_T_LESS;
+">" return HKL_T_GREATER;
+"==" return HKL_T_EQUAL;
+"!=" return HKL_T_NOT_EQUAL;
+
+"+" return HKL_T_PLUS;
+"-" return HKL_T_MINUS;
+"*" return HKL_T_ASTERISK;
+"/" return HKL_T_DIVIDE;
+"%" return HKL_T_MOD;
+"~" return HKL_T_BITWISE_NOT;
+"&" return HKL_T_BITWISE_AND;
+"|" return HKL_T_BITWISE_OR;
+"^" return HKL_T_BITWISE_XOR;
+
+"=" return HKL_T_ASSIGN;
+"+=" return HKL_T_PLUS_EQUAL;
+"-=" return HKL_T_MINUS_EQUAL;
+"*=" return HKL_T_ASTERISK_EQUAL;
+"/=" return HKL_T_DIVIDE_EQUAL;
+"%=" return HKL_T_MOD_EQUAL;
+"&=" return HKL_T_BITWISE_AND_EQUAL;
+"|=" return HKL_T_BITWISE_OR_EQUAL;
+"^=" return HKL_T_XOR_EQUAL;
+
+"++" return HKL_T_INCREMENT;
+"--" return HKL_T_DECREMENT;
+
. yyerror(yytext);
View
@@ -26,6 +26,7 @@
%token HKL_T_WHILE
%token HKL_T_END
%token HKL_T_RETURN
+%token HKL_T_BREAK
%token HKL_T_CLASS
%token HKL_T_FUNCTION
@@ -43,11 +44,25 @@
%token HKL_T_PROTOTYPE
%token HKL_T_PROTECTED
+%token HKL_T_TRUE
+%token HKL_T_FALSE
+
+%token HKL_T_TYPE_INT
+%token HKL_T_TYPE_REAL
+%token HKL_T_TYPE_STRING
+%token HKL_T_TYPE_ARRAY
+%token HKL_T_TYPE_HASH
+
%token HKL_T_PUTS
%token HKL_T_GETS
%token HKL_T_INCLUDE
+%token HKL_T_ASSERT
+
+%token HKL_T_TYPE_OF
+%token HKL_T_INSTANCE_OF
+
%token HKL_T_LPAREN
%token HKL_T_RPAREN
%token HKL_T_LBRACE
@@ -57,6 +72,39 @@
%token HKL_T_COMMA
%token HKL_T_DOT
+%token HKL_T_NOT
+%token HKL_T_OR
+%token HKL_T_AND
+%token HKL_T_LESS_EQUAL
+%token HKL_T_GREATER_EQUAL
+%token HKL_T_LESS
+%token HKL_T_GREATER
+%token HKL_T_EQUAL
+%token HKL_T_NOT_EQUAL
+
+%token HKL_T_PLUS
+%token HKL_T_MINUS
+%token HKL_T_ASTERISK
+%token HKL_T_DIVIDE
+%token HKL_T_MOD
+%token HKL_T_BITWISE_NOT
+%token HKL_T_BITWISE_AND
+%token HKL_T_BITWISE_OR
+%token HKL_T_BITWISE_XOR
+
+%token HKL_T_ASSIGN
+%token HKL_T_PLUS_EQUAL
+%token HKL_T_MINUS_EQUAL
+%token HKL_T_ASTERISK_EQUAL
+%token HKL_T_DIVIDE_EQUAL
+%token HKL_T_MOD_EQUAL
+%token HKL_T_BITWISE_AND_EQUAL
+%token HKL_T_BITWISE_OR_EQUAL
+%token HKL_T_XOR_EQUAL
+
+%token HKL_T_INCREMENT
+%token HKL_T_DECREMENT
+
// HKL Grammar
%%

0 comments on commit 736bf6c

Please sign in to comment.