add initial empty C, flex, and bison sources
This commit is contained in:
1 parent
8d8c08cd85
commit
3ead22e0cf
5 files changed
+84
-2
No files matched your search
@@ -0,0 +1,4 @@
|
||||
#ifndef PARSER_H
|
||||
#define PARSER_H
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,15 @@
|
||||
%option nounput
|
||||
%option bison-locations
|
||||
|
||||
%{
|
||||
|
||||
#include "parser.h"
|
||||
#include "parser.tab.h"
|
||||
|
||||
%}
|
||||
|
||||
%x str
|
||||
|
||||
%%
|
||||
|
||||
%%
|
||||
@@ -0,0 +1,38 @@
|
||||
%{
|
||||
|
||||
#include <stdio.h>
|
||||
#include "parser.h"
|
||||
#include "parser.tab.h"
|
||||
|
||||
#define yyerror(msg) handle_error(msg, &yyloc)
|
||||
|
||||
int yylex(YYSTYPE *, YYLTYPE *);
|
||||
static void handle_error(const char * str, const YYLTYPE * yylloc);
|
||||
|
||||
%}
|
||||
|
||||
%pure-parser
|
||||
%locations
|
||||
%error-verbose
|
||||
|
||||
%token PLUS;
|
||||
%token MINUS;
|
||||
|
||||
%%
|
||||
|
||||
translation_unit: PLUS;
|
||||
|
||||
%%
|
||||
|
||||
static void handle_error(const char * str, const YYLTYPE * yylloc)
|
||||
{
|
||||
fprintf(stderr, "error: %s (line %d, column %d)\n",
|
||||
str,
|
||||
yylloc->first_line,
|
||||
yylloc->first_column);
|
||||
}
|
||||
|
||||
int yywrap(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
Reference in new issue
Block a user