Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: enginmanap/Pas2C
base: 57c14432d6
...
head fork: enginmanap/Pas2C
compare: 7c8650e875
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 12 additions and 9 deletions.
  1. +7 −1 pascal.l
  2. +5 −8 pascal.y
View
8 pascal.l
@@ -7,6 +7,8 @@
digit [0-9]
alpha [a-zA-Z]
variable {alpha}({alpha}|{digit})*
+const_string L?\"(\\.|[^\\"])*\"
+
%%
@@ -24,9 +26,13 @@ variable {alpha}({alpha}|{digit})*
yylval.str = strdup(yytext);
return VARIABLE;
}
+{const_string} {
+ yylval.str = strdup(yytext);
+ return CONST_STRING;
+ }
[0-9]+ {
yylval.num = atoi(yytext);
- return INTEGER;
+ return CONST_INTEGER;
}
[-+/*()] return *yytext;
; return SEMICOLON;
View
13 pascal.y
@@ -10,7 +10,8 @@
char* str;
}
-%token <num> INTEGER
+%token <num> CONST_INTEGER
+%token <str> CONST_STRING
%token BLOCK_BEGIN
%token BLOCK_END
%token DEF_INTEGER
@@ -23,7 +24,7 @@
%token <str> VARIABLE
-%type <str> program block math definition assignment stmt stmt_list main_block program_definition function var_list const_string
+%type <str> program block math definition assignment stmt stmt_list main_block program_definition function const_string
%type <num> const_val
%%
@@ -40,7 +41,7 @@ main_block:
BLOCK_BEGIN stmt_list BLOCK_END PERIOD { $$ = strconcat("{", strconcat($2,"}")); }
const_val:
- INTEGER { $$ = $1; }
+ CONST_INTEGER { $$ = $1; }
block:
BLOCK_BEGIN stmt_list BLOCK_END SEMICOLON { $$ = strconcat("{", strconcat($2,"}")); }
@@ -71,12 +72,8 @@ function:
VARIABLE '(' VARIABLE ')' SEMICOLON { $$ = strconcat(findCVariant($1), strconcat("(", strconcat($3, strconcat(")", ";")))); }
| VARIABLE '(' const_string ')' SEMICOLON { $$ = strconcat(findCVariant($1), strconcat("(", strconcat($3, strconcat(")", ";")))); }
-var_list:
- VARIABLE { $$ = $1; }
- | var_list VARIABLE { $$ = strconcat($1, strconcat(" ",$2)); }
-
const_string:
- DOUBLE_QUOTES var_list DOUBLE_QUOTES { $$ = strconcat("\"", strconcat($2, "\"")); }
+ CONST_STRING { $$ = $1; }
%%

No commit comments for this range

Something went wrong with that request. Please try again.