-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #291 from ydah/fix-bug
Fix failed integration test for user defined parameterizing rules
- Loading branch information
Showing
11 changed files
with
182 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
spec/fixtures/integration/user_defined_parameterizing_rules.l
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
%option noinput nounput noyywrap never-interactive yylineno bison-bridge bison-locations | ||
|
||
%{ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include "user_defined_parameterizing_rules.h" | ||
|
||
int yycolumn = 0; | ||
|
||
#define YY_USER_ACTION \ | ||
yylloc->first_line = yylloc->last_line = yylineno; \ | ||
yylloc->first_column = yycolumn; \ | ||
yylloc->last_column = yycolumn + yyleng; \ | ||
yycolumn += yyleng; \ | ||
|
||
%} | ||
|
||
ODD [13579] | ||
EVEN [02468] | ||
|
||
%% | ||
|
||
{ODD} { | ||
yylval->num = atoi(yytext); | ||
return ODD; | ||
} | ||
|
||
{EVEN} { | ||
yylval->num = atoi(yytext); | ||
return EVEN; | ||
} | ||
|
||
[;] { | ||
return yytext[0]; | ||
} | ||
|
||
[\n|\r\n] { | ||
return(YYEOF); | ||
} | ||
|
||
[[:space:]] {} | ||
|
||
<<EOF>> { | ||
return(YYEOF); | ||
} | ||
|
||
. { | ||
fprintf(stderr, "Illegal character '%s'\n", yytext); | ||
return(YYEOF); | ||
} | ||
|
||
%% |
56 changes: 56 additions & 0 deletions
56
spec/fixtures/integration/user_defined_parameterizing_rules.y
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
%{ | ||
|
||
#define YYDEBUG 1 | ||
|
||
#include <stdio.h> | ||
|
||
#include "user_defined_parameterizing_rules.h" | ||
#include "user_defined_parameterizing_rules-lexer.h" | ||
|
||
static int yyerror(YYLTYPE *loc, const char *str); | ||
|
||
%} | ||
|
||
%expect 0 | ||
|
||
%union { | ||
int num; | ||
} | ||
|
||
%token <num> ODD EVEN | ||
|
||
%rule pair(X, Y): X Y { printf("(%d, %d)\n", $1, $2); } | ||
; | ||
|
||
%% | ||
|
||
program: stmts | ||
; | ||
|
||
stmts: separated_list(';', stmt) | ||
; | ||
|
||
stmt: pair(ODD, EVEN) { printf("pair odd even\n"); } | ||
| pair(EVEN, ODD) { printf("pair even odd\n"); } | ||
; | ||
|
||
%% | ||
|
||
static int yyerror(YYLTYPE *loc, const char *str) { | ||
fprintf(stderr, "parse error: %s\\n", str); | ||
return 0; | ||
} | ||
|
||
int main(int argc, char *argv[]) { | ||
yydebug = 1; | ||
|
||
if (argc == 2) { | ||
yy_scan_string(argv[1]); | ||
} | ||
|
||
if (yyparse()) { | ||
fprintf(stderr, "syntax error\n"); | ||
return 1; | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters