From 3fc42f8828f07e54d36f317a9eab9bf5692d1da9 Mon Sep 17 00:00:00 2001 From: dorley174 Date: Wed, 5 Nov 2025 03:27:21 +0300 Subject: [PATCH 1/7] new --- Makefile | 21 + README.md | 1 - ast.h | 84 --- ast.hpp | 72 ++ lex.yy.cc | 1794 -------------------------------------------- lexer | Bin 154768 -> 0 bytes lexer.cpp | 1974 ------------------------------------------------- lexer.l | 221 ++---- main.cpp | 42 +- mycompiler | Bin 108896 -> 0 bytes parser.cpp | 1799 -------------------------------------------- parser.hpp | 122 --- parser.tab.cc | 1279 -------------------------------- parser.tab.hh | 827 --------------------- parser.y | 274 +++---- stack.hh | 8 - tokens.hpp | 86 +++ 17 files changed, 399 insertions(+), 8205 deletions(-) create mode 100644 Makefile delete mode 100644 README.md delete mode 100644 ast.h create mode 100644 ast.hpp delete mode 100644 lex.yy.cc delete mode 100644 lexer delete mode 100644 lexer.cpp delete mode 100644 mycompiler delete mode 100644 parser.cpp delete mode 100644 parser.hpp delete mode 100644 parser.tab.cc delete mode 100644 parser.tab.hh delete mode 100644 stack.hh create mode 100644 tokens.hpp diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..bb9400c --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +CXX=g++ +CXXFLAGS=-std=c++17 -O2 +LEX=flex +YACC=bison + +all: mycompiler + +parser.cpp parser.tab.h: parser.y + $(YACC) -d parser.y -o parser.cpp + +lexer.cpp: lexer.l parser.tab.h + $(LEX) -o lexer.cpp lexer.l + +mycompiler: parser.cpp lexer.cpp main.cpp tokens.hpp ast.hpp + $(CXX) $(CXXFLAGS) -o mycompiler parser.cpp lexer.cpp main.cpp -lfl + +run: + ./mycompiler tests/test1.o + +clean: + rm -f mycompiler parser.cpp parser.tab.h lexer.cpp diff --git a/README.md b/README.md deleted file mode 100644 index d0e2dec..0000000 --- a/README.md +++ /dev/null @@ -1 +0,0 @@ -This is repo with compiler writen using C++ && Flex && Bison parser diff --git a/ast.h b/ast.h deleted file mode 100644 index c9599cf..0000000 --- a/ast.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef AST_H -#define AST_H - -#include -#include -#include -#include - -using namespace std; - -struct ASTNode { - virtual ~ASTNode() = default; - virtual void print(int indent=0) const = 0; -}; - -using ASTNodePtr = unique_ptr; - -static string indentStr(int n) { return string(n, ' '); } - -struct ProgramNode : ASTNode { - vector decls; - void print(int indent=0) const override { - cout << indentStr(indent) << "Program\n"; - for (auto &d : decls) d->print(indent+2); - } -}; - -struct ClassNode : ASTNode { - string name; - string extendsName; - vector members; - ClassNode(const string &n="") : name(n) {} - void print(int indent=0) const override { - cout << indentStr(indent) << "Class: " << name; - if (!extendsName.empty()) cout << " extends " << extendsName; - cout << "\n"; - for (auto &m : members) m->print(indent+2); - } -}; - -struct VarNode : ASTNode { - string name; - string type; - VarNode(const string &n="", const string &t="") : name(n), type(t) {} - void print(int indent=0) const override { - cout << indentStr(indent) << "Var: " << name; - if (!type.empty()) cout << " : " << type; - cout << "\n"; - } -}; - -struct MethodNode : ASTNode { - string name; - vector params; - vector body; - MethodNode(const string &n="") : name(n) {} - void print(int indent=0) const override { - cout << indentStr(indent) << "Method: " << name << "\n"; - for (auto &b : body) b->print(indent+2); - } -}; - -extern unique_ptr g_program; - -struct SimpleToken { - string kind; - string text; - int line; - int startCol; - int endCol; - - SimpleToken() = default; - SimpleToken(const string& k, const string& t, int l, int sc, int ec) - : kind(k), text(t), line(l), startCol(sc), endCol(ec) {} -}; -extern std::vector simpleTokens; - -extern size_t parserTokIndex; - -void yyerror(const char *s); -int yylex(); -void printAST(); - -#endif // AST_H diff --git a/ast.hpp b/ast.hpp new file mode 100644 index 0000000..fbed63f --- /dev/null +++ b/ast.hpp @@ -0,0 +1,72 @@ +// ast.hpp +#pragma once +#include +#include +#include +#include + +namespace AST { + +struct Node { virtual ~Node() = default; }; + +struct TypeName : Node { + std::string name; + explicit TypeName(std::string n) : name(std::move(n)) {} +}; + +struct Expr : Node { virtual void print(std::ostream& os) const = 0; }; + +struct IntLiteral : Expr { + long long value; + explicit IntLiteral(long long v) : value(v) {} + void print(std::ostream& os) const override { os << value; } +}; + +struct IdExpr : Expr { + std::string name; + explicit IdExpr(std::string n) : name(std::move(n)) {} + void print(std::ostream& os) const override { os << name; } +}; + +struct BinExpr : Expr { + char op; + std::unique_ptr lhs, rhs; + BinExpr(char op, std::unique_ptr l, std::unique_ptr r) + : op(op), lhs(std::move(l)), rhs(std::move(r)) {} + void print(std::ostream& os) const override { + lhs->print(os); os << " " << op << " "; rhs->print(os); + } +}; + +struct VarDecl : Node { + std::string name; + std::unique_ptr type; + std::unique_ptr init; // опционально + VarDecl(std::string n, std::unique_ptr t, std::unique_ptr i = {}) + : name(std::move(n)), type(std::move(t)), init(std::move(i)) {} +}; + +struct ClassDecl : Node { + std::string name; + std::vector> fields; + explicit ClassDecl(std::string n) : name(std::move(n)) {} +}; + +struct Program : Node { + std::vector> classes; + void printNormalized(std::ostream& os) const { + for (auto& c : classes) { + os << "Class: " << c->name << "\n"; + for (auto& v : c->fields) { + os << "var " << v->name << " : " << v->type->name; + if (v->init) { + os << " = "; + v->init->print(os); + } + os << "\n"; + } + } + } +}; + +} // namespace AST diff --git a/lex.yy.cc b/lex.yy.cc deleted file mode 100644 index aee928e..0000000 --- a/lex.yy.cc +++ /dev/null @@ -1,1794 +0,0 @@ -#line 2 "lex.yy.cc" - -#line 4 "lex.yy.cc" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 4 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - - /* The c++ scanner is a mess. The FlexLexer.h header file relies on the - * following macro. This is required in order to pass the c++-multiple-scanners - * test in the regression suite. We get reports that it breaks inheritance. - * We will address this in a future release of flex, or omit the C++ scanner - * altogether. - */ - #define yyFlexLexer yyFlexLexer - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#ifndef SIZE_MAX -#define SIZE_MAX (~(size_t)0) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -/* begin standard C++ headers. */ -#include -#include -#include -#include -#include -/* end standard C++ headers. */ - -/* TODO: this is always defined, so inline it */ -#define yyconst const - -#if defined(__GNUC__) && __GNUC__ >= 3 -#define yynoreturn __attribute__((__noreturn__)) -#else -#define yynoreturn -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an - * integer in range [0..255] for use as an array index. - */ -#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN (yy_start) = 1 + 2 * -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START (((yy_start) - 1) / 2) -#define YYSTATE YY_START -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin ) -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -extern int yyleng; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - #define YY_LESS_LINENO(n) - #define YY_LINENO_REWIND_TO(ptr) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = (yy_hold_char); \ - YY_RESTORE_YY_MORE_OFFSET \ - (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) -#define unput(c) yyunput( c, (yytext_ptr) ) - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - - std::streambuf* yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ - ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ - : NULL) -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] - -void *yyalloc ( yy_size_t ); -void *yyrealloc ( void *, yy_size_t ); -void yyfree ( void * ); - -#define yy_new_buffer yy_create_buffer -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ -#define YY_SKIP_YYWRAP -typedef flex_uint8_t YY_CHAR; - -#define yytext_ptr yytext -#define YY_INTERACTIVE - -#include - -int yyFlexLexer::yywrap() { return 1; } - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - (yytext_ptr) = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ - (yy_hold_char) = *yy_cp; \ - *yy_cp = '\0'; \ - (yy_c_buf_p) = yy_cp; -#define YY_NUM_RULES 10 -#define YY_END_OF_BUFFER 11 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static const flex_int16_t yy_accept[44] = - { 0, - 0, 0, 11, 9, 1, 2, 9, 9, 8, 5, - 6, 6, 6, 6, 6, 6, 6, 1, 2, 0, - 7, 0, 0, 5, 6, 6, 6, 6, 3, 6, - 6, 6, 4, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 0 - } ; - -static const YY_CHAR yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 5, 1, 1, 1, 1, 1, 6, - 6, 6, 6, 6, 6, 7, 6, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 1, 6, 6, - 6, 6, 1, 1, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 1, 10, 1, 1, 9, 1, 11, 9, 9, 9, - - 12, 13, 9, 14, 15, 9, 9, 16, 9, 17, - 18, 9, 9, 19, 20, 21, 22, 9, 23, 9, - 9, 9, 6, 1, 6, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static const YY_CHAR yy_meta[24] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2 - } ; - -static const flex_int16_t yy_base[46] = - { 0, - 0, 0, 63, 64, 60, 64, 58, 19, 64, 18, - 0, 44, 16, 46, 46, 38, 42, 53, 64, 23, - 64, 51, 45, 23, 0, 32, 35, 31, 0, 28, - 26, 32, 38, 33, 24, 21, 30, 25, 28, 20, - 26, 20, 64, 34, 30 - } ; - -static const flex_int16_t yy_def[46] = - { 0, - 43, 1, 43, 43, 43, 43, 43, 44, 43, 43, - 45, 45, 45, 45, 45, 45, 45, 43, 43, 44, - 43, 44, 43, 43, 45, 45, 45, 45, 45, 45, - 45, 45, 43, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 0, 43, 43 - } ; - -static const flex_int16_t yy_nxt[88] = - { 0, - 4, 5, 6, 7, 8, 9, 4, 10, 11, 4, - 11, 12, 13, 11, 14, 11, 11, 11, 15, 11, - 16, 11, 17, 21, 23, 24, 27, 21, 22, 23, - 24, 25, 22, 28, 20, 20, 29, 29, 42, 29, - 41, 29, 40, 39, 29, 33, 38, 37, 36, 29, - 35, 34, 33, 43, 18, 32, 31, 30, 29, 26, - 19, 18, 43, 3, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43 - } ; - -static const flex_int16_t yy_chk[88] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 8, 10, 10, 13, 20, 8, 24, - 24, 45, 20, 13, 44, 44, 42, 41, 40, 39, - 38, 37, 36, 35, 34, 33, 32, 31, 30, 28, - 27, 26, 23, 22, 18, 17, 16, 15, 14, 12, - 7, 5, 3, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43 - } ; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -#line 1 "lexer.l" -#line 4 "lexer.l" -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -class Token { -public: - int line; - int startCol; - int endCol; - - Token(int l, int s, int e) : line(l), startCol(s), endCol(e) {} - virtual ~Token() = default; - virtual void print() const = 0; -}; - -class KeywordToken : public Token { -public: - string value; - KeywordToken(const string& val, int l, int s, int e) : Token(l,s,e), value(val) {} - void print() const override { cout << "KEYWORD(" << value << ")\n"; } -}; - -class IdentifierToken : public Token { -public: - string name; - IdentifierToken(const string& n, int l, int s, int e) : Token(l,s,e), name(n) {} - void print() const override { cout << "IDENTIFIER(" << name << ")\n"; } -}; - -class IntegerToken : public Token { -public: - int value; - IntegerToken(int v, int l, int s, int e) : Token(l,s,e), value(v) {} - void print() const override { cout << "INTEGER(" << value << ")\n"; } -}; - -class RealToken : public Token { -public: - double value; - RealToken(double v, int l, int s, int e) : Token(l,s,e), value(v) {} - void print() const override { cout << "REAL(" << value << ")\n"; } -}; - -class BooleanToken : public Token { -public: - string value; - BooleanToken(const string& v, int l, int s, int e) : Token(l,s,e), value(v) {} - void print() const override { cout << "BOOLEAN(" << value << ")\n"; } -}; - -class StringToken : public Token { -public: - string value; - StringToken(const string& v, int l, int s, int e) : Token(l,s,e), value(v) {} - void print() const override { cout << "STRING(\"" << value << "\")\n"; } -}; - -class SymbolToken : public Token { -public: - string symbol; - SymbolToken(const string& s, int l, int sc, int ec) : Token(l,sc,ec), symbol(s) {} - void print() const override { cout << "SYMBOL(" << symbol << ")\n"; } -}; - -class UnknownToken : public Token { -public: - string text; - UnknownToken(const string& t, int l, int s, int e) : Token(l,s,e), text(t) {} - void print() const override { cout << "UNKNOWN(" << text << ")\n"; } -}; - -vector> tokens; -int currentLine = 1; -int currentCol = 1; - -struct SimpleToken { - string kind; - string text; - int line; - int startCol; - int endCol; -}; -vector simpleTokens; - -static inline void addToken(unique_ptr t) { - SimpleToken st; - st.line = t->line; - st.startCol = t->startCol; - st.endCol = t->endCol; - - if (auto *p = dynamic_cast(t.get())) { - st.kind = "KEYWORD"; st.text = p->value; - } else if (auto *p = dynamic_cast(t.get())) { - st.kind = "IDENTIFIER"; st.text = p->name; - } else if (auto *p = dynamic_cast(t.get())) { - st.kind = "INTEGER"; st.text = to_string(p->value); - } else if (auto *p = dynamic_cast(t.get())) { - st.kind = "REAL"; st.text = to_string(p->value); - } else if (auto *p = dynamic_cast(t.get())) { - st.kind = "BOOLEAN"; st.text = p->value; - } else if (auto *p = dynamic_cast(t.get())) { - st.kind = "STRING"; st.text = p->value; - } else if (auto *p = dynamic_cast(t.get())) { - st.kind = "SYMBOL"; st.text = p->symbol; - } else if (auto *p = dynamic_cast(t.get())) { - st.kind = "UNKNOWN"; st.text = p->text; - } - - simpleTokens.push_back(st); - tokens.push_back(move(t)); -} -#line 545 "lex.yy.cc" -#line 546 "lex.yy.cc" - -#define INITIAL 0 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy ( char *, const char *, int ); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen ( const char * ); -#endif - -#ifndef YY_NO_INPUT - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -#define ECHO LexerOutput( yytext, yyleng ) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ -\ - if ( (int)(result = LexerInput( (char *) buf, max_size )) < 0 ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) LexerError( msg ) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 -#define YY_DECL int yyFlexLexer::yylex() -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK /*LINTED*/break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - yy_state_type yy_current_state; - char *yy_cp, *yy_bp; - int yy_act; - - if ( !(yy_init) ) - { - (yy_init) = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! (yy_start) ) - (yy_start) = 1; /* first start state */ - - if ( ! yyin ) - yyin.rdbuf(std::cin.rdbuf()); - - if ( ! yyout ) - yyout.rdbuf(std::cout.rdbuf()); - - if ( ! YY_CURRENT_BUFFER ) { - yyensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE ); - } - - yy_load_buffer_state( ); - } - - { -#line 123 "lexer.l" - - -#line 681 "lex.yy.cc" - - while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ - { - yy_cp = (yy_c_buf_p); - - /* Support of yytext. */ - *yy_cp = (yy_hold_char); - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = (yy_start); -yy_match: - do - { - YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 44 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 64 ); - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - if ( yy_act == 0 ) - { /* have to back up */ - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); - yy_act = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = (yy_hold_char); - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 125 "lexer.l" -{ currentCol += yyleng; } - YY_BREAK -case 2: -/* rule 2 can match eol */ -YY_RULE_SETUP -#line 126 "lexer.l" -{ currentLine++; currentCol = 1; } - YY_BREAK -case 3: -YY_RULE_SETUP -#line 128 "lexer.l" -{ - addToken(make_unique(yytext, currentLine, currentCol, currentCol + yyleng - 1)); - currentCol += yyleng; -} - YY_BREAK -case 4: -YY_RULE_SETUP -#line 133 "lexer.l" -{ - addToken(make_unique(stod(yytext), currentLine, currentCol, currentCol + yyleng - 1)); - currentCol += yyleng; -} - YY_BREAK -case 5: -YY_RULE_SETUP -#line 138 "lexer.l" -{ - addToken(make_unique(stoi(yytext), currentLine, currentCol, currentCol + yyleng - 1)); - currentCol += yyleng; -} - YY_BREAK -case 6: -YY_RULE_SETUP -#line 143 "lexer.l" -{ - addToken(make_unique(yytext, currentLine, currentCol, currentCol + yyleng - 1)); - currentCol += yyleng; -} - YY_BREAK -case 7: -/* rule 7 can match eol */ -YY_RULE_SETUP -#line 148 "lexer.l" -{ - string val(yytext + 1, yyleng - 2); - addToken(make_unique(val, currentLine, currentCol, currentCol + yyleng - 1)); - currentCol += yyleng; -} - YY_BREAK -case 8: -YY_RULE_SETUP -#line 154 "lexer.l" -{ - addToken(make_unique(yytext, currentLine, currentCol, currentCol + yyleng - 1)); - currentCol += yyleng; -} - YY_BREAK -case 9: -YY_RULE_SETUP -#line 159 "lexer.l" -{ - addToken(make_unique(yytext, currentLine, currentCol, currentCol + yyleng - 1)); - currentCol += yyleng; -} - YY_BREAK -case 10: -YY_RULE_SETUP -#line 164 "lexer.l" -ECHO; - YY_BREAK -#line 812 "lex.yy.cc" -case YY_STATE_EOF(INITIAL): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = (yy_hold_char); - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin.rdbuf(); - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++(yy_c_buf_p); - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = (yy_c_buf_p); - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_END_OF_FILE: - { - (yy_did_buffer_switch_on_eof) = 0; - - if ( yywrap( ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = - (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - (yy_c_buf_p) = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of user's declarations */ -} /* end of yylex */ - -/* The contents of this function are C++ specific, so the () macro is not used. - * This constructor simply maintains backward compatibility. - * DEPRECATED - */ -yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ): - yyin(arg_yyin ? arg_yyin->rdbuf() : std::cin.rdbuf()), - yyout(arg_yyout ? arg_yyout->rdbuf() : std::cout.rdbuf()) -{ - ctor_common(); -} - -/* The contents of this function are C++ specific, so the () macro is not used. - */ -yyFlexLexer::yyFlexLexer( std::istream& arg_yyin, std::ostream& arg_yyout ): - yyin(arg_yyin.rdbuf()), - yyout(arg_yyout.rdbuf()) -{ - ctor_common(); -} - -/* The contents of this function are C++ specific, so the () macro is not used. - */ -void yyFlexLexer::ctor_common() -{ - yy_c_buf_p = 0; - yy_init = 0; - yy_start = 0; - yy_flex_debug = 0; - yylineno = 1; // this will only get updated if %option yylineno - - yy_did_buffer_switch_on_eof = 0; - - yy_looking_for_trail_begin = 0; - yy_more_flag = 0; - yy_more_len = 0; - yy_more_offset = yy_prev_more_offset = 0; - - yy_start_stack_ptr = yy_start_stack_depth = 0; - yy_start_stack = NULL; - - yy_buffer_stack = NULL; - yy_buffer_stack_top = 0; - yy_buffer_stack_max = 0; - - yy_state_buf = 0; - -} - -/* The contents of this function are C++ specific, so the () macro is not used. - */ -yyFlexLexer::~yyFlexLexer() -{ - delete [] yy_state_buf; - yyfree( yy_start_stack ); - yy_delete_buffer( YY_CURRENT_BUFFER ); - yyfree( yy_buffer_stack ); -} - -/* The contents of this function are C++ specific, so the () macro is not used. - */ -void yyFlexLexer::switch_streams( std::istream& new_in, std::ostream& new_out ) -{ - // was if( new_in ) - yy_delete_buffer( YY_CURRENT_BUFFER ); - yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); - - // was if( new_out ) - yyout.rdbuf(new_out.rdbuf()); -} - -/* The contents of this function are C++ specific, so the () macro is not used. - */ -void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) -{ - if( ! new_in ) { - new_in = &yyin; - } - - if ( ! new_out ) { - new_out = &yyout; - } - - switch_streams(*new_in, *new_out); -} - -#ifdef YY_INTERACTIVE -int yyFlexLexer::LexerInput( char* buf, int /* max_size */ ) -#else -int yyFlexLexer::LexerInput( char* buf, int max_size ) -#endif -{ - if ( yyin.eof() || yyin.fail() ) - return 0; - -#ifdef YY_INTERACTIVE - yyin.get( buf[0] ); - - if ( yyin.eof() ) - return 0; - - if ( yyin.bad() ) - return -1; - - return 1; - -#else - (void) yyin.read( buf, max_size ); - - if ( yyin.bad() ) - return -1; - else - return yyin.gcount(); -#endif -} - -void yyFlexLexer::LexerOutput( const char* buf, int size ) -{ - (void) yyout.write( buf, size ); -} - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -int yyFlexLexer::yy_get_next_buffer() -{ - char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - char *source = (yytext_ptr); - int number_to_move, i; - int ret_val; - - if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1); - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; - - else - { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; - - int yy_c_buf_p_offset = - (int) ((yy_c_buf_p) - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc( (void *) b->yy_ch_buf, - (yy_size_t) (b->yy_buf_size + 2) ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = NULL; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - (yy_n_chars), num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - if ( (yy_n_chars) == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin ); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( - (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - /* "- 2" to take care of EOB's */ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); - } - - (yy_n_chars) += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; - - (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; -} - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - yy_state_type yyFlexLexer::yy_get_previous_state() -{ - yy_state_type yy_current_state; - char *yy_cp; - - yy_current_state = (yy_start); - - for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) - { - YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 44 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - } - - return yy_current_state; -} - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) -{ - int yy_is_jam; - char *yy_cp = (yy_c_buf_p); - - YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 44 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 43); - - return yy_is_jam ? 0 : yy_current_state; -} - -#ifndef YY_NO_UNPUT - void yyFlexLexer::yyunput( int c, char* yy_bp) -{ - char *yy_cp; - - yy_cp = (yy_c_buf_p); - - /* undo effects of setting up yytext */ - *yy_cp = (yy_hold_char); - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - int number_to_move = (yy_n_chars) + 2; - char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - char *source = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - (yy_n_chars) = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - - (yytext_ptr) = yy_bp; - (yy_hold_char) = *yy_cp; - (yy_c_buf_p) = yy_cp; -} -#endif - - int yyFlexLexer::yyinput() -{ - int c; - - *(yy_c_buf_p) = (yy_hold_char); - - if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - /* This was really a NUL. */ - *(yy_c_buf_p) = '\0'; - - else - { /* need more input */ - int offset = (int) ((yy_c_buf_p) - (yytext_ptr)); - ++(yy_c_buf_p); - - switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart( yyin ); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap( ) ) - return 0; - - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = (yytext_ptr) + offset; - break; - } - } - } - - c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ - *(yy_c_buf_p) = '\0'; /* preserve yytext */ - (yy_hold_char) = *++(yy_c_buf_p); - - return c; -} - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * - * @note This function does not reset the start condition to @c INITIAL . - */ - void yyFlexLexer::yyrestart( std::istream& input_file ) -{ - - if ( ! YY_CURRENT_BUFFER ){ - yyensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE ); - } - - yy_init_buffer( YY_CURRENT_BUFFER, input_file ); - yy_load_buffer_state( ); -} - -/** Delegate to the new version that takes an istream reference. - * @param input_file A readable stream. - * - * @note This function does not reset the start condition to @c INITIAL . - */ -void yyFlexLexer::yyrestart( std::istream* input_file ) -{ - if( ! input_file ) { - input_file = &yyin; - } - yyrestart( *input_file ); -} - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * - */ - void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) -{ - - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack (); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( ); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - (yy_did_buffer_switch_on_eof) = 1; -} - - void yyFlexLexer::yy_load_buffer_state() -{ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin.rdbuf(YY_CURRENT_BUFFER_LVALUE->yy_input_file); - (yy_hold_char) = *(yy_c_buf_p); -} - -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * - * @return the allocated buffer state. - */ - YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream& file, int size ) -{ - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer( b, file ); - - return b; -} - -/** Delegate creation of buffers to the new version that takes an istream reference. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * - * @return the allocated buffer state. - */ - YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) -{ - return yy_create_buffer( *file, size ); -} - -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * - */ - void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) -{ - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yyfree( (void *) b->yy_ch_buf ); - - yyfree( (void *) b ); -} - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ - void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream& file ) - -{ - int oerrno = errno; - - yy_flush_buffer( b ); - - b->yy_input_file = file.rdbuf(); - b->yy_fill_buffer = 1; - - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } - - b->yy_is_interactive = 0; - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * - */ - void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) -{ - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * - */ -void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) -{ - if (new_buffer == NULL) - return; - - yyensure_buffer_stack(); - - /* This block is copied from yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - (yy_buffer_stack_top)++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * - */ -void yyFlexLexer::yypop_buffer_state (void) -{ - if (!YY_CURRENT_BUFFER) - return; - - yy_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - if ((yy_buffer_stack_top) > 0) - --(yy_buffer_stack_top); - - if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -void yyFlexLexer::yyensure_buffer_stack(void) -{ - yy_size_t num_to_alloc; - - if (!(yy_buffer_stack)) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ - (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - (yy_buffer_stack_max) = num_to_alloc; - (yy_buffer_stack_top) = 0; - return; - } - - if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - yy_size_t grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc - ((yy_buffer_stack), - num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); - (yy_buffer_stack_max) = num_to_alloc; - } -} - - void yyFlexLexer::yy_push_state( int _new_state ) -{ - if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) ) - { - yy_size_t new_size; - - (yy_start_stack_depth) += YY_START_STACK_INCR; - new_size = (yy_size_t) (yy_start_stack_depth) * sizeof( int ); - - if ( ! (yy_start_stack) ) - (yy_start_stack) = (int *) yyalloc( new_size ); - - else - (yy_start_stack) = (int *) yyrealloc( - (void *) (yy_start_stack), new_size ); - - if ( ! (yy_start_stack) ) - YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); - } - - (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START; - - BEGIN(_new_state); -} - - void yyFlexLexer::yy_pop_state() -{ - if ( --(yy_start_stack_ptr) < 0 ) - YY_FATAL_ERROR( "start-condition stack underflow" ); - - BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); -} - - int yyFlexLexer::yy_top_state() -{ - return (yy_start_stack)[(yy_start_stack_ptr) - 1]; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -void yyFlexLexer::LexerError( const char* msg ) -{ - std::cerr << msg << std::endl; - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = (yy_hold_char); \ - (yy_c_buf_p) = yytext + yyless_macro_arg; \ - (yy_hold_char) = *(yy_c_buf_p); \ - *(yy_c_buf_p) = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, const char * s2, int n ) -{ - - int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (const char * s ) -{ - int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *yyalloc (yy_size_t size ) -{ - return malloc(size); -} - -void *yyrealloc (void * ptr, yy_size_t size ) -{ - - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return realloc(ptr, size); -} - -void yyfree (void * ptr ) -{ - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#line 164 "lexer.l" - - -#ifndef NO_LEXER_MAIN -int main(int argc, char **argv) { - yyFlexLexer lexer; - ifstream file; - if (argc > 1) { - file.open(argv[1]); - if (!file.is_open()) { - perror("File opening failed"); - return 1; - } - lexer.switch_streams(&file, &cout); - } - while (lexer.yylex() != 0) {} - for (auto &t : tokens) t->print(); - return 0; -} -#endif - diff --git a/lexer b/lexer deleted file mode 100644 index 4256eb78d436654c7325a06b3fc115de06c833cc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 154768 zcmeFa4Rlo1)yI7kG7uF^)SwYjM?{UE0F1+qaoo=GDoY=8|$7hU@t^T%L-#hCNL* z?I}9SZ;@e7H@chcE;rXG=f+XUlphnN4*8k%No3Zc)K_AZo0ib!xN-TBI^9IGzVA{_ z?9$aA!|mEcqdqS`G#P#{QMb0HeP>?fj3I^JnK$d)d6iYQi_cwLH00bNh374-K5vjx zLG%jpD={@@!ekA%GzrZxqn5c;Pn+_DmuK)L|AV6v7mfL-{i&xf?sHn1BYEUUI(pV&>FMK8K3)Ey9`Y~p&}X@a{C13)PX75A zG#z~e22Dp_?NRS9J@h=@qux3?Tsrv+J?#I2NB*52?d^yCk4odm8HcB@_xm308tOq` z?cuKzJmmNBkTcc8&Z9i+_D2u-*LcVuOJ_-E=UNYcB|PZA^pMly5kG(R(EnBs{hK}P zx!EHgPVs1O9}hjdd)Rr9hnxxz`ky@d^$?FZjCr)H+#^1p^~isnhdxJo*z-Rgc6i!D z&s>js&-dtePkZ=xvWK4MddMH?LI0hH{xTl~)AZ{jJnFsJL;puT{CK-ZyZ-LcF9@r& z`n>9)|1%!+HR#hXO}ozVkpEMUcy9Hehdk_42R&WA!?D9rtTv~AS6axrR0r)&6}Nr0 zr4w~Ru0dbGIM9#T`t^HNcI|kBeiQK~a*9h*^J`^gbLLl9l`V{v*F?(7w6d|KIk&u~ zEK*Zm8G#TA70xcNoEKW8l}()hx6sHudts!eqI`b(64eVTszN1~i?qRIW2+aIT>)W! z^(=G|Aw$c`W-eYlaNxi}x-djlR?SH#YErpqfRIULGpiTeSSG4143*3j*+Xgd)Jc(f z3&*BWdZJXVORqLHEiDU8I=^hDDm7?8Sy^OmP4x|B^D3(5MCO)N)YMeh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 zn=cCW@%M377R!}^e78G45K6J5VN%Y`@=z#gAjEPWbPV)$)7RJOpw^c8J@L)wNCU>M zW|R}o_p>NVD~p1JXuCQnz0+fR%$9h#Ayro=#k9VeVTNh9W;42KO=gh0Qk~53O{^l>N!2$Tg-)Vs4QkD5MJFQex)MnOG=e2Z z)gVf3#`1iIZZi5i%=mo<++7ZgVP4`B3&*Svza7P(B z@(fKxTDBHf$MLd04a;F>U)qw!=T{u9kM%_24TzWz^`uub}uW6&5 znSSr<-A|=^`}q}kUelw!{Cj)%E#C8&;dxCbc=`S3&!E4*^4e=9E&oP5ujzC=zYkKs z{CUFnr~mc&-FRNpHC#EmIAPxD^Wzw#t4ROzBl`RbCPtU0iw}@{{nzLJhv^TmS>=E9 zt&&sIb$C$AukX?H0{Z)_*7IkhV4Cj2^IU!|r5umF6Y!j-FQGk^ z#u)t2^bYU&F_R@jHPr{b=k)oF-t!aiyr#Q`c>jam^BEObq_^DQ7C_&t=wsgVx9ya_ zX!=IYh}7rbQ+Qt6KeG!Nk-q<*aF1kydz<+--8297`49YBGH817f$jtT`+wv;zv~Z@ zU(?^5=svIVqv$Wa=eIX=X)+m2Z_x4vJ~*HO07 z*7L1+z7@}FKJzmANAEQqP0#b2^!-cl{1QChs(%0heNO2eN)L12(QF&$F||x)!-vv1 z{uy|F0-j&3f4~DX^g*PJ^gO?*(ZlumNgghxl4tl&eD77!Jkg5x@1ARJGe=Ou|7-bG p|8e*5ifA5~{uz1GkDf8N)qnK;3LHc~;+}s~yOip9?*Z>N^S|d==rsTU diff --git a/lexer.cpp b/lexer.cpp deleted file mode 100644 index 0a1a392..0000000 --- a/lexer.cpp +++ /dev/null @@ -1,1974 +0,0 @@ -#line 2 "lexer.cpp" - -#line 4 "lexer.cpp" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 4 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#ifndef SIZE_MAX -#define SIZE_MAX (~(size_t)0) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -/* begin standard C++ headers. */ - -/* TODO: this is always defined, so inline it */ -#define yyconst const - -#if defined(__GNUC__) && __GNUC__ >= 3 -#define yynoreturn __attribute__((__noreturn__)) -#else -#define yynoreturn -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an - * integer in range [0..255] for use as an array index. - */ -#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN (yy_start) = 1 + 2 * -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START (((yy_start) - 1) / 2) -#define YYSTATE YY_START -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin ) -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -extern int yyleng; - -extern FILE *yyin, *yyout; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - #define YY_LESS_LINENO(n) - #define YY_LINENO_REWIND_TO(ptr) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = (yy_hold_char); \ - YY_RESTORE_YY_MORE_OFFSET \ - (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) -#define unput(c) yyunput( c, (yytext_ptr) ) - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* Stack of input buffers. */ -static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ -static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ - ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ - : NULL) -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] - -/* yy_hold_char holds the character lost when yytext is formed. */ -static char yy_hold_char; -static int yy_n_chars; /* number of characters read into yy_ch_buf */ -int yyleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = NULL; -static int yy_init = 0; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow yywrap()'s to do buffer switches - * instead of setting up a fresh yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -void yyrestart ( FILE *input_file ); -void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size ); -void yy_delete_buffer ( YY_BUFFER_STATE b ); -void yy_flush_buffer ( YY_BUFFER_STATE b ); -void yypush_buffer_state ( YY_BUFFER_STATE new_buffer ); -void yypop_buffer_state ( void ); - -static void yyensure_buffer_stack ( void ); -static void yy_load_buffer_state ( void ); -static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file ); -#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER ) - -YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size ); -YY_BUFFER_STATE yy_scan_string ( const char *yy_str ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len ); - -void *yyalloc ( yy_size_t ); -void *yyrealloc ( void *, yy_size_t ); -void yyfree ( void * ); - -#define yy_new_buffer yy_create_buffer -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer( yyin, YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -#define yywrap() (/*CONSTCOND*/1) -#define YY_SKIP_YYWRAP -typedef flex_uint8_t YY_CHAR; - -FILE *yyin = NULL, *yyout = NULL; - -typedef int yy_state_type; - -extern int yylineno; -int yylineno = 1; - -extern char *yytext; -#ifdef yytext_ptr -#undef yytext_ptr -#endif -#define yytext_ptr yytext - -static yy_state_type yy_get_previous_state ( void ); -static yy_state_type yy_try_NUL_trans ( yy_state_type current_state ); -static int yy_get_next_buffer ( void ); -static void yynoreturn yy_fatal_error ( const char* msg ); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - (yytext_ptr) = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ - (yy_hold_char) = *yy_cp; \ - *yy_cp = '\0'; \ - (yy_c_buf_p) = yy_cp; -#define YY_NUM_RULES 10 -#define YY_END_OF_BUFFER 11 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static const flex_int16_t yy_accept[70] = - { 0, - 0, 0, 11, 9, 1, 2, 9, 9, 8, 5, - 8, 8, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 1, 2, 0, 7, 0, 0, 5, - 8, 6, 6, 6, 6, 6, 6, 6, 3, 6, - 6, 6, 6, 6, 6, 6, 4, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 0 - } ; - -static const YY_CHAR yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 5, 1, 1, 1, 1, 1, 6, - 6, 6, 6, 6, 6, 7, 6, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 9, 6, 6, - 10, 11, 1, 1, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - 6, 13, 6, 1, 12, 1, 14, 12, 15, 16, - - 17, 18, 12, 19, 20, 12, 12, 21, 22, 23, - 24, 25, 12, 26, 27, 28, 29, 30, 31, 32, - 12, 12, 6, 1, 6, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static const YY_CHAR yy_meta[33] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, - 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2 - } ; - -static const flex_int16_t yy_base[72] = - { 0, - 0, 0, 102, 103, 99, 103, 97, 28, 103, 27, - 89, 87, 0, 76, 15, 25, 19, 72, 78, 77, - 24, 79, 73, 89, 103, 35, 103, 87, 81, 37, - 103, 0, 74, 60, 70, 57, 63, 57, 0, 58, - 53, 52, 34, 50, 52, 57, 68, 48, 57, 56, - 45, 46, 51, 40, 45, 40, 49, 44, 37, 40, - 45, 37, 34, 42, 42, 41, 30, 25, 103, 54, - 40 - } ; - -static const flex_int16_t yy_def[72] = - { 0, - 69, 1, 69, 69, 69, 69, 69, 70, 69, 69, - 69, 69, 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 69, 69, 70, 69, 70, 69, 69, - 69, 71, 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 69, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 71, 0, 69, - 69 - } ; - -static const flex_int16_t yy_nxt[136] = - { 0, - 4, 5, 6, 7, 8, 9, 4, 10, 11, 12, - 9, 13, 4, 13, 14, 13, 15, 16, 13, 17, - 18, 19, 13, 13, 13, 20, 13, 21, 13, 22, - 23, 13, 27, 29, 30, 34, 39, 35, 37, 27, - 28, 32, 43, 29, 30, 39, 36, 28, 38, 44, - 55, 39, 39, 56, 26, 26, 39, 68, 39, 67, - 66, 39, 65, 39, 64, 39, 39, 39, 63, 62, - 39, 61, 60, 39, 59, 47, 58, 39, 57, 54, - 53, 52, 39, 51, 50, 39, 49, 48, 47, 69, - 24, 46, 45, 42, 41, 40, 33, 31, 31, 25, - - 24, 69, 3, 69, 69, 69, 69, 69, 69, 69, - 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, - 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, - 69, 69, 69, 69, 69 - } ; - -static const flex_int16_t yy_chk[136] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 8, 10, 10, 15, 17, 15, 16, 26, - 8, 71, 21, 30, 30, 17, 15, 26, 16, 21, - 43, 68, 67, 43, 70, 70, 66, 65, 64, 63, - 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, - 52, 51, 50, 49, 48, 47, 46, 45, 44, 42, - 41, 40, 38, 37, 36, 35, 34, 33, 29, 28, - 24, 23, 22, 20, 19, 18, 14, 12, 11, 7, - - 5, 3, 69, 69, 69, 69, 69, 69, 69, 69, - 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, - 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, - 69, 69, 69, 69, 69 - } ; - -static yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; - -extern int yy_flex_debug; -int yy_flex_debug = 0; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -char *yytext; -#line 1 "lexer.l" -#line 4 "lexer.l" -#include -#include -#include -#include -#include -#include -#include "parser.hpp" -#include "ast.h" -#undef yyFlexLexer -extern YYSTYPE yylval; -using namespace std; - -class Token { -public: - int line; - int startCol; - int endCol; - - Token(int l, int s, int e) : line(l), startCol(s), endCol(e) {} - virtual ~Token() = default; - virtual void print() const = 0; -}; - -class KeywordToken : public Token { -public: - string value; - KeywordToken(const string& val, int l, int s, int e) : Token(l,s,e), value(val) {} - void print() const override { cout << "KEYWORD(" << value << ")\n"; } -}; - -class IdentifierToken : public Token { -public: - string name; - IdentifierToken(const string& n, int l, int s, int e) : Token(l,s,e), name(n) {} - void print() const override { cout << "IDENTIFIER(" << name << ")\n"; } -}; - -class IntegerToken : public Token { -public: - int value; - IntegerToken(int v, int l, int s, int e) : Token(l,s,e), value(v) {} - void print() const override { cout << "INTEGER(" << value << ")\n"; } -}; - -class RealToken : public Token { -public: - double value; - RealToken(double v, int l, int s, int e) : Token(l,s,e), value(v) {} - void print() const override { cout << "REAL(" << value << ")\n"; } -}; - -class BooleanToken : public Token { -public: - string value; - BooleanToken(const string& v, int l, int s, int e) : Token(l,s,e), value(v) {} - void print() const override { cout << "BOOLEAN(" << value << ")\n"; } -}; - -class StringToken : public Token { -public: - string value; - StringToken(const string& v, int l, int s, int e) : Token(l,s,e), value(v) {} - void print() const override { cout << "STRING(\"" << value << "\")\n"; } -}; - -class SymbolToken : public Token { -public: - string symbol; - SymbolToken(const string& s, int l, int sc, int ec) : Token(l,sc,ec), symbol(s) {} - void print() const override { cout << "SYMBOL(" << symbol << ")\n"; } -}; - -class UnknownToken : public Token { -public: - string text; - UnknownToken(const string& t, int l, int s, int e) : Token(l,s,e), text(t) {} - void print() const override { cout << "UNKNOWN(" << text << ")\n"; } -}; - -int currentLine = 1; -int currentCol = 1; - -#line 579 "lexer.cpp" -#line 580 "lexer.cpp" - -#define INITIAL 0 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -static int yy_init_globals ( void ); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy ( void ); - -int yyget_debug ( void ); - -void yyset_debug ( int debug_flag ); - -YY_EXTRA_TYPE yyget_extra ( void ); - -void yyset_extra ( YY_EXTRA_TYPE user_defined ); - -FILE *yyget_in ( void ); - -void yyset_in ( FILE * _in_str ); - -FILE *yyget_out ( void ); - -void yyset_out ( FILE * _out_str ); - - int yyget_leng ( void ); - -char *yyget_text ( void ); - -int yyget_lineno ( void ); - -void yyset_lineno ( int _line_number ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap ( void ); -#else -extern int yywrap ( void ); -#endif -#endif - -#ifndef YY_NO_UNPUT - - static void yyunput ( int c, char *buf_ptr ); - -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy ( char *, const char *, int ); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen ( const char * ); -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput ( void ); -#else -static int input ( void ); -#endif - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - int n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ -\ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex (void); - -#define YY_DECL int yylex (void) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK /*LINTED*/break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - yy_state_type yy_current_state; - char *yy_cp, *yy_bp; - int yy_act; - - if ( !(yy_init) ) - { - (yy_init) = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! (yy_start) ) - (yy_start) = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - yyensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE ); - } - - yy_load_buffer_state( ); - } - - { -#line 88 "lexer.l" - - -#line 800 "lexer.cpp" - - while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ - { - yy_cp = (yy_c_buf_p); - - /* Support of yytext. */ - *yy_cp = (yy_hold_char); - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = (yy_start); -yy_match: - do - { - YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 70 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 103 ); - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - if ( yy_act == 0 ) - { /* have to back up */ - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); - yy_act = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = (yy_hold_char); - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 90 "lexer.l" -{ currentCol += yyleng; /* игнорируем */ } - YY_BREAK -case 2: -/* rule 2 can match eol */ -YY_RULE_SETUP -#line 91 "lexer.l" -{ currentLine++; currentCol = 1; } - YY_BREAK -case 3: -YY_RULE_SETUP -#line 93 "lexer.l" -{ - yylval.str = strdup(yytext); - int startCol = currentCol; - currentCol += yyleng; - if (strcmp(yytext, "if") == 0) return IF; - if (strcmp(yytext, "else") == 0) return ELSE; - if (strcmp(yytext, "while") == 0) return WHILE; - if (strcmp(yytext, "for") == 0) return LOOP; // если надо FOR - добавь - if (strcmp(yytext, "return") == 0) return RETURN; - if (strcmp(yytext, "true") == 0) return TRUE; - if (strcmp(yytext, "false") == 0) return FALSE; - if (strcmp(yytext, "class") == 0) return CLASS; - if (strcmp(yytext, "extends") == 0) return EXTENDS; - if (strcmp(yytext, "is") == 0) return IS; - if (strcmp(yytext, "end") == 0) return END; - if (strcmp(yytext, "var") == 0) return VAR; - if (strcmp(yytext, "method") == 0) return METHOD; - if (strcmp(yytext, "this") == 0) return THIS; - if (strcmp(yytext, "then") == 0) return THEN; - if (strcmp(yytext, "loop") == 0) return LOOP; - return IDENTIFIER; // если не keyword — идентификатор -} - YY_BREAK -case 4: -YY_RULE_SETUP -#line 116 "lexer.l" -{ - yylval.str = strdup(yytext); - int startCol = currentCol; - currentCol += yyleng; - return REAL; -} - YY_BREAK -case 5: -YY_RULE_SETUP -#line 123 "lexer.l" -{ - yylval.str = strdup(yytext); - int startCol = currentCol; - currentCol += yyleng; - return INTEGER; -} - YY_BREAK -case 6: -YY_RULE_SETUP -#line 130 "lexer.l" -{ - yylval.str = strdup(yytext); - int startCol = currentCol; - currentCol += yyleng; - return IDENTIFIER; -} - YY_BREAK -case 7: -/* rule 7 can match eol */ -YY_RULE_SETUP -#line 137 "lexer.l" -{ - string val(yytext + 1, yyleng - 2); - yylval.str = strdup(val.c_str()); - int startCol = currentCol; - currentCol += yyleng; - return STRING; -} - YY_BREAK -case 8: -YY_RULE_SETUP -#line 145 "lexer.l" -{ - yylval.str = strdup(yytext); - int startCol = currentCol; - currentCol += yyleng; - if (strcmp(yytext, ":") == 0) return COLON; - if (strcmp(yytext, ";") == 0) return SEMI; - if (strcmp(yytext, "(") == 0) return LPAREN; - if (strcmp(yytext, ")") == 0) return RPAREN; - if (strcmp(yytext, ",") == 0) return COMMA; - if (strcmp(yytext, ".") == 0) return DOT; - if (strcmp(yytext, ":=") == 0) return ASSIGN; - if (strcmp(yytext, "=>") == 0) return ARROW; - return SYMBOL; -} - YY_BREAK -case 9: -YY_RULE_SETUP -#line 160 "lexer.l" -{ - yylval.str = strdup(yytext); - int startCol = currentCol; - currentCol += yyleng; - return UNKNOWN; -} - YY_BREAK -case 10: -YY_RULE_SETUP -#line 167 "lexer.l" -ECHO; - YY_BREAK -#line 969 "lexer.cpp" -case YY_STATE_EOF(INITIAL): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = (yy_hold_char); - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++(yy_c_buf_p); - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = (yy_c_buf_p); - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_END_OF_FILE: - { - (yy_did_buffer_switch_on_eof) = 0; - - if ( yywrap( ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = - (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - (yy_c_buf_p) = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of user's declarations */ -} /* end of yylex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (void) -{ - char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - char *source = (yytext_ptr); - int number_to_move, i; - int ret_val; - - if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1); - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; - - else - { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; - - int yy_c_buf_p_offset = - (int) ((yy_c_buf_p) - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc( (void *) b->yy_ch_buf, - (yy_size_t) (b->yy_buf_size + 2) ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = NULL; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - (yy_n_chars), num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - if ( (yy_n_chars) == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin ); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( - (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - /* "- 2" to take care of EOB's */ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); - } - - (yy_n_chars) += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; - - (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; -} - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - static yy_state_type yy_get_previous_state (void) -{ - yy_state_type yy_current_state; - char *yy_cp; - - yy_current_state = (yy_start); - - for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) - { - YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 70 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - } - - return yy_current_state; -} - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) -{ - int yy_is_jam; - char *yy_cp = (yy_c_buf_p); - - YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 70 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 69); - - return yy_is_jam ? 0 : yy_current_state; -} - -#ifndef YY_NO_UNPUT - - static void yyunput (int c, char * yy_bp ) -{ - char *yy_cp; - - yy_cp = (yy_c_buf_p); - - /* undo effects of setting up yytext */ - *yy_cp = (yy_hold_char); - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - int number_to_move = (yy_n_chars) + 2; - char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - char *source = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - (yy_n_chars) = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - - (yytext_ptr) = yy_bp; - (yy_hold_char) = *yy_cp; - (yy_c_buf_p) = yy_cp; -} - -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (void) -#else - static int input (void) -#endif - -{ - int c; - - *(yy_c_buf_p) = (yy_hold_char); - - if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - /* This was really a NUL. */ - *(yy_c_buf_p) = '\0'; - - else - { /* need more input */ - int offset = (int) ((yy_c_buf_p) - (yytext_ptr)); - ++(yy_c_buf_p); - - switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart( yyin ); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap( ) ) - return 0; - - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = (yytext_ptr) + offset; - break; - } - } - } - - c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ - *(yy_c_buf_p) = '\0'; /* preserve yytext */ - (yy_hold_char) = *++(yy_c_buf_p); - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * - * @note This function does not reset the start condition to @c INITIAL . - */ - void yyrestart (FILE * input_file ) -{ - - if ( ! YY_CURRENT_BUFFER ){ - yyensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer( yyin, YY_BUF_SIZE ); - } - - yy_init_buffer( YY_CURRENT_BUFFER, input_file ); - yy_load_buffer_state( ); -} - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * - */ - void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) -{ - - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack (); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state( ); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - (yy_did_buffer_switch_on_eof) = 1; -} - -static void yy_load_buffer_state (void) -{ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - (yy_hold_char) = *(yy_c_buf_p); -} - -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * - * @return the allocated buffer state. - */ - YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) -{ - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer( b, file ); - - return b; -} - -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * - */ - void yy_delete_buffer (YY_BUFFER_STATE b ) -{ - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yyfree( (void *) b->yy_ch_buf ); - - yyfree( (void *) b ); -} - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ - static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) - -{ - int oerrno = errno; - - yy_flush_buffer( b ); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } - - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * - */ - void yy_flush_buffer (YY_BUFFER_STATE b ) -{ - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state( ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * - */ -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) -{ - if (new_buffer == NULL) - return; - - yyensure_buffer_stack(); - - /* This block is copied from yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - (yy_buffer_stack_top)++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * - */ -void yypop_buffer_state (void) -{ - if (!YY_CURRENT_BUFFER) - return; - - yy_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - if ((yy_buffer_stack_top) > 0) - --(yy_buffer_stack_top); - - if (YY_CURRENT_BUFFER) { - yy_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void yyensure_buffer_stack (void) -{ - yy_size_t num_to_alloc; - - if (!(yy_buffer_stack)) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ - (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - (yy_buffer_stack_max) = num_to_alloc; - (yy_buffer_stack_top) = 0; - return; - } - - if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - yy_size_t grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc - ((yy_buffer_stack), - num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); - (yy_buffer_stack_max) = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return NULL; - - b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = NULL; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer( b ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -YY_BUFFER_STATE yy_scan_string (const char * yystr ) -{ - - return yy_scan_bytes( yystr, (int) strlen(yystr) ); -} - -/** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = (yy_size_t) (_yybytes_len + 2); - buf = (char *) yyalloc( n ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer( buf, n ); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yynoreturn yy_fatal_error (const char* msg ) -{ - fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = (yy_hold_char); \ - (yy_c_buf_p) = yytext + yyless_macro_arg; \ - (yy_hold_char) = *(yy_c_buf_p); \ - *(yy_c_buf_p) = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the current line number. - * - */ -int yyget_lineno (void) -{ - - return yylineno; -} - -/** Get the input stream. - * - */ -FILE *yyget_in (void) -{ - return yyin; -} - -/** Get the output stream. - * - */ -FILE *yyget_out (void) -{ - return yyout; -} - -/** Get the length of the current token. - * - */ -int yyget_leng (void) -{ - return yyleng; -} - -/** Get the current token. - * - */ - -char *yyget_text (void) -{ - return yytext; -} - -/** Set the current line number. - * @param _line_number line number - * - */ -void yyset_lineno (int _line_number ) -{ - - yylineno = _line_number; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param _in_str A readable stream. - * - * @see yy_switch_to_buffer - */ -void yyset_in (FILE * _in_str ) -{ - yyin = _in_str ; -} - -void yyset_out (FILE * _out_str ) -{ - yyout = _out_str ; -} - -int yyget_debug (void) -{ - return yy_flex_debug; -} - -void yyset_debug (int _bdebug ) -{ - yy_flex_debug = _bdebug ; -} - -static int yy_init_globals (void) -{ - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from yylex_destroy(), so don't allocate here. - */ - - (yy_buffer_stack) = NULL; - (yy_buffer_stack_top) = 0; - (yy_buffer_stack_max) = 0; - (yy_c_buf_p) = NULL; - (yy_init) = 0; - (yy_start) = 0; - -/* Defined in main.c */ -#ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; -#else - yyin = NULL; - yyout = NULL; -#endif - - /* For future reference: Set errno on error, since we are called by - * yylex_init() - */ - return 0; -} - -/* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy (void) -{ - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - yy_delete_buffer( YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(); - } - - /* Destroy the stack itself. */ - yyfree((yy_buffer_stack) ); - (yy_buffer_stack) = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * yylex() is called, initialization will occur. */ - yy_init_globals( ); - - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, const char * s2, int n ) -{ - - int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (const char * s ) -{ - int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *yyalloc (yy_size_t size ) -{ - return malloc(size); -} - -void *yyrealloc (void * ptr, yy_size_t size ) -{ - - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return realloc(ptr, size); -} - -void yyfree (void * ptr ) -{ - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#line 167 "lexer.l" - diff --git a/lexer.l b/lexer.l index e624b65..0c9f2ee 100644 --- a/lexer.l +++ b/lexer.l @@ -1,167 +1,80 @@ %option noyywrap - +%option outfile="lexer.cpp" +%option c++ %{ -#include -#include -#include -#include -#include -#include -#include "parser.hpp" -#include "ast.h" -#undef yyFlexLexer -extern YYSTYPE yylval; -using namespace std; +#include "tokens.hpp" +#include "parser.tab.h" // bison сгенерит +#include -class Token { -public: - int line; - int startCol; - int endCol; - - Token(int l, int s, int e) : line(l), startCol(s), endCol(e) {} - virtual ~Token() = default; - virtual void print() const = 0; -}; - -class KeywordToken : public Token { -public: - string value; - KeywordToken(const string& val, int l, int s, int e) : Token(l,s,e), value(val) {} - void print() const override { cout << "KEYWORD(" << value << ")\n"; } -}; - -class IdentifierToken : public Token { -public: - string name; - IdentifierToken(const string& n, int l, int s, int e) : Token(l,s,e), name(n) {} - void print() const override { cout << "IDENTIFIER(" << name << ")\n"; } -}; - -class IntegerToken : public Token { -public: - int value; - IntegerToken(int v, int l, int s, int e) : Token(l,s,e), value(v) {} - void print() const override { cout << "INTEGER(" << value << ")\n"; } -}; - -class RealToken : public Token { -public: - double value; - RealToken(double v, int l, int s, int e) : Token(l,s,e), value(v) {} - void print() const override { cout << "REAL(" << value << ")\n"; } -}; - -class BooleanToken : public Token { -public: - string value; - BooleanToken(const string& v, int l, int s, int e) : Token(l,s,e), value(v) {} - void print() const override { cout << "BOOLEAN(" << value << ")\n"; } -}; - -class StringToken : public Token { -public: - string value; - StringToken(const string& v, int l, int s, int e) : Token(l,s,e), value(v) {} - void print() const override { cout << "STRING(\"" << value << "\")\n"; } -}; - -class SymbolToken : public Token { -public: - string symbol; - SymbolToken(const string& s, int l, int sc, int ec) : Token(l,sc,ec), symbol(s) {} - void print() const override { cout << "SYMBOL(" << symbol << ")\n"; } -}; - -class UnknownToken : public Token { -public: - string text; - UnknownToken(const string& t, int l, int s, int e) : Token(l,s,e), text(t) {} - void print() const override { cout << "UNKNOWN(" << text << ")\n"; } -}; - -int currentLine = 1; -int currentCol = 1; - -%} +using namespace std; -%% +static int cur_line = 1; +static int cur_col = 1; -[ \t]+ { currentCol += yyleng; /* игнорируем */ } -\r?\n { currentLine++; currentCol = 1; } - -"if"|"else"|"while"|"for"|"return"|"true"|"false"|"class"|"extends"|"is"|"end"|"var"|"method"|"this"|"then"|"loop" { - yylval.str = strdup(yytext); - int startCol = currentCol; - currentCol += yyleng; - if (strcmp(yytext, "if") == 0) return IF; - if (strcmp(yytext, "else") == 0) return ELSE; - if (strcmp(yytext, "while") == 0) return WHILE; - if (strcmp(yytext, "for") == 0) return LOOP; // если надо FOR - добавь - if (strcmp(yytext, "return") == 0) return RETURN; - if (strcmp(yytext, "true") == 0) return TRUE; - if (strcmp(yytext, "false") == 0) return FALSE; - if (strcmp(yytext, "class") == 0) return CLASS; - if (strcmp(yytext, "extends") == 0) return EXTENDS; - if (strcmp(yytext, "is") == 0) return IS; - if (strcmp(yytext, "end") == 0) return END; - if (strcmp(yytext, "var") == 0) return VAR; - if (strcmp(yytext, "method") == 0) return METHOD; - if (strcmp(yytext, "this") == 0) return THIS; - if (strcmp(yytext, "then") == 0) return THEN; - if (strcmp(yytext, "loop") == 0) return LOOP; - return IDENTIFIER; // если не keyword — идентификатор -} +#define YY_USER_ACTION \ + /* обновим столбцы: */ \ + cur_col += yyleng; -[0-9]+\.[0-9]+ { - yylval.str = strdup(yytext); - int startCol = currentCol; - currentCol += yyleng; - return REAL; +static int start_col_for_rule() { + return cur_col - yyleng + 1; } -[0-9]+ { - yylval.str = strdup(yytext); - int startCol = currentCol; - currentCol += yyleng; - return INTEGER; -} - -[A-Za-z_][A-Za-z0-9_]* { - yylval.str = strdup(yytext); - int startCol = currentCol; - currentCol += yyleng; - return IDENTIFIER; +// Утилита: создать токен и вывести его +template +static T* make_token_and_echo(Args&&... args) { + T* t = new T(std::forward(args)...); + printToken(t); + return t; } +%} -\"([^\\\"]|\\.)*\" { - string val(yytext + 1, yyleng - 2); - yylval.str = strdup(val.c_str()); - int startCol = currentCol; - currentCol += yyleng; - return STRING; -} +ws [ \t\r]+ +newline \n +id [A-Za-z_][A-Za-z0-9_]* +intlit [0-9]+ -(:=|=>|[+\-*/=(){};,<>:\[\]]) { - yylval.str = strdup(yytext); - int startCol = currentCol; - currentCol += yyleng; - if (strcmp(yytext, ":") == 0) return COLON; - if (strcmp(yytext, ";") == 0) return SEMI; - if (strcmp(yytext, "(") == 0) return LPAREN; - if (strcmp(yytext, ")") == 0) return RPAREN; - if (strcmp(yytext, ",") == 0) return COMMA; - if (strcmp(yytext, ".") == 0) return DOT; - if (strcmp(yytext, ":=") == 0) return ASSIGN; - if (strcmp(yytext, "=>") == 0) return ARROW; - return SYMBOL; -} +%% -. { - yylval.str = strdup(yytext); - int startCol = currentCol; - currentCol += yyleng; - return UNKNOWN; -} +{ws} {/* пропуск, столбец уже учтён */} +{newline} { cur_line++; cur_col = 1; } + +"class" { auto t = make_token_and_echo(TokenKind::Class, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_CLASS; } +"is" { auto t = make_token_and_echo(TokenKind::Is, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_IS; } +"var" { auto t = make_token_and_echo(TokenKind::Var, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_VAR; } +"end" { auto t = make_token_and_echo(TokenKind::End, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_END; } + +"Int" { auto t = make_token_and_echo("Int", cur_line, start_col_for_rule()); yylval.tok = t; return T_INT_TYPE; } + +":" { auto t = make_token_and_echo(TokenKind::Colon, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_COLON; } +";" { auto t = make_token_and_echo(TokenKind::Semicolon, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_SEMI; } +"=" { auto t = make_token_and_echo(TokenKind::Assign, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_ASSIGN; } +"(" { auto t = make_token_and_echo(TokenKind::LParen, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_LPAREN; } +")" { auto t = make_token_and_echo(TokenKind::RParen, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_RPAREN; } +"\\+" { auto t = make_token_and_echo(TokenKind::Plus, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_PLUS; } +"-" { auto t = make_token_and_echo(TokenKind::Minus, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_MINUS; } +"\\*" { auto t = make_token_and_echo(TokenKind::Star, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_STAR; } +"/" { auto t = make_token_and_echo(TokenKind::Slash, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_SLASH; } +"\\." { auto t = make_token_and_echo(TokenKind::Dot, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_DOT; } + +{intlit} { + long long v = atoll(yytext); + auto t = make_token_and_echo(v, yytext, cur_line, start_col_for_rule()); + yylval.tok = t; return T_INTEGER; + } + +{id} { + std::string s(yytext); + // Если не ключевое слово/тип — идентификатор + auto t = make_token_and_echo(s, cur_line, start_col_for_rule()); + yylval.tok = t; return T_IDENTIFIER; + } + +"//".* { /* комментарии до конца строки */ } +"/*"([^*]|\*+[^*/])*\*+"/" { /* блочный комментарий */ } + +. { + fprintf(stderr, "Unknown char '%s' at %d:%d\n", yytext, cur_line, start_col_for_rule()); + } -%% \ No newline at end of file +%% +// yywrap по умолчанию отключён опцией diff --git a/main.cpp b/main.cpp index a45cb6b..8cddde9 100644 --- a/main.cpp +++ b/main.cpp @@ -1,25 +1,45 @@ +// main.cpp #include +#include #include +#include "ast.hpp" + +extern int yyparse(void); extern FILE* yyin; -extern int yyparse(); -extern void printAST(); +extern AST::Program* g_program; -int main(int argc, char **argv) { +int main(int argc, char** argv) { if (argc < 2) { - std::cerr << "Usage: " << argv[0] << " \n"; + std::cerr << "Usage: ./mycompiler \n"; return 1; } - yyin = fopen(argv[1], "r"); + const char* path = argv[1]; + yyin = fopen(path, "r"); if (!yyin) { - std::cerr << "Failed to open input file\n"; + std::perror("fopen"); return 1; } - int res = yyparse(); - if (res == 0) { - printAST(); + + // Парсим; лексер уже печатает поток токенов: + // например: + // CLASS + // IDENTIFIER(Point) + // IS + // VAR + // IDENTIFIER(x) + // COLON + // TYPE(Int) + // ... + if (yyparse() == 0) { + // Печать нормализованного AST (раскладывание) + if (g_program) { + std::cout << "\n--- AST ---\n"; + g_program->printNormalized(std::cout); + } } else { - std::cerr << "Parsing failed\n"; + std::cerr << "Parsing failed.\n"; } + fclose(yyin); - return res; + return 0; } diff --git a/mycompiler b/mycompiler deleted file mode 100644 index 5e30f9094f3c026626d98e035744c77894230c6a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 108896 zcmeEv4O~=J`u`c=0xAlcQ}~jNrsi9QZ-sA#%Gg+HtU_690Rjqzz`~4SX;MHrjkIJh z>-M&6S!?gqnoFfdY7UhZwN}=;Mdj8^SW%g=tvUbibI!SQ&s=8cW&gkb|Nr^?y?ln} zp6Bg6=Q+=F&bjB_xwFnbe{Ph;!t^7Woy(|Hb+*8yNrLUq22UDGWxZJ%8_H}f7W5c= zbUrgY5CtL*9mb0yiv}dQWI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@+E`m9JuKdvdQ9n{5-vI9q+WG zF9#T|{E-94@X)`B4;2F}O_4Lj0`g++SYU9v@TmoQ@u__AVR5%pk(@q-a+I)Hj_-oe zrT5eL(fe0Eo8mp6fxn)I|22KTq}O}5N6CLIv7YHWDZ%v9l3wrnJsC}QjQ$~aeD*Aq ze!ryG`wENRPLI#yIKO@N*|L`ZfTY*^T1o$0x!dKZ&yc(T|7-fEB)#4@NHQ{6z_8&Vf0`S8M&#K*`R|htd+1$0r{ie(H6OiSgY?e?(htiA zm-PMTO@(zuj#e^ACUAHax&+8B5-;?ARR{OPr?6o z`dfifyDES0yS*ZKB;Ucy?*EVA$6)#ul1}g4(x1v>sr;dL`s_g1{n1xQLb+M&oX4#6WB<#9df!fk z3tZNt^E7^=Drz@vd_Gg?-EMEqU+?rCb^3Ogrr$2<^{#YU1bx=~iAYa5YWiK0UhlVQ z!wQ2H%1G{~Au){|O~2$g;)Zc1_ob4a^cP*4uh#1`z=HWNKY`Qh{d@dq(gxEjpEL1$ zFunKvS^0p|N-rhRW%wg1{eOIvDc4vD ItVien0s6^Yd;kCd diff --git a/parser.cpp b/parser.cpp deleted file mode 100644 index f003747..0000000 --- a/parser.cpp +++ /dev/null @@ -1,1799 +0,0 @@ -/* A Bison parser, made by GNU Bison 3.8.2. */ - -/* Bison implementation for Yacc-like parsers in C - - Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 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 3 of the License, 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, see . */ - -/* 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. */ - -/* C LALR(1) parser skeleton written by Richard Stallman, by - simplifying the original so-called "semantic" parser. */ - -/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, - especially those whose name start with YY_ or yy_. They are - private implementation details that can be changed or removed. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -/* Identify Bison output, and Bison version. */ -#define YYBISON 30802 - -/* Bison version string. */ -#define YYBISON_VERSION "3.8.2" - -/* Skeleton name. */ -#define YYSKELETON_NAME "yacc.c" - -/* Pure parsers. */ -#define YYPURE 0 - -/* Push parsers. */ -#define YYPUSH 0 - -/* Pull parsers. */ -#define YYPULL 1 - - - - -/* First part of user prologue. */ -#line 3 "parser.y" - -#include -#include -#include -#include -#include -#include "ast.h" -#include - -using namespace std; - -unique_ptr g_program = nullptr; -size_t parserTokIndex = 0; -vector simpleTokens; - -void yyerror(const char *s) { - cerr << "Parse error: " << s << "\n"; -} - -void printAST() { - if (g_program) { - g_program->print(0); - } else { - cout << "No AST generated.\n"; - } -} - -#line 99 "parser.cpp" - -# ifndef YY_CAST -# ifdef __cplusplus -# define YY_CAST(Type, Val) static_cast (Val) -# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast (Val) -# else -# define YY_CAST(Type, Val) ((Type) (Val)) -# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val)) -# endif -# endif -# ifndef YY_NULLPTR -# if defined __cplusplus -# if 201103L <= __cplusplus -# define YY_NULLPTR nullptr -# else -# define YY_NULLPTR 0 -# endif -# else -# define YY_NULLPTR ((void*)0) -# endif -# endif - -#include "parser.hpp" -/* Symbol kind. */ -enum yysymbol_kind_t -{ - YYSYMBOL_YYEMPTY = -2, - YYSYMBOL_YYEOF = 0, /* "end of file" */ - YYSYMBOL_YYerror = 1, /* error */ - YYSYMBOL_YYUNDEF = 2, /* "invalid token" */ - YYSYMBOL_CLASS = 3, /* CLASS */ - YYSYMBOL_EXTENDS = 4, /* EXTENDS */ - YYSYMBOL_IS = 5, /* IS */ - YYSYMBOL_END = 6, /* END */ - YYSYMBOL_VAR = 7, /* VAR */ - YYSYMBOL_METHOD = 8, /* METHOD */ - YYSYMBOL_THIS = 9, /* THIS */ - YYSYMBOL_RETURN = 10, /* RETURN */ - YYSYMBOL_IF = 11, /* IF */ - YYSYMBOL_THEN = 12, /* THEN */ - YYSYMBOL_ELSE = 13, /* ELSE */ - YYSYMBOL_WHILE = 14, /* WHILE */ - YYSYMBOL_LOOP = 15, /* LOOP */ - YYSYMBOL_TRUE = 16, /* TRUE */ - YYSYMBOL_FALSE = 17, /* FALSE */ - YYSYMBOL_IDENTIFIER = 18, /* IDENTIFIER */ - YYSYMBOL_INTEGER = 19, /* INTEGER */ - YYSYMBOL_REAL = 20, /* REAL */ - YYSYMBOL_STRING = 21, /* STRING */ - YYSYMBOL_SYMBOL = 22, /* SYMBOL */ - YYSYMBOL_UNKNOWN = 23, /* UNKNOWN */ - YYSYMBOL_COLON = 24, /* COLON */ - YYSYMBOL_SEMI = 25, /* SEMI */ - YYSYMBOL_LPAREN = 26, /* LPAREN */ - YYSYMBOL_RPAREN = 27, /* RPAREN */ - YYSYMBOL_COMMA = 28, /* COMMA */ - YYSYMBOL_DOT = 29, /* DOT */ - YYSYMBOL_ASSIGN = 30, /* ASSIGN */ - YYSYMBOL_ARROW = 31, /* ARROW */ - YYSYMBOL_YYACCEPT = 32, /* $accept */ - YYSYMBOL_program = 33, /* program */ - YYSYMBOL_top_list = 34, /* top_list */ - YYSYMBOL_top_item = 35, /* top_item */ - YYSYMBOL_class_decl = 36, /* class_decl */ - YYSYMBOL_class_opt_ext = 37, /* class_opt_ext */ - YYSYMBOL_class_body = 38, /* class_body */ - YYSYMBOL_class_member = 39, /* class_member */ - YYSYMBOL_var_decl = 40, /* var_decl */ - YYSYMBOL_maybe_type = 41, /* maybe_type */ - YYSYMBOL_method_decl = 42, /* method_decl */ - YYSYMBOL_method_body = 43, /* method_body */ - YYSYMBOL_method_member = 44 /* method_member */ -}; -typedef enum yysymbol_kind_t yysymbol_kind_t; - - - - -#ifdef short -# undef short -#endif - -/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure - and (if available) are included - so that the code can choose integer types of a good width. */ - -#ifndef __PTRDIFF_MAX__ -# include /* INFRINGES ON USER NAME SPACE */ -# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ -# include /* INFRINGES ON USER NAME SPACE */ -# define YY_STDINT_H -# endif -#endif - -/* Narrow types that promote to a signed type and that can represent a - signed or unsigned integer of at least N bits. In tables they can - save space and decrease cache pressure. Promoting to a signed type - helps avoid bugs in integer arithmetic. */ - -#ifdef __INT_LEAST8_MAX__ -typedef __INT_LEAST8_TYPE__ yytype_int8; -#elif defined YY_STDINT_H -typedef int_least8_t yytype_int8; -#else -typedef signed char yytype_int8; -#endif - -#ifdef __INT_LEAST16_MAX__ -typedef __INT_LEAST16_TYPE__ yytype_int16; -#elif defined YY_STDINT_H -typedef int_least16_t yytype_int16; -#else -typedef short yytype_int16; -#endif - -/* Work around bug in HP-UX 11.23, which defines these macros - incorrectly for preprocessor constants. This workaround can likely - be removed in 2023, as HPE has promised support for HP-UX 11.23 - (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of - . */ -#ifdef __hpux -# undef UINT_LEAST8_MAX -# undef UINT_LEAST16_MAX -# define UINT_LEAST8_MAX 255 -# define UINT_LEAST16_MAX 65535 -#endif - -#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__ -typedef __UINT_LEAST8_TYPE__ yytype_uint8; -#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \ - && UINT_LEAST8_MAX <= INT_MAX) -typedef uint_least8_t yytype_uint8; -#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX -typedef unsigned char yytype_uint8; -#else -typedef short yytype_uint8; -#endif - -#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__ -typedef __UINT_LEAST16_TYPE__ yytype_uint16; -#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \ - && UINT_LEAST16_MAX <= INT_MAX) -typedef uint_least16_t yytype_uint16; -#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX -typedef unsigned short yytype_uint16; -#else -typedef int yytype_uint16; -#endif - -#ifndef YYPTRDIFF_T -# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__ -# define YYPTRDIFF_T __PTRDIFF_TYPE__ -# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__ -# elif defined PTRDIFF_MAX -# ifndef ptrdiff_t -# include /* INFRINGES ON USER NAME SPACE */ -# endif -# define YYPTRDIFF_T ptrdiff_t -# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX -# else -# define YYPTRDIFF_T long -# define YYPTRDIFF_MAXIMUM LONG_MAX -# endif -#endif - -#ifndef YYSIZE_T -# ifdef __SIZE_TYPE__ -# define YYSIZE_T __SIZE_TYPE__ -# elif defined size_t -# define YYSIZE_T size_t -# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# else -# define YYSIZE_T unsigned -# endif -#endif - -#define YYSIZE_MAXIMUM \ - YY_CAST (YYPTRDIFF_T, \ - (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \ - ? YYPTRDIFF_MAXIMUM \ - : YY_CAST (YYSIZE_T, -1))) - -#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) - - -/* Stored state numbers (used for stacks). */ -typedef yytype_int8 yy_state_t; - -/* State numbers in computations. */ -typedef int yy_state_fast_t; - -#ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS -# if ENABLE_NLS -# include /* INFRINGES ON USER NAME SPACE */ -# define YY_(Msgid) dgettext ("bison-runtime", Msgid) -# endif -# endif -# ifndef YY_ -# define YY_(Msgid) Msgid -# endif -#endif - - -#ifndef YY_ATTRIBUTE_PURE -# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) -# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) -# else -# define YY_ATTRIBUTE_PURE -# endif -#endif - -#ifndef YY_ATTRIBUTE_UNUSED -# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__) -# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) -# else -# define YY_ATTRIBUTE_UNUSED -# endif -#endif - -/* Suppress unused-variable warnings by "using" E. */ -#if ! defined lint || defined __GNUC__ -# define YY_USE(E) ((void) (E)) -#else -# define YY_USE(E) /* empty */ -#endif - -/* Suppress an incorrect diagnostic about yylval being uninitialized. */ -#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__ -# if __GNUC__ * 100 + __GNUC_MINOR__ < 407 -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") -# else -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \ - _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") -# endif -# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ - _Pragma ("GCC diagnostic pop") -#else -# define YY_INITIAL_VALUE(Value) Value -#endif -#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -# define YY_IGNORE_MAYBE_UNINITIALIZED_END -#endif -#ifndef YY_INITIAL_VALUE -# define YY_INITIAL_VALUE(Value) /* Nothing. */ -#endif - -#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__ -# define YY_IGNORE_USELESS_CAST_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"") -# define YY_IGNORE_USELESS_CAST_END \ - _Pragma ("GCC diagnostic pop") -#endif -#ifndef YY_IGNORE_USELESS_CAST_BEGIN -# define YY_IGNORE_USELESS_CAST_BEGIN -# define YY_IGNORE_USELESS_CAST_END -#endif - - -#define YY_ASSERT(E) ((void) (0 && (E))) - -#if 1 - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -# ifdef YYSTACK_USE_ALLOCA -# if YYSTACK_USE_ALLOCA -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# elif defined __BUILTIN_VA_ARG_INCR -# include /* INFRINGES ON USER NAME SPACE */ -# elif defined _AIX -# define YYSTACK_ALLOC __alloca -# elif defined _MSC_VER -# include /* INFRINGES ON USER NAME SPACE */ -# define alloca _alloca -# else -# define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS -# include /* INFRINGES ON USER NAME SPACE */ - /* Use EXIT_SUCCESS as a witness for stdlib.h. */ -# ifndef EXIT_SUCCESS -# define EXIT_SUCCESS 0 -# endif -# endif -# endif -# endif -# endif - -# ifdef YYSTACK_ALLOC - /* Pacify GCC's 'empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) -# ifndef YYSTACK_ALLOC_MAXIMUM - /* The OS might guarantee only one guard page at the bottom of the stack, - and a page size can be as small as 4096 bytes. So we cannot safely - invoke alloca (N) if N exceeds 4096. Use a slightly smaller number - to allow for a few compiler-allocated temporary stack slots. */ -# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ -# endif -# else -# define YYSTACK_ALLOC YYMALLOC -# define YYSTACK_FREE YYFREE -# ifndef YYSTACK_ALLOC_MAXIMUM -# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM -# endif -# if (defined __cplusplus && ! defined EXIT_SUCCESS \ - && ! ((defined YYMALLOC || defined malloc) \ - && (defined YYFREE || defined free))) -# include /* INFRINGES ON USER NAME SPACE */ -# ifndef EXIT_SUCCESS -# define EXIT_SUCCESS 0 -# endif -# endif -# ifndef YYMALLOC -# define YYMALLOC malloc -# if ! defined malloc && ! defined EXIT_SUCCESS -void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# ifndef YYFREE -# define YYFREE free -# if ! defined free && ! defined EXIT_SUCCESS -void free (void *); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# endif -#endif /* 1 */ - -#if (! defined yyoverflow \ - && (! defined __cplusplus \ - || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - yy_state_t yyss_alloc; - YYSTYPE yyvs_alloc; -}; - -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1) - -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# define YYSTACK_BYTES(N) \ - ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \ - + YYSTACK_GAP_MAXIMUM) - -# define YYCOPY_NEEDED 1 - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ - do \ - { \ - YYPTRDIFF_T yynewbytes; \ - YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ - Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / YYSIZEOF (*yyptr); \ - } \ - while (0) - -#endif - -#if defined YYCOPY_NEEDED && YYCOPY_NEEDED -/* Copy COUNT objects from SRC to DST. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(Dst, Src, Count) \ - __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src))) -# else -# define YYCOPY(Dst, Src, Count) \ - do \ - { \ - YYPTRDIFF_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (Dst)[yyi] = (Src)[yyi]; \ - } \ - while (0) -# endif -# endif -#endif /* !YYCOPY_NEEDED */ - -/* YYFINAL -- State number of the termination state. */ -#define YYFINAL 3 -/* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 26 - -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 32 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 13 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 21 -/* YYNSTATES -- Number of states. */ -#define YYNSTATES 34 - -/* YYMAXUTOK -- Last valid token kind. */ -#define YYMAXUTOK 286 - - -/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, with out-of-bounds checking. */ -#define YYTRANSLATE(YYX) \ - (0 <= (YYX) && (YYX) <= YYMAXUTOK \ - ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \ - : YYSYMBOL_YYUNDEF) - -/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex. */ -static const yytype_int8 yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31 -}; - -#if YYDEBUG -/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ -static const yytype_uint8 yyrline[] = -{ - 0, 55, 55, 67, 68, 75, 76, 77, 81, 95, - 96, 100, 101, 108, 109, 113, 122, 123, 127, 139, - 140, 147 -}; -#endif - -/** Accessing symbol of state STATE. */ -#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State]) - -#if 1 -/* The user-facing name of the symbol whose (internal) number is - YYSYMBOL. No bounds checking. */ -static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED; - -/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = -{ - "\"end of file\"", "error", "\"invalid token\"", "CLASS", "EXTENDS", - "IS", "END", "VAR", "METHOD", "THIS", "RETURN", "IF", "THEN", "ELSE", - "WHILE", "LOOP", "TRUE", "FALSE", "IDENTIFIER", "INTEGER", "REAL", - "STRING", "SYMBOL", "UNKNOWN", "COLON", "SEMI", "LPAREN", "RPAREN", - "COMMA", "DOT", "ASSIGN", "ARROW", "$accept", "program", "top_list", - "top_item", "class_decl", "class_opt_ext", "class_body", "class_member", - "var_decl", "maybe_type", "method_decl", "method_body", "method_member", YY_NULLPTR -}; - -static const char * -yysymbol_name (yysymbol_kind_t yysymbol) -{ - return yytname[yysymbol]; -} -#endif - -#define YYPACT_NINF (-25) - -#define yypact_value_is_default(Yyn) \ - ((Yyn) == YYPACT_NINF) - -#define YYTABLE_NINF (-1) - -#define yytable_value_is_error(Yyn) \ - 0 - -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -static const yytype_int8 yypact[] = -{ - -25, 4, 0, -25, -13, -6, -4, -25, -25, -25, - -25, 9, -9, -10, -1, 13, 1, -3, -7, -25, - -25, -25, -25, 16, 3, -25, -25, -25, -25, -25, - -5, -25, -25, -25 -}; - -/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. - Performed when YYTABLE does not specify something else to do. Zero - means the default is an error. */ -static const yytype_int8 yydefact[] = -{ - 3, 0, 2, 1, 0, 0, 0, 4, 5, 6, - 7, 9, 16, 0, 0, 0, 0, 0, 0, 10, - 11, 17, 15, 0, 0, 19, 8, 12, 13, 14, - 0, 18, 21, 20 -}; - -/* YYPGOTO[NTERM-NUM]. */ -static const yytype_int8 yypgoto[] = -{ - -25, -25, -25, -25, -25, -25, -25, -25, -24, -25, - 2, -25, -25 -}; - -/* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int8 yydefgoto[] = -{ - 0, 1, 2, 7, 8, 15, 24, 27, 9, 17, - 10, 30, 33 -}; - -/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule whose - number is the opposite. If YYTABLE_NINF, syntax error. */ -static const yytype_int8 yytable[] = -{ - 28, 31, 5, 4, 3, 11, 32, 5, 6, 26, - 5, 6, 12, 14, 13, 16, 18, 19, 20, 21, - 23, 25, 22, 0, 0, 0, 29 -}; - -static const yytype_int8 yycheck[] = -{ - 24, 6, 7, 3, 0, 18, 30, 7, 8, 6, - 7, 8, 18, 4, 18, 24, 26, 18, 5, 18, - 27, 5, 25, -1, -1, -1, 24 -}; - -/* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of - state STATE-NUM. */ -static const yytype_int8 yystos[] = -{ - 0, 33, 34, 0, 3, 7, 8, 35, 36, 40, - 42, 18, 18, 18, 4, 37, 24, 41, 26, 18, - 5, 18, 25, 27, 38, 5, 6, 39, 40, 42, - 43, 6, 40, 44 -}; - -/* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */ -static const yytype_int8 yyr1[] = -{ - 0, 32, 33, 34, 34, 35, 35, 35, 36, 37, - 37, 38, 38, 39, 39, 40, 41, 41, 42, 43, - 43, 44 -}; - -/* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */ -static const yytype_int8 yyr2[] = -{ - 0, 2, 1, 0, 2, 1, 1, 1, 6, 0, - 2, 0, 2, 1, 1, 4, 0, 2, 7, 0, - 2, 1 -}; - - -enum { YYENOMEM = -2 }; - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab -#define YYNOMEM goto yyexhaustedlab - - -#define YYRECOVERING() (!!yyerrstatus) - -#define YYBACKUP(Token, Value) \ - do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ - while (0) - -/* Backward compatibility with an undocumented macro. - Use YYerror or YYUNDEF. */ -#define YYERRCODE YYUNDEF - - -/* Enable debugging if requested. */ -#if YYDEBUG - -# ifndef YYFPRINTF -# include /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# endif - -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (0) - - - - -# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yy_symbol_print (stderr, \ - Kind, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (0) - - -/*-----------------------------------. -| Print this symbol's value on YYO. | -`-----------------------------------*/ - -static void -yy_symbol_value_print (FILE *yyo, - yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) -{ - FILE *yyoutput = yyo; - YY_USE (yyoutput); - if (!yyvaluep) - return; - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - YY_USE (yykind); - YY_IGNORE_MAYBE_UNINITIALIZED_END -} - - -/*---------------------------. -| Print this symbol on YYO. | -`---------------------------*/ - -static void -yy_symbol_print (FILE *yyo, - yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) -{ - YYFPRINTF (yyo, "%s %s (", - yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind)); - - yy_symbol_value_print (yyo, yykind, yyvaluep); - YYFPRINTF (yyo, ")"); -} - -/*------------------------------------------------------------------. -| yy_stack_print -- Print the state stack from its BOTTOM up to its | -| TOP (included). | -`------------------------------------------------------------------*/ - -static void -yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop) -{ - YYFPRINTF (stderr, "Stack now"); - for (; yybottom <= yytop; yybottom++) - { - int yybot = *yybottom; - YYFPRINTF (stderr, " %d", yybot); - } - YYFPRINTF (stderr, "\n"); -} - -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (0) - - -/*------------------------------------------------. -| Report that the YYRULE is going to be reduced. | -`------------------------------------------------*/ - -static void -yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, - int yyrule) -{ - int yylno = yyrline[yyrule]; - int yynrhs = yyr2[yyrule]; - int yyi; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n", - yyrule - 1, yylno); - /* The symbols being reduced. */ - for (yyi = 0; yyi < yynrhs; yyi++) - { - YYFPRINTF (stderr, " $%d = ", yyi + 1); - yy_symbol_print (stderr, - YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]), - &yyvsp[(yyi + 1) - (yynrhs)]); - YYFPRINTF (stderr, "\n"); - } -} - -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (yyssp, yyvsp, Rule); \ -} while (0) - -/* Nonzero means print parse trace. It is left uninitialized so that - multiple parsers can coexist. */ -int yydebug; -#else /* !YYDEBUG */ -# define YYDPRINTF(Args) ((void) 0) -# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) -# define YY_STACK_PRINT(Bottom, Top) -# define YY_REDUCE_PRINT(Rule) -#endif /* !YYDEBUG */ - - -/* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH -# define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only - if the built-in stack extension method is used). - - Do not make this value too large; the results are undefined if - YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) - evaluated with infinite-precision integer arithmetic. */ - -#ifndef YYMAXDEPTH -# define YYMAXDEPTH 10000 -#endif - - -/* Context of a parse error. */ -typedef struct -{ - yy_state_t *yyssp; - yysymbol_kind_t yytoken; -} yypcontext_t; - -/* Put in YYARG at most YYARGN of the expected tokens given the - current YYCTX, and return the number of tokens stored in YYARG. If - YYARG is null, return the number of expected tokens (guaranteed to - be less than YYNTOKENS). Return YYENOMEM on memory exhaustion. - Return 0 if there are more than YYARGN expected tokens, yet fill - YYARG up to YYARGN. */ -static int -yypcontext_expected_tokens (const yypcontext_t *yyctx, - yysymbol_kind_t yyarg[], int yyargn) -{ - /* Actual size of YYARG. */ - int yycount = 0; - int yyn = yypact[+*yyctx->yyssp]; - if (!yypact_value_is_default (yyn)) - { - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. In other words, skip the first -YYN actions for - this state because they are default actions. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yyx; - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYSYMBOL_YYerror - && !yytable_value_is_error (yytable[yyx + yyn])) - { - if (!yyarg) - ++yycount; - else if (yycount == yyargn) - return 0; - else - yyarg[yycount++] = YY_CAST (yysymbol_kind_t, yyx); - } - } - if (yyarg && yycount == 0 && 0 < yyargn) - yyarg[0] = YYSYMBOL_YYEMPTY; - return yycount; -} - - - - -#ifndef yystrlen -# if defined __GLIBC__ && defined _STRING_H -# define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S))) -# else -/* Return the length of YYSTR. */ -static YYPTRDIFF_T -yystrlen (const char *yystr) -{ - YYPTRDIFF_T yylen; - for (yylen = 0; yystr[yylen]; yylen++) - continue; - return yylen; -} -# endif -#endif - -#ifndef yystpcpy -# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -static char * -yystpcpy (char *yydest, const char *yysrc) -{ - char *yyd = yydest; - const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -#endif - -#ifndef yytnamerr -/* Copy to YYRES the contents of YYSTR after stripping away unnecessary - quotes and backslashes, so that it's suitable for yyerror. The - heuristic is that double-quoting is unnecessary unless the string - contains an apostrophe, a comma, or backslash (other than - backslash-backslash). YYSTR is taken from yytname. If YYRES is - null, do not copy; instead, return the length of what the result - would have been. */ -static YYPTRDIFF_T -yytnamerr (char *yyres, const char *yystr) -{ - if (*yystr == '"') - { - YYPTRDIFF_T yyn = 0; - char const *yyp = yystr; - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - else - goto append; - - append: - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes: ; - } - - if (yyres) - return yystpcpy (yyres, yystr) - yyres; - else - return yystrlen (yystr); -} -#endif - - -static int -yy_syntax_error_arguments (const yypcontext_t *yyctx, - yysymbol_kind_t yyarg[], int yyargn) -{ - /* Actual size of YYARG. */ - int yycount = 0; - /* There are many possibilities here to consider: - - If this state is a consistent state with a default action, then - the only way this function was invoked is if the default action - is an error action. In that case, don't check for expected - tokens because there are none. - - The only way there can be no lookahead present (in yychar) is if - this state is a consistent state with a default action. Thus, - detecting the absence of a lookahead is sufficient to determine - that there is no unexpected or expected token to report. In that - case, just report a simple "syntax error". - - Don't assume there isn't a lookahead just because this state is a - consistent state with a default action. There might have been a - previous inconsistent state, consistent state with a non-default - action, or user semantic action that manipulated yychar. - - Of course, the expected token list depends on states to have - correct lookahead information, and it depends on the parser not - to perform extra reductions after fetching a lookahead from the - scanner and before detecting a syntax error. Thus, state merging - (from LALR or IELR) and default reductions corrupt the expected - token list. However, the list is correct for canonical LR with - one exception: it will still contain any token that will not be - accepted due to an error action in a later state. - */ - if (yyctx->yytoken != YYSYMBOL_YYEMPTY) - { - int yyn; - if (yyarg) - yyarg[yycount] = yyctx->yytoken; - ++yycount; - yyn = yypcontext_expected_tokens (yyctx, - yyarg ? yyarg + 1 : yyarg, yyargn - 1); - if (yyn == YYENOMEM) - return YYENOMEM; - else - yycount += yyn; - } - return yycount; -} - -/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message - about the unexpected token YYTOKEN for the state stack whose top is - YYSSP. - - Return 0 if *YYMSG was successfully written. Return -1 if *YYMSG is - not large enough to hold the message. In that case, also set - *YYMSG_ALLOC to the required number of bytes. Return YYENOMEM if the - required number of bytes is too large to store. */ -static int -yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg, - const yypcontext_t *yyctx) -{ - enum { YYARGS_MAX = 5 }; - /* Internationalized format string. */ - const char *yyformat = YY_NULLPTR; - /* Arguments of yyformat: reported tokens (one for the "unexpected", - one per "expected"). */ - yysymbol_kind_t yyarg[YYARGS_MAX]; - /* Cumulated lengths of YYARG. */ - YYPTRDIFF_T yysize = 0; - - /* Actual size of YYARG. */ - int yycount = yy_syntax_error_arguments (yyctx, yyarg, YYARGS_MAX); - if (yycount == YYENOMEM) - return YYENOMEM; - - switch (yycount) - { -#define YYCASE_(N, S) \ - case N: \ - yyformat = S; \ - break - default: /* Avoid compiler warnings. */ - YYCASE_(0, YY_("syntax error")); - YYCASE_(1, YY_("syntax error, unexpected %s")); - YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); - YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); - YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); - YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); -#undef YYCASE_ - } - - /* Compute error message size. Don't count the "%s"s, but reserve - room for the terminator. */ - yysize = yystrlen (yyformat) - 2 * yycount + 1; - { - int yyi; - for (yyi = 0; yyi < yycount; ++yyi) - { - YYPTRDIFF_T yysize1 - = yysize + yytnamerr (YY_NULLPTR, yytname[yyarg[yyi]]); - if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) - yysize = yysize1; - else - return YYENOMEM; - } - } - - if (*yymsg_alloc < yysize) - { - *yymsg_alloc = 2 * yysize; - if (! (yysize <= *yymsg_alloc - && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) - *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; - return -1; - } - - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - { - char *yyp = *yymsg; - int yyi = 0; - while ((*yyp = *yyformat) != '\0') - if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yytname[yyarg[yyi++]]); - yyformat += 2; - } - else - { - ++yyp; - ++yyformat; - } - } - return 0; -} - - -/*-----------------------------------------------. -| Release the memory associated to this symbol. | -`-----------------------------------------------*/ - -static void -yydestruct (const char *yymsg, - yysymbol_kind_t yykind, YYSTYPE *yyvaluep) -{ - YY_USE (yyvaluep); - if (!yymsg) - yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp); - - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - YY_USE (yykind); - YY_IGNORE_MAYBE_UNINITIALIZED_END -} - - -/* Lookahead token kind. */ -int yychar; - -/* The semantic value of the lookahead symbol. */ -YYSTYPE yylval; -/* Number of syntax errors so far. */ -int yynerrs; - - - - -/*----------. -| yyparse. | -`----------*/ - -int -yyparse (void) -{ - yy_state_fast_t yystate = 0; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus = 0; - - /* Refer to the stacks through separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* Their size. */ - YYPTRDIFF_T yystacksize = YYINITDEPTH; - - /* The state stack: array, bottom, top. */ - yy_state_t yyssa[YYINITDEPTH]; - yy_state_t *yyss = yyssa; - yy_state_t *yyssp = yyss; - - /* The semantic value stack: array, bottom, top. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp = yyvs; - - int yyn; - /* The return value of yyparse. */ - int yyresult; - /* Lookahead symbol kind. */ - yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY; - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf; - -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) - - /* The number of symbols on the RHS of the reduced rule. - Keep to zero when no symbol should be popped. */ - int yylen = 0; - - YYDPRINTF ((stderr, "Starting parse\n")); - - yychar = YYEMPTY; /* Cause a token to be read. */ - - goto yysetstate; - - -/*------------------------------------------------------------. -| yynewstate -- push a new state, which is found in yystate. | -`------------------------------------------------------------*/ -yynewstate: - /* In all cases, when you get here, the value and location stacks - have just been pushed. So pushing a state here evens the stacks. */ - yyssp++; - - -/*--------------------------------------------------------------------. -| yysetstate -- set current state (the top of the stack) to yystate. | -`--------------------------------------------------------------------*/ -yysetstate: - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - YY_ASSERT (0 <= yystate && yystate < YYNSTATES); - YY_IGNORE_USELESS_CAST_BEGIN - *yyssp = YY_CAST (yy_state_t, yystate); - YY_IGNORE_USELESS_CAST_END - YY_STACK_PRINT (yyss, yyssp); - - if (yyss + yystacksize - 1 <= yyssp) -#if !defined yyoverflow && !defined YYSTACK_RELOCATE - YYNOMEM; -#else - { - /* Get the current used size of the three stacks, in elements. */ - YYPTRDIFF_T yysize = yyssp - yyss + 1; - -# if defined yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - yy_state_t *yyss1 = yyss; - YYSTYPE *yyvs1 = yyvs; - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * YYSIZEOF (*yyssp), - &yyvs1, yysize * YYSIZEOF (*yyvsp), - &yystacksize); - yyss = yyss1; - yyvs = yyvs1; - } -# else /* defined YYSTACK_RELOCATE */ - /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) - YYNOMEM; - yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; - - { - yy_state_t *yyss1 = yyss; - union yyalloc *yyptr = - YY_CAST (union yyalloc *, - YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize)))); - if (! yyptr) - YYNOMEM; - YYSTACK_RELOCATE (yyss_alloc, yyss); - YYSTACK_RELOCATE (yyvs_alloc, yyvs); -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif - - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; - - YY_IGNORE_USELESS_CAST_BEGIN - YYDPRINTF ((stderr, "Stack size increased to %ld\n", - YY_CAST (long, yystacksize))); - YY_IGNORE_USELESS_CAST_END - - if (yyss + yystacksize - 1 <= yyssp) - YYABORT; - } -#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ - - - if (yystate == YYFINAL) - YYACCEPT; - - goto yybackup; - - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: - /* Do appropriate processing given the current state. Read a - lookahead token if we need one and don't already have one. */ - - /* First try to decide what to do without reference to lookahead token. */ - yyn = yypact[yystate]; - if (yypact_value_is_default (yyn)) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */ - if (yychar == YYEMPTY) - { - YYDPRINTF ((stderr, "Reading a token\n")); - yychar = yylex (); - } - - if (yychar <= YYEOF) - { - yychar = YYEOF; - yytoken = YYSYMBOL_YYEOF; - YYDPRINTF ((stderr, "Now at end of input.\n")); - } - else if (yychar == YYerror) - { - /* The scanner already issued an error message, process directly - to error recovery. But do not keep the error token as - lookahead, it is too special and may lead us to an endless - loop in error recovery. */ - yychar = YYUNDEF; - yytoken = YYSYMBOL_YYerror; - goto yyerrlab1; - } - else - { - yytoken = YYTRANSLATE (yychar); - YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); - } - - /* If the proper action on seeing token YYTOKEN is to reduce or to - detect an error, take that action. */ - yyn += yytoken; - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) - goto yydefault; - yyn = yytable[yyn]; - if (yyn <= 0) - { - if (yytable_value_is_error (yyn)) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; - - /* Shift the lookahead token. */ - YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - yystate = yyn; - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - *++yyvsp = yylval; - YY_IGNORE_MAYBE_UNINITIALIZED_END - - /* Discard the shifted token. */ - yychar = YYEMPTY; - goto yynewstate; - - -/*-----------------------------------------------------------. -| yydefault -- do the default action for the current state. | -`-----------------------------------------------------------*/ -yydefault: - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - - -/*-----------------------------. -| yyreduce -- do a reduction. | -`-----------------------------*/ -yyreduce: - /* yyn is the number of a rule to reduce with. */ - yylen = yyr2[yyn]; - - /* If YYLEN is nonzero, implement the default value of the action: - '$$ = $1'. - - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. Assigning to YYVAL - unconditionally makes the parser a bit smaller, and it avoids a - GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1-yylen]; - - - YY_REDUCE_PRINT (yyn); - switch (yyn) - { - case 2: /* program: top_list */ -#line 55 "parser.y" - { - g_program = make_unique(); - if ((yyvsp[0].vec)) { - for (ASTNode* p : *(yyvsp[0].vec)) { - g_program->decls.emplace_back(unique_ptr(p)); - } - delete (yyvsp[0].vec); - } - } -#line 1423 "parser.cpp" - break; - - case 3: /* top_list: %empty */ -#line 67 "parser.y" - { (yyval.vec) = new vector(); } -#line 1429 "parser.cpp" - break; - - case 4: /* top_list: top_list top_item */ -#line 68 "parser.y" - { - (yyval.vec) = (yyvsp[-1].vec); - if ((yyvsp[0].node)) (yyval.vec)->push_back((yyvsp[0].node)); - } -#line 1438 "parser.cpp" - break; - - case 5: /* top_item: class_decl */ -#line 75 "parser.y" - { (yyval.node) = (yyvsp[0].node); } -#line 1444 "parser.cpp" - break; - - case 6: /* top_item: var_decl */ -#line 76 "parser.y" - { (yyval.node) = (yyvsp[0].node); } -#line 1450 "parser.cpp" - break; - - case 7: /* top_item: method_decl */ -#line 77 "parser.y" - { (yyval.node) = (yyvsp[0].node); } -#line 1456 "parser.cpp" - break; - - case 8: /* class_decl: CLASS IDENTIFIER class_opt_ext IS class_body END */ -#line 81 "parser.y" - { - auto cn = new ClassNode((yyvsp[-4].str) ? string((yyvsp[-4].str)) : string()); - if ((yyvsp[-3].str)) cn->extendsName = string((yyvsp[-3].str)); - if ((yyvsp[-1].vec)) { - for (ASTNode* m : *(yyvsp[-1].vec)) cn->members.emplace_back(unique_ptr(m)); - delete (yyvsp[-1].vec); - } - if ((yyvsp[-4].str)) free((yyvsp[-4].str)); - if ((yyvsp[-3].str)) free((yyvsp[-3].str)); - (yyval.node) = cn; - } -#line 1472 "parser.cpp" - break; - - case 9: /* class_opt_ext: %empty */ -#line 95 "parser.y" - { (yyval.str) = nullptr; } -#line 1478 "parser.cpp" - break; - - case 10: /* class_opt_ext: EXTENDS IDENTIFIER */ -#line 96 "parser.y" - { (yyval.str) = (yyvsp[0].str); } -#line 1484 "parser.cpp" - break; - - case 11: /* class_body: %empty */ -#line 100 "parser.y" - { (yyval.vec) = new vector(); } -#line 1490 "parser.cpp" - break; - - case 12: /* class_body: class_body class_member */ -#line 101 "parser.y" - { - (yyval.vec) = (yyvsp[-1].vec); - if ((yyvsp[0].node)) (yyval.vec)->push_back((yyvsp[0].node)); - } -#line 1499 "parser.cpp" - break; - - case 13: /* class_member: var_decl */ -#line 108 "parser.y" - { (yyval.node) = (yyvsp[0].node); } -#line 1505 "parser.cpp" - break; - - case 14: /* class_member: method_decl */ -#line 109 "parser.y" - { (yyval.node) = (yyvsp[0].node); } -#line 1511 "parser.cpp" - break; - - case 15: /* var_decl: VAR IDENTIFIER maybe_type SEMI */ -#line 113 "parser.y" - { - auto vn = new VarNode((yyvsp[-2].str) ? string((yyvsp[-2].str)) : string(), (yyvsp[-1].str) ? string((yyvsp[-1].str)) : string()); - if ((yyvsp[-2].str)) free((yyvsp[-2].str)); - if ((yyvsp[-1].str)) free((yyvsp[-1].str)); - (yyval.node) = vn; - } -#line 1522 "parser.cpp" - break; - - case 16: /* maybe_type: %empty */ -#line 122 "parser.y" - { (yyval.str) = nullptr; } -#line 1528 "parser.cpp" - break; - - case 17: /* maybe_type: COLON IDENTIFIER */ -#line 123 "parser.y" - { (yyval.str) = (yyvsp[0].str); } -#line 1534 "parser.cpp" - break; - - case 18: /* method_decl: METHOD IDENTIFIER LPAREN RPAREN IS method_body END */ -#line 127 "parser.y" - { - auto mn = new MethodNode((yyvsp[-5].str) ? string((yyvsp[-5].str)) : string()); - if ((yyvsp[-1].vec)) { - for (ASTNode* b : *(yyvsp[-1].vec)) mn->body.emplace_back(unique_ptr(b)); - delete (yyvsp[-1].vec); - } - if ((yyvsp[-5].str)) free((yyvsp[-5].str)); - (yyval.node) = mn; - } -#line 1548 "parser.cpp" - break; - - case 19: /* method_body: %empty */ -#line 139 "parser.y" - { (yyval.vec) = new vector(); } -#line 1554 "parser.cpp" - break; - - case 20: /* method_body: method_body method_member */ -#line 140 "parser.y" - { - (yyval.vec) = (yyvsp[-1].vec); - if ((yyvsp[0].node)) (yyval.vec)->push_back((yyvsp[0].node)); - } -#line 1563 "parser.cpp" - break; - - case 21: /* method_member: var_decl */ -#line 147 "parser.y" - { (yyval.node) = (yyvsp[0].node); } -#line 1569 "parser.cpp" - break; - - -#line 1573 "parser.cpp" - - default: break; - } - /* User semantic actions sometimes alter yychar, and that requires - that yytoken be updated with the new translation. We take the - approach of translating immediately before every use of yytoken. - One alternative is translating here after every semantic action, - but that translation would be missed if the semantic action invokes - YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or - if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an - incorrect destructor might then be invoked immediately. In the - case of YYERROR or YYBACKUP, subsequent parser actions might lead - to an incorrect destructor call or verbose syntax error message - before the lookahead is translated. */ - YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc); - - YYPOPSTACK (yylen); - yylen = 0; - - *++yyvsp = yyval; - - /* Now 'shift' the result of the reduction. Determine what state - that goes to, based on the state we popped back to and the rule - number reduced by. */ - { - const int yylhs = yyr1[yyn] - YYNTOKENS; - const int yyi = yypgoto[yylhs] + *yyssp; - yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp - ? yytable[yyi] - : yydefgoto[yylhs]); - } - - goto yynewstate; - - -/*--------------------------------------. -| yyerrlab -- here on detecting error. | -`--------------------------------------*/ -yyerrlab: - /* Make sure we have latest lookahead translation. See comments at - user semantic actions for why this is necessary. */ - yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar); - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) - { - ++yynerrs; - { - yypcontext_t yyctx - = {yyssp, yytoken}; - char const *yymsgp = YY_("syntax error"); - int yysyntax_error_status; - yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx); - if (yysyntax_error_status == 0) - yymsgp = yymsg; - else if (yysyntax_error_status == -1) - { - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = YY_CAST (char *, - YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc))); - if (yymsg) - { - yysyntax_error_status - = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx); - yymsgp = yymsg; - } - else - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - yysyntax_error_status = YYENOMEM; - } - } - yyerror (yymsgp); - if (yysyntax_error_status == YYENOMEM) - YYNOMEM; - } - } - - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ - - if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } - else - { - yydestruct ("Error: discarding", - yytoken, &yylval); - yychar = YYEMPTY; - } - } - - /* Else will try to reuse lookahead token after shifting the error - token. */ - goto yyerrlab1; - - -/*---------------------------------------------------. -| yyerrorlab -- error raised explicitly by YYERROR. | -`---------------------------------------------------*/ -yyerrorlab: - /* Pacify compilers when the user code never invokes YYERROR and the - label yyerrorlab therefore never appears in user code. */ - if (0) - YYERROR; - ++yynerrs; - - /* Do not reclaim the symbols of the rule whose action triggered - this YYERROR. */ - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - yystate = *yyssp; - goto yyerrlab1; - - -/*-------------------------------------------------------------. -| yyerrlab1 -- common code for both syntax error and YYERROR. | -`-------------------------------------------------------------*/ -yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ - - /* Pop stack until we find a state that shifts the error token. */ - for (;;) - { - yyn = yypact[yystate]; - if (!yypact_value_is_default (yyn)) - { - yyn += YYSYMBOL_YYerror; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } - - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; - - - yydestruct ("Error: popping", - YY_ACCESSING_SYMBOL (yystate), yyvsp); - YYPOPSTACK (1); - yystate = *yyssp; - YY_STACK_PRINT (yyss, yyssp); - } - - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - *++yyvsp = yylval; - YY_IGNORE_MAYBE_UNINITIALIZED_END - - - /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp); - - yystate = yyn; - goto yynewstate; - - -/*-------------------------------------. -| yyacceptlab -- YYACCEPT comes here. | -`-------------------------------------*/ -yyacceptlab: - yyresult = 0; - goto yyreturnlab; - - -/*-----------------------------------. -| yyabortlab -- YYABORT comes here. | -`-----------------------------------*/ -yyabortlab: - yyresult = 1; - goto yyreturnlab; - - -/*-----------------------------------------------------------. -| yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. | -`-----------------------------------------------------------*/ -yyexhaustedlab: - yyerror (YY_("memory exhausted")); - yyresult = 2; - goto yyreturnlab; - - -/*----------------------------------------------------------. -| yyreturnlab -- parsing is finished, clean up and return. | -`----------------------------------------------------------*/ -yyreturnlab: - if (yychar != YYEMPTY) - { - /* Make sure we have latest lookahead translation. See comments at - user semantic actions for why this is necessary. */ - yytoken = YYTRANSLATE (yychar); - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval); - } - /* Do not reclaim the symbols of the rule whose action triggered - this YYABORT or YYACCEPT. */ - YYPOPSTACK (yylen); - YY_STACK_PRINT (yyss, yyssp); - while (yyssp != yyss) - { - yydestruct ("Cleanup: popping", - YY_ACCESSING_SYMBOL (+*yyssp), yyvsp); - YYPOPSTACK (1); - } -#ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); -#endif - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - return yyresult; -} - -#line 150 "parser.y" - - -int yylex(void); diff --git a/parser.hpp b/parser.hpp deleted file mode 100644 index ef1c428..0000000 --- a/parser.hpp +++ /dev/null @@ -1,122 +0,0 @@ -/* A Bison parser, made by GNU Bison 3.8.2. */ - -/* Bison interface for Yacc-like parsers in C - - Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 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 3 of the License, 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, see . */ - -/* 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. */ - -/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, - especially those whose name start with YY_ or yy_. They are - private implementation details that can be changed or removed. */ - -#ifndef YY_YY_PARSER_HPP_INCLUDED -# define YY_YY_PARSER_HPP_INCLUDED -/* Debug traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif -#if YYDEBUG -extern int yydebug; -#endif -/* "%code requires" blocks. */ -#line 31 "parser.y" - - #include - class ASTNode; // forward declaration - -#line 54 "parser.hpp" - -/* Token kinds. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - enum yytokentype - { - YYEMPTY = -2, - YYEOF = 0, /* "end of file" */ - YYerror = 256, /* error */ - YYUNDEF = 257, /* "invalid token" */ - CLASS = 258, /* CLASS */ - EXTENDS = 259, /* EXTENDS */ - IS = 260, /* IS */ - END = 261, /* END */ - VAR = 262, /* VAR */ - METHOD = 263, /* METHOD */ - THIS = 264, /* THIS */ - RETURN = 265, /* RETURN */ - IF = 266, /* IF */ - THEN = 267, /* THEN */ - ELSE = 268, /* ELSE */ - WHILE = 269, /* WHILE */ - LOOP = 270, /* LOOP */ - TRUE = 271, /* TRUE */ - FALSE = 272, /* FALSE */ - IDENTIFIER = 273, /* IDENTIFIER */ - INTEGER = 274, /* INTEGER */ - REAL = 275, /* REAL */ - STRING = 276, /* STRING */ - SYMBOL = 277, /* SYMBOL */ - UNKNOWN = 278, /* UNKNOWN */ - COLON = 279, /* COLON */ - SEMI = 280, /* SEMI */ - LPAREN = 281, /* LPAREN */ - RPAREN = 282, /* RPAREN */ - COMMA = 283, /* COMMA */ - DOT = 284, /* DOT */ - ASSIGN = 285, /* ASSIGN */ - ARROW = 286 /* ARROW */ - }; - typedef enum yytokentype yytoken_kind_t; -#endif - -/* Value type. */ -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -union YYSTYPE -{ -#line 36 "parser.y" - - char* str; - ASTNode* node; - std::vector* vec; - -#line 108 "parser.hpp" - -}; -typedef union YYSTYPE YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 -# define YYSTYPE_IS_DECLARED 1 -#endif - - -extern YYSTYPE yylval; - - -int yyparse (void); - - -#endif /* !YY_YY_PARSER_HPP_INCLUDED */ diff --git a/parser.tab.cc b/parser.tab.cc deleted file mode 100644 index 8fa0537..0000000 --- a/parser.tab.cc +++ /dev/null @@ -1,1279 +0,0 @@ -// A Bison parser, made by GNU Bison 3.8.2. - -// Skeleton implementation for Bison LALR(1) parsers in C++ - -// Copyright (C) 2002-2015, 2018-2021 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 3 of the License, 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, see . - -// 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. - -// DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, -// especially those whose name start with YY_ or yy_. They are -// private implementation details that can be changed or removed. - - - -// First part of user prologue. -#line 7 "parser.y" - -/* C++ includes and AST definitions */ -#include -#include -#include -#include -#include /* strdup, free */ -using namespace std; - -/* --- AST classes (C++ style) --- */ -struct ASTNode { - virtual ~ASTNode() = default; - virtual void print(int indent=0) const = 0; -}; - -using ASTNodePtr = unique_ptr; - -static string indentStr(int n) { return string(n, ' '); } - -struct ProgramNode : ASTNode { - vector decls; - void print(int indent=0) const override { - cout << indentStr(indent) << "Program\n"; - for (auto &d : decls) d->print(indent+2); - } -}; - -struct ClassNode : ASTNode { - string name; - string extendsName; - vector members; - ClassNode(const string &n="") : name(n) {} - void print(int indent=0) const override { - cout << indentStr(indent) << "Class: " << name; - if (!extendsName.empty()) cout << " extends " << extendsName; - cout << "\n"; - for (auto &m : members) m->print(indent+2); - } -}; - -struct VarNode : ASTNode { - string name; - string type; - VarNode(const string &n="", const string &t="") : name(n), type(t) {} - void print(int indent=0) const override { - cout << indentStr(indent) << "Var: " << name; - if (!type.empty()) cout << " : " << type; - cout << "\n"; - } -}; - -struct MethodNode : ASTNode { - string name; - vector params; - vector body; - MethodNode(const string &n="") : name(n) {} - void print(int indent=0) const override { - cout << indentStr(indent) << "Method: " << name << "\n"; - for (auto &b : body) b->print(indent+2); - } -}; - -/* глобальный root AST (используется в main.cpp) */ -std::unique_ptr g_program = nullptr; - -/* Forward: лексер предоставляет этот тип и вектор simpleTokens */ -struct SimpleToken { std::string kind; std::string text; int line; int startCol; int endCol; }; -extern std::vector simpleTokens; /* defined in lexer.l */ - -/* индекс для доступа к simpleTokens из yylex() */ -static size_t parserTokIndex = 0; - - -#line 115 "parser.tab.cc" - - -#include "parser.tab.hh" - - - - -#ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS -# if ENABLE_NLS -# include // FIXME: INFRINGES ON USER NAME SPACE. -# define YY_(msgid) dgettext ("bison-runtime", msgid) -# endif -# endif -# ifndef YY_ -# define YY_(msgid) msgid -# endif -#endif - - -// Whether we are compiled with exception support. -#ifndef YY_EXCEPTIONS -# if defined __GNUC__ && !defined __EXCEPTIONS -# define YY_EXCEPTIONS 0 -# else -# define YY_EXCEPTIONS 1 -# endif -#endif - - - -// Enable debugging if requested. -#if YYDEBUG - -// A pseudo ostream that takes yydebug_ into account. -# define YYCDEBUG if (yydebug_) (*yycdebug_) - -# define YY_SYMBOL_PRINT(Title, Symbol) \ - do { \ - if (yydebug_) \ - { \ - *yycdebug_ << Title << ' '; \ - yy_print_ (*yycdebug_, Symbol); \ - *yycdebug_ << '\n'; \ - } \ - } while (false) - -# define YY_REDUCE_PRINT(Rule) \ - do { \ - if (yydebug_) \ - yy_reduce_print_ (Rule); \ - } while (false) - -# define YY_STACK_PRINT() \ - do { \ - if (yydebug_) \ - yy_stack_print_ (); \ - } while (false) - -#else // !YYDEBUG - -# define YYCDEBUG if (false) std::cerr -# define YY_SYMBOL_PRINT(Title, Symbol) YY_USE (Symbol) -# define YY_REDUCE_PRINT(Rule) static_cast (0) -# define YY_STACK_PRINT() static_cast (0) - -#endif // !YYDEBUG - -#define yyerrok (yyerrstatus_ = 0) -#define yyclearin (yyla.clear ()) - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab -#define YYRECOVERING() (!!yyerrstatus_) - -namespace yy { -#line 193 "parser.tab.cc" - - /// Build a parser object. - parser::parser () -#if YYDEBUG - : yydebug_ (false), - yycdebug_ (&std::cerr) -#else - -#endif - {} - - parser::~parser () - {} - - parser::syntax_error::~syntax_error () YY_NOEXCEPT YY_NOTHROW - {} - - /*---------. - | symbol. | - `---------*/ - - // basic_symbol. - template - parser::basic_symbol::basic_symbol (const basic_symbol& that) - : Base (that) - , value (that.value) - {} - - - /// Constructor for valueless symbols. - template - parser::basic_symbol::basic_symbol (typename Base::kind_type t) - : Base (t) - , value () - {} - - template - parser::basic_symbol::basic_symbol (typename Base::kind_type t, YY_RVREF (value_type) v) - : Base (t) - , value (YY_MOVE (v)) - {} - - - template - parser::symbol_kind_type - parser::basic_symbol::type_get () const YY_NOEXCEPT - { - return this->kind (); - } - - - template - bool - parser::basic_symbol::empty () const YY_NOEXCEPT - { - return this->kind () == symbol_kind::S_YYEMPTY; - } - - template - void - parser::basic_symbol::move (basic_symbol& s) - { - super_type::move (s); - value = YY_MOVE (s.value); - } - - // by_kind. - parser::by_kind::by_kind () YY_NOEXCEPT - : kind_ (symbol_kind::S_YYEMPTY) - {} - -#if 201103L <= YY_CPLUSPLUS - parser::by_kind::by_kind (by_kind&& that) YY_NOEXCEPT - : kind_ (that.kind_) - { - that.clear (); - } -#endif - - parser::by_kind::by_kind (const by_kind& that) YY_NOEXCEPT - : kind_ (that.kind_) - {} - - parser::by_kind::by_kind (token_kind_type t) YY_NOEXCEPT - : kind_ (yytranslate_ (t)) - {} - - - - void - parser::by_kind::clear () YY_NOEXCEPT - { - kind_ = symbol_kind::S_YYEMPTY; - } - - void - parser::by_kind::move (by_kind& that) - { - kind_ = that.kind_; - that.clear (); - } - - parser::symbol_kind_type - parser::by_kind::kind () const YY_NOEXCEPT - { - return kind_; - } - - - parser::symbol_kind_type - parser::by_kind::type_get () const YY_NOEXCEPT - { - return this->kind (); - } - - - - // by_state. - parser::by_state::by_state () YY_NOEXCEPT - : state (empty_state) - {} - - parser::by_state::by_state (const by_state& that) YY_NOEXCEPT - : state (that.state) - {} - - void - parser::by_state::clear () YY_NOEXCEPT - { - state = empty_state; - } - - void - parser::by_state::move (by_state& that) - { - state = that.state; - that.clear (); - } - - parser::by_state::by_state (state_type s) YY_NOEXCEPT - : state (s) - {} - - parser::symbol_kind_type - parser::by_state::kind () const YY_NOEXCEPT - { - if (state == empty_state) - return symbol_kind::S_YYEMPTY; - else - return YY_CAST (symbol_kind_type, yystos_[+state]); - } - - parser::stack_symbol_type::stack_symbol_type () - {} - - parser::stack_symbol_type::stack_symbol_type (YY_RVREF (stack_symbol_type) that) - : super_type (YY_MOVE (that.state), YY_MOVE (that.value)) - { -#if 201103L <= YY_CPLUSPLUS - // that is emptied. - that.state = empty_state; -#endif - } - - parser::stack_symbol_type::stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) that) - : super_type (s, YY_MOVE (that.value)) - { - // that is emptied. - that.kind_ = symbol_kind::S_YYEMPTY; - } - -#if YY_CPLUSPLUS < 201103L - parser::stack_symbol_type& - parser::stack_symbol_type::operator= (const stack_symbol_type& that) - { - state = that.state; - value = that.value; - return *this; - } - - parser::stack_symbol_type& - parser::stack_symbol_type::operator= (stack_symbol_type& that) - { - state = that.state; - value = that.value; - // that is emptied. - that.state = empty_state; - return *this; - } -#endif - - template - void - parser::yy_destroy_ (const char* yymsg, basic_symbol& yysym) const - { - if (yymsg) - YY_SYMBOL_PRINT (yymsg, yysym); - - // User destructor. - YY_USE (yysym.kind ()); - } - -#if YYDEBUG - template - void - parser::yy_print_ (std::ostream& yyo, const basic_symbol& yysym) const - { - std::ostream& yyoutput = yyo; - YY_USE (yyoutput); - if (yysym.empty ()) - yyo << "empty symbol"; - else - { - symbol_kind_type yykind = yysym.kind (); - yyo << (yykind < YYNTOKENS ? "token" : "nterm") - << ' ' << yysym.name () << " ("; - YY_USE (yykind); - yyo << ')'; - } - } -#endif - - void - parser::yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym) - { - if (m) - YY_SYMBOL_PRINT (m, sym); - yystack_.push (YY_MOVE (sym)); - } - - void - parser::yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym) - { -#if 201103L <= YY_CPLUSPLUS - yypush_ (m, stack_symbol_type (s, std::move (sym))); -#else - stack_symbol_type ss (s, sym); - yypush_ (m, ss); -#endif - } - - void - parser::yypop_ (int n) YY_NOEXCEPT - { - yystack_.pop (n); - } - -#if YYDEBUG - std::ostream& - parser::debug_stream () const - { - return *yycdebug_; - } - - void - parser::set_debug_stream (std::ostream& o) - { - yycdebug_ = &o; - } - - - parser::debug_level_type - parser::debug_level () const - { - return yydebug_; - } - - void - parser::set_debug_level (debug_level_type l) - { - yydebug_ = l; - } -#endif // YYDEBUG - - parser::state_type - parser::yy_lr_goto_state_ (state_type yystate, int yysym) - { - int yyr = yypgoto_[yysym - YYNTOKENS] + yystate; - if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate) - return yytable_[yyr]; - else - return yydefgoto_[yysym - YYNTOKENS]; - } - - bool - parser::yy_pact_value_is_default_ (int yyvalue) YY_NOEXCEPT - { - return yyvalue == yypact_ninf_; - } - - bool - parser::yy_table_value_is_error_ (int yyvalue) YY_NOEXCEPT - { - return yyvalue == yytable_ninf_; - } - - int - parser::operator() () - { - return parse (); - } - - int - parser::parse () - { - int yyn; - /// Length of the RHS of the rule being reduced. - int yylen = 0; - - // Error handling. - int yynerrs_ = 0; - int yyerrstatus_ = 0; - - /// The lookahead symbol. - symbol_type yyla; - - /// The return value of parse (). - int yyresult; - -#if YY_EXCEPTIONS - try -#endif // YY_EXCEPTIONS - { - YYCDEBUG << "Starting parse\n"; - - - /* Initialize the stack. The initial state will be set in - yynewstate, since the latter expects the semantical and the - location values to have been already stored, initialize these - stacks with a primary value. */ - yystack_.clear (); - yypush_ (YY_NULLPTR, 0, YY_MOVE (yyla)); - - /*-----------------------------------------------. - | yynewstate -- push a new symbol on the stack. | - `-----------------------------------------------*/ - yynewstate: - YYCDEBUG << "Entering state " << int (yystack_[0].state) << '\n'; - YY_STACK_PRINT (); - - // Accept? - if (yystack_[0].state == yyfinal_) - YYACCEPT; - - goto yybackup; - - - /*-----------. - | yybackup. | - `-----------*/ - yybackup: - // Try to take a decision without lookahead. - yyn = yypact_[+yystack_[0].state]; - if (yy_pact_value_is_default_ (yyn)) - goto yydefault; - - // Read a lookahead token. - if (yyla.empty ()) - { - YYCDEBUG << "Reading a token\n"; -#if YY_EXCEPTIONS - try -#endif // YY_EXCEPTIONS - { - yyla.kind_ = yytranslate_ (yylex (&yyla.value)); - } -#if YY_EXCEPTIONS - catch (const syntax_error& yyexc) - { - YYCDEBUG << "Caught exception: " << yyexc.what() << '\n'; - error (yyexc); - goto yyerrlab1; - } -#endif // YY_EXCEPTIONS - } - YY_SYMBOL_PRINT ("Next token is", yyla); - - if (yyla.kind () == symbol_kind::S_YYerror) - { - // The scanner already issued an error message, process directly - // to error recovery. But do not keep the error token as - // lookahead, it is too special and may lead us to an endless - // loop in error recovery. */ - yyla.kind_ = symbol_kind::S_YYUNDEF; - goto yyerrlab1; - } - - /* If the proper action on seeing token YYLA.TYPE is to reduce or - to detect an error, take that action. */ - yyn += yyla.kind (); - if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.kind ()) - { - goto yydefault; - } - - // Reduce or error. - yyn = yytable_[yyn]; - if (yyn <= 0) - { - if (yy_table_value_is_error_ (yyn)) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - - // Count tokens shifted since error; after three, turn off error status. - if (yyerrstatus_) - --yyerrstatus_; - - // Shift the lookahead token. - yypush_ ("Shifting", state_type (yyn), YY_MOVE (yyla)); - goto yynewstate; - - - /*-----------------------------------------------------------. - | yydefault -- do the default action for the current state. | - `-----------------------------------------------------------*/ - yydefault: - yyn = yydefact_[+yystack_[0].state]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - - - /*-----------------------------. - | yyreduce -- do a reduction. | - `-----------------------------*/ - yyreduce: - yylen = yyr2_[yyn]; - { - stack_symbol_type yylhs; - yylhs.state = yy_lr_goto_state_ (yystack_[yylen].state, yyr1_[yyn]); - /* If YYLEN is nonzero, implement the default value of the - action: '$$ = $1'. Otherwise, use the top of the stack. - - Otherwise, the following line sets YYLHS.VALUE to garbage. - This behavior is undocumented and Bison users should not rely - upon it. */ - if (yylen) - yylhs.value = yystack_[yylen - 1].value; - else - yylhs.value = yystack_[0].value; - - - // Perform the reduction. - YY_REDUCE_PRINT (yyn); -#if YY_EXCEPTIONS - try -#endif // YY_EXCEPTIONS - { - switch (yyn) - { - case 2: // program: top_list -#line 106 "parser.y" - { - /* $1 = std::vector* */ - g_program.reset(new ProgramNode()); - if ((yystack_[0].value.vec)) { - for (ASTNode* p : *(yystack_[0].value.vec)) { - g_program->decls.emplace_back( std::unique_ptr(p) ); - } - delete (yystack_[0].value.vec); - } - } -#line 658 "parser.tab.cc" - break; - - case 3: // top_list: %empty -#line 120 "parser.y" - { (yylhs.value.vec) = new std::vector(); } -#line 664 "parser.tab.cc" - break; - - case 4: // top_list: top_list top_item -#line 122 "parser.y" - { - /* $1 = vector*, $2 = ASTNode* */ - (yylhs.value.vec) = (yystack_[1].value.vec); - if ((yystack_[0].value.node)) (yylhs.value.vec)->push_back((yystack_[0].value.node)); - } -#line 674 "parser.tab.cc" - break; - - case 5: // top_item: class_decl -#line 130 "parser.y" - { (yylhs.value.node) = (yystack_[0].value.node); } -#line 680 "parser.tab.cc" - break; - - case 6: // top_item: var_decl -#line 131 "parser.y" - { (yylhs.value.node) = (yystack_[0].value.node); } -#line 686 "parser.tab.cc" - break; - - case 7: // top_item: method_decl -#line 132 "parser.y" - { (yylhs.value.node) = (yystack_[0].value.node); } -#line 692 "parser.tab.cc" - break; - - case 8: // class_decl: CLASS IDENTIFIER class_opt_ext IS class_body END -#line 137 "parser.y" - { - /* $2 = char* (name), $3 = char* (extends or NULL), $5 = vector* members */ - ClassNode* cn = new ClassNode((yystack_[4].value.str) ? string((yystack_[4].value.str)) : string()); - if ((yystack_[3].value.str)) cn->extendsName = string((yystack_[3].value.str)); - if ((yystack_[1].value.vec)) { - for (ASTNode* m : *(yystack_[1].value.vec)) cn->members.emplace_back( std::unique_ptr(m) ); - delete (yystack_[1].value.vec); - } - if ((yystack_[4].value.str)) free((yystack_[4].value.str)); - if ((yystack_[3].value.str)) free((yystack_[3].value.str)); - (yylhs.value.node) = cn; - } -#line 709 "parser.tab.cc" - break; - - case 9: // class_opt_ext: %empty -#line 152 "parser.y" - { (yylhs.value.str) = nullptr; } -#line 715 "parser.tab.cc" - break; - - case 10: // class_opt_ext: EXTENDS IDENTIFIER -#line 153 "parser.y" - { (yylhs.value.str) = (yystack_[0].value.str); } -#line 721 "parser.tab.cc" - break; - - case 11: // class_body: %empty -#line 157 "parser.y" - { (yylhs.value.vec) = new std::vector(); } -#line 727 "parser.tab.cc" - break; - - case 12: // class_body: class_body class_member -#line 159 "parser.y" - { - (yylhs.value.vec) = (yystack_[1].value.vec); - if ((yystack_[0].value.node)) (yylhs.value.vec)->push_back((yystack_[0].value.node)); - } -#line 736 "parser.tab.cc" - break; - - case 13: // class_member: var_decl -#line 166 "parser.y" - { (yylhs.value.node) = (yystack_[0].value.node); } -#line 742 "parser.tab.cc" - break; - - case 14: // class_member: method_decl -#line 167 "parser.y" - { (yylhs.value.node) = (yystack_[0].value.node); } -#line 748 "parser.tab.cc" - break; - - case 15: // var_decl: VAR IDENTIFIER maybe_type SEMI -#line 172 "parser.y" - { - /* $2 = name (char*), $3 = type (char* or nullptr) */ - VarNode* vn = new VarNode((yystack_[2].value.str) ? string((yystack_[2].value.str)) : string(), (yystack_[1].value.str) ? string((yystack_[1].value.str)) : string()); - if ((yystack_[2].value.str)) free((yystack_[2].value.str)); - if ((yystack_[1].value.str)) free((yystack_[1].value.str)); - (yylhs.value.node) = vn; - } -#line 760 "parser.tab.cc" - break; - - case 16: // maybe_type: %empty -#line 182 "parser.y" - { (yylhs.value.str) = nullptr; } -#line 766 "parser.tab.cc" - break; - - case 17: // maybe_type: COLON IDENTIFIER -#line 183 "parser.y" - { (yylhs.value.str) = (yystack_[0].value.str); } -#line 772 "parser.tab.cc" - break; - - case 18: // method_decl: METHOD IDENTIFIER LPAREN RPAREN IS method_body END -#line 188 "parser.y" - { - /* $2 = name, $6 = vector* body */ - MethodNode* mn = new MethodNode((yystack_[5].value.str) ? string((yystack_[5].value.str)) : string()); - if ((yystack_[1].value.vec)) { - for (ASTNode* b : *(yystack_[1].value.vec)) mn->body.emplace_back( std::unique_ptr(b) ); - delete (yystack_[1].value.vec); - } - if ((yystack_[5].value.str)) free((yystack_[5].value.str)); - (yylhs.value.node) = mn; - } -#line 787 "parser.tab.cc" - break; - - case 19: // method_body: %empty -#line 201 "parser.y" - { (yylhs.value.vec) = new std::vector(); } -#line 793 "parser.tab.cc" - break; - - case 20: // method_body: method_body method_member -#line 203 "parser.y" - { - (yylhs.value.vec) = (yystack_[1].value.vec); - if ((yystack_[0].value.node)) (yylhs.value.vec)->push_back((yystack_[0].value.node)); - } -#line 802 "parser.tab.cc" - break; - - case 21: // method_member: var_decl -#line 210 "parser.y" - { (yylhs.value.node) = (yystack_[0].value.node); } -#line 808 "parser.tab.cc" - break; - - case 22: // method_member: %empty -#line 212 "parser.y" - { (yylhs.value.node) = new VarNode("__dummy__", ""); } -#line 814 "parser.tab.cc" - break; - - -#line 818 "parser.tab.cc" - - default: - break; - } - } -#if YY_EXCEPTIONS - catch (const syntax_error& yyexc) - { - YYCDEBUG << "Caught exception: " << yyexc.what() << '\n'; - error (yyexc); - YYERROR; - } -#endif // YY_EXCEPTIONS - YY_SYMBOL_PRINT ("-> $$ =", yylhs); - yypop_ (yylen); - yylen = 0; - - // Shift the result of the reduction. - yypush_ (YY_NULLPTR, YY_MOVE (yylhs)); - } - goto yynewstate; - - - /*--------------------------------------. - | yyerrlab -- here on detecting error. | - `--------------------------------------*/ - yyerrlab: - // If not already recovering from an error, report this error. - if (!yyerrstatus_) - { - ++yynerrs_; - std::string msg = YY_("syntax error"); - error (YY_MOVE (msg)); - } - - - if (yyerrstatus_ == 3) - { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ - - // Return failure if at end of input. - if (yyla.kind () == symbol_kind::S_YYEOF) - YYABORT; - else if (!yyla.empty ()) - { - yy_destroy_ ("Error: discarding", yyla); - yyla.clear (); - } - } - - // Else will try to reuse lookahead token after shifting the error token. - goto yyerrlab1; - - - /*---------------------------------------------------. - | yyerrorlab -- error raised explicitly by YYERROR. | - `---------------------------------------------------*/ - yyerrorlab: - /* Pacify compilers when the user code never invokes YYERROR and - the label yyerrorlab therefore never appears in user code. */ - if (false) - YYERROR; - - /* Do not reclaim the symbols of the rule whose action triggered - this YYERROR. */ - yypop_ (yylen); - yylen = 0; - YY_STACK_PRINT (); - goto yyerrlab1; - - - /*-------------------------------------------------------------. - | yyerrlab1 -- common code for both syntax error and YYERROR. | - `-------------------------------------------------------------*/ - yyerrlab1: - yyerrstatus_ = 3; // Each real token shifted decrements this. - // Pop stack until we find a state that shifts the error token. - for (;;) - { - yyn = yypact_[+yystack_[0].state]; - if (!yy_pact_value_is_default_ (yyn)) - { - yyn += symbol_kind::S_YYerror; - if (0 <= yyn && yyn <= yylast_ - && yycheck_[yyn] == symbol_kind::S_YYerror) - { - yyn = yytable_[yyn]; - if (0 < yyn) - break; - } - } - - // Pop the current state because it cannot handle the error token. - if (yystack_.size () == 1) - YYABORT; - - yy_destroy_ ("Error: popping", yystack_[0]); - yypop_ (); - YY_STACK_PRINT (); - } - { - stack_symbol_type error_token; - - - // Shift the error token. - error_token.state = state_type (yyn); - yypush_ ("Shifting", YY_MOVE (error_token)); - } - goto yynewstate; - - - /*-------------------------------------. - | yyacceptlab -- YYACCEPT comes here. | - `-------------------------------------*/ - yyacceptlab: - yyresult = 0; - goto yyreturn; - - - /*-----------------------------------. - | yyabortlab -- YYABORT comes here. | - `-----------------------------------*/ - yyabortlab: - yyresult = 1; - goto yyreturn; - - - /*-----------------------------------------------------. - | yyreturn -- parsing is finished, return the result. | - `-----------------------------------------------------*/ - yyreturn: - if (!yyla.empty ()) - yy_destroy_ ("Cleanup: discarding lookahead", yyla); - - /* Do not reclaim the symbols of the rule whose action triggered - this YYABORT or YYACCEPT. */ - yypop_ (yylen); - YY_STACK_PRINT (); - while (1 < yystack_.size ()) - { - yy_destroy_ ("Cleanup: popping", yystack_[0]); - yypop_ (); - } - - return yyresult; - } -#if YY_EXCEPTIONS - catch (...) - { - YYCDEBUG << "Exception caught: cleaning lookahead and stack\n"; - // Do not try to display the values of the reclaimed symbols, - // as their printers might throw an exception. - if (!yyla.empty ()) - yy_destroy_ (YY_NULLPTR, yyla); - - while (1 < yystack_.size ()) - { - yy_destroy_ (YY_NULLPTR, yystack_[0]); - yypop_ (); - } - throw; - } -#endif // YY_EXCEPTIONS - } - - void - parser::error (const syntax_error& yyexc) - { - error (yyexc.what ()); - } - -#if YYDEBUG || 0 - const char * - parser::symbol_name (symbol_kind_type yysymbol) - { - return yytname_[yysymbol]; - } -#endif // #if YYDEBUG || 0 - - - - - - - - - - const signed char parser::yypact_ninf_ = -25; - - const signed char parser::yytable_ninf_ = -1; - - const signed char - parser::yypact_[] = - { - -25, 4, 0, -25, -13, -6, -4, -25, -25, -25, - -25, 9, -9, -10, -1, 13, 1, -3, -7, -25, - -25, -25, -25, 16, 3, -25, -25, -25, -25, -25, - -5, -25, -25, -25 - }; - - const signed char - parser::yydefact_[] = - { - 3, 0, 2, 1, 0, 0, 0, 4, 5, 6, - 7, 9, 16, 0, 0, 0, 0, 0, 0, 10, - 11, 17, 15, 0, 0, 19, 8, 12, 13, 14, - 0, 18, 21, 20 - }; - - const signed char - parser::yypgoto_[] = - { - -25, -25, -25, -25, -25, -25, -25, -25, -24, -25, - 2, -25, -25 - }; - - const signed char - parser::yydefgoto_[] = - { - 0, 1, 2, 7, 8, 15, 24, 27, 9, 17, - 10, 30, 33 - }; - - const signed char - parser::yytable_[] = - { - 28, 31, 5, 4, 3, 11, 32, 5, 6, 26, - 5, 6, 12, 14, 13, 16, 18, 19, 20, 21, - 23, 25, 22, 0, 0, 0, 29 - }; - - const signed char - parser::yycheck_[] = - { - 24, 6, 7, 3, 0, 18, 30, 7, 8, 6, - 7, 8, 18, 4, 18, 24, 26, 18, 5, 18, - 27, 5, 25, -1, -1, -1, 24 - }; - - const signed char - parser::yystos_[] = - { - 0, 33, 34, 0, 3, 7, 8, 35, 36, 40, - 42, 18, 18, 18, 4, 37, 24, 41, 26, 18, - 5, 18, 25, 27, 38, 5, 6, 39, 40, 42, - 43, 6, 40, 44 - }; - - const signed char - parser::yyr1_[] = - { - 0, 32, 33, 34, 34, 35, 35, 35, 36, 37, - 37, 38, 38, 39, 39, 40, 41, 41, 42, 43, - 43, 44, 44 - }; - - const signed char - parser::yyr2_[] = - { - 0, 2, 1, 0, 2, 1, 1, 1, 6, 0, - 2, 0, 2, 1, 1, 4, 0, 2, 7, 0, - 2, 1, 0 - }; - - -#if YYDEBUG - // YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - // First, the terminals, then, starting at \a YYNTOKENS, nonterminals. - const char* - const parser::yytname_[] = - { - "\"end of file\"", "error", "\"invalid token\"", "CLASS", "EXTENDS", - "IS", "END", "VAR", "METHOD", "THIS", "RETURN", "IF", "THEN", "ELSE", - "WHILE", "LOOP", "TRUE", "FALSE", "IDENTIFIER", "INTEGER", "REAL", - "STRING", "SYMBOL", "UNKNOWN", "COLON", "SEMI", "LPAREN", "RPAREN", - "COMMA", "DOT", "ASSIGN", "ARROW", "$accept", "program", "top_list", - "top_item", "class_decl", "class_opt_ext", "class_body", "class_member", - "var_decl", "maybe_type", "method_decl", "method_body", "method_member", YY_NULLPTR - }; -#endif - - -#if YYDEBUG - const unsigned char - parser::yyrline_[] = - { - 0, 105, 105, 120, 121, 130, 131, 132, 136, 152, - 153, 157, 158, 166, 167, 171, 182, 183, 187, 201, - 202, 210, 212 - }; - - void - parser::yy_stack_print_ () const - { - *yycdebug_ << "Stack now"; - for (stack_type::const_iterator - i = yystack_.begin (), - i_end = yystack_.end (); - i != i_end; ++i) - *yycdebug_ << ' ' << int (i->state); - *yycdebug_ << '\n'; - } - - void - parser::yy_reduce_print_ (int yyrule) const - { - int yylno = yyrline_[yyrule]; - int yynrhs = yyr2_[yyrule]; - // Print the symbols being reduced, and their result. - *yycdebug_ << "Reducing stack by rule " << yyrule - 1 - << " (line " << yylno << "):\n"; - // The symbols being reduced. - for (int yyi = 0; yyi < yynrhs; yyi++) - YY_SYMBOL_PRINT (" $" << yyi + 1 << " =", - yystack_[(yynrhs) - (yyi + 1)]); - } -#endif // YYDEBUG - - parser::symbol_kind_type - parser::yytranslate_ (int t) YY_NOEXCEPT - { - // YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to - // TOKEN-NUM as returned by yylex. - static - const signed char - translate_table[] = - { - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31 - }; - // Last valid token kind. - const int code_max = 286; - - if (t <= 0) - return symbol_kind::S_YYEOF; - else if (t <= code_max) - return static_cast (translate_table[t]); - else - return symbol_kind::S_YYUNDEF; - } - -} // yy -#line 1189 "parser.tab.cc" - -#line 215 "parser.y" - - -/* ---- C/C++ вспомогательный код: yylex() и yyerror() ---- */ -%{ - -/* Реализация yylex() читает из simpleTokens, который создаёт lexer.l (flex) */ -/* simpleTokens: vector (SimpleToken defined in lexer.l) */ -#include - -/* Прототип extern из lexer.l: - extern std::vector simpleTokens; - (SimpleToken = { std::string kind, text; int line,startCol,endCol }) -*/ -extern std::vector simpleTokens; - -int yylex(void) { - if (parserTokIndex >= simpleTokens.size()) return 0; /* EOF */ - - const SimpleToken &t = simpleTokens[parserTokIndex++]; - - /* Ключевые слова и идентификаторы: - Лексер ранее помечал ключевые слова kind == "KEYWORD" и booleans etc. - Здесь сопоставляем текст. При необходимости можно погружать в нижний регистр. - */ - - if (t.kind == "KEYWORD") { - if (t.text == "class") return CLASS; - if (t.text == "extends") return EXTENDS; - if (t.text == "is") return IS; - if (t.text == "end") return END; - if (t.text == "var") return VAR; - if (t.text == "method") return METHOD; - if (t.text == "this") return THIS; - if (t.text == "return") return RETURN; - if (t.text == "if") return IF; - if (t.text == "then") return THEN; - if (t.text == "else") return ELSE; - if (t.text == "while") return WHILE; - if (t.text == "loop") return LOOP; - if (t.text == "true") { - yylval.str = strdup(t.text.c_str()); - return TRUE; - } - if (t.text == "false") { - yylval.str = strdup(t.text.c_str()); - return FALSE; - } - /* если flex пометил как KEYWORD, но текст не совпал, отдаём как IDENTIFIER */ - yylval.str = strdup(t.text.c_str()); - return IDENTIFIER; - } else if (t.kind == "IDENTIFIER") { - yylval.str = strdup(t.text.c_str()); - return IDENTIFIER; - } else if (t.kind == "INTEGER") { - yylval.str = strdup(t.text.c_str()); - return INTEGER; - } else if (t.kind == "REAL") { - yylval.str = strdup(t.text.c_str()); - return REAL; - } else if (t.kind == "STRING") { - yylval.str = strdup(t.text.c_str()); - return STRING; - } else if (t.kind == "SYMBOL") { - if (t.text == ":") { return COLON; } - if (t.text == ";") { return SEMI; } - if (t.text == "(") { return LPAREN; } - if (t.text == ")") { return RPAREN; } - if (t.text == ",") { return COMMA; } - if (t.text == ".") { return DOT; } - if (t.text == ":=") { return ASSIGN; } - if (t.text == "=>") { return ARROW; } - /* иначе отдаём как SYMBOL (несем семантику в yylval.str) */ - yylval.str = strdup(t.text.c_str()); - return SYMBOL; - } else if (t.kind == "UNKNOWN") { - yylval.str = strdup(t.text.c_str()); - return UNKNOWN; - } else { - /* fallback: ignore */ - return 0; - } -} - -/* Простая ошибка парсинга */ -void yyerror(const char *s) { - std::cerr << "Parse error: " << s << "\n"; -} - -%} diff --git a/parser.tab.hh b/parser.tab.hh deleted file mode 100644 index e23d15b..0000000 --- a/parser.tab.hh +++ /dev/null @@ -1,827 +0,0 @@ -// A Bison parser, made by GNU Bison 3.8.2. - -// Skeleton interface for Bison LALR(1) parsers in C++ - -// Copyright (C) 2002-2015, 2018-2021 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 3 of the License, 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, see . - -// 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. - - -/** - ** \file parser.tab.hh - ** Define the yy::parser class. - */ - -// C++ LALR(1) parser skeleton written by Akim Demaille. - -// DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, -// especially those whose name start with YY_ or yy_. They are -// private implementation details that can be changed or removed. - -#ifndef YY_YY_PARSER_TAB_HH_INCLUDED -# define YY_YY_PARSER_TAB_HH_INCLUDED - - -# include // std::abort -# include -# include -# include -# include - -#if defined __cplusplus -# define YY_CPLUSPLUS __cplusplus -#else -# define YY_CPLUSPLUS 199711L -#endif - -// Support move semantics when possible. -#if 201103L <= YY_CPLUSPLUS -# define YY_MOVE std::move -# define YY_MOVE_OR_COPY move -# define YY_MOVE_REF(Type) Type&& -# define YY_RVREF(Type) Type&& -# define YY_COPY(Type) Type -#else -# define YY_MOVE -# define YY_MOVE_OR_COPY copy -# define YY_MOVE_REF(Type) Type& -# define YY_RVREF(Type) const Type& -# define YY_COPY(Type) const Type& -#endif - -// Support noexcept when possible. -#if 201103L <= YY_CPLUSPLUS -# define YY_NOEXCEPT noexcept -# define YY_NOTHROW -#else -# define YY_NOEXCEPT -# define YY_NOTHROW throw () -#endif - -// Support constexpr when possible. -#if 201703 <= YY_CPLUSPLUS -# define YY_CONSTEXPR constexpr -#else -# define YY_CONSTEXPR -#endif - - - -#ifndef YY_ATTRIBUTE_PURE -# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) -# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) -# else -# define YY_ATTRIBUTE_PURE -# endif -#endif - -#ifndef YY_ATTRIBUTE_UNUSED -# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__) -# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) -# else -# define YY_ATTRIBUTE_UNUSED -# endif -#endif - -/* Suppress unused-variable warnings by "using" E. */ -#if ! defined lint || defined __GNUC__ -# define YY_USE(E) ((void) (E)) -#else -# define YY_USE(E) /* empty */ -#endif - -/* Suppress an incorrect diagnostic about yylval being uninitialized. */ -#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__ -# if __GNUC__ * 100 + __GNUC_MINOR__ < 407 -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") -# else -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \ - _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") -# endif -# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ - _Pragma ("GCC diagnostic pop") -#else -# define YY_INITIAL_VALUE(Value) Value -#endif -#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -# define YY_IGNORE_MAYBE_UNINITIALIZED_END -#endif -#ifndef YY_INITIAL_VALUE -# define YY_INITIAL_VALUE(Value) /* Nothing. */ -#endif - -#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__ -# define YY_IGNORE_USELESS_CAST_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"") -# define YY_IGNORE_USELESS_CAST_END \ - _Pragma ("GCC diagnostic pop") -#endif -#ifndef YY_IGNORE_USELESS_CAST_BEGIN -# define YY_IGNORE_USELESS_CAST_BEGIN -# define YY_IGNORE_USELESS_CAST_END -#endif - -# ifndef YY_CAST -# ifdef __cplusplus -# define YY_CAST(Type, Val) static_cast (Val) -# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast (Val) -# else -# define YY_CAST(Type, Val) ((Type) (Val)) -# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val)) -# endif -# endif -# ifndef YY_NULLPTR -# if defined __cplusplus -# if 201103L <= __cplusplus -# define YY_NULLPTR nullptr -# else -# define YY_NULLPTR 0 -# endif -# else -# define YY_NULLPTR ((void*)0) -# endif -# endif - -/* Debug traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif - -namespace yy { -#line 182 "parser.tab.hh" - - - - - /// A Bison parser. - class parser - { - public: -#ifdef YYSTYPE -# ifdef __GNUC__ -# pragma GCC message "bison: do not #define YYSTYPE in C++, use %define api.value.type" -# endif - typedef YYSTYPE value_type; -#else - /// Symbol semantic values. - union value_type - { -#line 82 "parser.y" - - char* str; /* для IDENTIFIER, STRING, INTEGER (как строка) */ - ASTNode* node; /* для отдельных узлов (Var, Class, Method) */ - std::vector* vec; /* для списков узлов (список объявлений) */ - -#line 206 "parser.tab.hh" - - }; -#endif - /// Backward compatibility (Bison 3.8). - typedef value_type semantic_type; - - - /// Syntax errors thrown from user actions. - struct syntax_error : std::runtime_error - { - syntax_error (const std::string& m) - : std::runtime_error (m) - {} - - syntax_error (const syntax_error& s) - : std::runtime_error (s.what ()) - {} - - ~syntax_error () YY_NOEXCEPT YY_NOTHROW; - }; - - /// Token kinds. - struct token - { - enum token_kind_type - { - YYEMPTY = -2, - YYEOF = 0, // "end of file" - YYerror = 256, // error - YYUNDEF = 257, // "invalid token" - CLASS = 258, // CLASS - EXTENDS = 259, // EXTENDS - IS = 260, // IS - END = 261, // END - VAR = 262, // VAR - METHOD = 263, // METHOD - THIS = 264, // THIS - RETURN = 265, // RETURN - IF = 266, // IF - THEN = 267, // THEN - ELSE = 268, // ELSE - WHILE = 269, // WHILE - LOOP = 270, // LOOP - TRUE = 271, // TRUE - FALSE = 272, // FALSE - IDENTIFIER = 273, // IDENTIFIER - INTEGER = 274, // INTEGER - REAL = 275, // REAL - STRING = 276, // STRING - SYMBOL = 277, // SYMBOL - UNKNOWN = 278, // UNKNOWN - COLON = 279, // COLON - SEMI = 280, // SEMI - LPAREN = 281, // LPAREN - RPAREN = 282, // RPAREN - COMMA = 283, // COMMA - DOT = 284, // DOT - ASSIGN = 285, // ASSIGN - ARROW = 286 // ARROW - }; - /// Backward compatibility alias (Bison 3.6). - typedef token_kind_type yytokentype; - }; - - /// Token kind, as returned by yylex. - typedef token::token_kind_type token_kind_type; - - /// Backward compatibility alias (Bison 3.6). - typedef token_kind_type token_type; - - /// Symbol kinds. - struct symbol_kind - { - enum symbol_kind_type - { - YYNTOKENS = 32, ///< Number of tokens. - S_YYEMPTY = -2, - S_YYEOF = 0, // "end of file" - S_YYerror = 1, // error - S_YYUNDEF = 2, // "invalid token" - S_CLASS = 3, // CLASS - S_EXTENDS = 4, // EXTENDS - S_IS = 5, // IS - S_END = 6, // END - S_VAR = 7, // VAR - S_METHOD = 8, // METHOD - S_THIS = 9, // THIS - S_RETURN = 10, // RETURN - S_IF = 11, // IF - S_THEN = 12, // THEN - S_ELSE = 13, // ELSE - S_WHILE = 14, // WHILE - S_LOOP = 15, // LOOP - S_TRUE = 16, // TRUE - S_FALSE = 17, // FALSE - S_IDENTIFIER = 18, // IDENTIFIER - S_INTEGER = 19, // INTEGER - S_REAL = 20, // REAL - S_STRING = 21, // STRING - S_SYMBOL = 22, // SYMBOL - S_UNKNOWN = 23, // UNKNOWN - S_COLON = 24, // COLON - S_SEMI = 25, // SEMI - S_LPAREN = 26, // LPAREN - S_RPAREN = 27, // RPAREN - S_COMMA = 28, // COMMA - S_DOT = 29, // DOT - S_ASSIGN = 30, // ASSIGN - S_ARROW = 31, // ARROW - S_YYACCEPT = 32, // $accept - S_program = 33, // program - S_top_list = 34, // top_list - S_top_item = 35, // top_item - S_class_decl = 36, // class_decl - S_class_opt_ext = 37, // class_opt_ext - S_class_body = 38, // class_body - S_class_member = 39, // class_member - S_var_decl = 40, // var_decl - S_maybe_type = 41, // maybe_type - S_method_decl = 42, // method_decl - S_method_body = 43, // method_body - S_method_member = 44 // method_member - }; - }; - - /// (Internal) symbol kind. - typedef symbol_kind::symbol_kind_type symbol_kind_type; - - /// The number of tokens. - static const symbol_kind_type YYNTOKENS = symbol_kind::YYNTOKENS; - - /// A complete symbol. - /// - /// Expects its Base type to provide access to the symbol kind - /// via kind (). - /// - /// Provide access to semantic value. - template - struct basic_symbol : Base - { - /// Alias to Base. - typedef Base super_type; - - /// Default constructor. - basic_symbol () YY_NOEXCEPT - : value () - {} - -#if 201103L <= YY_CPLUSPLUS - /// Move constructor. - basic_symbol (basic_symbol&& that) - : Base (std::move (that)) - , value (std::move (that.value)) - {} -#endif - - /// Copy constructor. - basic_symbol (const basic_symbol& that); - /// Constructor for valueless symbols. - basic_symbol (typename Base::kind_type t); - - /// Constructor for symbols with semantic value. - basic_symbol (typename Base::kind_type t, - YY_RVREF (value_type) v); - - /// Destroy the symbol. - ~basic_symbol () - { - clear (); - } - - - - /// Destroy contents, and record that is empty. - void clear () YY_NOEXCEPT - { - Base::clear (); - } - -#if YYDEBUG || 0 - /// The user-facing name of this symbol. - const char *name () const YY_NOEXCEPT - { - return parser::symbol_name (this->kind ()); - } -#endif // #if YYDEBUG || 0 - - - /// Backward compatibility (Bison 3.6). - symbol_kind_type type_get () const YY_NOEXCEPT; - - /// Whether empty. - bool empty () const YY_NOEXCEPT; - - /// Destructive move, \a s is emptied into this. - void move (basic_symbol& s); - - /// The semantic value. - value_type value; - - private: -#if YY_CPLUSPLUS < 201103L - /// Assignment operator. - basic_symbol& operator= (const basic_symbol& that); -#endif - }; - - /// Type access provider for token (enum) based symbols. - struct by_kind - { - /// The symbol kind as needed by the constructor. - typedef token_kind_type kind_type; - - /// Default constructor. - by_kind () YY_NOEXCEPT; - -#if 201103L <= YY_CPLUSPLUS - /// Move constructor. - by_kind (by_kind&& that) YY_NOEXCEPT; -#endif - - /// Copy constructor. - by_kind (const by_kind& that) YY_NOEXCEPT; - - /// Constructor from (external) token numbers. - by_kind (kind_type t) YY_NOEXCEPT; - - - - /// Record that this symbol is empty. - void clear () YY_NOEXCEPT; - - /// Steal the symbol kind from \a that. - void move (by_kind& that); - - /// The (internal) type number (corresponding to \a type). - /// \a empty when empty. - symbol_kind_type kind () const YY_NOEXCEPT; - - /// Backward compatibility (Bison 3.6). - symbol_kind_type type_get () const YY_NOEXCEPT; - - /// The symbol kind. - /// \a S_YYEMPTY when empty. - symbol_kind_type kind_; - }; - - /// Backward compatibility for a private implementation detail (Bison 3.6). - typedef by_kind by_type; - - /// "External" symbols: returned by the scanner. - struct symbol_type : basic_symbol - {}; - - /// Build a parser object. - parser (); - virtual ~parser (); - -#if 201103L <= YY_CPLUSPLUS - /// Non copyable. - parser (const parser&) = delete; - /// Non copyable. - parser& operator= (const parser&) = delete; -#endif - - /// Parse. An alias for parse (). - /// \returns 0 iff parsing succeeded. - int operator() (); - - /// Parse. - /// \returns 0 iff parsing succeeded. - virtual int parse (); - -#if YYDEBUG - /// The current debugging stream. - std::ostream& debug_stream () const YY_ATTRIBUTE_PURE; - /// Set the current debugging stream. - void set_debug_stream (std::ostream &); - - /// Type for debugging levels. - typedef int debug_level_type; - /// The current debugging level. - debug_level_type debug_level () const YY_ATTRIBUTE_PURE; - /// Set the current debugging level. - void set_debug_level (debug_level_type l); -#endif - - /// Report a syntax error. - /// \param msg a description of the syntax error. - virtual void error (const std::string& msg); - - /// Report a syntax error. - void error (const syntax_error& err); - -#if YYDEBUG || 0 - /// The user-facing name of the symbol whose (internal) number is - /// YYSYMBOL. No bounds checking. - static const char *symbol_name (symbol_kind_type yysymbol); -#endif // #if YYDEBUG || 0 - - - - - private: -#if YY_CPLUSPLUS < 201103L - /// Non copyable. - parser (const parser&); - /// Non copyable. - parser& operator= (const parser&); -#endif - - - /// Stored state numbers (used for stacks). - typedef signed char state_type; - - /// Compute post-reduction state. - /// \param yystate the current state - /// \param yysym the nonterminal to push on the stack - static state_type yy_lr_goto_state_ (state_type yystate, int yysym); - - /// Whether the given \c yypact_ value indicates a defaulted state. - /// \param yyvalue the value to check - static bool yy_pact_value_is_default_ (int yyvalue) YY_NOEXCEPT; - - /// Whether the given \c yytable_ value indicates a syntax error. - /// \param yyvalue the value to check - static bool yy_table_value_is_error_ (int yyvalue) YY_NOEXCEPT; - - static const signed char yypact_ninf_; - static const signed char yytable_ninf_; - - /// Convert a scanner token kind \a t to a symbol kind. - /// In theory \a t should be a token_kind_type, but character literals - /// are valid, yet not members of the token_kind_type enum. - static symbol_kind_type yytranslate_ (int t) YY_NOEXCEPT; - -#if YYDEBUG || 0 - /// For a symbol, its name in clear. - static const char* const yytname_[]; -#endif // #if YYDEBUG || 0 - - - // Tables. - // YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - // STATE-NUM. - static const signed char yypact_[]; - - // YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. - // Performed when YYTABLE does not specify something else to do. Zero - // means the default is an error. - static const signed char yydefact_[]; - - // YYPGOTO[NTERM-NUM]. - static const signed char yypgoto_[]; - - // YYDEFGOTO[NTERM-NUM]. - static const signed char yydefgoto_[]; - - // YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If - // positive, shift that token. If negative, reduce the rule whose - // number is the opposite. If YYTABLE_NINF, syntax error. - static const signed char yytable_[]; - - static const signed char yycheck_[]; - - // YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of - // state STATE-NUM. - static const signed char yystos_[]; - - // YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. - static const signed char yyr1_[]; - - // YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. - static const signed char yyr2_[]; - - -#if YYDEBUG - // YYRLINE[YYN] -- Source line where rule number YYN was defined. - static const unsigned char yyrline_[]; - /// Report on the debug stream that the rule \a r is going to be reduced. - virtual void yy_reduce_print_ (int r) const; - /// Print the state stack on the debug stream. - virtual void yy_stack_print_ () const; - - /// Debugging level. - int yydebug_; - /// Debug stream. - std::ostream* yycdebug_; - - /// \brief Display a symbol kind, value and location. - /// \param yyo The output stream. - /// \param yysym The symbol. - template - void yy_print_ (std::ostream& yyo, const basic_symbol& yysym) const; -#endif - - /// \brief Reclaim the memory associated to a symbol. - /// \param yymsg Why this token is reclaimed. - /// If null, print nothing. - /// \param yysym The symbol. - template - void yy_destroy_ (const char* yymsg, basic_symbol& yysym) const; - - private: - /// Type access provider for state based symbols. - struct by_state - { - /// Default constructor. - by_state () YY_NOEXCEPT; - - /// The symbol kind as needed by the constructor. - typedef state_type kind_type; - - /// Constructor. - by_state (kind_type s) YY_NOEXCEPT; - - /// Copy constructor. - by_state (const by_state& that) YY_NOEXCEPT; - - /// Record that this symbol is empty. - void clear () YY_NOEXCEPT; - - /// Steal the symbol kind from \a that. - void move (by_state& that); - - /// The symbol kind (corresponding to \a state). - /// \a symbol_kind::S_YYEMPTY when empty. - symbol_kind_type kind () const YY_NOEXCEPT; - - /// The state number used to denote an empty symbol. - /// We use the initial state, as it does not have a value. - enum { empty_state = 0 }; - - /// The state. - /// \a empty when empty. - state_type state; - }; - - /// "Internal" symbol: element of the stack. - struct stack_symbol_type : basic_symbol - { - /// Superclass. - typedef basic_symbol super_type; - /// Construct an empty symbol. - stack_symbol_type (); - /// Move or copy construction. - stack_symbol_type (YY_RVREF (stack_symbol_type) that); - /// Steal the contents from \a sym to build this. - stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) sym); -#if YY_CPLUSPLUS < 201103L - /// Assignment, needed by push_back by some old implementations. - /// Moves the contents of that. - stack_symbol_type& operator= (stack_symbol_type& that); - - /// Assignment, needed by push_back by other implementations. - /// Needed by some other old implementations. - stack_symbol_type& operator= (const stack_symbol_type& that); -#endif - }; - - /// A stack with random access from its top. - template > - class stack - { - public: - // Hide our reversed order. - typedef typename S::iterator iterator; - typedef typename S::const_iterator const_iterator; - typedef typename S::size_type size_type; - typedef typename std::ptrdiff_t index_type; - - stack (size_type n = 200) YY_NOEXCEPT - : seq_ (n) - {} - -#if 201103L <= YY_CPLUSPLUS - /// Non copyable. - stack (const stack&) = delete; - /// Non copyable. - stack& operator= (const stack&) = delete; -#endif - - /// Random access. - /// - /// Index 0 returns the topmost element. - const T& - operator[] (index_type i) const - { - return seq_[size_type (size () - 1 - i)]; - } - - /// Random access. - /// - /// Index 0 returns the topmost element. - T& - operator[] (index_type i) - { - return seq_[size_type (size () - 1 - i)]; - } - - /// Steal the contents of \a t. - /// - /// Close to move-semantics. - void - push (YY_MOVE_REF (T) t) - { - seq_.push_back (T ()); - operator[] (0).move (t); - } - - /// Pop elements from the stack. - void - pop (std::ptrdiff_t n = 1) YY_NOEXCEPT - { - for (; 0 < n; --n) - seq_.pop_back (); - } - - /// Pop all elements from the stack. - void - clear () YY_NOEXCEPT - { - seq_.clear (); - } - - /// Number of elements on the stack. - index_type - size () const YY_NOEXCEPT - { - return index_type (seq_.size ()); - } - - /// Iterator on top of the stack (going downwards). - const_iterator - begin () const YY_NOEXCEPT - { - return seq_.begin (); - } - - /// Bottom of the stack. - const_iterator - end () const YY_NOEXCEPT - { - return seq_.end (); - } - - /// Present a slice of the top of a stack. - class slice - { - public: - slice (const stack& stack, index_type range) YY_NOEXCEPT - : stack_ (stack) - , range_ (range) - {} - - const T& - operator[] (index_type i) const - { - return stack_[range_ - i]; - } - - private: - const stack& stack_; - index_type range_; - }; - - private: -#if YY_CPLUSPLUS < 201103L - /// Non copyable. - stack (const stack&); - /// Non copyable. - stack& operator= (const stack&); -#endif - /// The wrapped container. - S seq_; - }; - - - /// Stack type. - typedef stack stack_type; - - /// The stack. - stack_type yystack_; - - /// Push a new state on the stack. - /// \param m a debug message to display - /// if null, no trace is output. - /// \param sym the symbol - /// \warning the contents of \a s.value is stolen. - void yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym); - - /// Push a new look ahead token on the state on the stack. - /// \param m a debug message to display - /// if null, no trace is output. - /// \param s the state - /// \param sym the symbol (for its value and location). - /// \warning the contents of \a sym.value is stolen. - void yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym); - - /// Pop \a n symbols from the stack. - void yypop_ (int n = 1) YY_NOEXCEPT; - - /// Constants. - enum - { - yylast_ = 26, ///< Last index in yytable_. - yynnts_ = 13, ///< Number of nonterminal symbols. - yyfinal_ = 3 ///< Termination state number. - }; - - - - }; - - -} // yy -#line 823 "parser.tab.hh" - - - - -#endif // !YY_YY_PARSER_TAB_HH_INCLUDED diff --git a/parser.y b/parser.y index 024cccb..c32e058 100644 --- a/parser.y +++ b/parser.y @@ -1,152 +1,122 @@ -%define parse.error verbose - -%{ -#include -#include -#include -#include -#include -#include "ast.h" -#include - -using namespace std; - -unique_ptr g_program = nullptr; -size_t parserTokIndex = 0; -vector simpleTokens; - -void yyerror(const char *s) { - cerr << "Parse error: " << s << "\n"; -} - -void printAST() { - if (g_program) { - g_program->print(0); - } else { - cout << "No AST generated.\n"; - } -} -%} - -%code requires { - #include - class ASTNode; // forward declaration -} - -%union { - char* str; - ASTNode* node; - std::vector* vec; -} - -%token CLASS EXTENDS IS END VAR METHOD THIS RETURN IF THEN ELSE WHILE LOOP TRUE FALSE -%token IDENTIFIER INTEGER REAL STRING -%token SYMBOL UNKNOWN -%token COLON SEMI LPAREN RPAREN COMMA DOT ASSIGN ARROW - -%type top_list class_body method_body -%type top_item class_decl var_decl method_decl class_member method_member -%type maybe_type class_opt_ext -%start program - -%% - -program: - top_list { - g_program = make_unique(); - if ($1) { - for (ASTNode* p : *$1) { - g_program->decls.emplace_back(unique_ptr(p)); - } - delete $1; - } - } -; - -top_list: - /* empty */ { $$ = new vector(); } - | top_list top_item { - $$ = $1; - if ($2) $$->push_back($2); - } -; - -top_item: - class_decl { $$ = $1; } - | var_decl { $$ = $1; } - | method_decl { $$ = $1; } -; - -class_decl: - CLASS IDENTIFIER class_opt_ext IS class_body END { - auto cn = new ClassNode($2 ? string($2) : string()); - if ($3) cn->extendsName = string($3); - if ($5) { - for (ASTNode* m : *$5) cn->members.emplace_back(unique_ptr(m)); - delete $5; - } - if ($2) free($2); - if ($3) free($3); - $$ = cn; - } -; - -class_opt_ext: - /* empty */ { $$ = nullptr; } - | EXTENDS IDENTIFIER { $$ = $2; } -; - -class_body: - /* empty */ { $$ = new vector(); } - | class_body class_member { - $$ = $1; - if ($2) $$->push_back($2); - } -; - -class_member: - var_decl { $$ = $1; } - | method_decl { $$ = $1; } -; - -var_decl: - VAR IDENTIFIER maybe_type SEMI { - auto vn = new VarNode($2 ? string($2) : string(), $3 ? string($3) : string()); - if ($2) free($2); - if ($3) free($3); - $$ = vn; - } -; - -maybe_type: - /* empty */ { $$ = nullptr; } - | COLON IDENTIFIER { $$ = $2; } -; - -method_decl: - METHOD IDENTIFIER LPAREN RPAREN IS method_body END { - auto mn = new MethodNode($2 ? string($2) : string()); - if ($6) { - for (ASTNode* b : *$6) mn->body.emplace_back(unique_ptr(b)); - delete $6; - } - if ($2) free($2); - $$ = mn; - } -; - -method_body: - /* empty */ { $$ = new vector(); } - | method_body method_member { - $$ = $1; - if ($2) $$->push_back($2); - } -; - -method_member: - var_decl { $$ = $1; } -; - -%% - -int yylex(void); +/* parser.y */ +%{ +#include +#include +#include +#include +#include +#include "tokens.hpp" +#include "ast.hpp" + +extern int yylex(void); +extern FILE* yyin; +void yyerror(const char* s); + +using namespace AST; + +Program* g_program = nullptr; +%} + +%define api.pure full +%define parse.error verbose +%define api.prefix {yy} +%define api.value.type {union} +%define api.token.prefix {T_} + +%union { + Token* tok; + AST::Program* program; + AST::ClassDecl* classDecl; + std::vector* classList; + AST::VarDecl* varDecl; + std::vector* varList; + AST::TypeName* typeName; + AST::Expr* expr; +} + +%token CLASS IS VAR END +%token IDENTIFIER INT_TYPE INTEGER +%token COLON SEMI ASSIGN +%token LPAREN RPAREN PLUS MINUS STAR SLASH DOT + +%type program +%type class_list +%type class_decl +%type var_decl_list +%type var_decl +%type type +%type expr term factor + +%% + +program + : class_list + { + auto prog = new Program(); + for (auto* c : *$1) prog->classes.emplace_back(c); + delete $1; + g_program = prog; + $$ = prog; + } + ; + +class_list + : class_decl { $$ = new std::vector(); $$->push_back($1); } + | class_list class_decl { $$ = $1; $$->push_back($2); } + ; + +class_decl + : CLASS IDENTIFIER IS var_decl_list END + { + auto cls = new ClassDecl($2->lexeme); + for (auto* v : *$4) cls->fields.emplace_back(v); + delete $4; + $$ = cls; + } + ; + +var_decl_list + : /* empty */ { $$ = new std::vector(); } + | var_decl_list var_decl { $$ = $1; $$->push_back($2); } + ; + +var_decl + : VAR IDENTIFIER COLON type SEMI + { + $$ = new VarDecl($2->lexeme, std::unique_ptr($4)); + } + | VAR IDENTIFIER COLON type ASSIGN expr SEMI + { + $$ = new VarDecl($2->lexeme, std::unique_ptr($4), std::unique_ptr($6)); + } + ; + +type + : INT_TYPE { $$ = new TypeName("Int"); } + | IDENTIFIER { $$ = new TypeName($1->lexeme); } + ; + +/* Выражения: раскладываем a+b+10 и т.п. в бинарные узлы */ +expr + : expr PLUS term { $$ = new BinExpr('+', std::unique_ptr($1), std::unique_ptr($3)); } + | expr MINUS term { $$ = new BinExpr('-', std::unique_ptr($1), std::unique_ptr($3)); } + | term { $$ = $1; } + ; + +term + : term STAR factor { $$ = new BinExpr('*', std::unique_ptr($1), std::unique_ptr($3)); } + | term SLASH factor { $$ = new BinExpr('/', std::unique_ptr($1), std::unique_ptr($3)); } + | factor { $$ = $1; } + ; + +factor + : INTEGER { $$ = new IntLiteral(static_cast($1)->value); } + | IDENTIFIER { $$ = new IdExpr($1->lexeme); } + | LPAREN expr RPAREN { $$ = $2; } + ; + +%% + +void yyerror(const char* s) { + fprintf(stderr, "Parse error: %s\n", s); +} diff --git a/stack.hh b/stack.hh deleted file mode 100644 index 746965d..0000000 --- a/stack.hh +++ /dev/null @@ -1,8 +0,0 @@ -// A Bison parser, made by GNU Bison 3.8.2. - -// Starting with Bison 3.2, this file is useless: the structure it -// used to define is now defined with the parser itself. -// -// To get rid of this file: -// 1. add '%require "3.2"' (or newer) to your grammar file -// 2. remove references to this file from your build system. diff --git a/tokens.hpp b/tokens.hpp new file mode 100644 index 0000000..ac802b2 --- /dev/null +++ b/tokens.hpp @@ -0,0 +1,86 @@ +// tokens.hpp +#pragma once +#include +#include +#include + +enum class TokenKind { + Class, Is, Var, End, + Identifier, TypeName, + IntegerLiteral, + Colon, Semicolon, Assign, + LParen, RParen, Plus, Minus, Star, Slash, + Dot, +}; + +struct Token { + TokenKind kind; + std::string lexeme; + int line = 1; + int column = 1; + Token(TokenKind k, std::string lx, int ln=1, int col=1) + : kind(k), lexeme(std::move(lx)), line(ln), column(col) {} + virtual ~Token() = default; + virtual std::string info() const { return lexeme; } +}; + +struct KeywordToken : Token { + KeywordToken(TokenKind k, const std::string& lx, int ln, int col) + : Token(k, lx, ln, col) {} +}; + +struct SymbolToken : Token { + SymbolToken(TokenKind k, const std::string& lx, int ln, int col) + : Token(k, lx, ln, col) {} +}; + +struct IdentifierToken : Token { + IdentifierToken(const std::string& name, int ln, int col) + : Token(TokenKind::Identifier, name, ln, col) {} +}; + +struct TypeToken : Token { + TypeToken(const std::string& name, int ln, int col) + : Token(TokenKind::TypeName, name, ln, col) {} +}; + +struct IntegerToken : Token { + long long value; + IntegerToken(long long v, const std::string& lx, int ln, int col) + : Token(TokenKind::IntegerLiteral, lx, ln, col), value(v) {} + std::string info() const override { return std::to_string(value); } +}; + +// Утилита для красивого имени токена +inline const char* tokenKindName(TokenKind k) { + switch (k) { + case TokenKind::Class: return "CLASS"; + case TokenKind::Is: return "IS"; + case TokenKind::Var: return "VAR"; + case TokenKind::End: return "END"; + case TokenKind::Identifier: return "IDENTIFIER"; + case TokenKind::TypeName: return "TYPE"; + case TokenKind::IntegerLiteral: return "INTEGER"; + case TokenKind::Colon: return "COLON"; + case TokenKind::Semicolon: return "SEMICOLON"; + case TokenKind::Assign: return "ASSIGN"; + case TokenKind::LParen: return "LPAREN"; + case TokenKind::RParen: return "RPAREN"; + case TokenKind::Plus: return "PLUS"; + case TokenKind::Minus: return "MINUS"; + case TokenKind::Star: return "STAR"; + case TokenKind::Slash: return "SLASH"; + case TokenKind::Dot: return "DOT"; + } + return "UNKNOWN"; +} + +// Печать «следа» токенов из лексера +inline void printToken(const Token* t) { + std::cout << tokenKindName(t->kind); + if (t->kind == TokenKind::Identifier || t->kind == TokenKind::TypeName) + std::cout << "(" << t->lexeme << ")"; + else if (t->kind == TokenKind::IntegerLiteral) + std::cout << "(" << static_cast(t)->value << ")"; + std::cout << "\n"; +} From 1c0393c91f2506e3254faef9743a0b8eeffd1390 Mon Sep 17 00:00:00 2001 From: dorley174 Date: Wed, 5 Nov 2025 03:52:51 +0300 Subject: [PATCH 2/7] new1 --- Makefile | 23 ++++---- ast.hpp | 129 +++++++++++++++++++++++++++++++------------- lexer.l | 137 +++++++++++++++++++++++----------------------- main.cpp | 39 ++++++-------- parser.y | 156 +++++++++++++++++++++++++++++++---------------------- tokens.hpp | 113 ++++++++++++++++++++------------------ 6 files changed, 340 insertions(+), 257 deletions(-) diff --git a/Makefile b/Makefile index bb9400c..8e1418e 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,16 @@ -CXX=g++ -CXXFLAGS=-std=c++17 -O2 -LEX=flex -YACC=bison +CXX := g++ +CXXFLAGS := -std=c++17 -Wall -Wextra -O2 all: mycompiler -parser.cpp parser.tab.h: parser.y - $(YACC) -d parser.y -o parser.cpp +parser.cpp parser.hpp: parser.y + bison -d -o parser.cpp parser.y -lexer.cpp: lexer.l parser.tab.h - $(LEX) -o lexer.cpp lexer.l +lexer.cpp: lexer.l parser.hpp + flex -o lexer.cpp lexer.l -mycompiler: parser.cpp lexer.cpp main.cpp tokens.hpp ast.hpp - $(CXX) $(CXXFLAGS) -o mycompiler parser.cpp lexer.cpp main.cpp -lfl - -run: - ./mycompiler tests/test1.o +mycompiler: parser.cpp lexer.cpp main.cpp + $(CXX) $(CXXFLAGS) -o $@ parser.cpp lexer.cpp main.cpp -lfl clean: - rm -f mycompiler parser.cpp parser.tab.h lexer.cpp + rm -f parser.cpp parser.hpp lexer.cpp mycompiler diff --git a/ast.hpp b/ast.hpp index fbed63f..93300f0 100644 --- a/ast.hpp +++ b/ast.hpp @@ -1,71 +1,124 @@ // ast.hpp #pragma once -#include #include #include #include +#include namespace AST { -struct Node { virtual ~Node() = default; }; - -struct TypeName : Node { - std::string name; - explicit TypeName(std::string n) : name(std::move(n)) {} +struct Node { + virtual ~Node() = default; + virtual void print(std::ostream& os, int indent = 0) const = 0; }; -struct Expr : Node { virtual void print(std::ostream& os) const = 0; }; +inline void doIndent(std::ostream& os, int n) { + for (int i = 0; i < n; ++i) os << " "; +} + +// ==== Expressions ==== + +struct Expr : Node { }; struct IntLiteral : Expr { - long long value; - explicit IntLiteral(long long v) : value(v) {} - void print(std::ostream& os) const override { os << value; } + std::int64_t value; + explicit IntLiteral(std::int64_t v) : value(v) {} + void print(std::ostream& os, int indent) const override { + doIndent(os, indent); os << "Int(" << value << ")\n"; + } }; -struct IdExpr : Expr { +struct Identifier : Expr { std::string name; - explicit IdExpr(std::string n) : name(std::move(n)) {} - void print(std::ostream& os) const override { os << name; } + explicit Identifier(std::string n) : name(std::move(n)) {} + void print(std::ostream& os, int indent) const override { + doIndent(os, indent); os << "Id(" << name << ")\n"; + } }; -struct BinExpr : Expr { - char op; - std::unique_ptr lhs, rhs; - BinExpr(char op, std::unique_ptr l, std::unique_ptr r) - : op(op), lhs(std::move(l)), rhs(std::move(r)) {} - void print(std::ostream& os) const override { - lhs->print(os); os << " " << op << " "; rhs->print(os); +enum class BinOp { Add, Sub, Mul, Div, Assign }; + +struct Binary : Expr { + BinOp op; + Expr* lhs; + Expr* rhs; + Binary(BinOp o, Expr* l, Expr* r) : op(o), lhs(l), rhs(r) {} + ~Binary() { delete lhs; delete rhs; } + + static const char* opToStr(BinOp o) { + switch (o) { + case BinOp::Add: return "+"; + case BinOp::Sub: return "-"; + case BinOp::Mul: return "*"; + case BinOp::Div: return "/"; + case BinOp::Assign: return "="; + } + return "?"; + } + void print(std::ostream& os, int indent) const override { + doIndent(os, indent); + os << "BinOp(" << opToStr(op) << ")\n"; + lhs->print(os, indent + 1); + rhs->print(os, indent + 1); } }; +struct Unary : Expr { + enum class Op { Neg }; + Op op; + Expr* rhs; + Unary(Op o, Expr* e) : op(o), rhs(e) {} + ~Unary() { delete rhs; } + void print(std::ostream& os, int indent) const override { + doIndent(os, indent); + os << "Unary(-)\n"; + rhs->print(os, indent + 1); + } +}; + +// ==== Declarations / Program ==== + struct VarDecl : Node { std::string name; - std::unique_ptr type; - std::unique_ptr init; // опционально - VarDecl(std::string n, std::unique_ptr t, std::unique_ptr i = {}) - : name(std::move(n)), type(std::move(t)), init(std::move(i)) {} + std::string typeName; + Expr* init; // может быть nullptr + + VarDecl(std::string n, std::string t, Expr* i) + : name(std::move(n)), typeName(std::move(t)), init(i) {} + ~VarDecl() { delete init; } + + void print(std::ostream& os, int indent) const override { + doIndent(os, indent); + os << "var " << name << " : " << typeName; + if (init) { + os << " =\n"; + init->print(os, indent + 1); + } else { + os << "\n"; + } + } }; struct ClassDecl : Node { std::string name; - std::vector> fields; + std::vector fields; + explicit ClassDecl(std::string n) : name(std::move(n)) {} + ~ClassDecl() { for (auto* v : fields) delete v; } + + void print(std::ostream& os, int indent) const override { + doIndent(os, indent); + os << "Class: " << name << "\n"; + for (auto* v : fields) v->print(os, indent + 1); + } }; struct Program : Node { - std::vector> classes; - void printNormalized(std::ostream& os) const { - for (auto& c : classes) { - os << "Class: " << c->name << "\n"; - for (auto& v : c->fields) { - os << "var " << v->name << " : " << v->type->name; - if (v->init) { - os << " = "; - v->init->print(os); - } - os << "\n"; - } - } + std::vector classes; + ~Program() { for (auto* c : classes) delete c; } + + void print(std::ostream& os, int indent = 0) const override { + for (auto* c : classes) c->print(os, indent); } }; diff --git a/lexer.l b/lexer.l index 0c9f2ee..eaf45df 100644 --- a/lexer.l +++ b/lexer.l @@ -1,80 +1,83 @@ -%option noyywrap -%option outfile="lexer.cpp" -%option c++ +/* lexer.l */ %{ -#include "tokens.hpp" -#include "parser.tab.h" // bison сгенерит +#include #include +#include +#include +#include "parser.hpp" +#include "tokens.hpp" -using namespace std; - -static int cur_line = 1; -static int cur_col = 1; - -#define YY_USER_ACTION \ - /* обновим столбцы: */ \ - cur_col += yyleng; +int yycolumn = 1; +extern int yylineno; -static int start_col_for_rule() { - return cur_col - yyleng + 1; +static inline void push_kw(TokenKind k, const char* text) { + EmitToken(std::make_unique(k, text, yylineno, yycolumn)); + yycolumn += yyleng; } - -// Утилита: создать токен и вывести его -template -static T* make_token_and_echo(Args&&... args) { - T* t = new T(std::forward(args)...); - printToken(t); - return t; +static inline void push_sym(TokenKind k, const char* text) { + EmitToken(std::make_unique(k, text, yylineno, yycolumn)); + yycolumn += yyleng; } %} -ws [ \t\r]+ -newline \n -id [A-Za-z_][A-Za-z0-9_]* -intlit [0-9]+ - -%% - -{ws} {/* пропуск, столбец уже учтён */} -{newline} { cur_line++; cur_col = 1; } - -"class" { auto t = make_token_and_echo(TokenKind::Class, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_CLASS; } -"is" { auto t = make_token_and_echo(TokenKind::Is, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_IS; } -"var" { auto t = make_token_and_echo(TokenKind::Var, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_VAR; } -"end" { auto t = make_token_and_echo(TokenKind::End, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_END; } - -"Int" { auto t = make_token_and_echo("Int", cur_line, start_col_for_rule()); yylval.tok = t; return T_INT_TYPE; } - -":" { auto t = make_token_and_echo(TokenKind::Colon, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_COLON; } -";" { auto t = make_token_and_echo(TokenKind::Semicolon, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_SEMI; } -"=" { auto t = make_token_and_echo(TokenKind::Assign, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_ASSIGN; } -"(" { auto t = make_token_and_echo(TokenKind::LParen, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_LPAREN; } -")" { auto t = make_token_and_echo(TokenKind::RParen, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_RPAREN; } -"\\+" { auto t = make_token_and_echo(TokenKind::Plus, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_PLUS; } -"-" { auto t = make_token_and_echo(TokenKind::Minus, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_MINUS; } -"\\*" { auto t = make_token_and_echo(TokenKind::Star, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_STAR; } -"/" { auto t = make_token_and_echo(TokenKind::Slash, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_SLASH; } -"\\." { auto t = make_token_and_echo(TokenKind::Dot, yytext, cur_line, start_col_for_rule()); yylval.tok = t; return T_DOT; } - -{intlit} { - long long v = atoll(yytext); - auto t = make_token_and_echo(v, yytext, cur_line, start_col_for_rule()); - yylval.tok = t; return T_INTEGER; - } +/* Упрощаем жизнь: Flex не будет вызывать yywrap из libfl */ +%option noyywrap +%option nodefault +%option yylineno -{id} { - std::string s(yytext); - // Если не ключевое слово/тип — идентификатор - auto t = make_token_and_echo(s, cur_line, start_col_for_rule()); - yylval.tok = t; return T_IDENTIFIER; - } +ID [A-Za-z_][A-Za-z0-9_]* +INT [0-9]+ +WS [ \t\r]+ -"//".* { /* комментарии до конца строки */ } -"/*"([^*]|\*+[^*/])*\*+"/" { /* блочный комментарий */ } +%% -. { - fprintf(stderr, "Unknown char '%s' at %d:%d\n", yytext, cur_line, start_col_for_rule()); - } +"class" { push_kw(TokenKind::CLASS, yytext); return CLASS; } +"var" { push_kw(TokenKind::VAR, yytext); return VAR; } +"is" { push_kw(TokenKind::IS, yytext); return IS; } +"end" { push_kw(TokenKind::END, yytext); return END; } + +/* Базовые встроенные типы */ +"Int" { EmitToken(std::make_unique(yytext, yylineno, yycolumn)); + yylval.cstr = strdup(yytext); yycolumn += yyleng; return TYPE_NAME; } +"String" { EmitToken(std::make_unique(yytext, yylineno, yycolumn)); + yylval.cstr = strdup(yytext); yycolumn += yyleng; return TYPE_NAME; } +"Bool" { EmitToken(std::make_unique(yytext, yylineno, yycolumn)); + yylval.cstr = strdup(yytext); yycolumn += yyleng; return TYPE_NAME; } +"Float" { EmitToken(std::make_unique(yytext, yylineno, yycolumn)); + yylval.cstr = strdup(yytext); yycolumn += yyleng; return TYPE_NAME; } + +/* Идентификаторы */ +{ID} { EmitToken(std::make_unique(yytext, yylineno, yycolumn)); + yylval.cstr = strdup(yytext); yycolumn += yyleng; return IDENTIFIER; } + +/* Целые литералы */ +{INT} { long long v = atoll(yytext); + EmitToken(std::make_unique(yytext, v, yylineno, yycolumn)); + yylval.ival = v; yycolumn += yyleng; return INT_LITERAL; } + +/* Знаки и операторы */ +":" { push_sym(TokenKind::COLON, yytext); return COLON; } +";" { push_sym(TokenKind::SEMICOLON, yytext); return SEMICOLON; } +"," { push_sym(TokenKind::COMMA, yytext); return COMMA; } +"(" { push_sym(TokenKind::LPAREN, yytext); return LPAREN; } +")" { push_sym(TokenKind::RPAREN, yytext); return RPAREN; } +"{" { push_sym(TokenKind::LBRACE, yytext); return LBRACE; } +"}" { push_sym(TokenKind::RBRACE, yytext); return RBRACE; } +"=" { push_sym(TokenKind::ASSIGN, yytext); return ASSIGN; } +"+" { push_sym(TokenKind::PLUS, yytext); return PLUS; } +"-" { push_sym(TokenKind::MINUS, yytext); return MINUS; } +"*" { push_sym(TokenKind::STAR, yytext); return STAR; } +"/" { push_sym(TokenKind::SLASH, yytext); return SLASH; } + +/* Комментарии // до конца строки */ +"//".* { yycolumn += yyleng; /* пропускаем */ } + +/* Пробельные */ +{WS} { yycolumn += yyleng; } +\n { yycolumn = 1; } + +/* Неожиданные символы */ +. { std::fprintf(stderr, "Unknown char '%s' at %d:%d\n", yytext, yylineno, yycolumn); + yycolumn += yyleng; } %% -// yywrap по умолчанию отключён опцией diff --git a/main.cpp b/main.cpp index 8cddde9..db4c867 100644 --- a/main.cpp +++ b/main.cpp @@ -1,45 +1,38 @@ // main.cpp #include -#include #include #include "ast.hpp" +#include "tokens.hpp" -extern int yyparse(void); +extern int yyparse(void); extern FILE* yyin; extern AST::Program* g_program; int main(int argc, char** argv) { if (argc < 2) { - std::cerr << "Usage: ./mycompiler \n"; + std::cerr << "Usage: " << argv[0] << " \n"; return 1; } - const char* path = argv[1]; - yyin = fopen(path, "r"); + yyin = std::fopen(argv[1], "r"); if (!yyin) { std::perror("fopen"); return 1; } - // Парсим; лексер уже печатает поток токенов: - // например: - // CLASS - // IDENTIFIER(Point) - // IS - // VAR - // IDENTIFIER(x) - // COLON - // TYPE(Int) - // ... - if (yyparse() == 0) { - // Печать нормализованного AST (раскладывание) + std::cout << "=== LEXER TOKENS ===\n"; + int rc = yyparse(); + std::fclose(yyin); + + if (rc == 0) { + std::cout << "\n=== AST ===\n"; if (g_program) { - std::cout << "\n--- AST ---\n"; - g_program->printNormalized(std::cout); + g_program->print(std::cout); + delete g_program; + g_program = nullptr; } + return 0; } else { - std::cerr << "Parsing failed.\n"; + std::cerr << "Parse failed.\n"; + return 2; } - - fclose(yyin); - return 0; } diff --git a/parser.y b/parser.y index c32e058..e81eab3 100644 --- a/parser.y +++ b/parser.y @@ -1,122 +1,150 @@ -/* parser.y */ +// parser.y %{ #include #include -#include -#include +#include #include -#include "tokens.hpp" +#include #include "ast.hpp" +#include "tokens.hpp" extern int yylex(void); -extern FILE* yyin; +extern int yylineno; void yyerror(const char* s); -using namespace AST; - -Program* g_program = nullptr; +AST::Program* g_program = nullptr; %} -%define api.pure full +/* Явно попросим заголовок "parser.hpp" */ +%defines "parser.hpp" +/* Подробные сообщения об ошибках */ %define parse.error verbose -%define api.prefix {yy} -%define api.value.type {union} -%define api.token.prefix {T_} +/* Семантические типы */ %union { - Token* tok; - AST::Program* program; - AST::ClassDecl* classDecl; - std::vector* classList; - AST::VarDecl* varDecl; - std::vector* varList; - AST::TypeName* typeName; - AST::Expr* expr; + long long ival; + char* cstr; + AST::Program* program; + AST::ClassDecl* classdecl; + AST::VarDecl* vardecl; + AST::Expr* expr; + std::vector* classlist; + std::vector* varlist; } -%token CLASS IS VAR END -%token IDENTIFIER INT_TYPE INTEGER -%token COLON SEMI ASSIGN -%token LPAREN RPAREN PLUS MINUS STAR SLASH DOT +/* Токены */ +%token CLASS VAR IS END +%token COLON SEMICOLON COMMA +%token LPAREN RPAREN LBRACE RBRACE +%token ASSIGN PLUS MINUS STAR SLASH + +%token IDENTIFIER +%token TYPE_NAME +%token INT_LITERAL -%type program -%type class_list -%type class_decl -%type var_decl_list -%type var_decl -%type type -%type expr term factor +/* Типы нетерминалов */ +%type program +%type class_list +%type class_decl +%type class_body var_decl_list +%type var_decl +%type expr additive_expr multiplicative_expr unary_expr primary_expr %% program : class_list { - auto prog = new Program(); - for (auto* c : *$1) prog->classes.emplace_back(c); + g_program = new AST::Program(); + for (auto* c : *$1) g_program->classes.push_back(c); delete $1; - g_program = prog; - $$ = prog; } ; class_list - : class_decl { $$ = new std::vector(); $$->push_back($1); } - | class_list class_decl { $$ = $1; $$->push_back($2); } + : class_list class_decl + { $$ = $1; $1->push_back($2); } + | class_decl + { $$ = new std::vector(); $$->push_back($1); } ; class_decl - : CLASS IDENTIFIER IS var_decl_list END + : CLASS IDENTIFIER IS class_body END { - auto cls = new ClassDecl($2->lexeme); - for (auto* v : *$4) cls->fields.emplace_back(v); + $$ = new AST::ClassDecl($2); + for (auto* v : *$4) $$->fields.push_back(v); + free($2); delete $4; - $$ = cls; } ; +class_body + : var_decl_list { $$ = $1; } + | /* empty */ { $$ = new std::vector(); } + ; + var_decl_list - : /* empty */ { $$ = new std::vector(); } - | var_decl_list var_decl { $$ = $1; $$->push_back($2); } + : var_decl_list var_decl + { $$ = $1; $1->push_back($2); } + | var_decl + { $$ = new std::vector(); $$->push_back($1); } ; var_decl - : VAR IDENTIFIER COLON type SEMI + : VAR IDENTIFIER COLON TYPE_NAME SEMICOLON { - $$ = new VarDecl($2->lexeme, std::unique_ptr($4)); + $$ = new AST::VarDecl($2, $4, nullptr); + free($2); free($4); } - | VAR IDENTIFIER COLON type ASSIGN expr SEMI + | VAR IDENTIFIER COLON TYPE_NAME ASSIGN expr SEMICOLON { - $$ = new VarDecl($2->lexeme, std::unique_ptr($4), std::unique_ptr($6)); + $$ = new AST::VarDecl($2, $4, $6); + free($2); free($4); } ; -type - : INT_TYPE { $$ = new TypeName("Int"); } - | IDENTIFIER { $$ = new TypeName($1->lexeme); } - ; +/* ===== expressions ===== */ -/* Выражения: раскладываем a+b+10 и т.п. в бинарные узлы */ expr - : expr PLUS term { $$ = new BinExpr('+', std::unique_ptr($1), std::unique_ptr($3)); } - | expr MINUS term { $$ = new BinExpr('-', std::unique_ptr($1), std::unique_ptr($3)); } - | term { $$ = $1; } + : additive_expr { $$ = $1; } + ; + +additive_expr + : additive_expr PLUS multiplicative_expr + { $$ = new AST::Binary(AST::BinOp::Add, $1, $3); } + | additive_expr MINUS multiplicative_expr + { $$ = new AST::Binary(AST::BinOp::Sub, $1, $3); } + | multiplicative_expr + { $$ = $1; } + ; + +multiplicative_expr + : multiplicative_expr STAR unary_expr + { $$ = new AST::Binary(AST::BinOp::Mul, $1, $3); } + | multiplicative_expr SLASH unary_expr + { $$ = new AST::Binary(AST::BinOp::Div, $1, $3); } + | unary_expr + { $$ = $1; } ; -term - : term STAR factor { $$ = new BinExpr('*', std::unique_ptr($1), std::unique_ptr($3)); } - | term SLASH factor { $$ = new BinExpr('/', std::unique_ptr($1), std::unique_ptr($3)); } - | factor { $$ = $1; } +unary_expr + : MINUS unary_expr + { $$ = new AST::Unary(AST::Unary::Op::Neg, $2); } + | primary_expr + { $$ = $1; } ; -factor - : INTEGER { $$ = new IntLiteral(static_cast($1)->value); } - | IDENTIFIER { $$ = new IdExpr($1->lexeme); } - | LPAREN expr RPAREN { $$ = $2; } +primary_expr + : INT_LITERAL + { $$ = new AST::IntLiteral($1); } + | IDENTIFIER + { $$ = new AST::Identifier($1); free($1); } + | LPAREN expr RPAREN + { $$ = $2; } ; %% void yyerror(const char* s) { - fprintf(stderr, "Parse error: %s\n", s); + std::fprintf(stderr, "Parse error at line %d: %s\n", yylineno, s); } diff --git a/tokens.hpp b/tokens.hpp index ac802b2..6f317e5 100644 --- a/tokens.hpp +++ b/tokens.hpp @@ -1,27 +1,32 @@ // tokens.hpp #pragma once #include -#include +#include #include +#include +#include enum class TokenKind { - Class, Is, Var, End, - Identifier, TypeName, - IntegerLiteral, - Colon, Semicolon, Assign, - LParen, RParen, Plus, Minus, Star, Slash, - Dot, + // Ключевые + CLASS, VAR, IS, END, + // Идентификаторы / типы / литералы + IDENTIFIER, TYPE_NAME, INT_LITERAL, + // Знаки + COLON, SEMICOLON, COMMA, + LPAREN, RPAREN, LBRACE, RBRACE, + ASSIGN, PLUS, MINUS, STAR, SLASH, + END_OF_FILE }; struct Token { - TokenKind kind; + TokenKind kind; std::string lexeme; - int line = 1; - int column = 1; - Token(TokenKind k, std::string lx, int ln=1, int col=1) + int line; + int column; + + Token(TokenKind k, std::string lx, int ln, int col) : kind(k), lexeme(std::move(lx)), line(ln), column(col) {} virtual ~Token() = default; - virtual std::string info() const { return lexeme; } }; struct KeywordToken : Token { @@ -29,58 +34,64 @@ struct KeywordToken : Token { : Token(k, lx, ln, col) {} }; -struct SymbolToken : Token { - SymbolToken(TokenKind k, const std::string& lx, int ln, int col) - : Token(k, lx, ln, col) {} -}; - struct IdentifierToken : Token { - IdentifierToken(const std::string& name, int ln, int col) - : Token(TokenKind::Identifier, name, ln, col) {} + IdentifierToken(const std::string& lx, int ln, int col) + : Token(TokenKind::IDENTIFIER, lx, ln, col) {} }; -struct TypeToken : Token { - TypeToken(const std::string& name, int ln, int col) - : Token(TokenKind::TypeName, name, ln, col) {} +struct TypeNameToken : Token { + TypeNameToken(const std::string& lx, int ln, int col) + : Token(TokenKind::TYPE_NAME, lx, ln, col) {} }; struct IntegerToken : Token { - long long value; - IntegerToken(long long v, const std::string& lx, int ln, int col) - : Token(TokenKind::IntegerLiteral, lx, ln, col), value(v) {} - std::string info() const override { return std::to_string(value); } + std::int64_t value; + IntegerToken(const std::string& lx, std::int64_t v, int ln, int col) + : Token(TokenKind::INT_LITERAL, lx, ln, col), value(v) {} }; -// Утилита для красивого имени токена -inline const char* tokenKindName(TokenKind k) { +struct SymbolToken : Token { + SymbolToken(TokenKind k, const std::string& lx, int ln, int col) + : Token(k, lx, ln, col) {} +}; + +inline const char* TokenKindToString(TokenKind k) { switch (k) { - case TokenKind::Class: return "CLASS"; - case TokenKind::Is: return "IS"; - case TokenKind::Var: return "VAR"; - case TokenKind::End: return "END"; - case TokenKind::Identifier: return "IDENTIFIER"; - case TokenKind::TypeName: return "TYPE"; - case TokenKind::IntegerLiteral: return "INTEGER"; - case TokenKind::Colon: return "COLON"; - case TokenKind::Semicolon: return "SEMICOLON"; - case TokenKind::Assign: return "ASSIGN"; - case TokenKind::LParen: return "LPAREN"; - case TokenKind::RParen: return "RPAREN"; - case TokenKind::Plus: return "PLUS"; - case TokenKind::Minus: return "MINUS"; - case TokenKind::Star: return "STAR"; - case TokenKind::Slash: return "SLASH"; - case TokenKind::Dot: return "DOT"; + case TokenKind::CLASS: return "CLASS"; + case TokenKind::VAR: return "VAR"; + case TokenKind::IS: return "IS"; + case TokenKind::END: return "END"; + case TokenKind::IDENTIFIER: return "IDENTIFIER"; + case TokenKind::TYPE_NAME: return "TYPE_NAME"; + case TokenKind::INT_LITERAL: return "INT_LITERAL"; + case TokenKind::COLON: return "COLON"; + case TokenKind::SEMICOLON: return "SEMICOLON"; + case TokenKind::COMMA: return "COMMA"; + case TokenKind::LPAREN: return "LPAREN"; + case TokenKind::RPAREN: return "RPAREN"; + case TokenKind::LBRACE: return "LBRACE"; + case TokenKind::RBRACE: return "RBRACE"; + case TokenKind::ASSIGN: return "ASSIGN"; + case TokenKind::PLUS: return "PLUS"; + case TokenKind::MINUS: return "MINUS"; + case TokenKind::STAR: return "STAR"; + case TokenKind::SLASH: return "SLASH"; + case TokenKind::END_OF_FILE: return "EOF"; } return "UNKNOWN"; } -// Печать «следа» токенов из лексера -inline void printToken(const Token* t) { - std::cout << tokenKindName(t->kind); - if (t->kind == TokenKind::Identifier || t->kind == TokenKind::TypeName) +// Хранилище всех токенов для отладки (inline, чтобы не требовать .cpp) +inline std::vector> g_tokens; + +inline void EmitToken(std::unique_ptr t) { + std::cout << TokenKindToString(t->kind); + if (t->kind == TokenKind::IDENTIFIER || t->kind == TokenKind::TYPE_NAME) { std::cout << "(" << t->lexeme << ")"; - else if (t->kind == TokenKind::IntegerLiteral) - std::cout << "(" << static_cast(t)->value << ")"; + } else if (t->kind == TokenKind::INT_LITERAL) { + auto* it = static_cast(t.get()); + std::cout << "(" << it->value << ")"; + } std::cout << "\n"; + g_tokens.emplace_back(std::move(t)); } From 6cd8d42d7ddc2405695dd5ee47d603e1550cb52b Mon Sep 17 00:00:00 2001 From: dorley174 Date: Wed, 5 Nov 2025 03:55:04 +0300 Subject: [PATCH 3/7] lexer comments --- lexer.l | 9 --------- 1 file changed, 9 deletions(-) diff --git a/lexer.l b/lexer.l index eaf45df..8bf104d 100644 --- a/lexer.l +++ b/lexer.l @@ -1,4 +1,3 @@ -/* lexer.l */ %{ #include #include @@ -20,7 +19,6 @@ static inline void push_sym(TokenKind k, const char* text) { } %} -/* Упрощаем жизнь: Flex не будет вызывать yywrap из libfl */ %option noyywrap %option nodefault %option yylineno @@ -36,7 +34,6 @@ WS [ \t\r]+ "is" { push_kw(TokenKind::IS, yytext); return IS; } "end" { push_kw(TokenKind::END, yytext); return END; } -/* Базовые встроенные типы */ "Int" { EmitToken(std::make_unique(yytext, yylineno, yycolumn)); yylval.cstr = strdup(yytext); yycolumn += yyleng; return TYPE_NAME; } "String" { EmitToken(std::make_unique(yytext, yylineno, yycolumn)); @@ -46,16 +43,13 @@ WS [ \t\r]+ "Float" { EmitToken(std::make_unique(yytext, yylineno, yycolumn)); yylval.cstr = strdup(yytext); yycolumn += yyleng; return TYPE_NAME; } -/* Идентификаторы */ {ID} { EmitToken(std::make_unique(yytext, yylineno, yycolumn)); yylval.cstr = strdup(yytext); yycolumn += yyleng; return IDENTIFIER; } -/* Целые литералы */ {INT} { long long v = atoll(yytext); EmitToken(std::make_unique(yytext, v, yylineno, yycolumn)); yylval.ival = v; yycolumn += yyleng; return INT_LITERAL; } -/* Знаки и операторы */ ":" { push_sym(TokenKind::COLON, yytext); return COLON; } ";" { push_sym(TokenKind::SEMICOLON, yytext); return SEMICOLON; } "," { push_sym(TokenKind::COMMA, yytext); return COMMA; } @@ -69,14 +63,11 @@ WS [ \t\r]+ "*" { push_sym(TokenKind::STAR, yytext); return STAR; } "/" { push_sym(TokenKind::SLASH, yytext); return SLASH; } -/* Комментарии // до конца строки */ "//".* { yycolumn += yyleng; /* пропускаем */ } -/* Пробельные */ {WS} { yycolumn += yyleng; } \n { yycolumn = 1; } -/* Неожиданные символы */ . { std::fprintf(stderr, "Unknown char '%s' at %d:%d\n", yytext, yylineno, yycolumn); yycolumn += yyleng; } From 4b62740baf6d9cfbadb92266061cd85fb3530c61 Mon Sep 17 00:00:00 2001 From: dorley174 Date: Wed, 5 Nov 2025 03:56:53 +0300 Subject: [PATCH 4/7] =?UTF-8?q?comments=D0=BA=D1=83=D0=B2=D0=B3=D1=81?= =?UTF-8?q?=D1=88=D1=82=D0=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ast.hpp | 15 ++------------- lexer.l | 3 +-- main.cpp | 3 --- parser.y | 11 +---------- tokens.hpp | 12 +++--------- 5 files changed, 7 insertions(+), 37 deletions(-) diff --git a/ast.hpp b/ast.hpp index 93300f0..1a50764 100644 --- a/ast.hpp +++ b/ast.hpp @@ -1,4 +1,3 @@ -// ast.hpp #pragma once #include #include @@ -16,8 +15,6 @@ inline void doIndent(std::ostream& os, int n) { for (int i = 0; i < n; ++i) os << " "; } -// ==== Expressions ==== - struct Expr : Node { }; struct IntLiteral : Expr { @@ -44,7 +41,6 @@ struct Binary : Expr { Expr* rhs; Binary(BinOp o, Expr* l, Expr* r) : op(o), lhs(l), rhs(r) {} ~Binary() { delete lhs; delete rhs; } - static const char* opToStr(BinOp o) { switch (o) { case BinOp::Add: return "+"; @@ -76,17 +72,13 @@ struct Unary : Expr { } }; -// ==== Declarations / Program ==== - struct VarDecl : Node { std::string name; std::string typeName; - Expr* init; // может быть nullptr - + Expr* init; VarDecl(std::string n, std::string t, Expr* i) : name(std::move(n)), typeName(std::move(t)), init(i) {} ~VarDecl() { delete init; } - void print(std::ostream& os, int indent) const override { doIndent(os, indent); os << "var " << name << " : " << typeName; @@ -102,10 +94,8 @@ struct VarDecl : Node { struct ClassDecl : Node { std::string name; std::vector fields; - explicit ClassDecl(std::string n) : name(std::move(n)) {} ~ClassDecl() { for (auto* v : fields) delete v; } - void print(std::ostream& os, int indent) const override { doIndent(os, indent); os << "Class: " << name << "\n"; @@ -116,10 +106,9 @@ struct ClassDecl : Node { struct Program : Node { std::vector classes; ~Program() { for (auto* c : classes) delete c; } - void print(std::ostream& os, int indent = 0) const override { for (auto* c : classes) c->print(os, indent); } }; -} // namespace AST +} diff --git a/lexer.l b/lexer.l index 8bf104d..eafcc5e 100644 --- a/lexer.l +++ b/lexer.l @@ -63,8 +63,7 @@ WS [ \t\r]+ "*" { push_sym(TokenKind::STAR, yytext); return STAR; } "/" { push_sym(TokenKind::SLASH, yytext); return SLASH; } -"//".* { yycolumn += yyleng; /* пропускаем */ } - +"//".* { yycolumn += yyleng; } {WS} { yycolumn += yyleng; } \n { yycolumn = 1; } diff --git a/main.cpp b/main.cpp index db4c867..0e358f5 100644 --- a/main.cpp +++ b/main.cpp @@ -1,4 +1,3 @@ -// main.cpp #include #include #include "ast.hpp" @@ -18,11 +17,9 @@ int main(int argc, char** argv) { std::perror("fopen"); return 1; } - std::cout << "=== LEXER TOKENS ===\n"; int rc = yyparse(); std::fclose(yyin); - if (rc == 0) { std::cout << "\n=== AST ===\n"; if (g_program) { diff --git a/parser.y b/parser.y index e81eab3..3d4b7db 100644 --- a/parser.y +++ b/parser.y @@ -1,4 +1,3 @@ -// parser.y %{ #include #include @@ -15,12 +14,9 @@ void yyerror(const char* s); AST::Program* g_program = nullptr; %} -/* Явно попросим заголовок "parser.hpp" */ %defines "parser.hpp" -/* Подробные сообщения об ошибках */ %define parse.error verbose -/* Семантические типы */ %union { long long ival; char* cstr; @@ -32,17 +28,14 @@ AST::Program* g_program = nullptr; std::vector* varlist; } -/* Токены */ %token CLASS VAR IS END %token COLON SEMICOLON COMMA %token LPAREN RPAREN LBRACE RBRACE %token ASSIGN PLUS MINUS STAR SLASH - %token IDENTIFIER %token TYPE_NAME %token INT_LITERAL -/* Типы нетерминалов */ %type program %type class_list %type class_decl @@ -80,7 +73,7 @@ class_decl class_body : var_decl_list { $$ = $1; } - | /* empty */ { $$ = new std::vector(); } + | { $$ = new std::vector(); } ; var_decl_list @@ -103,8 +96,6 @@ var_decl } ; -/* ===== expressions ===== */ - expr : additive_expr { $$ = $1; } ; diff --git a/tokens.hpp b/tokens.hpp index 6f317e5..a9ceca2 100644 --- a/tokens.hpp +++ b/tokens.hpp @@ -1,4 +1,3 @@ -// tokens.hpp #pragma once #include #include @@ -7,11 +6,8 @@ #include enum class TokenKind { - // Ключевые CLASS, VAR, IS, END, - // Идентификаторы / типы / литералы IDENTIFIER, TYPE_NAME, INT_LITERAL, - // Знаки COLON, SEMICOLON, COMMA, LPAREN, RPAREN, LBRACE, RBRACE, ASSIGN, PLUS, MINUS, STAR, SLASH, @@ -19,11 +15,10 @@ enum class TokenKind { }; struct Token { - TokenKind kind; + TokenKind kind; std::string lexeme; - int line; - int column; - + int line; + int column; Token(TokenKind k, std::string lx, int ln, int col) : kind(k), lexeme(std::move(lx)), line(ln), column(col) {} virtual ~Token() = default; @@ -81,7 +76,6 @@ inline const char* TokenKindToString(TokenKind k) { return "UNKNOWN"; } -// Хранилище всех токенов для отладки (inline, чтобы не требовать .cpp) inline std::vector> g_tokens; inline void EmitToken(std::unique_ptr t) { From ece027cc1b62f3938ff4044a7378178b2fb3fd2c Mon Sep 17 00:00:00 2001 From: dorley174 Date: Wed, 5 Nov 2025 03:59:11 +0300 Subject: [PATCH 5/7] fix parser 1 --- parser.y | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/parser.y b/parser.y index 3d4b7db..7370f09 100644 --- a/parser.y +++ b/parser.y @@ -14,6 +14,17 @@ void yyerror(const char* s); AST::Program* g_program = nullptr; %} +/* Вставляется в parser.hpp */ +%code requires { + #include + namespace AST { + struct Program; + struct ClassDecl; + struct VarDecl; + struct Expr; + } +} + %defines "parser.hpp" %define parse.error verbose From 648caa35901d0c6077ca8ac5054e619740b25b8a Mon Sep 17 00:00:00 2001 From: dorley174 Date: Wed, 5 Nov 2025 04:15:05 +0300 Subject: [PATCH 6/7] adding more slots for ast --- ast.hpp | 66 ++++++++++++++++++++++++++++++- lexer.l | 9 +++++ parser.y | 113 ++++++++++++++++++++++++++++++++++++++++++++--------- tokens.hpp | 18 +++++++-- 4 files changed, 183 insertions(+), 23 deletions(-) diff --git a/ast.hpp b/ast.hpp index 1a50764..dba43ba 100644 --- a/ast.hpp +++ b/ast.hpp @@ -25,6 +25,14 @@ struct IntLiteral : Expr { } }; +struct BoolLiteral : Expr { + bool value; + explicit BoolLiteral(bool v) : value(v) {} + void print(std::ostream& os, int indent) const override { + doIndent(os, indent); os << "Bool(" << (value ? "true" : "false") << ")\n"; + } +}; + struct Identifier : Expr { std::string name; explicit Identifier(std::string n) : name(std::move(n)) {} @@ -72,6 +80,34 @@ struct Unary : Expr { } }; +struct Stmt : Node { }; + +struct ReturnStmt : Stmt { + Expr* value; + explicit ReturnStmt(Expr* v) : value(v) {} + ~ReturnStmt() { delete value; } + void print(std::ostream& os, int indent) const override { + doIndent(os, indent); os << "return\n"; + value->print(os, indent + 1); + } +}; + +struct IfStmt : Stmt { + Expr* cond; + Stmt* thenS; + Stmt* elseS; + IfStmt(Expr* c, Stmt* t, Stmt* e) : cond(c), thenS(t), elseS(e) {} + ~IfStmt() { delete cond; delete thenS; delete elseS; } + void print(std::ostream& os, int indent) const override { + doIndent(os, indent); os << "if\n"; + cond->print(os, indent + 1); + doIndent(os, indent); os << "then\n"; + thenS->print(os, indent + 1); + doIndent(os, indent); os << "else\n"; + elseS->print(os, indent + 1); + } +}; + struct VarDecl : Node { std::string name; std::string typeName; @@ -91,15 +127,43 @@ struct VarDecl : Node { } }; +struct Param { + std::string name; + std::string typeName; + Param(std::string n, std::string t) : name(std::move(n)), typeName(std::move(t)) {} +}; + +struct MethodDecl : Node { + std::string name; + std::vector params; + std::string returnType; + Stmt* body; + MethodDecl(std::string n, std::string rt, Stmt* b) + : name(std::move(n)), returnType(std::move(rt)), body(b) {} + ~MethodDecl() { for (auto* p : params) delete p; delete body; } + void print(std::ostream& os, int indent) const override { + doIndent(os, indent); + os << "method " << name << "("; + for (size_t i = 0; i < params.size(); ++i) { + os << params[i]->name << " : " << params[i]->typeName; + if (i + 1 < params.size()) os << ", "; + } + os << ") : " << returnType << "\n"; + if (body) body->print(os, indent + 1); + } +}; + struct ClassDecl : Node { std::string name; std::vector fields; + std::vector methods; explicit ClassDecl(std::string n) : name(std::move(n)) {} - ~ClassDecl() { for (auto* v : fields) delete v; } + ~ClassDecl() { for (auto* v : fields) delete v; for (auto* m : methods) delete m; } void print(std::ostream& os, int indent) const override { doIndent(os, indent); os << "Class: " << name << "\n"; for (auto* v : fields) v->print(os, indent + 1); + for (auto* m : methods) m->print(os, indent + 1); } }; diff --git a/lexer.l b/lexer.l index eafcc5e..4655ae5 100644 --- a/lexer.l +++ b/lexer.l @@ -34,6 +34,14 @@ WS [ \t\r]+ "is" { push_kw(TokenKind::IS, yytext); return IS; } "end" { push_kw(TokenKind::END, yytext); return END; } +"method" { push_kw(TokenKind::METHOD, yytext); return METHOD; } +"return" { push_kw(TokenKind::RETURN, yytext); return RETURN; } +"if" { push_kw(TokenKind::IF, yytext); return IF; } +"then" { push_kw(TokenKind::THEN, yytext); return THEN; } +"else" { push_kw(TokenKind::ELSE, yytext); return ELSE; } +"true" { push_kw(TokenKind::TRUEKW, yytext); return TRUE; } +"false" { push_kw(TokenKind::FALSEKW, yytext); return FALSE; } + "Int" { EmitToken(std::make_unique(yytext, yylineno, yycolumn)); yylval.cstr = strdup(yytext); yycolumn += yyleng; return TYPE_NAME; } "String" { EmitToken(std::make_unique(yytext, yylineno, yycolumn)); @@ -50,6 +58,7 @@ WS [ \t\r]+ EmitToken(std::make_unique(yytext, v, yylineno, yycolumn)); yylval.ival = v; yycolumn += yyleng; return INT_LITERAL; } +"=>" { push_sym(TokenKind::ARROW, yytext); return ARROW; } ":" { push_sym(TokenKind::COLON, yytext); return COLON; } ";" { push_sym(TokenKind::SEMICOLON, yytext); return SEMICOLON; } "," { push_sym(TokenKind::COMMA, yytext); return COMMA; } diff --git a/parser.y b/parser.y index 7370f09..06c0439 100644 --- a/parser.y +++ b/parser.y @@ -14,14 +14,17 @@ void yyerror(const char* s); AST::Program* g_program = nullptr; %} -/* Вставляется в parser.hpp */ %code requires { #include namespace AST { + struct Node; struct Program; struct ClassDecl; struct VarDecl; struct Expr; + struct Stmt; + struct MethodDecl; + struct Param; } } @@ -29,20 +32,28 @@ AST::Program* g_program = nullptr; %define parse.error verbose %union { - long long ival; - char* cstr; - AST::Program* program; - AST::ClassDecl* classdecl; - AST::VarDecl* vardecl; - AST::Expr* expr; - std::vector* classlist; - std::vector* varlist; + long long ival; + char* cstr; + AST::Program* program; + AST::ClassDecl* classdecl; + AST::VarDecl* vardecl; + AST::Expr* expr; + AST::Stmt* stmt; + AST::MethodDecl* methoddecl; + AST::Param* param; + AST::Node* node; + std::vector* classlist; + std::vector* memberlist; + std::vector* varlist; + std::vector* paramlist; } %token CLASS VAR IS END +%token METHOD RETURN IF THEN ELSE +%token TRUE FALSE %token COLON SEMICOLON COMMA %token LPAREN RPAREN LBRACE RBRACE -%token ASSIGN PLUS MINUS STAR SLASH +%token ASSIGN ARROW PLUS MINUS STAR SLASH %token IDENTIFIER %token TYPE_NAME %token INT_LITERAL @@ -50,8 +61,13 @@ AST::Program* g_program = nullptr; %type program %type class_list %type class_decl -%type class_body var_decl_list +%type class_body member_list +%type member %type var_decl +%type method_decl +%type opt_params param_list +%type param +%type method_body stmt if_stmt %type expr additive_expr multiplicative_expr unary_expr primary_expr %% @@ -76,22 +92,31 @@ class_decl : CLASS IDENTIFIER IS class_body END { $$ = new AST::ClassDecl($2); - for (auto* v : *$4) $$->fields.push_back(v); + for (auto* n : *$4) { + if (auto* v = dynamic_cast(n)) $$->fields.push_back(v); + else if (auto* m = dynamic_cast(n)) $$->methods.push_back(m); + else delete n; + } free($2); delete $4; } ; class_body - : var_decl_list { $$ = $1; } - | { $$ = new std::vector(); } + : member_list { $$ = $1; } + | { $$ = new std::vector(); } ; -var_decl_list - : var_decl_list var_decl +member_list + : member_list member { $$ = $1; $1->push_back($2); } - | var_decl - { $$ = new std::vector(); $$->push_back($1); } + | member + { $$ = new std::vector(); $$->push_back($1); } + ; + +member + : var_decl { $$ = $1; } + | method_decl { $$ = $1; } ; var_decl @@ -107,6 +132,54 @@ var_decl } ; +method_decl + : METHOD IDENTIFIER LPAREN opt_params RPAREN COLON TYPE_NAME ARROW method_body + { + $$ = new AST::MethodDecl($2, $7, $9); + if ($4) { for (auto* p : *$4) $$->params.push_back(p); delete $4; } + free($2); free($7); + } + ; + +opt_params + : param_list { $$ = $1; } + | { $$ = new std::vector(); } + ; + +param_list + : param_list COMMA param + { $$ = $1; $1->push_back($3); } + | param + { $$ = new std::vector(); $$->push_back($1); } + ; + +param + : IDENTIFIER COLON TYPE_NAME + { + $$ = new AST::Param($1, $3); + free($1); free($3); + } + ; + +method_body + : expr + { $$ = new AST::ReturnStmt($1); } + | stmt + { $$ = $1; } + ; + +stmt + : RETURN expr + { $$ = new AST::ReturnStmt($2); } + | if_stmt + { $$ = $1; } + ; + +if_stmt + : IF expr THEN stmt ELSE stmt + { $$ = new AST::IfStmt($2, $4, $6); } + ; + expr : additive_expr { $$ = $1; } ; @@ -139,6 +212,10 @@ unary_expr primary_expr : INT_LITERAL { $$ = new AST::IntLiteral($1); } + | TRUE + { $$ = new AST::BoolLiteral(true); } + | FALSE + { $$ = new AST::BoolLiteral(false); } | IDENTIFIER { $$ = new AST::Identifier($1); free($1); } | LPAREN expr RPAREN diff --git a/tokens.hpp b/tokens.hpp index a9ceca2..5571070 100644 --- a/tokens.hpp +++ b/tokens.hpp @@ -7,18 +7,20 @@ enum class TokenKind { CLASS, VAR, IS, END, + METHOD, RETURN, IF, THEN, ELSE, + TRUEKW, FALSEKW, IDENTIFIER, TYPE_NAME, INT_LITERAL, COLON, SEMICOLON, COMMA, LPAREN, RPAREN, LBRACE, RBRACE, - ASSIGN, PLUS, MINUS, STAR, SLASH, + ASSIGN, ARROW, PLUS, MINUS, STAR, SLASH, END_OF_FILE }; struct Token { - TokenKind kind; + TokenKind kind; std::string lexeme; - int line; - int column; + int line; + int column; Token(TokenKind k, std::string lx, int ln, int col) : kind(k), lexeme(std::move(lx)), line(ln), column(col) {} virtual ~Token() = default; @@ -56,6 +58,13 @@ inline const char* TokenKindToString(TokenKind k) { case TokenKind::VAR: return "VAR"; case TokenKind::IS: return "IS"; case TokenKind::END: return "END"; + case TokenKind::METHOD: return "METHOD"; + case TokenKind::RETURN: return "RETURN"; + case TokenKind::IF: return "IF"; + case TokenKind::THEN: return "THEN"; + case TokenKind::ELSE: return "ELSE"; + case TokenKind::TRUEKW: return "TRUE"; + case TokenKind::FALSEKW: return "FALSE"; case TokenKind::IDENTIFIER: return "IDENTIFIER"; case TokenKind::TYPE_NAME: return "TYPE_NAME"; case TokenKind::INT_LITERAL: return "INT_LITERAL"; @@ -67,6 +76,7 @@ inline const char* TokenKindToString(TokenKind k) { case TokenKind::LBRACE: return "LBRACE"; case TokenKind::RBRACE: return "RBRACE"; case TokenKind::ASSIGN: return "ASSIGN"; + case TokenKind::ARROW: return "ARROW"; case TokenKind::PLUS: return "PLUS"; case TokenKind::MINUS: return "MINUS"; case TokenKind::STAR: return "STAR"; From 200010c7505b5bb3db0ccb5fd0692fc8a0414283 Mon Sep 17 00:00:00 2001 From: dorley174 Date: Wed, 5 Nov 2025 04:21:01 +0300 Subject: [PATCH 7/7] adding tests --- tests/old/test.o | 36 +++++++++++++++++------------------- tests/old/test1.o | 9 ++++----- tests/old/test10.o | 29 +++++++++++++---------------- tests/old/test11.o | 33 +++++++++++++++------------------ tests/old/test12.o | 18 +++++++++--------- tests/old/test13.o | 21 +++++++++++---------- tests/old/test14.o | 21 ++++++++++----------- tests/old/test15.o | 31 +++++++++++++------------------ tests/old/test2.o | 13 ++++++------- tests/old/test3.o | 15 ++++++++------- tests/old/test4.o | 21 ++++++++++----------- tests/old/test5.o | 17 ++++++++--------- tests/old/test6.o | 14 ++++++-------- tests/old/test7.o | 18 +++++++----------- tests/old/test8.o | 11 +++++------ tests/old/test9.o | 34 ++++++++++++++++------------------ 16 files changed, 158 insertions(+), 183 deletions(-) diff --git a/tests/old/test.o b/tests/old/test.o index 5c111b0..d1a85d7 100644 --- a/tests/old/test.o +++ b/tests/old/test.o @@ -1,24 +1,22 @@ + class C is - var x : 10.1.2.3 - method Foo(a : Float ) : Float => a + var x : Float; + method Foo(a : Float) : Float => a end -class Animal { - void speak() { - output("..."); - } -} +class Animal is + method speak() : Void => + "..." +end -class Dog : Animal { - void bark() { - output("woof"); - } -} +class Dog is + method bark() : Void => + "woof" +end -class Main { - void main() { - Dog d; - d.speak(); - d.bark(); - } -} \ No newline at end of file +class Main is + method main() : Void => + var d : Dog; + d.Foo(0); # для примера, так как вызовы методов надо упрощать + d.bark() +end diff --git a/tests/old/test1.o b/tests/old/test1.o index cd3c59d..8e2a0df 100644 --- a/tests/old/test1.o +++ b/tests/old/test1.o @@ -1,5 +1,4 @@ -class Main { - void main() { - output("Hello, World!"); - } -} +class Main is + method main() : Void => + output("Hello, World!") +end \ No newline at end of file diff --git a/tests/old/test10.o b/tests/old/test10.o index 2b94af2..c04c96c 100644 --- a/tests/old/test10.o +++ b/tests/old/test10.o @@ -1,19 +1,16 @@ -class Animal { - void speak() { - output("..."); - } -} +class Animal is + method speak() : Void => + output("...") +end -class Dog : Animal { - void bark() { - output("woof"); - } -} +class Dog is + method bark() : Void => + output("woof") +end -class Main { - void main() { - Dog d; +class Main is + var d : Dog; + method main() : Void => d.speak(); - d.bark(); - } -} + d.bark() +end \ No newline at end of file diff --git a/tests/old/test11.o b/tests/old/test11.o index 928c7aa..0873c64 100644 --- a/tests/old/test11.o +++ b/tests/old/test11.o @@ -1,20 +1,17 @@ -class Animal { - virtual void speak() { - output("..."); - } -} +class Animal is + method speak() : Void => + output("...") +end -class Dog : Animal { - override void speak() { - output("woof"); - } -} +class Dog is + method speak() : Void => + output("woof") +end -class Main { - void main() { - Animal a; - Dog d; - a = d; // полиморфизм - a.speak(); // должен вызвать Dog.speak() - } -} +class Main is + var a : Animal; + var d : Dog; + method main() : Void => + a := d; # полиморфизм + a.speak() # должен вызвать Dog.speak() +end \ No newline at end of file diff --git a/tests/old/test12.o b/tests/old/test12.o index f49a43b..f0776f4 100644 --- a/tests/old/test12.o +++ b/tests/old/test12.o @@ -1,9 +1,9 @@ -class Main { - void main() { - int[3] arr; - arr[0] = 10; - arr[1] = 20; - arr[2] = 30; - output(arr[1]); - } -} +class Main is + var arr : Array; + method main() : Void => + arr := Array(3); + arr[0] := 10; + arr[1] := 20; + arr[2] := 30; + output(arr[1]) +end \ No newline at end of file diff --git a/tests/old/test13.o b/tests/old/test13.o index e3caf70..b28eedd 100644 --- a/tests/old/test13.o +++ b/tests/old/test13.o @@ -1,10 +1,11 @@ -class Main { - int fact(int n) { - if (n == 0) return 1; - return n * fact(n - 1); - } - - void main() { - output(fact(5)); - } -} +class Main is + method fact(n : Int) : Int => + if n == 0 then + 1 + else + n * fact(n - 1) + end + + method main() : Void => + output(fact(5)) +end \ No newline at end of file diff --git a/tests/old/test14.o b/tests/old/test14.o index a840d7d..74b939d 100644 --- a/tests/old/test14.o +++ b/tests/old/test14.o @@ -1,11 +1,10 @@ -class Main { - void main() { - bool a; - a = true; - if (a) { - output(1); - } else { - output(0); - } - } -} +class Main is + var a : Bool; + method main() : Void => + a := true; + if a then + output(1) + else + output(0) + end +end \ No newline at end of file diff --git a/tests/old/test15.o b/tests/old/test15.o index 1e3e0f4..a7449da 100644 --- a/tests/old/test15.o +++ b/tests/old/test15.o @@ -1,20 +1,15 @@ -class A { - int get() { - return 42; - } -} +class A is + method get() : Int => 42 +end -class B { - A obj; +class B is + var obj : A; + method print() : Void => + output(obj.get()) +end - void print() { - output(obj.get()); - } -} - -class Main { - void main() { - B b; - b.print(); - } -} +class Main is + var b : B; + method main() : Void => + b.print() +end \ No newline at end of file diff --git a/tests/old/test2.o b/tests/old/test2.o index f4f9b63..e3a40a4 100644 --- a/tests/old/test2.o +++ b/tests/old/test2.o @@ -1,7 +1,6 @@ -class Main { - void main() { - int x; - x = 5; - output(x); - } -} +class Main is + var x : Int; + method main() : Void => + x := 5; + output(x) +end \ No newline at end of file diff --git a/tests/old/test3.o b/tests/old/test3.o index 71dc050..5c95525 100644 --- a/tests/old/test3.o +++ b/tests/old/test3.o @@ -1,7 +1,8 @@ -class Main { - void main() { - int a; int b; - a = 2; b = 3; - output(a + b); - } -} +class Main is + var a : Int; + var b : Int; + method main() : Void => + a := 2; + b := 3; + output(a + b) +end \ No newline at end of file diff --git a/tests/old/test4.o b/tests/old/test4.o index 08115ec..a4cbc14 100644 --- a/tests/old/test4.o +++ b/tests/old/test4.o @@ -1,11 +1,10 @@ -class Main { - void main() { - int x; - x = 10; - if (x > 5) { - output(1); - } else { - output(0); - } - } -} +class Main is + var x : Int; + method main() : Void => + x := 10; + if x > 5 then + output(1) + else + output(0) + end +end \ No newline at end of file diff --git a/tests/old/test5.o b/tests/old/test5.o index 14e9b6a..4dd7b80 100644 --- a/tests/old/test5.o +++ b/tests/old/test5.o @@ -1,10 +1,9 @@ -class Main { - void main() { - int i; - i = 0; - while (i < 3) { +class Main is + var i : Int; + method main() : Void => + i := 0; + while i < 3 do output(i); - i = i + 1; - } - } -} + i := i + 1 + end +end \ No newline at end of file diff --git a/tests/old/test6.o b/tests/old/test6.o index 6109f2a..0e7da82 100644 --- a/tests/old/test6.o +++ b/tests/old/test6.o @@ -1,8 +1,6 @@ -class Main { - int square(int x) { - return x * x; - } - void main() { - output(square(4)); - } -} +class Main is + method square(x : Int) : Int => x * x + + method main() : Void => + output(square(4)) +end \ No newline at end of file diff --git a/tests/old/test7.o b/tests/old/test7.o index 22ef258..c9bbaf6 100644 --- a/tests/old/test7.o +++ b/tests/old/test7.o @@ -1,12 +1,8 @@ -class Main { - int add(int a, int b) { - return a + b; - } - int mul(int a, int b) { - return a * b; - } - void main() { +class Main is + method add(a : Int, b : Int) : Int => a + b + method mul(a : Int, b : Int) : Int => a * b + + method main() : Void => output(add(2, 3)); - output(mul(2, 3)); - } -} + output(mul(2, 3)) +end \ No newline at end of file diff --git a/tests/old/test8.o b/tests/old/test8.o index 3c709c4..104f74d 100644 --- a/tests/old/test8.o +++ b/tests/old/test8.o @@ -1,7 +1,6 @@ -class Main { - void main() { - int x; +class Main is + var x : Int; + method main() : Void => input(x); - output(x + 1); - } -} + output(x + 1) +end \ No newline at end of file diff --git a/tests/old/test9.o b/tests/old/test9.o index 73f1407..e8be7b9 100644 --- a/tests/old/test9.o +++ b/tests/old/test9.o @@ -1,21 +1,19 @@ -class Point { - int x; - int y; - - void init(int a, int b) { - x = a; y = b; - } - - void print() { +class Point is + var x : Int; + var y : Int; + + method init(a : Int, b : Int) : Void => + x := a; + y := b + + method print() : Void => output(x); - output(y); - } -} + output(y) +end -class Main { - void main() { - Point p; +class Main is + var p : Point; + method main() : Void => p.init(3, 4); - p.print(); - } -} + p.print() +end \ No newline at end of file