add proper C++ support
This commit is contained in:
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
def.tab.cc
|
||||||
|
def.tab.hh
|
||||||
|
def.tab.o
|
||||||
|
leks
|
||||||
|
lex.yy.cc
|
||||||
|
lex.yy.o
|
||||||
10
Makefile
10
Makefile
@@ -7,19 +7,19 @@ LD=gcc
|
|||||||
all: leks
|
all: leks
|
||||||
|
|
||||||
leks: def.tab.o lex.yy.o
|
leks: def.tab.o lex.yy.o
|
||||||
$(CXX) lex.yy.o def.tab.o -o leks -ll
|
$(CXX) -std=c++11 lex.yy.o def.tab.o -o leks -ll
|
||||||
|
|
||||||
lex.yy.o: lex.yy.cc
|
lex.yy.o: lex.yy.cc
|
||||||
$(CXX) -c lex.yy.cc
|
$(CXX) -std=c++11 -c lex.yy.cc
|
||||||
|
|
||||||
lex.yy.cc: z5.l
|
lex.yy.cc: z5.l
|
||||||
$(LEX) -c++ -o lex.yy.cc z5.l
|
$(LEX) -o lex.yy.cc z5.l
|
||||||
|
|
||||||
def.tab.o: def.tab.cc
|
def.tab.o: def.tab.cc
|
||||||
$(CXX) -c def.tab.cc
|
$(CXX) -std=c++11 -c def.tab.cc
|
||||||
|
|
||||||
def.tab.cc: def.yy
|
def.tab.cc: def.yy
|
||||||
$(YACC) -d def.yy
|
$(YACC) -d def.yy
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm *.o cutie def.tab.cc def.tab.hh def.yy.cc
|
rm *.o cutie def.tab.cc def.tab.hh lex.yy.*
|
||||||
|
|||||||
1621
def.tab.cc
1621
def.tab.cc
File diff suppressed because it is too large
Load Diff
77
def.tab.hh
77
def.tab.hh
@@ -1,77 +0,0 @@
|
|||||||
/* A Bison parser, made by GNU Bison 2.3. */
|
|
||||||
|
|
||||||
/* Skeleton interface for Bison's Yacc-like parsers in C
|
|
||||||
|
|
||||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
|
||||||
Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2, or (at your option)
|
|
||||||
any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA. */
|
|
||||||
|
|
||||||
/* As a special exception, you may create a larger work that contains
|
|
||||||
part or all of the Bison parser skeleton and distribute that work
|
|
||||||
under terms of your choice, so long as that work isn't itself a
|
|
||||||
parser generator using the skeleton or a modified version thereof
|
|
||||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
|
||||||
the parser skeleton itself, you may (at your option) remove this
|
|
||||||
special exception, which will cause the skeleton and the resulting
|
|
||||||
Bison output files to be licensed under the GNU General Public
|
|
||||||
License without this special exception.
|
|
||||||
|
|
||||||
This special exception was added by the Free Software Foundation in
|
|
||||||
version 2.2 of Bison. */
|
|
||||||
|
|
||||||
/* Tokens. */
|
|
||||||
#ifndef YYTOKENTYPE
|
|
||||||
# define YYTOKENTYPE
|
|
||||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
|
||||||
know about them. */
|
|
||||||
enum yytokentype {
|
|
||||||
ID = 258,
|
|
||||||
INT_LIT = 259,
|
|
||||||
LET = 260,
|
|
||||||
INT_TYPE = 261,
|
|
||||||
SEMICOLON = 262,
|
|
||||||
COLON = 263
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
/* Tokens. */
|
|
||||||
#define ID 258
|
|
||||||
#define INT_LIT 259
|
|
||||||
#define LET 260
|
|
||||||
#define INT_TYPE 261
|
|
||||||
#define SEMICOLON 262
|
|
||||||
#define COLON 263
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
|
||||||
typedef union YYSTYPE
|
|
||||||
#line 14 "def.yy"
|
|
||||||
{
|
|
||||||
char *text;
|
|
||||||
int ival;
|
|
||||||
}
|
|
||||||
/* Line 1529 of yacc.c. */
|
|
||||||
#line 70 "def.tab.hh"
|
|
||||||
YYSTYPE;
|
|
||||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
|
||||||
# define YYSTYPE_IS_DECLARED 1
|
|
||||||
# define YYSTYPE_IS_TRIVIAL 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern YYSTYPE yylval;
|
|
||||||
|
|
||||||
5
def.yy
5
def.yy
@@ -5,10 +5,11 @@
|
|||||||
#define INFILE_ERROR 1
|
#define INFILE_ERROR 1
|
||||||
#define OUTFILE_ERROR 2
|
#define OUTFILE_ERROR 2
|
||||||
|
|
||||||
extern int yylex(void);
|
|
||||||
extern void yyerror(const char *s);
|
|
||||||
extern int yylineno;
|
extern int yylineno;
|
||||||
extern FILE *yyin;
|
extern FILE *yyin;
|
||||||
|
int yylex();
|
||||||
|
|
||||||
|
void yyerror(const char *msg, ...);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%union {
|
%union {
|
||||||
|
|||||||
6
z5.l
6
z5.l
@@ -7,8 +7,7 @@
|
|||||||
#define INFILE_ERROR 1
|
#define INFILE_ERROR 1
|
||||||
#define OUTFILE_ERROR 2
|
#define OUTFILE_ERROR 2
|
||||||
|
|
||||||
extern int yylineno;
|
void yyerror(const char *msg, ...);
|
||||||
void yyerror(char *msg, ...);
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%option noyywrap
|
%option noyywrap
|
||||||
@@ -38,7 +37,8 @@ void yyerror(char *msg, ...);
|
|||||||
\n {yylineno++;}
|
\n {yylineno++;}
|
||||||
. {yyerror("Blad leksykalny\n");}
|
. {yyerror("Blad leksykalny\n");}
|
||||||
%%
|
%%
|
||||||
void yyerror(char *msg, ...)
|
|
||||||
|
void yyerror(const char *msg, ...)
|
||||||
{
|
{
|
||||||
printf("%d: %s", yylineno, msg);
|
printf("%d: %s", yylineno, msg);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user