-
Notifications
You must be signed in to change notification settings - Fork 28
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 #446 from ydah/locations
Ensure compatibility with Bison for `%locations`
- Loading branch information
Showing
25 changed files
with
657 additions
and
525 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
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 |
---|---|---|
|
@@ -40,6 +40,7 @@ class Lexer | |
%rule | ||
%no-stdlib | ||
%inline | ||
%locations | ||
) | ||
|
||
def initialize(grammar_file) | ||
|
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
Large diffs are not rendered by default.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,8 @@ after_pop_stack(int len) | |
%left '+' '-' | ||
%left '*' '/' | ||
|
||
%locations | ||
|
||
%% | ||
|
||
program : /* empty */ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
%option noinput nounput noyywrap never-interactive yylineno bison-bridge bison-locations | ||
|
||
%{ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include "prologue_epilogue_optional.h" | ||
|
||
%} | ||
|
||
NUMBER [0-9]+ | ||
|
||
%% | ||
|
||
{NUMBER} { | ||
((void) yylloc); | ||
yylval->val = atoi(yytext); | ||
return 1; | ||
} | ||
|
||
[+\-\*\/\(\)] { | ||
return yytext[0]; | ||
} | ||
|
||
[\n|\r\n] { | ||
return(YYEOF); | ||
} | ||
|
||
[[:space:]] {} | ||
|
||
<<EOF>> { | ||
return(YYEOF); | ||
} | ||
|
||
. { | ||
fprintf(stderr, "Illegal character '%s'\n", yytext); | ||
return(YYEOF); | ||
} | ||
|
||
%% |
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,37 @@ | ||
%{ | ||
|
||
#include <stdio.h> | ||
#include "contains_at_reference.h" | ||
#include "contains_at_reference-lexer.h" | ||
|
||
static int yyerror(YYLTYPE *loc, const char *str); | ||
|
||
%} | ||
|
||
%union { | ||
int val; | ||
} | ||
|
||
%% | ||
|
||
program : /* empty */ { (void)@1; } | ||
; | ||
|
||
%% | ||
|
||
static int yyerror(YYLTYPE *loc, const char *str) { | ||
fprintf(stderr, "parse error: %s\n", str); | ||
return 0; | ||
} | ||
|
||
int main(int argc, char *argv[]) { | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,8 @@ line_1(void) | |
|
||
%token <i> NUM | ||
|
||
%locations | ||
|
||
%% | ||
|
||
program : { | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ static int yyerror(YYLTYPE *loc, const char *str); | |
int val; | ||
} | ||
|
||
%locations | ||
|
||
%% | ||
|
||
program : /* empty */ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,8 @@ static int yyerror(YYLTYPE *loc, const char *str); | |
} | ||
; | ||
|
||
%locations | ||
|
||
%% | ||
|
||
program: stmts | ||
|
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