From 6b8d4ec4cacacaa29477dd5165025425e48e459f Mon Sep 17 00:00:00 2001 From: Leandro Nini Date: Sun, 19 Jul 2026 14:59:11 +0200 Subject: [PATCH 1/2] Updat Exomizer to version 2.0.11 --- CMakeLists.txt | 11 +- README.md | 2 +- src/asm/Makefile | 73 + src/asm/asm.tab.c | 3038 ++++++++++++++++++++++++ src/asm/asm.tab.h | 167 ++ src/asm/asm.y | 435 ++++ src/asm/asm.yy | 285 +++ src/asm/asmtab.c | 2900 ---------------------- src/asm/asmtab.h | 232 -- src/asm/callback.h | 3 + src/asm/{chnkpool.c => chunkpool.c} | 89 +- src/asm/{chnkpool.h => chunkpool.h} | 17 +- src/asm/expr.c | 7 +- src/asm/expr.h | 2 +- src/asm/int.h | 6 +- src/asm/lex.yy.c | 2748 +++++++++++++++++++++ src/asm/lexyy.c | 2323 ------------------ src/asm/log.c | 45 +- src/asm/log.h | 20 +- src/asm/map.c | 186 ++ src/asm/map.h | 69 + src/asm/membuf.c | 71 +- src/asm/membuf.h | 17 +- src/asm/{membufio.c => membuf_io.c} | 7 +- src/asm/{membufio.h => membuf_io.h} | 0 src/asm/{namedbuf.c => named_buffer.c} | 91 +- src/asm/{namedbuf.h => named_buffer.h} | 19 +- src/asm/parse.c | 517 ++-- src/asm/parse.h | 36 +- src/asm/pc.c | 47 +- src/asm/vec.c | 91 +- src/asm/vec.h | 29 +- src/data/altplayer.s | 34 +- src/data/altplayer_s.s | 34 +- src/data/player.s | 34 +- src/data/player_s.s | 34 +- src/reloc.cpp | 8 +- 37 files changed, 7836 insertions(+), 5891 deletions(-) create mode 100644 src/asm/Makefile create mode 100644 src/asm/asm.tab.c create mode 100644 src/asm/asm.tab.h create mode 100644 src/asm/asm.y create mode 100644 src/asm/asm.yy delete mode 100644 src/asm/asmtab.c delete mode 100644 src/asm/asmtab.h rename src/asm/{chnkpool.c => chunkpool.c} (54%) rename src/asm/{chnkpool.h => chunkpool.h} (85%) create mode 100644 src/asm/lex.yy.c delete mode 100644 src/asm/lexyy.c create mode 100644 src/asm/map.c create mode 100644 src/asm/map.h rename src/asm/{membufio.c => membuf_io.c} (96%) rename src/asm/{membufio.h => membuf_io.h} (100%) rename src/asm/{namedbuf.c => named_buffer.c} (52%) rename src/asm/{namedbuf.h => named_buffer.h} (69%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 15058d2..d99aa7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,14 +33,15 @@ set(LOADTRK_SOURCES src/sound.cpp src/console.cpp src/sid.cpp - src/asm/asmtab.c - src/asm/chnkpool.c + src/asm/asm.tab.c + src/asm/chunkpool.c src/asm/expr.c - src/asm/lexyy.c + src/asm/lex.yy.c src/asm/log.c + src/asm/map.c src/asm/membuf.c - src/asm/membufio.c - src/asm/namedbuf.c + src/asm/membuf_io.c + src/asm/named_buffer.c src/asm/parse.c src/asm/pc.c src/asm/vec.c diff --git a/README.md b/README.md index 7049bc2..e9c5605 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ _You should have received a copy of the GNU General Public License https://github.com/thestk/rtmidi distributed under MIT license -* Exomizer +* Exomizer 2.0.11 https://bitbucket.org/magli143/exomizer/ distributed under ZLIB license diff --git a/src/asm/Makefile b/src/asm/Makefile new file mode 100644 index 0000000..2ccd367 --- /dev/null +++ b/src/asm/Makefile @@ -0,0 +1,73 @@ +# +# Makefile for exomizer +# +WFLAGS = --std=c89 -Wall -Wstrict-prototypes +CFLAGS = $(WFLAGS) -O3 -ffast-math -fomit-frame-pointer -fgcse -pedantic -D_XOPEN_SOURCE=500 +LDFLAGS = -s + +#CFLAGS = -g $(WFLAGS) +#LDFLAGS = -g + +SHARED_OBJS = getflag.o log.o membuf.o +RAW_OBJS = match.o search.o exo_raw.o optimal.o output.o membuf_io.o \ + chunkpool.o radix.o exo_helper.o exodec.o progress.o exo_util.o \ + vec.o +EXO_OBJS = match.o search.o exo_main.o optimal.o output.o membuf_io.o \ + chunkpool.o radix.o exo_helper.o exodec.o progress.o asm.tab.o \ + lex.yy.o parse.o expr.o pc.o vec.o named_buffer.o map.o desfx.o \ + 6502emu.o exo_util.o sfxdecr.o +BAS_OBJS = bas_main.o bprg_renumber.o bprg_link_patch.o bprg_trampoline.o \ + bprg.o vec.o +ALL_OBJS = $(EXO_OBJS) $(RAW_OBJS) $(BAS_OBJS) $(SHARED_OBJS) + +#.SILENT: + +.PHONY: build clean +.INTERMEDIATE: b2membuf exoraw + +build: $(MAKEFILE) exomizer exobasic + +exomizer: deps $(EXO_OBJS) $(SHARED_OBJS) + @echo "Linking $@" + @$(CC) $(LDFLAGS) -o $@ $(EXO_OBJS) $(SHARED_OBJS) + +exoraw: deps $(RAW_OBJS) $(SHARED_OBJS) + @echo "Linking $@" + @$(CC) $(LDFLAGS) -o $@ $(RAW_OBJS) $(SHARED_OBJS) + +exobasic: deps $(BAS_OBJS) $(SHARED_OBJS) + @echo "Linking $@" + @$(CC) $(LDFLAGS) -o $@ $(BAS_OBJS) $(SHARED_OBJS) + +clean: + @echo "Cleaning project" + -@$(RM) $(EXO_OBJS) $(RAW_OBJS) $(BAS_OBJS) $(SHARED_OBJS) + -@$(RM) b2membuf.o b2membuf b2membuf.exe sfxdecr sfxdecr.c deps + -@$(RM) exomizer exoraw exobasic exomizer.exe exoraw.exe exobasic.exe + + +asm.tab.h asm.tab.c: asm.y + bison -t -d asm.y + +lex.yy.c: asm.yy + flex -B asm.yy + +sfxdecr.c: sfxdecr b2membuf + @./b2membuf sfxdecr >sfxdecr.c + +sfxdecr: sfxdecr.s exoraw + @echo "Compressing $<" + @./exoraw -q sfxdecr.s -o sfxdecr + +-include deps + +deps: $(wildcard *.h) asm.tab.h + @echo "Generating dependencies" + @$(CC) -MM $(wildcard *.c) >$@ + +%.o: %.c + @echo "Compiling $<" + @$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $< + +%: %.o + @$(CC) $(LDFLAGS) $< -o $@ diff --git a/src/asm/asm.tab.c b/src/asm/asm.tab.c new file mode 100644 index 0000000..1c35b37 --- /dev/null +++ b/src/asm/asm.tab.c @@ -0,0 +1,3038 @@ +/* A Bison parser, made by GNU Bison 3.0.4. */ + +/* Bison implementation for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2015 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. */ + +/* 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. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "3.0.4" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + + + + +/* Copy the first part of user declarations. */ +#line 28 "asm.y" /* yacc.c:339 */ + +#include "int.h" +#include "parse.h" +#include "vec.h" +#include "membuf.h" +#include "log.h" +#include +#define YYERROR_VERBOSE + +static struct vec asm_atoms[1]; + +/* prototypes to silence compiler warnings */ +int yylex(void); +void yyerror(const char *s); + + +#line 83 "asm.tab.c" /* yacc.c:339 */ + +# ifndef YY_NULLPTR +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif +# endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* In a future release of Bison, this section will be replaced + by #include "asm.tab.h". */ +#ifndef YY_YY_ASM_TAB_H_INCLUDED +# define YY_YY_ASM_TAB_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 1 +#endif +#if YYDEBUG +extern int yydebug; +#endif + +/* Token type. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + enum yytokentype + { + INCLUDE = 258, + IF = 259, + DEFINED = 260, + MACRO = 261, + MACRO_STRING = 262, + ORG = 263, + ERROR = 264, + ECHO1 = 265, + INCBIN = 266, + INCLEN = 267, + INCWORD = 268, + RES = 269, + WORD = 270, + BYTE = 271, + LDA = 272, + LDX = 273, + LDY = 274, + STA = 275, + STX = 276, + STY = 277, + AND = 278, + ORA = 279, + EOR = 280, + ADC = 281, + SBC = 282, + CMP = 283, + CPX = 284, + CPY = 285, + TSX = 286, + TXS = 287, + PHA = 288, + PLA = 289, + PHP = 290, + PLP = 291, + SEI = 292, + CLI = 293, + NOP = 294, + TYA = 295, + TAY = 296, + TXA = 297, + TAX = 298, + CLC = 299, + SEC = 300, + RTS = 301, + JSR = 302, + JMP = 303, + BEQ = 304, + BNE = 305, + BCC = 306, + BCS = 307, + BPL = 308, + BMI = 309, + BVC = 310, + BVS = 311, + INX = 312, + DEX = 313, + INY = 314, + DEY = 315, + INC = 316, + DEC = 317, + LSR = 318, + ASL = 319, + ROR = 320, + ROL = 321, + BIT = 322, + SYMBOL = 323, + STRING = 324, + LAND = 325, + LOR = 326, + LNOT = 327, + LPAREN = 328, + RPAREN = 329, + COMMA = 330, + COLON = 331, + X = 332, + Y = 333, + HASH = 334, + PLUS = 335, + MINUS = 336, + MULT = 337, + DIV = 338, + MOD = 339, + LT = 340, + GT = 341, + EQ = 342, + NEQ = 343, + ASSIGN = 344, + GUESS = 345, + NUMBER = 346, + vNEG = 347, + LABEL = 348 + }; +#endif + +/* Value type. */ +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED + +union YYSTYPE +{ +#line 145 "asm.y" /* yacc.c:355 */ + + i32 num; + char *str; + struct atom *atom; + struct expr *expr; + +#line 224 "asm.tab.c" /* yacc.c:355 */ +}; + +typedef union YYSTYPE YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 +#endif + + +extern YYSTYPE yylval; + +int yyparse (void); + +#endif /* !YY_YY_ASM_TAB_H_INCLUDED */ + +/* Copy the second part of user declarations. */ + +#line 241 "asm.tab.c" /* yacc.c:358 */ + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#else +typedef signed char yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#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 +# if (defined __GNUC__ \ + && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ + || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C +# define YY_ATTRIBUTE(Spec) __attribute__(Spec) +# else +# define YY_ATTRIBUTE(Spec) /* empty */ +# endif +#endif + +#ifndef YY_ATTRIBUTE_PURE +# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) +#endif + +#ifndef YY_ATTRIBUTE_UNUSED +# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) +#endif + +#if !defined _Noreturn \ + && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) +# if defined _MSC_VER && 1200 <= _MSC_VER +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(E) ((void) (E)) +#else +# define YYUSE(E) /* empty */ +#endif + +#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# 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 yyoverflow || YYERROR_VERBOSE + +/* 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 /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (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 \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*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, (Count) * sizeof (*(Src))) +# else +# define YYCOPY(Dst, Src, Count) \ + do \ + { \ + YYSIZE_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 218 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 646 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 94 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 17 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 198 +/* YYNSTATES -- Number of states. */ +#define YYNSTATES 320 + +/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned + by yylex, with out-of-bounds checking. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 348 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, without out-of-bounds checking. */ +static const yytype_uint8 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, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, + 85, 86, 87, 88, 89, 90, 91, 92, 93 +}; + +#if YYDEBUG + /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 182, 182, 182, 183, 184, 185, 186, 187, 188, + 189, 190, 191, 192, 193, 194, 196, 197, 198, 199, + 200, 202, 204, 207, 208, 210, 211, 212, 213, 214, + 215, 216, 217, 219, 220, 221, 222, 223, 225, 226, + 227, 228, 229, 231, 232, 233, 234, 235, 236, 237, + 239, 240, 241, 243, 244, 245, 247, 248, 249, 250, + 251, 252, 253, 254, 256, 257, 258, 259, 260, 261, + 262, 263, 265, 266, 267, 268, 269, 270, 271, 272, + 274, 275, 276, 277, 278, 279, 280, 281, 283, 284, + 285, 286, 287, 288, 289, 290, 292, 293, 294, 295, + 296, 297, 298, 299, 301, 302, 303, 304, 305, 306, + 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, + 318, 319, 320, 321, 322, 323, 325, 326, 327, 328, + 329, 330, 331, 332, 333, 334, 336, 337, 338, 339, + 341, 342, 343, 344, 346, 347, 348, 349, 351, 352, + 353, 354, 355, 357, 358, 359, 360, 361, 363, 364, + 365, 366, 367, 369, 370, 371, 372, 373, 375, 376, + 378, 379, 380, 381, 382, 383, 384, 385, 386, 388, + 389, 390, 391, 392, 393, 394, 395, 396, 398, 399, + 401, 402, 403, 404, 405, 406, 407, 408, 410 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || 0 +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "INCLUDE", "IF", "DEFINED", "MACRO", + "MACRO_STRING", "ORG", "ERROR", "ECHO1", "INCBIN", "INCLEN", "INCWORD", + "RES", "WORD", "BYTE", "LDA", "LDX", "LDY", "STA", "STX", "STY", "AND", + "ORA", "EOR", "ADC", "SBC", "CMP", "CPX", "CPY", "TSX", "TXS", "PHA", + "PLA", "PHP", "PLP", "SEI", "CLI", "NOP", "TYA", "TAY", "TXA", "TAX", + "CLC", "SEC", "RTS", "JSR", "JMP", "BEQ", "BNE", "BCC", "BCS", "BPL", + "BMI", "BVC", "BVS", "INX", "DEX", "INY", "DEY", "INC", "DEC", "LSR", + "ASL", "ROR", "ROL", "BIT", "SYMBOL", "STRING", "LAND", "LOR", "LNOT", + "LPAREN", "RPAREN", "COMMA", "COLON", "X", "Y", "HASH", "PLUS", "MINUS", + "MULT", "DIV", "MOD", "LT", "GT", "EQ", "NEQ", "ASSIGN", "GUESS", + "NUMBER", "vNEG", "LABEL", "$accept", "stmts", "stmt", "atom", "exprs", + "op", "am_im", "am_a", "am_ax", "am_ay", "am_zp", "am_zpx", "am_zpy", + "am_ix", "am_iy", "expr", "lexpr", YY_NULLPTR +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[NUM] -- (External) token number corresponding to the + (internal) symbol number NUM (which must be that of a token). */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, + 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, + 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, + 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, + 345, 346, 347, 348 +}; +# endif + +#define YYPACT_NINF -211 + +#define yypact_value_is_default(Yystate) \ + (!!((Yystate) == (-211))) + +#define YYTABLE_NINF -1 + +#define yytable_value_is_error(Yytable_value) \ + 0 + + /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +static const yytype_int16 yypact[] = +{ + 287, -68, -23, -14, -211, -4, 15, 84, 85, 92, + 105, 107, 186, 189, 344, 363, 366, 377, 186, 186, + 186, 186, 186, 186, 347, 347, -211, -211, -211, -211, + -211, -211, -211, -211, -211, -211, -211, -211, -211, -211, + -211, -211, 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, -211, -211, -211, -211, 377, 377, 377, 377, + 377, 377, 388, -33, 112, 83, -211, -211, -211, 120, + 154, 121, 208, 122, 123, 124, 208, 208, 208, 108, + 127, -211, 208, 208, 208, 208, -211, -211, -211, -211, + -211, -211, -211, -211, -211, 494, 208, 208, -211, -211, + -211, -211, -211, 504, -211, -211, -211, -211, -211, 514, + -211, -211, -211, -211, -211, -211, -211, -211, -211, -211, + -65, -211, -211, -211, -211, -211, -211, -211, -211, -211, + -211, -211, -211, -211, -211, -211, -211, -211, -211, -211, + -211, -211, -211, -211, -211, -211, -211, -211, -211, -211, + -211, -211, -211, -211, -211, -211, -211, -211, -211, -211, + -211, -211, -211, -211, -211, -211, -211, -211, -211, -211, + -211, -211, 208, -211, -211, -211, -211, -211, -211, -211, + -211, -211, -211, -211, -211, -211, -211, -211, -211, -211, + -211, -211, -211, -211, -211, -211, -211, -211, -211, -211, + -211, -211, -211, -211, -211, -211, -211, -211, -211, -211, + -211, -211, -211, -211, -211, 208, 208, -211, -211, -211, + 131, 135, 154, 154, 156, -19, 143, 303, 144, -45, + -7, 524, 7, -65, 21, 125, 126, 132, -65, -211, + 534, 77, 208, 208, 208, 208, 208, 314, 544, 119, + 142, -65, -65, -65, -211, 141, -211, -60, 82, 208, + 208, 208, 208, 154, 154, -211, -211, -211, -211, -211, + 208, -211, 208, 208, -211, 208, -211, 149, 153, 171, + 147, 148, -211, -211, -21, -21, -211, -211, -211, -211, + 151, 179, -211, -65, -65, -65, -65, -211, 185, 87, + 204, 468, -65, -211, 208, 178, 190, -211, -211, -211, + -211, -211, 208, -211, 473, -211, -211, 484, -211, -211 +}; + + /* 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_uint8 yydefact[] = +{ + 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 111, 110, 112, 113, + 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, + 124, 125, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 136, 137, 138, 139, 0, 0, 148, 153, + 158, 163, 0, 0, 0, 0, 3, 14, 16, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 189, 0, 0, 0, 0, 188, 25, 28, 29, + 30, 26, 27, 31, 32, 171, 0, 0, 33, 36, + 37, 34, 35, 171, 38, 41, 42, 39, 40, 171, + 45, 46, 47, 43, 44, 48, 49, 52, 50, 51, + 171, 55, 53, 54, 56, 59, 60, 61, 57, 58, + 62, 63, 64, 67, 68, 69, 65, 66, 70, 71, + 72, 75, 76, 77, 73, 74, 78, 79, 80, 83, + 84, 85, 81, 82, 86, 87, 88, 91, 92, 93, + 89, 90, 94, 95, 96, 99, 100, 101, 97, 98, + 102, 103, 0, 104, 106, 105, 107, 109, 108, 126, + 127, 128, 129, 130, 131, 132, 133, 134, 135, 142, + 143, 140, 141, 146, 147, 144, 145, 151, 152, 149, + 150, 156, 157, 154, 155, 161, 162, 159, 160, 166, + 167, 164, 165, 169, 168, 0, 0, 4, 1, 2, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 24, 0, 0, 0, 0, 170, 184, + 174, 0, 0, 0, 0, 0, 0, 0, 174, 0, + 0, 174, 5, 6, 12, 0, 192, 0, 0, 0, + 0, 0, 0, 0, 0, 7, 13, 8, 9, 10, + 0, 20, 0, 0, 18, 0, 19, 0, 0, 185, + 0, 0, 172, 173, 179, 180, 181, 182, 183, 185, + 0, 0, 193, 194, 195, 196, 197, 191, 190, 0, + 0, 0, 23, 186, 0, 0, 0, 175, 176, 198, + 11, 21, 0, 17, 0, 178, 177, 0, 187, 22 +}; + + /* YYPGOTO[NTERM-NUM]. */ +static const yytype_int16 yypgoto[] = +{ + -211, -211, 201, -211, -74, -211, 150, 467, 479, 164, + 18, 348, 253, 614, 623, -12, -210 +}; + + /* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 65, 66, 67, 232, 68, 87, 88, 89, 90, + 91, 92, 102, 93, 94, 120, 225 +}; + + /* 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_uint16 yytable[] = +{ + 95, 103, 109, 95, 234, 69, 95, 95, 95, 95, + 95, 95, 256, 258, 289, 242, 243, 244, 245, 246, + 242, 243, 244, 245, 246, 259, 260, 261, 262, 269, + 270, 101, 107, 113, 118, 122, 128, 136, 144, 152, + 160, 168, 175, 178, 109, 109, 109, 109, 109, 109, + 70, 263, 264, 297, 298, 265, 215, 216, 224, 71, + 227, 244, 245, 246, 231, 233, 233, 271, 272, 72, + 237, 238, 239, 240, 191, 195, 199, 203, 207, 211, + 214, 274, 275, 218, 247, 248, 1, 2, 73, 3, + 4, 5, 6, 7, 8, 276, 275, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 263, 264, 282, 283, 292, 74, 75, 221, + 251, 310, 275, 98, 104, 76, 79, 80, 124, 132, + 140, 148, 156, 164, 173, 176, 64, 100, 77, 112, + 78, 235, 127, 135, 143, 151, 159, 167, 217, 220, + 226, 228, 229, 230, 277, 278, 299, 283, 79, 80, + 236, 79, 80, 252, 253, 254, 279, 280, 255, 291, + 224, 257, 242, 243, 244, 245, 246, 266, 268, 282, + 79, 80, 81, 303, 306, 307, 222, 223, 304, 308, + 284, 285, 286, 287, 288, 84, 242, 243, 244, 245, + 246, 259, 260, 261, 262, 86, 305, 293, 294, 295, + 296, 224, 224, 309, 81, 263, 315, 81, 233, 82, + 300, 301, 96, 302, 316, 83, 219, 84, 83, 119, + 84, 85, 0, 0, 97, 0, 81, 86, 311, 312, + 86, 96, 0, 0, 242, 243, 244, 245, 246, 84, + 1, 2, 314, 3, 4, 5, 6, 7, 8, 86, + 317, 9, 10, 11, 12, 13, 14, 15, 16, 17, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 79, 80, 0, 79, + 80, 0, 108, 114, 0, 123, 129, 137, 145, 153, + 161, 169, 0, 0, 0, 79, 80, 267, 79, 80, + 64, 0, 0, 242, 243, 244, 245, 246, 289, 79, + 80, 0, 0, 0, 242, 243, 244, 245, 246, 0, + 79, 80, 0, 0, 192, 196, 200, 204, 208, 212, + 0, 0, 81, 0, 0, 81, 0, 96, 0, 0, + 96, 0, 0, 83, 0, 84, 83, 0, 84, 85, + 0, 81, 172, 0, 81, 86, 82, 0, 86, 96, + 0, 0, 0, 0, 84, 81, 0, 84, 85, 0, + 96, 97, 0, 0, 86, 0, 81, 86, 84, 0, + 0, 96, 85, 0, 0, 0, 0, 0, 86, 84, + 0, 0, 0, 172, 0, 0, 0, 0, 0, 86, + 99, 105, 110, 117, 121, 125, 133, 141, 149, 157, + 165, 174, 177, 106, 111, 0, 0, 126, 134, 142, + 150, 158, 166, 0, 0, 0, 0, 0, 0, 179, + 180, 181, 182, 183, 184, 185, 186, 187, 188, 0, + 0, 0, 0, 189, 193, 197, 201, 205, 209, 213, + 0, 0, 0, 0, 0, 190, 194, 198, 202, 206, + 210, 0, 313, 0, 0, 0, 0, 318, 242, 243, + 244, 245, 246, 242, 243, 244, 245, 246, 319, 0, + 0, 0, 0, 0, 242, 243, 244, 245, 246, 241, + 0, 0, 0, 0, 242, 243, 244, 245, 246, 249, + 0, 0, 0, 0, 242, 243, 244, 245, 246, 250, + 0, 0, 0, 0, 242, 243, 244, 245, 246, 273, + 0, 0, 0, 0, 242, 243, 244, 245, 246, 281, + 0, 0, 0, 0, 242, 243, 244, 245, 246, 290, + 0, 0, 0, 0, 242, 243, 244, 245, 246, 115, + 0, 0, 130, 138, 146, 154, 162, 170, 116, 0, + 0, 131, 139, 147, 155, 163, 171 +}; + +static const yytype_int16 yycheck[] = +{ + 12, 13, 14, 15, 78, 73, 18, 19, 20, 21, + 22, 23, 222, 223, 74, 80, 81, 82, 83, 84, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 74, + 75, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 56, 57, 58, 59, 60, 61, + 73, 70, 71, 263, 264, 74, 89, 90, 70, 73, + 72, 82, 83, 84, 76, 77, 78, 74, 75, 73, + 82, 83, 84, 85, 56, 57, 58, 59, 60, 61, + 62, 74, 75, 0, 96, 97, 3, 4, 73, 6, + 7, 8, 9, 10, 11, 74, 75, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 70, 71, 77, 78, 74, 73, 73, 5, + 172, 74, 75, 13, 14, 73, 12, 13, 18, 19, + 20, 21, 22, 23, 24, 25, 93, 13, 73, 15, + 73, 73, 18, 19, 20, 21, 22, 23, 76, 69, + 69, 69, 69, 69, 69, 69, 270, 78, 12, 13, + 73, 12, 13, 215, 216, 74, 74, 75, 73, 68, + 222, 223, 80, 81, 82, 83, 84, 74, 74, 77, + 12, 13, 68, 74, 77, 77, 72, 73, 75, 78, + 242, 243, 244, 245, 246, 81, 80, 81, 82, 83, + 84, 85, 86, 87, 88, 91, 75, 259, 260, 261, + 262, 263, 264, 74, 68, 70, 78, 68, 270, 73, + 272, 273, 73, 275, 74, 79, 65, 81, 79, 16, + 81, 85, -1, -1, 85, -1, 68, 91, 74, 75, + 91, 73, -1, -1, 80, 81, 82, 83, 84, 81, + 3, 4, 304, 6, 7, 8, 9, 10, 11, 91, + 312, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 12, 13, -1, 12, + 13, -1, 14, 15, -1, 17, 18, 19, 20, 21, + 22, 23, -1, -1, -1, 12, 13, 74, 12, 13, + 93, -1, -1, 80, 81, 82, 83, 84, 74, 12, + 13, -1, -1, -1, 80, 81, 82, 83, 84, -1, + 12, 13, -1, -1, 56, 57, 58, 59, 60, 61, + -1, -1, 68, -1, -1, 68, -1, 73, -1, -1, + 73, -1, -1, 79, -1, 81, 79, -1, 81, 85, + -1, 68, 85, -1, 68, 91, 73, -1, 91, 73, + -1, -1, -1, -1, 81, 68, -1, 81, 85, -1, + 73, 85, -1, -1, 91, -1, 68, 91, 81, -1, + -1, 73, 85, -1, -1, -1, -1, -1, 91, 81, + -1, -1, -1, 85, -1, -1, -1, -1, -1, 91, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 14, 15, -1, -1, 18, 19, 20, + 21, 22, 23, -1, -1, -1, -1, -1, -1, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, + -1, -1, -1, 56, 57, 58, 59, 60, 61, 62, + -1, -1, -1, -1, -1, 56, 57, 58, 59, 60, + 61, -1, 74, -1, -1, -1, -1, 74, 80, 81, + 82, 83, 84, 80, 81, 82, 83, 84, 74, -1, + -1, -1, -1, -1, 80, 81, 82, 83, 84, 75, + -1, -1, -1, -1, 80, 81, 82, 83, 84, 75, + -1, -1, -1, -1, 80, 81, 82, 83, 84, 75, + -1, -1, -1, -1, 80, 81, 82, 83, 84, 75, + -1, -1, -1, -1, 80, 81, 82, 83, 84, 75, + -1, -1, -1, -1, 80, 81, 82, 83, 84, 75, + -1, -1, -1, -1, 80, 81, 82, 83, 84, 15, + -1, -1, 18, 19, 20, 21, 22, 23, 15, -1, + -1, 18, 19, 20, 21, 22, 23 +}; + + /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 3, 4, 6, 7, 8, 9, 10, 11, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 93, 95, 96, 97, 99, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 12, + 13, 68, 73, 79, 81, 85, 91, 100, 101, 102, + 103, 104, 105, 107, 108, 109, 73, 85, 100, 101, + 103, 104, 106, 109, 100, 101, 102, 104, 105, 109, + 101, 102, 103, 104, 105, 107, 108, 101, 104, 106, + 109, 101, 104, 105, 100, 101, 102, 103, 104, 105, + 107, 108, 100, 101, 102, 103, 104, 105, 107, 108, + 100, 101, 102, 103, 104, 105, 107, 108, 100, 101, + 102, 103, 104, 105, 107, 108, 100, 101, 102, 103, + 104, 105, 107, 108, 100, 101, 102, 103, 104, 105, + 107, 108, 85, 100, 101, 104, 100, 101, 104, 101, + 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, + 102, 104, 105, 101, 102, 104, 105, 101, 102, 104, + 105, 101, 102, 104, 105, 101, 102, 104, 105, 101, + 102, 104, 105, 101, 104, 89, 90, 76, 0, 96, + 69, 5, 72, 73, 109, 110, 69, 109, 69, 69, + 69, 109, 98, 109, 98, 73, 73, 109, 109, 109, + 109, 75, 80, 81, 82, 83, 84, 109, 109, 75, + 75, 109, 109, 109, 74, 73, 110, 109, 110, 85, + 86, 87, 88, 70, 71, 74, 74, 74, 74, 74, + 75, 74, 75, 75, 74, 75, 74, 69, 69, 74, + 75, 75, 77, 78, 109, 109, 109, 109, 109, 74, + 75, 68, 74, 109, 109, 109, 109, 110, 110, 98, + 109, 109, 109, 74, 75, 75, 77, 77, 78, 74, + 74, 74, 75, 74, 109, 78, 74, 109, 74, 74 +}; + + /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 94, 95, 95, 96, 96, 96, 96, 96, 96, + 96, 96, 96, 96, 96, 96, 97, 97, 97, 97, + 97, 97, 97, 98, 98, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, + 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, + 110, 110, 110, 110, 110, 110, 110, 110, 110 +}; + + /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 2, 1, 2, 3, 3, 4, 4, 4, + 4, 6, 4, 4, 1, 1, 1, 6, 4, 4, + 4, 6, 8, 3, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, + 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, + 2, 2, 2, 1, 2, 2, 2, 2, 1, 2, + 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, + 2, 1, 3, 3, 2, 4, 4, 5, 5, 3, + 3, 3, 3, 3, 2, 3, 4, 6, 1, 1, + 3, 3, 2, 3, 3, 3, 3, 3, 4 +}; + + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +#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) + +/* Error token number */ +#define YYTERROR 1 +#define YYERRCODE 256 + + + +/* 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) + +/* This macro is provided for backward compatibility. */ +#ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +#endif + + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + + +/*----------------------------------------. +| Print this symbol's value on YYOUTPUT. | +`----------------------------------------*/ + +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +{ + FILE *yyo = yyoutput; + YYUSE (yyo); + if (!yyvaluep) + return; +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + YYUSE (yytype); +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +{ + YYFPRINTF (yyoutput, "%s %s (", + yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +static void +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *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 (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) +{ + unsigned long int yylno = yyrline[yyrule]; + int yynrhs = yyr2[yyrule]; + int yyi; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, + yystos[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) +# define YY_SYMBOL_PRINT(Title, Type, 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 + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +yystrlen (const char *yystr) +{ + YYSIZE_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 YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_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; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* 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 2 if the + required number of bytes is too large to store. */ +static int +yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, + yytype_int16 *yyssp, int yytoken) +{ + YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); + YYSIZE_T yysize = yysize0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + /* Internationalized format string. */ + const char *yyformat = YY_NULLPTR; + /* Arguments of yyformat. */ + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + /* Number of reported tokens (one for the "unexpected", one per + "expected"). */ + 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 (yytoken != YYEMPTY) + { + int yyn = yypact[*yyssp]; + yyarg[yycount++] = yytname[yytoken]; + 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 != YYTERROR + && !yytable_value_is_error (yytable[yyx + yyn])) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + break; + } + yyarg[yycount++] = yytname[yyx]; + { + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + } + } + } + + switch (yycount) + { +# define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + 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_ + } + + { + YYSIZE_T yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + + 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, yyarg[yyi++]); + yyformat += 2; + } + else + { + yyp++; + yyformat++; + } + } + return 0; +} +#endif /* YYERROR_VERBOSE */ + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +{ + YYUSE (yyvaluep); + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YYUSE (yytype); + YY_IGNORE_MAYBE_UNINITIALIZED_END +} + + + + +/* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; +/* Number of syntax errors so far. */ +int yynerrs; + + +/*----------. +| yyparse. | +`----------*/ + +int +yyparse (void) +{ + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + 'yyss': related to states. + 'yyvs': related to semantic values. + + Refer to the stacks through separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + YYSIZE_T yystacksize; + + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#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; + + yyssp = yyss = yyssa; + yyvsp = yyvs = yyvsa; + yystacksize = YYINITDEPTH; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + 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: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef 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. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* 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 * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + 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 YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = yylex (); + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + 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); + + /* Discard the shifted token. */ + yychar = YYEMPTY; + + yystate = yyn; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + 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 4: +#line 183 "asm.y" /* yacc.c:1646 */ + { new_label((yyvsp[-1].str)); } +#line 1615 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 5: +#line 184 "asm.y" /* yacc.c:1646 */ + { new_symbol_expr((yyvsp[-2].str), (yyvsp[0].expr)); } +#line 1621 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 6: +#line 185 "asm.y" /* yacc.c:1646 */ + { new_symbol_expr_guess((yyvsp[-2].str), (yyvsp[0].expr)); } +#line 1627 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 7: +#line 186 "asm.y" /* yacc.c:1646 */ + { push_if_state((yyvsp[-1].expr)); } +#line 1633 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 8: +#line 187 "asm.y" /* yacc.c:1646 */ + { set_org((yyvsp[-1].expr)); } +#line 1639 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 9: +#line 188 "asm.y" /* yacc.c:1646 */ + { asm_error((yyvsp[-1].str)); } +#line 1645 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 10: +#line 189 "asm.y" /* yacc.c:1646 */ + { asm_echo((yyvsp[-1].str), NULL); } +#line 1651 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 11: +#line 190 "asm.y" /* yacc.c:1646 */ + { asm_echo((yyvsp[-3].str), (yyvsp[-1].atom)); } +#line 1657 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 12: +#line 191 "asm.y" /* yacc.c:1646 */ + { asm_include((yyvsp[-1].str)); } +#line 1663 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 13: +#line 192 "asm.y" /* yacc.c:1646 */ + { push_macro_state((yyvsp[-1].str)); } +#line 1669 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 14: +#line 193 "asm.y" /* yacc.c:1646 */ + { vec_push(asm_atoms, &(yyvsp[0].atom)); } +#line 1675 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 15: +#line 194 "asm.y" /* yacc.c:1646 */ + { macro_append((yyvsp[0].str)); } +#line 1681 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 16: +#line 196 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = (yyvsp[0].atom); } +#line 1687 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 17: +#line 197 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_res((yyvsp[-3].expr), (yyvsp[-1].expr)); } +#line 1693 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 18: +#line 198 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = exprs_to_word_exprs((yyvsp[-1].atom)); } +#line 1699 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 19: +#line 199 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = exprs_to_byte_exprs((yyvsp[-1].atom)); } +#line 1705 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 20: +#line 200 "asm.y" /* yacc.c:1646 */ + { + (yyval.atom) = new_incbin((yyvsp[-1].str), NULL, NULL); } +#line 1712 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 21: +#line 202 "asm.y" /* yacc.c:1646 */ + { + (yyval.atom) = new_incbin((yyvsp[-3].str), (yyvsp[-1].expr), NULL); } +#line 1719 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 22: +#line 204 "asm.y" /* yacc.c:1646 */ + { + (yyval.atom) = new_incbin((yyvsp[-5].str), (yyvsp[-3].expr), (yyvsp[-1].expr)); } +#line 1726 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 23: +#line 207 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = exprs_add((yyvsp[-2].atom), (yyvsp[0].expr)); } +#line 1732 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 24: +#line 208 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_exprs((yyvsp[0].expr)); } +#line 1738 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 25: +#line 210 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xA9, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); } +#line 1744 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 26: +#line 211 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xA5, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1750 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 27: +#line 212 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xB5, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1756 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 28: +#line 213 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xAD, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1762 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 29: +#line 214 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xBD, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1768 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 30: +#line 215 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xB9, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1774 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 31: +#line 216 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xA1, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1780 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 32: +#line 217 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xB1, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1786 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 33: +#line 219 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xA2, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); } +#line 1792 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 34: +#line 220 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xA6, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1798 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 35: +#line 221 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xB6, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1804 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 36: +#line 222 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xAE, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1810 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 37: +#line 223 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xBE, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1816 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 38: +#line 225 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xA0, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); } +#line 1822 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 39: +#line 226 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xA4, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1828 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 40: +#line 227 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xB4, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1834 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 41: +#line 228 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xAC, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1840 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 42: +#line 229 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xBC, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1846 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 43: +#line 231 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x85, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1852 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 44: +#line 232 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x95, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1858 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 45: +#line 233 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x8D, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1864 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 46: +#line 234 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x9D, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1870 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 47: +#line 235 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x99, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1876 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 48: +#line 236 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x81, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1882 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 49: +#line 237 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x91, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1888 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 50: +#line 239 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x86, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1894 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 51: +#line 240 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x96, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1900 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 52: +#line 241 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x8e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1906 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 53: +#line 243 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x84, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1912 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 54: +#line 244 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x94, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1918 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 55: +#line 245 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x8c, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1924 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 56: +#line 247 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x29, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); } +#line 1930 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 57: +#line 248 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x25, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1936 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 58: +#line 249 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x35, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1942 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 59: +#line 250 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x2d, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1948 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 60: +#line 251 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x3d, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1954 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 61: +#line 252 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x39, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1960 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 62: +#line 253 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x21, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1966 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 63: +#line 254 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x31, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1972 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 64: +#line 256 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x09, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); } +#line 1978 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 65: +#line 257 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x05, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1984 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 66: +#line 258 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x15, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1990 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 67: +#line 259 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x0d, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1996 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 68: +#line 260 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x1d, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2002 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 69: +#line 261 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x19, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2008 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 70: +#line 262 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x01, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2014 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 71: +#line 263 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x11, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2020 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 72: +#line 265 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x49, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); } +#line 2026 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 73: +#line 266 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x45, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2032 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 74: +#line 267 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x55, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2038 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 75: +#line 268 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x4d, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2044 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 76: +#line 269 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x5d, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2050 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 77: +#line 270 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x59, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2056 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 78: +#line 271 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x41, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2062 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 79: +#line 272 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x51, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2068 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 80: +#line 274 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x69, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); } +#line 2074 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 81: +#line 275 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x65, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2080 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 82: +#line 276 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x75, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2086 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 83: +#line 277 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x6D, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2092 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 84: +#line 278 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x7D, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2098 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 85: +#line 279 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x79, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2104 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 86: +#line 280 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x61, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2110 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 87: +#line 281 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x71, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2116 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 88: +#line 283 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xe9, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); } +#line 2122 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 89: +#line 284 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xe5, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2128 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 90: +#line 285 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xf5, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2134 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 91: +#line 286 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xeD, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2140 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 92: +#line 287 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xfD, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2146 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 93: +#line 288 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xf9, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2152 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 94: +#line 289 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xe1, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2158 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 95: +#line 290 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xf1, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2164 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 96: +#line 292 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xc9, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); } +#line 2170 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 97: +#line 293 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xc5, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2176 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 98: +#line 294 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xd5, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2182 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 99: +#line 295 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xcD, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2188 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 100: +#line 296 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xdD, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2194 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 101: +#line 297 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xd9, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2200 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 102: +#line 298 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xc1, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2206 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 103: +#line 299 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xd1, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2212 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 104: +#line 301 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xe0, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2218 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 105: +#line 302 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xe4, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2224 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 106: +#line 303 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xec, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2230 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 107: +#line 304 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xc0, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2236 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 108: +#line 305 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xc4, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2242 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 109: +#line 306 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xcc, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2248 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 110: +#line 308 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op0(0x9A); } +#line 2254 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 111: +#line 309 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op0(0xBA); } +#line 2260 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 112: +#line 310 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op0(0x48); } +#line 2266 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 113: +#line 311 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op0(0x68); } +#line 2272 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 114: +#line 312 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op0(0x08); } +#line 2278 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 115: +#line 313 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op0(0x28); } +#line 2284 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 116: +#line 314 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op0(0x78); } +#line 2290 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 117: +#line 315 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op0(0x58); } +#line 2296 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 118: +#line 316 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op0(0xea); } +#line 2302 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 119: +#line 317 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op0(0x98); } +#line 2308 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 120: +#line 318 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op0(0xa8); } +#line 2314 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 121: +#line 319 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op0(0x8a); } +#line 2320 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 122: +#line 320 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op0(0xaa); } +#line 2326 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 123: +#line 321 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op0(0x18); } +#line 2332 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 124: +#line 322 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op0(0x38); } +#line 2338 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 125: +#line 323 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op0(0x60); } +#line 2344 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 126: +#line 325 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x20, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2350 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 127: +#line 326 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x4c, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2356 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 128: +#line 327 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xf0, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); } +#line 2362 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 129: +#line 328 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xd0, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); } +#line 2368 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 130: +#line 329 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x90, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); } +#line 2374 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 131: +#line 330 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xb0, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); } +#line 2380 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 132: +#line 331 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x10, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); } +#line 2386 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 133: +#line 332 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x30, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); } +#line 2392 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 134: +#line 333 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x50, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); } +#line 2398 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 135: +#line 334 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x70, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); } +#line 2404 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 136: +#line 336 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op0(0xe8); } +#line 2410 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 137: +#line 337 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op0(0xca); } +#line 2416 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 138: +#line 338 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op0(0xc8); } +#line 2422 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 139: +#line 339 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op0(0x88); } +#line 2428 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 140: +#line 341 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xe6, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2434 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 141: +#line 342 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xf6, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2440 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 142: +#line 343 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xee, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2446 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 143: +#line 344 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xfe, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2452 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 144: +#line 346 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xc6, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2458 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 145: +#line 347 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xd6, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2464 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 146: +#line 348 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xce, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2470 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 147: +#line 349 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0xde, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2476 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 148: +#line 351 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op0(0x4a); } +#line 2482 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 149: +#line 352 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x46, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2488 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 150: +#line 353 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x56, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2494 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 151: +#line 354 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x4e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2500 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 152: +#line 355 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x5e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2506 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 153: +#line 357 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op0(0x0a); } +#line 2512 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 154: +#line 358 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x06, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2518 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 155: +#line 359 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x16, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2524 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 156: +#line 360 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x0e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2530 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 157: +#line 361 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x1e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2536 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 158: +#line 363 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op0(0x6a); } +#line 2542 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 159: +#line 364 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x66, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2548 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 160: +#line 365 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x76, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2554 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 161: +#line 366 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x6e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2560 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 162: +#line 367 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x7e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2566 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 163: +#line 369 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op0(0x2a); } +#line 2572 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 164: +#line 370 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x26, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2578 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 165: +#line 371 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x36, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2584 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 166: +#line 372 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x2e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2590 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 167: +#line 373 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x3e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2596 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 168: +#line 375 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x24, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2602 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 169: +#line 376 "asm.y" /* yacc.c:1646 */ + { (yyval.atom) = new_op(0x2c, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2608 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 170: +#line 378 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = (yyvsp[0].expr); } +#line 2614 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 171: +#line 379 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = (yyvsp[0].expr); } +#line 2620 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 172: +#line 380 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = (yyvsp[-2].expr); } +#line 2626 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 173: +#line 381 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = (yyvsp[-2].expr); } +#line 2632 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 174: +#line 382 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = (yyvsp[0].expr); } +#line 2638 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 175: +#line 383 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = (yyvsp[-2].expr); } +#line 2644 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 176: +#line 384 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = (yyvsp[-2].expr); } +#line 2650 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 177: +#line 385 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = (yyvsp[-3].expr); } +#line 2656 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 178: +#line 386 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = (yyvsp[-3].expr); } +#line 2662 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 179: +#line 388 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = new_expr_op2(PLUS, (yyvsp[-2].expr), (yyvsp[0].expr)); } +#line 2668 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 180: +#line 389 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = new_expr_op2(MINUS, (yyvsp[-2].expr), (yyvsp[0].expr)); } +#line 2674 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 181: +#line 390 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = new_expr_op2(MULT, (yyvsp[-2].expr), (yyvsp[0].expr)); } +#line 2680 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 182: +#line 391 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = new_expr_op2(DIV, (yyvsp[-2].expr), (yyvsp[0].expr)); } +#line 2686 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 183: +#line 392 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = new_expr_op2(MOD, (yyvsp[-2].expr), (yyvsp[0].expr)); } +#line 2692 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 184: +#line 393 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = new_expr_op1(vNEG, (yyvsp[0].expr)); } +#line 2698 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 185: +#line 394 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = (yyvsp[-1].expr); } +#line 2704 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 186: +#line 395 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = new_expr_inclen((yyvsp[-1].str)); } +#line 2710 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 187: +#line 396 "asm.y" /* yacc.c:1646 */ + { + (yyval.expr) = new_expr_incword((yyvsp[-3].str), (yyvsp[-1].expr)); } +#line 2717 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 188: +#line 398 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = new_expr_number((yyvsp[0].num)); } +#line 2723 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 189: +#line 399 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = new_expr_symref((yyvsp[0].str)); } +#line 2729 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 190: +#line 401 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = new_expr_op2(LOR, (yyvsp[-2].expr), (yyvsp[0].expr)); } +#line 2735 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 191: +#line 402 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = new_expr_op2(LAND, (yyvsp[-2].expr), (yyvsp[0].expr)); } +#line 2741 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 192: +#line 403 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = new_expr_op1(LNOT, (yyvsp[0].expr)); } +#line 2747 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 193: +#line 404 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = (yyvsp[-1].expr); } +#line 2753 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 194: +#line 405 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = new_expr_op2(LT, (yyvsp[-2].expr), (yyvsp[0].expr)); } +#line 2759 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 195: +#line 406 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = new_expr_op2(GT, (yyvsp[-2].expr), (yyvsp[0].expr)); } +#line 2765 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 196: +#line 407 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = new_expr_op2(EQ, (yyvsp[-2].expr), (yyvsp[0].expr)); } +#line 2771 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 197: +#line 408 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = new_expr_op2(NEQ, (yyvsp[-2].expr), (yyvsp[0].expr)); } +#line 2777 "asm.tab.c" /* yacc.c:1646 */ + break; + + case 198: +#line 410 "asm.y" /* yacc.c:1646 */ + { (yyval.expr) = new_is_defined((yyvsp[-1].str)); } +#line 2783 "asm.tab.c" /* yacc.c:1646 */ + break; + + +#line 2787 "asm.tab.c" /* yacc.c:1646 */ + 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 ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++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. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + 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 ? YYEMPTY : YYTRANSLATE (yychar); + + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (YY_("syntax error")); +#else +# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ + yyssp, yytoken) + { + char const *yymsgp = YY_("syntax error"); + int yysyntax_error_status; + yysyntax_error_status = YYSYNTAX_ERROR; + if (yysyntax_error_status == 0) + yymsgp = yymsg; + else if (yysyntax_error_status == 1) + { + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); + if (!yymsg) + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + yysyntax_error_status = 2; + } + else + { + yysyntax_error_status = YYSYNTAX_ERROR; + yymsgp = yymsg; + } + } + yyerror (yymsgp); + if (yysyntax_error_status == 2) + goto yyexhaustedlab; + } +# undef YYSYNTAX_ERROR +#endif + } + + + + 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 like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* 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. */ + + for (;;) + { + yyn = yypact[yystate]; + if (!yypact_value_is_default (yyn)) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + 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", + yystos[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", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#if !defined yyoverflow || YYERROR_VERBOSE +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + 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", + yystos[*yyssp], yyvsp); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + return yyresult; +} +#line 412 "asm.y" /* yacc.c:1906 */ + + +void yyerror (const char *s) +{ + fprintf (stderr, "line %d, %s\n", num_lines, s); +} + +void asm_set_source(struct membuf *buffer); + +int assembleSinglePass(struct membuf *source, struct membuf *dest) +{ + int val; + + yydebug = 0; + asm_src_buffer_push(source); + vec_init(asm_atoms, sizeof(struct atom*)); + val = yyparse(); + if(val == 0) + { + output_atoms(dest, asm_atoms); + } + vec_free(asm_atoms, NULL); + return val; +} diff --git a/src/asm/asm.tab.h b/src/asm/asm.tab.h new file mode 100644 index 0000000..9cfe51b --- /dev/null +++ b/src/asm/asm.tab.h @@ -0,0 +1,167 @@ +/* A Bison parser, made by GNU Bison 3.0.4. */ + +/* Bison interface for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2015 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. */ + +#ifndef YY_YY_ASM_TAB_H_INCLUDED +# define YY_YY_ASM_TAB_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 1 +#endif +#if YYDEBUG +extern int yydebug; +#endif + +/* Token type. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + enum yytokentype + { + INCLUDE = 258, + IF = 259, + DEFINED = 260, + MACRO = 261, + MACRO_STRING = 262, + ORG = 263, + ERROR = 264, + ECHO1 = 265, + INCBIN = 266, + INCLEN = 267, + INCWORD = 268, + RES = 269, + WORD = 270, + BYTE = 271, + LDA = 272, + LDX = 273, + LDY = 274, + STA = 275, + STX = 276, + STY = 277, + AND = 278, + ORA = 279, + EOR = 280, + ADC = 281, + SBC = 282, + CMP = 283, + CPX = 284, + CPY = 285, + TSX = 286, + TXS = 287, + PHA = 288, + PLA = 289, + PHP = 290, + PLP = 291, + SEI = 292, + CLI = 293, + NOP = 294, + TYA = 295, + TAY = 296, + TXA = 297, + TAX = 298, + CLC = 299, + SEC = 300, + RTS = 301, + JSR = 302, + JMP = 303, + BEQ = 304, + BNE = 305, + BCC = 306, + BCS = 307, + BPL = 308, + BMI = 309, + BVC = 310, + BVS = 311, + INX = 312, + DEX = 313, + INY = 314, + DEY = 315, + INC = 316, + DEC = 317, + LSR = 318, + ASL = 319, + ROR = 320, + ROL = 321, + BIT = 322, + SYMBOL = 323, + STRING = 324, + LAND = 325, + LOR = 326, + LNOT = 327, + LPAREN = 328, + RPAREN = 329, + COMMA = 330, + COLON = 331, + X = 332, + Y = 333, + HASH = 334, + PLUS = 335, + MINUS = 336, + MULT = 337, + DIV = 338, + MOD = 339, + LT = 340, + GT = 341, + EQ = 342, + NEQ = 343, + ASSIGN = 344, + GUESS = 345, + NUMBER = 346, + vNEG = 347, + LABEL = 348 + }; +#endif + +/* Value type. */ +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED + +union YYSTYPE +{ +#line 145 "asm.y" /* yacc.c:1909 */ + + i32 num; + char *str; + struct atom *atom; + struct expr *expr; + +#line 155 "asm.tab.h" /* yacc.c:1909 */ +}; + +typedef union YYSTYPE YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 +#endif + + +extern YYSTYPE yylval; + +int yyparse (void); + +#endif /* !YY_YY_ASM_TAB_H_INCLUDED */ diff --git a/src/asm/asm.y b/src/asm/asm.y new file mode 100644 index 0000000..11b9e27 --- /dev/null +++ b/src/asm/asm.y @@ -0,0 +1,435 @@ +/* + * Copyright (c) 2005 Magnus Lind. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software, alter it and re- + * distribute it freely for any non-commercial, non-profit purpose subject to + * the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not + * be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any distribution. + * + * 4. The names of this software and/or it's copyright holders may not be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + */ + +%{ +#include "int.h" +#include "parse.h" +#include "vec.h" +#include "membuf.h" +#include "log.h" +#include +#define YYERROR_VERBOSE + +static struct vec asm_atoms[1]; + +/* prototypes to silence compiler warnings */ +int yylex(void); +void yyerror(const char *s); + +%} + +%expect 5 + +%token INCLUDE +%token IF +%token DEFINED +%token MACRO +%token MACRO_STRING +%token ORG +%token ERROR +%token ECHO1 +%token INCBIN +%token INCLEN +%token INCWORD +%token RES +%token WORD +%token BYTE + +%token LDA +%token LDX +%token LDY +%token STA +%token STX +%token STY +%token AND +%token ORA +%token EOR +%token ADC +%token SBC +%token CMP +%token CPX +%token CPY + +%token TSX +%token TXS +%token PHA +%token PLA +%token PHP +%token PLP +%token SEI +%token CLI +%token NOP +%token TYA +%token TAY +%token TXA +%token TAX +%token CLC +%token SEC +%token RTS + +%token JSR +%token JMP +%token BEQ +%token BNE +%token BCC +%token BCS +%token BPL +%token BMI +%token BVC +%token BVS +%token INX +%token DEX +%token INY +%token DEY +%token INC +%token DEC + +%token LSR +%token ASL +%token ROR +%token ROL +%token BIT + +%token SYMBOL +%token STRING + +%token LAND +%token LOR +%token LNOT + +%token LPAREN +%token RPAREN +%token COMMA +%token COLON +%token X +%token Y +%token HASH +%token PLUS +%token MINUS +%token MULT +%token DIV +%token MOD +%token LT +%token GT +%token EQ +%token NEQ +%token ASSIGN +%token GUESS +%token NUMBER + +%union +{ + i32 num; + char *str; + struct atom *atom; + struct expr *expr; +} + +%right ASSIGN +%right GUESS +%left LOR +%left LAND +%nonassoc LT GT EQ +%left MINUS PLUS +%left MULT DIV MOD +%left vNEG +%left LNOT + +%token LABEL + +%type lexpr +%type expr +%type op; +%type atom; +%type exprs; + +%type am_im; +%type am_a; +%type am_ax; +%type am_ay; +%type am_zp; +%type am_zpx; +%type am_zpy; +%type am_ix; +%type am_iy; + +%% + +stmts: stmts stmt | stmt; +stmt: LABEL COLON { new_label($1); } | + SYMBOL ASSIGN expr { new_symbol_expr($1, $3); } | + SYMBOL GUESS expr { new_symbol_expr_guess($1, $3); } | + IF LPAREN lexpr RPAREN { push_if_state($3); } | + ORG LPAREN expr RPAREN { set_org($3); } | + ERROR LPAREN STRING RPAREN { asm_error($3); } | + ECHO1 LPAREN STRING RPAREN { asm_echo($3, NULL); } | + ECHO1 LPAREN STRING COMMA exprs RPAREN { asm_echo($3, $5); } | + INCLUDE LPAREN STRING RPAREN { asm_include($3); } | + MACRO LPAREN STRING RPAREN { push_macro_state($3); } | + atom { vec_push(asm_atoms, &$1); } | + MACRO_STRING { macro_append($1); }; + +atom: op { $$ = $1; } | + RES LPAREN expr COMMA expr RPAREN { $$ = new_res($3, $5); } | + WORD LPAREN exprs RPAREN { $$ = exprs_to_word_exprs($3); } | + BYTE LPAREN exprs RPAREN { $$ = exprs_to_byte_exprs($3); } | + INCBIN LPAREN STRING RPAREN { + $$ = new_incbin($3, NULL, NULL); } | + INCBIN LPAREN STRING COMMA expr RPAREN { + $$ = new_incbin($3, $5, NULL); } | + INCBIN LPAREN STRING COMMA expr COMMA expr RPAREN { + $$ = new_incbin($3, $5, $7); }; + +exprs: exprs COMMA expr { $$ = exprs_add($1, $3); } | + expr { $$ = new_exprs($1); }; + +op: LDA am_im { $$ = new_op(0xA9, ATOM_TYPE_OP_ARG_UI8, $2); } | + LDA am_zp { $$ = new_op(0xA5, ATOM_TYPE_OP_ARG_U8, $2); } | + LDA am_zpx { $$ = new_op(0xB5, ATOM_TYPE_OP_ARG_U8, $2); } | + LDA am_a { $$ = new_op(0xAD, ATOM_TYPE_OP_ARG_U16, $2); } | + LDA am_ax { $$ = new_op(0xBD, ATOM_TYPE_OP_ARG_U16, $2); } | + LDA am_ay { $$ = new_op(0xB9, ATOM_TYPE_OP_ARG_U16, $2); } | + LDA am_ix { $$ = new_op(0xA1, ATOM_TYPE_OP_ARG_U8, $2); } | + LDA am_iy { $$ = new_op(0xB1, ATOM_TYPE_OP_ARG_U8, $2); }; + +op: LDX am_im { $$ = new_op(0xA2, ATOM_TYPE_OP_ARG_UI8, $2); } | + LDX am_zp { $$ = new_op(0xA6, ATOM_TYPE_OP_ARG_U8, $2); } | + LDX am_zpy { $$ = new_op(0xB6, ATOM_TYPE_OP_ARG_U8, $2); } | + LDX am_a { $$ = new_op(0xAE, ATOM_TYPE_OP_ARG_U16, $2); } | + LDX am_ay { $$ = new_op(0xBE, ATOM_TYPE_OP_ARG_U16, $2); }; + +op: LDY am_im { $$ = new_op(0xA0, ATOM_TYPE_OP_ARG_UI8, $2); } | + LDY am_zp { $$ = new_op(0xA4, ATOM_TYPE_OP_ARG_U8, $2); } | + LDY am_zpx { $$ = new_op(0xB4, ATOM_TYPE_OP_ARG_U8, $2); } | + LDY am_a { $$ = new_op(0xAC, ATOM_TYPE_OP_ARG_U16, $2); } | + LDY am_ax { $$ = new_op(0xBC, ATOM_TYPE_OP_ARG_U16, $2); }; + +op: STA am_zp { $$ = new_op(0x85, ATOM_TYPE_OP_ARG_U8, $2); } | + STA am_zpx { $$ = new_op(0x95, ATOM_TYPE_OP_ARG_U8, $2); } | + STA am_a { $$ = new_op(0x8D, ATOM_TYPE_OP_ARG_U16, $2); } | + STA am_ax { $$ = new_op(0x9D, ATOM_TYPE_OP_ARG_U16, $2); } | + STA am_ay { $$ = new_op(0x99, ATOM_TYPE_OP_ARG_U16, $2); } | + STA am_ix { $$ = new_op(0x81, ATOM_TYPE_OP_ARG_U8, $2); } | + STA am_iy { $$ = new_op(0x91, ATOM_TYPE_OP_ARG_U8, $2); }; + +op: STX am_zp { $$ = new_op(0x86, ATOM_TYPE_OP_ARG_U8, $2); } | + STX am_zpy { $$ = new_op(0x96, ATOM_TYPE_OP_ARG_U8, $2); } | + STX am_a { $$ = new_op(0x8e, ATOM_TYPE_OP_ARG_U16, $2); }; + +op: STY am_zp { $$ = new_op(0x84, ATOM_TYPE_OP_ARG_U8, $2); } | + STY am_zpx { $$ = new_op(0x94, ATOM_TYPE_OP_ARG_U8, $2); } | + STY am_a { $$ = new_op(0x8c, ATOM_TYPE_OP_ARG_U16, $2); }; + +op: AND am_im { $$ = new_op(0x29, ATOM_TYPE_OP_ARG_UI8, $2); } | + AND am_zp { $$ = new_op(0x25, ATOM_TYPE_OP_ARG_U8, $2); } | + AND am_zpx { $$ = new_op(0x35, ATOM_TYPE_OP_ARG_U8, $2); } | + AND am_a { $$ = new_op(0x2d, ATOM_TYPE_OP_ARG_U16, $2); } | + AND am_ax { $$ = new_op(0x3d, ATOM_TYPE_OP_ARG_U16, $2); } | + AND am_ay { $$ = new_op(0x39, ATOM_TYPE_OP_ARG_U16, $2); } | + AND am_ix { $$ = new_op(0x21, ATOM_TYPE_OP_ARG_U8, $2); } | + AND am_iy { $$ = new_op(0x31, ATOM_TYPE_OP_ARG_U8, $2); }; + +op: ORA am_im { $$ = new_op(0x09, ATOM_TYPE_OP_ARG_UI8, $2); } | + ORA am_zp { $$ = new_op(0x05, ATOM_TYPE_OP_ARG_U8, $2); } | + ORA am_zpx { $$ = new_op(0x15, ATOM_TYPE_OP_ARG_U8, $2); } | + ORA am_a { $$ = new_op(0x0d, ATOM_TYPE_OP_ARG_U16, $2); } | + ORA am_ax { $$ = new_op(0x1d, ATOM_TYPE_OP_ARG_U16, $2); } | + ORA am_ay { $$ = new_op(0x19, ATOM_TYPE_OP_ARG_U16, $2); } | + ORA am_ix { $$ = new_op(0x01, ATOM_TYPE_OP_ARG_U8, $2); } | + ORA am_iy { $$ = new_op(0x11, ATOM_TYPE_OP_ARG_U8, $2); }; + +op: EOR am_im { $$ = new_op(0x49, ATOM_TYPE_OP_ARG_UI8, $2); } | + EOR am_zp { $$ = new_op(0x45, ATOM_TYPE_OP_ARG_U8, $2); } | + EOR am_zpx { $$ = new_op(0x55, ATOM_TYPE_OP_ARG_U8, $2); } | + EOR am_a { $$ = new_op(0x4d, ATOM_TYPE_OP_ARG_U16, $2); } | + EOR am_ax { $$ = new_op(0x5d, ATOM_TYPE_OP_ARG_U16, $2); } | + EOR am_ay { $$ = new_op(0x59, ATOM_TYPE_OP_ARG_U16, $2); } | + EOR am_ix { $$ = new_op(0x41, ATOM_TYPE_OP_ARG_U8, $2); } | + EOR am_iy { $$ = new_op(0x51, ATOM_TYPE_OP_ARG_U8, $2); }; + +op: ADC am_im { $$ = new_op(0x69, ATOM_TYPE_OP_ARG_UI8, $2); } | + ADC am_zp { $$ = new_op(0x65, ATOM_TYPE_OP_ARG_U8, $2); } | + ADC am_zpx { $$ = new_op(0x75, ATOM_TYPE_OP_ARG_U8, $2); } | + ADC am_a { $$ = new_op(0x6D, ATOM_TYPE_OP_ARG_U16, $2); } | + ADC am_ax { $$ = new_op(0x7D, ATOM_TYPE_OP_ARG_U16, $2); } | + ADC am_ay { $$ = new_op(0x79, ATOM_TYPE_OP_ARG_U16, $2); } | + ADC am_ix { $$ = new_op(0x61, ATOM_TYPE_OP_ARG_U8, $2); } | + ADC am_iy { $$ = new_op(0x71, ATOM_TYPE_OP_ARG_U8, $2); }; + +op: SBC am_im { $$ = new_op(0xe9, ATOM_TYPE_OP_ARG_UI8, $2); } | + SBC am_zp { $$ = new_op(0xe5, ATOM_TYPE_OP_ARG_U8, $2); } | + SBC am_zpx { $$ = new_op(0xf5, ATOM_TYPE_OP_ARG_U8, $2); } | + SBC am_a { $$ = new_op(0xeD, ATOM_TYPE_OP_ARG_U16, $2); } | + SBC am_ax { $$ = new_op(0xfD, ATOM_TYPE_OP_ARG_U16, $2); } | + SBC am_ay { $$ = new_op(0xf9, ATOM_TYPE_OP_ARG_U16, $2); } | + SBC am_ix { $$ = new_op(0xe1, ATOM_TYPE_OP_ARG_U8, $2); } | + SBC am_iy { $$ = new_op(0xf1, ATOM_TYPE_OP_ARG_U8, $2); }; + +op: CMP am_im { $$ = new_op(0xc9, ATOM_TYPE_OP_ARG_UI8, $2); } | + CMP am_zp { $$ = new_op(0xc5, ATOM_TYPE_OP_ARG_U8, $2); } | + CMP am_zpx { $$ = new_op(0xd5, ATOM_TYPE_OP_ARG_U8, $2); } | + CMP am_a { $$ = new_op(0xcD, ATOM_TYPE_OP_ARG_U16, $2); } | + CMP am_ax { $$ = new_op(0xdD, ATOM_TYPE_OP_ARG_U16, $2); } | + CMP am_ay { $$ = new_op(0xd9, ATOM_TYPE_OP_ARG_U16, $2); } | + CMP am_ix { $$ = new_op(0xc1, ATOM_TYPE_OP_ARG_U8, $2); } | + CMP am_iy { $$ = new_op(0xd1, ATOM_TYPE_OP_ARG_U8, $2); }; + +op: CPX am_im { $$ = new_op(0xe0, ATOM_TYPE_OP_ARG_U8, $2); } | + CPX am_zp { $$ = new_op(0xe4, ATOM_TYPE_OP_ARG_U8, $2); } | + CPX am_a { $$ = new_op(0xec, ATOM_TYPE_OP_ARG_U16, $2); } | + CPY am_im { $$ = new_op(0xc0, ATOM_TYPE_OP_ARG_U8, $2); } | + CPY am_zp { $$ = new_op(0xc4, ATOM_TYPE_OP_ARG_U8, $2); } | + CPY am_a { $$ = new_op(0xcc, ATOM_TYPE_OP_ARG_U16, $2); }; + +op: TXS { $$ = new_op0(0x9A); } | + TSX { $$ = new_op0(0xBA); } | + PHA { $$ = new_op0(0x48); } | + PLA { $$ = new_op0(0x68); } | + PHP { $$ = new_op0(0x08); } | + PLP { $$ = new_op0(0x28); } | + SEI { $$ = new_op0(0x78); } | + CLI { $$ = new_op0(0x58); } | + NOP { $$ = new_op0(0xea); } | + TYA { $$ = new_op0(0x98); } | + TAY { $$ = new_op0(0xa8); } | + TXA { $$ = new_op0(0x8a); } | + TAX { $$ = new_op0(0xaa); } | + CLC { $$ = new_op0(0x18); } | + SEC { $$ = new_op0(0x38); } | + RTS { $$ = new_op0(0x60); }; + +op: JSR am_a { $$ = new_op(0x20, ATOM_TYPE_OP_ARG_U16, $2); } | + JMP am_a { $$ = new_op(0x4c, ATOM_TYPE_OP_ARG_U16, $2); } | + BEQ am_a { $$ = new_op(0xf0, ATOM_TYPE_OP_ARG_I8, $2); } | + BNE am_a { $$ = new_op(0xd0, ATOM_TYPE_OP_ARG_I8, $2); } | + BCC am_a { $$ = new_op(0x90, ATOM_TYPE_OP_ARG_I8, $2); } | + BCS am_a { $$ = new_op(0xb0, ATOM_TYPE_OP_ARG_I8, $2); } | + BPL am_a { $$ = new_op(0x10, ATOM_TYPE_OP_ARG_I8, $2); } | + BMI am_a { $$ = new_op(0x30, ATOM_TYPE_OP_ARG_I8, $2); } | + BVC am_a { $$ = new_op(0x50, ATOM_TYPE_OP_ARG_I8, $2); } | + BVS am_a { $$ = new_op(0x70, ATOM_TYPE_OP_ARG_I8, $2); }; + +op: INX { $$ = new_op0(0xe8); } | + DEX { $$ = new_op0(0xca); } | + INY { $$ = new_op0(0xc8); } | + DEY { $$ = new_op0(0x88); }; + +op: INC am_zp { $$ = new_op(0xe6, ATOM_TYPE_OP_ARG_U8, $2); } | + INC am_zpx { $$ = new_op(0xf6, ATOM_TYPE_OP_ARG_U8, $2); } | + INC am_a { $$ = new_op(0xee, ATOM_TYPE_OP_ARG_U16, $2); } | + INC am_ax { $$ = new_op(0xfe, ATOM_TYPE_OP_ARG_U16, $2); }; + +op: DEC am_zp { $$ = new_op(0xc6, ATOM_TYPE_OP_ARG_U8, $2); } | + DEC am_zpx { $$ = new_op(0xd6, ATOM_TYPE_OP_ARG_U8, $2); } | + DEC am_a { $$ = new_op(0xce, ATOM_TYPE_OP_ARG_U16, $2); } | + DEC am_ax { $$ = new_op(0xde, ATOM_TYPE_OP_ARG_U16, $2); }; + +op: LSR { $$ = new_op0(0x4a); } | + LSR am_zp { $$ = new_op(0x46, ATOM_TYPE_OP_ARG_U8, $2); } | + LSR am_zpx { $$ = new_op(0x56, ATOM_TYPE_OP_ARG_U8, $2); } | + LSR am_a { $$ = new_op(0x4e, ATOM_TYPE_OP_ARG_U16, $2); } | + LSR am_ax { $$ = new_op(0x5e, ATOM_TYPE_OP_ARG_U16, $2); }; + +op: ASL { $$ = new_op0(0x0a); } | + ASL am_zp { $$ = new_op(0x06, ATOM_TYPE_OP_ARG_U8, $2); } | + ASL am_zpx { $$ = new_op(0x16, ATOM_TYPE_OP_ARG_U8, $2); } | + ASL am_a { $$ = new_op(0x0e, ATOM_TYPE_OP_ARG_U16, $2); } | + ASL am_ax { $$ = new_op(0x1e, ATOM_TYPE_OP_ARG_U16, $2); }; + +op: ROR { $$ = new_op0(0x6a); } | + ROR am_zp { $$ = new_op(0x66, ATOM_TYPE_OP_ARG_U8, $2); } | + ROR am_zpx { $$ = new_op(0x76, ATOM_TYPE_OP_ARG_U8, $2); } | + ROR am_a { $$ = new_op(0x6e, ATOM_TYPE_OP_ARG_U16, $2); } | + ROR am_ax { $$ = new_op(0x7e, ATOM_TYPE_OP_ARG_U16, $2); }; + +op: ROL { $$ = new_op0(0x2a); } | + ROL am_zp { $$ = new_op(0x26, ATOM_TYPE_OP_ARG_U8, $2); } | + ROL am_zpx { $$ = new_op(0x36, ATOM_TYPE_OP_ARG_U8, $2); } | + ROL am_a { $$ = new_op(0x2e, ATOM_TYPE_OP_ARG_U16, $2); } | + ROL am_ax { $$ = new_op(0x3e, ATOM_TYPE_OP_ARG_U16, $2); }; + +op: BIT am_zp { $$ = new_op(0x24, ATOM_TYPE_OP_ARG_U8, $2); } | + BIT am_a { $$ = new_op(0x2c, ATOM_TYPE_OP_ARG_U16, $2); }; + +am_im: HASH expr { $$ = $2; }; +am_a: expr { $$ = $1; }; +am_ax: expr COMMA X { $$ = $1; }; +am_ay: expr COMMA Y { $$ = $1; }; +am_zp: LT expr { $$ = $2; }; +am_zpx: LT expr COMMA X { $$ = $2; }; +am_zpy: LT expr COMMA Y { $$ = $2; }; +am_ix: LPAREN expr COMMA X RPAREN { $$ = $2; }; +am_iy: LPAREN expr RPAREN COMMA Y { $$ = $2; }; + +expr: expr PLUS expr { $$ = new_expr_op2(PLUS, $1, $3); } | + expr MINUS expr { $$ = new_expr_op2(MINUS, $1, $3); } | + expr MULT expr { $$ = new_expr_op2(MULT, $1, $3); } | + expr DIV expr { $$ = new_expr_op2(DIV, $1, $3); } | + expr MOD expr { $$ = new_expr_op2(MOD, $1, $3); } | + MINUS expr %prec vNEG { $$ = new_expr_op1(vNEG, $2); } | + LPAREN expr RPAREN { $$ = $2; } | + INCLEN LPAREN STRING RPAREN { $$ = new_expr_inclen($3); } | + INCWORD LPAREN STRING COMMA expr RPAREN { + $$ = new_expr_incword($3, $5); } | + NUMBER { $$ = new_expr_number($1); } | + SYMBOL { $$ = new_expr_symref($1); }; + +lexpr: lexpr LOR lexpr { $$ = new_expr_op2(LOR, $1, $3); } | + lexpr LAND lexpr { $$ = new_expr_op2(LAND, $1, $3); } | + LNOT lexpr { $$ = new_expr_op1(LNOT, $2); } | + LPAREN lexpr RPAREN { $$ = $2; } | + expr LT expr { $$ = new_expr_op2(LT, $1, $3); } | + expr GT expr { $$ = new_expr_op2(GT, $1, $3); } | + expr EQ expr { $$ = new_expr_op2(EQ, $1, $3); } | + expr NEQ expr { $$ = new_expr_op2(NEQ, $1, $3); }; + +lexpr: DEFINED LPAREN SYMBOL RPAREN { $$ = new_is_defined($3); }; + +%% + +void yyerror (const char *s) +{ + fprintf (stderr, "line %d, %s\n", num_lines, s); +} + +void asm_set_source(struct membuf *buffer); + +int assembleSinglePass(struct membuf *source, struct membuf *dest) +{ + int val; + + yydebug = 0; + asm_src_buffer_push(source); + vec_init(asm_atoms, sizeof(struct atom*)); + val = yyparse(); + if(val == 0) + { + output_atoms(dest, asm_atoms); + } + vec_free(asm_atoms, NULL); + return val; +} diff --git a/src/asm/asm.yy b/src/asm/asm.yy new file mode 100644 index 0000000..65b4b07 --- /dev/null +++ b/src/asm/asm.yy @@ -0,0 +1,285 @@ +/* + * Copyright (c) 2002 - 2005 Magnus Lind. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software, alter it and re- + * distribute it freely for any non-commercial, non-profit purpose subject to + * the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not + * be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any distribution. + * + * 4. The names of this software and/or it's copyright holders may not be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + */ + +/* scanner for a simple assembler */ +%{ +#include +#include +#include "int.h" +#include "membuf.h" +#include "parse.h" +#include "asm.tab.h" + +#define MAX_SRC_BUFFER_DEPTH 10 +static YY_BUFFER_STATE src_buffers[MAX_SRC_BUFFER_DEPTH]; +static int src_buffer_depth = 0; + +static char *strdupped_get(char *text); +static int strdupped_cmp(const void *a, const void *b); +static void strdupped_free(void *a); + +int num_lines = 1; +int push_state_skip = 0; +int push_state_init = 0; +int push_state_macro = 0; +struct vec strdupped[1]; + +%} + +%x SKIP SKIP_ALL QUOTED_STRING SKIP_LINE MACROO + +%option noyywrap +%option case-insensitive +%option stack + +%% + + if(push_state_init) + {push_state_init = 0; yy_push_state(INITIAL); } + if(push_state_skip) + {push_state_skip = 0; yy_push_state(SKIP); } + if(push_state_macro) + {push_state_macro = 0; yy_push_state(MACROO); } + +\.if return IF; +\.elif BEGIN(SKIP_ALL); +\.else BEGIN(SKIP); +\.endif yy_pop_state(); + +\.include return INCLUDE; +\.macro return MACRO; + +\.defined return DEFINED; +\.org return ORG; +\.error return ERROR; +\.echo return ECHO1; +\.incbin return INCBIN; +\.inclen return INCLEN; +\.incword return INCWORD; +\.res return RES; +\.word return WORD; +\.byte return BYTE; + +\" BEGIN(QUOTED_STRING); +\; BEGIN(SKIP_LINE); + +lda return LDA; +ldx return LDX; +ldy return LDY; +sta return STA; +stx return STX; +sty return STY; +and return AND; +ora return ORA; +eor return EOR; +adc return ADC; +sbc return SBC; +cmp return CMP; +cpx return CPX; +cpy return CPY; + +tsx return TSX; +txs return TXS; +pha return PHA; +pla return PLA; +php return PHP; +plp return PLP; +sei return SEI; +cli return CLI; +nop return NOP; +tya return TYA; +tay return TAY; +txa return TXA; +tax return TAX; +clc return CLC; +sec return SEC; +rts return RTS; + +jsr return JSR; +jmp return JMP; +beq return BEQ; +bne return BNE; +bcc return BCC; +bcs return BCS; +bpl return BPL; +bmi return BMI; +bvc return BVC; +bvs return BCS; +inx return INX; +dex return DEX; +iny return INY; +dey return DEY; +inc return INC; +dec return DEC; +lsr return LSR; +asl return ASL; +ror return ROR; +rol return ROL; +bit return BIT; + +[0-9]+ { yylval.num = atoi(yytext); return NUMBER; } + +$[0-9a-f]+ { yylval.num = strtol(yytext + 1, NULL, 16); return NUMBER; } + +\< return LT; +\> return GT; +== return EQ; +!= return NEQ; +! return LNOT; +\&\& return LAND; +\|\| return LOR; + +\( return LPAREN; +\) return RPAREN; +\, return COMMA; +\: return COLON; +\# return HASH; +\+ return PLUS; +\- return MINUS; +\* return MULT; +\/ return DIV; +\% return MOD; + +\= return ASSIGN; +\?= return GUESS; + +x return X; +y return Y; + +[a-z][_a-z0-9]*/: { yylval.str = strdupped_get(yytext); return LABEL; } +[a-z][_a-z0-9]* { yylval.str = strdupped_get(yytext); return SYMBOL; } + +\r\n|\n ++num_lines; + +[ \t] /* eat whitespace */ + +. printf("unknown character found %s\n", yytext); + +\.if yy_push_state(SKIP_ALL); +\.elif { yy_pop_state(); return IF; } +\.else BEGIN(INITIAL); +\.endif yy_pop_state(); +\r\n|\n ++num_lines; +. + +\.endmacro yy_pop_state(); +\.+ { yylval.str = yytext; return MACRO_STRING; } +[^\.]+ { yylval.str = yytext; return MACRO_STRING; } + +\.if yy_push_state(SKIP_ALL); +\.endif yy_pop_state(); +\r\n|\n ++num_lines; +. + +[^\"]* { + /* multi-line string with correct line count */ + char *p = strdupped_get(yytext); + yylval.str = p; + while (*p != '\0') + { + if (*p++ == '\n') + { + ++num_lines; + } + } + return STRING; +} +\" BEGIN(INITIAL); + +\r\n|\n { ++num_lines; BEGIN(INITIAL); } +. + +<> { + if(--src_buffer_depth == 0) + { + yyterminate(); + } + else + { + yy_delete_buffer(YY_CURRENT_BUFFER); + yy_switch_to_buffer(src_buffers[src_buffer_depth]); + } + } + +%% + +void scanner_init(void) +{ + vec_init(strdupped, sizeof(char*)); +} + +void asm_src_buffer_push(struct membuf *buffer) +{ + if(src_buffer_depth == MAX_SRC_BUFFER_DEPTH) + { + fprintf(stderr, "source buffers nested too deep\n"); + exit(1); + } + src_buffers[src_buffer_depth++] = YY_CURRENT_BUFFER; + yy_scan_bytes(membuf_get(buffer), membuf_memlen(buffer)); +} + +static char *strdupped_get(char *text) +{ + char **pp; + /*printf("get \"%s\" => ", text);*/ + if(vec_insert_uniq(strdupped, strdupped_cmp, &text, (void*)&pp)) + { + /* replace the pointer to since will be reused */ + *pp = strdup(text); + } + /*printf("%p\n", *pp);*/ + return *pp; +} + +static void strdupped_free(void *a) +{ + char *b = *(char**)a; + /*printf("free => %p \"%s\"\n", b, b);*/ + free(b); +} + +static int strdupped_cmp(const void *a, const void *b) +{ + char *c = *(char**)a; + char *d = *(char**)b; + + return strcmp(c, d); +} + +void scanner_free(void) +{ + vec_free(strdupped, strdupped_free); +} + + +void silence_warnings_about_unused_functions(void) +{ + yyunput(0, NULL); + input(); + yy_top_state(); +} diff --git a/src/asm/asmtab.c b/src/asm/asmtab.c deleted file mode 100644 index 5010b48..0000000 --- a/src/asm/asmtab.c +++ /dev/null @@ -1,2900 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.1. */ - -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* Written by Richard Stallman by simplifying the original so called - ``semantic'' parser. */ - -/* 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. */ - -int yylex(void); -int yyerror (char *s); - -/* Identify Bison output. */ -#define YYBISON 1 - -/* Bison version. */ -#define YYBISON_VERSION "2.1" - -/* Skeleton name. */ -#define YYSKELETON_NAME "yacc.c" - -/* Pure parsers. */ -#define YYPURE 0 - -/* Using locations. */ -#define YYLSP_NEEDED 0 - - - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - INCLUDE = 258, - IF = 259, - DEFINED = 260, - MACRO = 261, - MACRO_STRING = 262, - ORG = 263, - ERROR = 264, - ECHO = 265, - INCBIN = 266, - INCWORD = 267, - RES = 268, - WORD = 269, - BYTE = 270, - LDA = 271, - LDX = 272, - LDY = 273, - STA = 274, - STX = 275, - STY = 276, - AND = 277, - ORA = 278, - EOR = 279, - ADC = 280, - SBC = 281, - CMP = 282, - CPX = 283, - CPY = 284, - TSX = 285, - TXS = 286, - PHA = 287, - PLA = 288, - PHP = 289, - PLP = 290, - SEI = 291, - CLI = 292, - NOP = 293, - TYA = 294, - TAY = 295, - TXA = 296, - TAX = 297, - CLC = 298, - SEC = 299, - RTS = 300, - JSR = 301, - JMP = 302, - BEQ = 303, - BNE = 304, - BCC = 305, - BCS = 306, - BPL = 307, - BMI = 308, - BVC = 309, - BVS = 310, - INX = 311, - DEX = 312, - INY = 313, - DEY = 314, - INC = 315, - DEC = 316, - LSR = 317, - ASL = 318, - ROR = 319, - ROL = 320, - SYMBOL = 321, - STRING = 322, - LAND = 323, - LOR = 324, - LNOT = 325, - LPAREN = 326, - RPAREN = 327, - COMMA = 328, - COLON = 329, - X = 330, - Y = 331, - HASH = 332, - PLUS = 333, - MINUS = 334, - MULT = 335, - DIV = 336, - MOD = 337, - LT = 338, - GT = 339, - EQ = 340, - NEQ = 341, - ASSIGN = 342, - NUMBER = 343, - vNEG = 344 - }; -#endif -/* Tokens. */ -#define INCLUDE 258 -#define IF 259 -#define DEFINED 260 -#define MACRO 261 -#define MACRO_STRING 262 -#define ORG 263 -#define ERROR 264 -#define ECHO 265 -#define INCBIN 266 -#define INCWORD 267 -#define RES 268 -#define WORD 269 -#define BYTE 270 -#define LDA 271 -#define LDX 272 -#define LDY 273 -#define STA 274 -#define STX 275 -#define STY 276 -#define AND 277 -#define ORA 278 -#define EOR 279 -#define ADC 280 -#define SBC 281 -#define CMP 282 -#define CPX 283 -#define CPY 284 -#define TSX 285 -#define TXS 286 -#define PHA 287 -#define PLA 288 -#define PHP 289 -#define PLP 290 -#define SEI 291 -#define CLI 292 -#define NOP 293 -#define TYA 294 -#define TAY 295 -#define TXA 296 -#define TAX 297 -#define CLC 298 -#define SEC 299 -#define RTS 300 -#define JSR 301 -#define JMP 302 -#define BEQ 303 -#define BNE 304 -#define BCC 305 -#define BCS 306 -#define BPL 307 -#define BMI 308 -#define BVC 309 -#define BVS 310 -#define INX 311 -#define DEX 312 -#define INY 313 -#define DEY 314 -#define INC 315 -#define DEC 316 -#define LSR 317 -#define ASL 318 -#define ROR 319 -#define ROL 320 -#define SYMBOL 321 -#define STRING 322 -#define LAND 323 -#define LOR 324 -#define LNOT 325 -#define LPAREN 326 -#define RPAREN 327 -#define COMMA 328 -#define COLON 329 -#define X 330 -#define Y 331 -#define HASH 332 -#define PLUS 333 -#define MINUS 334 -#define MULT 335 -#define DIV 336 -#define MOD 337 -#define LT 338 -#define GT 339 -#define EQ 340 -#define NEQ 341 -#define ASSIGN 342 -#define NUMBER 343 -#define vNEG 344 - - - - -/* Copy the first part of user declarations. */ -// #line 1 "asm.y" - -#include "int.h" -#include "parse.h" -#include "vec.h" -#include "membuf.h" -#include "log.h" -#include - -#define YYERROR_VERBOSE - -static struct vec asm_atoms[1]; - - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 1 -#endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif - -/* Enabling the token table. */ -#ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE 0 -#endif - -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -// #line 110 "asm.y" -typedef union YYSTYPE { - i32 num; - char *str; - struct atom *atom; - struct expr *expr; -} YYSTYPE; -/* Line 196 of yacc.c. */ -// #line 282 "asm.tab.c" -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif - - - -/* Copy the second part of user declarations. */ - - -/* Line 219 of yacc.c. */ -// #line 294 "asm.tab.c" - -#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) -# define YYSIZE_T __SIZE_TYPE__ -#endif -#if ! defined (YYSIZE_T) && defined (size_t) -# define YYSIZE_T size_t -#endif -#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus)) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -#endif -#if ! defined (YYSIZE_T) -# define YYSIZE_T unsigned int -#endif - -#ifndef YY_ -# if 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 - -#if ! defined (yyoverflow) || YYERROR_VERBOSE - -/* 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 -# else -# define YYSTACK_ALLOC alloca -# if defined (__STDC__) || defined (__cplusplus) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYINCLUDED_STDLIB_H -# 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 2005 */ -# endif -# else -# define YYSTACK_ALLOC YYMALLOC -# define YYSTACK_FREE YYFREE -# ifndef YYSTACK_ALLOC_MAXIMUM -# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1) -# endif -# ifdef __cplusplus -extern "C" { -# endif -# ifndef YYMALLOC -# define YYMALLOC malloc -# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \ - && (defined (__STDC__) || defined (__cplusplus))) -void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# ifndef YYFREE -# define YYFREE free -# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \ - && (defined (__STDC__) || defined (__cplusplus))) -void free (void *); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# ifdef __cplusplus -} -# endif -# endif -#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ - - -#if (! defined (yyoverflow) \ - && (! defined (__cplusplus) \ - || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - short int yyss; - YYSTYPE yyvs; - }; - -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) - -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ - + YYSTACK_GAP_MAXIMUM) - -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined (__GNUC__) && 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (0) -# endif -# endif - -/* 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) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (0) - -#endif - -#if defined (__STDC__) || defined (__cplusplus) - typedef signed char yysigned_char; -#else - typedef short int yysigned_char; -#endif - -/* YYFINAL -- State number of the termination state. */ -#define YYFINAL 212 -/* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 591 - -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 90 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 17 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 193 -/* YYNRULES -- Number of states. */ -#define YYNSTATES 307 - -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 344 - -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) - -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const unsigned char 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, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, - 85, 86, 87, 88, 89 -}; - -#if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const unsigned short int yyprhs[] = -{ - 0, 0, 3, 6, 8, 11, 15, 20, 25, 30, - 35, 40, 45, 47, 49, 51, 58, 63, 68, 73, - 80, 89, 93, 95, 98, 101, 104, 107, 110, 113, - 116, 119, 122, 125, 128, 131, 134, 137, 140, 143, - 146, 149, 152, 155, 158, 161, 164, 167, 170, 173, - 176, 179, 182, 185, 188, 191, 194, 197, 200, 203, - 206, 209, 212, 215, 218, 221, 224, 227, 230, 233, - 236, 239, 242, 245, 248, 251, 254, 257, 260, 263, - 266, 269, 272, 275, 278, 281, 284, 287, 290, 293, - 296, 299, 302, 305, 308, 311, 314, 317, 320, 323, - 326, 329, 332, 335, 338, 341, 344, 347, 350, 352, - 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, - 374, 376, 378, 380, 382, 385, 388, 391, 394, 397, - 400, 403, 406, 409, 412, 414, 416, 418, 420, 423, - 426, 429, 432, 435, 438, 441, 444, 446, 449, 452, - 455, 458, 460, 463, 466, 469, 472, 474, 477, 480, - 483, 486, 488, 491, 494, 497, 500, 503, 505, 509, - 513, 516, 521, 526, 532, 538, 542, 546, 550, 554, - 558, 561, 565, 572, 574, 576, 580, 584, 587, 591, - 595, 599, 603, 607 -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yysigned_char yyrhs[] = -{ - 91, 0, -1, 91, 92, -1, 92, -1, 66, 74, - -1, 66, 87, 105, -1, 4, 71, 106, 72, -1, - 8, 71, 105, 72, -1, 9, 71, 67, 72, -1, - 10, 71, 67, 72, -1, 3, 71, 67, 72, -1, - 6, 71, 67, 72, -1, 93, -1, 7, -1, 95, - -1, 13, 71, 105, 73, 105, 72, -1, 14, 71, - 94, 72, -1, 15, 71, 94, 72, -1, 11, 71, - 67, 72, -1, 11, 71, 67, 73, 105, 72, -1, - 11, 71, 67, 73, 105, 73, 105, 72, -1, 94, - 73, 105, -1, 105, -1, 16, 96, -1, 16, 100, - -1, 16, 101, -1, 16, 97, -1, 16, 98, -1, - 16, 99, -1, 16, 103, -1, 16, 104, -1, 17, - 96, -1, 17, 100, -1, 17, 102, -1, 17, 97, - -1, 17, 99, -1, 18, 96, -1, 18, 100, -1, - 18, 101, -1, 18, 97, -1, 18, 99, -1, 19, - 100, -1, 19, 101, -1, 19, 97, -1, 19, 98, - -1, 19, 99, -1, 19, 103, -1, 19, 104, -1, - 20, 100, -1, 20, 102, -1, 20, 97, -1, 21, - 100, -1, 21, 101, -1, 21, 97, -1, 22, 96, - -1, 22, 100, -1, 22, 101, -1, 22, 97, -1, - 22, 98, -1, 22, 99, -1, 22, 103, -1, 22, - 104, -1, 23, 96, -1, 23, 100, -1, 23, 101, - -1, 23, 97, -1, 23, 98, -1, 23, 99, -1, - 23, 103, -1, 23, 104, -1, 24, 96, -1, 24, - 100, -1, 24, 101, -1, 24, 97, -1, 24, 98, - -1, 24, 99, -1, 24, 103, -1, 24, 104, -1, - 25, 96, -1, 25, 100, -1, 25, 101, -1, 25, - 97, -1, 25, 98, -1, 25, 99, -1, 25, 103, - -1, 25, 104, -1, 26, 96, -1, 26, 100, -1, - 26, 101, -1, 26, 97, -1, 26, 98, -1, 26, - 99, -1, 26, 103, -1, 26, 104, -1, 27, 96, - -1, 27, 100, -1, 27, 101, -1, 27, 97, -1, - 27, 98, -1, 27, 99, -1, 27, 103, -1, 27, - 104, -1, 28, 96, -1, 28, 100, -1, 28, 97, - -1, 29, 96, -1, 29, 100, -1, 29, 97, -1, - 31, -1, 30, -1, 32, -1, 33, -1, 34, -1, - 35, -1, 36, -1, 37, -1, 38, -1, 39, -1, - 40, -1, 41, -1, 42, -1, 43, -1, 44, -1, - 45, -1, 46, 97, -1, 47, 97, -1, 48, 97, - -1, 49, 97, -1, 50, 97, -1, 51, 97, -1, - 52, 97, -1, 53, 97, -1, 54, 97, -1, 55, - 97, -1, 56, -1, 57, -1, 58, -1, 59, -1, - 60, 100, -1, 60, 101, -1, 60, 97, -1, 60, - 98, -1, 61, 100, -1, 61, 101, -1, 61, 97, - -1, 61, 98, -1, 62, -1, 62, 100, -1, 62, - 101, -1, 62, 97, -1, 62, 98, -1, 63, -1, - 63, 100, -1, 63, 101, -1, 63, 97, -1, 63, - 98, -1, 64, -1, 64, 100, -1, 64, 101, -1, - 64, 97, -1, 64, 98, -1, 65, -1, 65, 100, - -1, 65, 101, -1, 65, 97, -1, 65, 98, -1, - 77, 105, -1, 105, -1, 105, 73, 75, -1, 105, - 73, 76, -1, 83, 105, -1, 83, 105, 73, 75, - -1, 83, 105, 73, 76, -1, 71, 105, 73, 75, - 72, -1, 71, 105, 72, 73, 76, -1, 105, 78, - 105, -1, 105, 79, 105, -1, 105, 80, 105, -1, - 105, 81, 105, -1, 105, 82, 105, -1, 79, 105, - -1, 71, 105, 72, -1, 12, 71, 67, 73, 105, - 72, -1, 88, -1, 66, -1, 106, 69, 106, -1, - 106, 68, 106, -1, 70, 106, -1, 71, 106, 72, - -1, 105, 83, 105, -1, 105, 84, 105, -1, 105, - 85, 105, -1, 105, 86, 105, -1, 5, 71, 66, - 72, -1 -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const unsigned short int yyrline[] = -{ - 0, 144, 144, 144, 145, 146, 147, 148, 149, 150, - 151, 152, 153, 154, 156, 157, 158, 159, 160, 162, - 164, 167, 168, 170, 171, 172, 173, 174, 175, 176, - 177, 179, 180, 181, 182, 183, 185, 186, 187, 188, - 189, 191, 192, 193, 194, 195, 196, 197, 199, 200, - 201, 203, 204, 205, 207, 208, 209, 210, 211, 212, - 213, 214, 216, 217, 218, 219, 220, 221, 222, 223, - 225, 226, 227, 228, 229, 230, 231, 232, 234, 235, - 236, 237, 238, 239, 240, 241, 243, 244, 245, 246, - 247, 248, 249, 250, 252, 253, 254, 255, 256, 257, - 258, 259, 261, 262, 263, 264, 265, 266, 268, 269, - 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, - 280, 281, 282, 283, 285, 286, 287, 288, 289, 290, - 291, 292, 293, 294, 296, 297, 298, 299, 301, 302, - 303, 304, 306, 307, 308, 309, 311, 312, 313, 314, - 315, 317, 318, 319, 320, 321, 323, 324, 325, 326, - 327, 329, 330, 331, 332, 333, 335, 336, 337, 338, - 339, 340, 341, 342, 343, 345, 346, 347, 348, 349, - 350, 351, 352, 354, 355, 357, 358, 359, 360, 361, - 362, 363, 364, 366 -}; -#endif - -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE -/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = -{ - "$end", "error", "$undefined", "INCLUDE", "IF", "DEFINED", "MACRO", - "MACRO_STRING", "ORG", "ERROR", "ECHO", "INCBIN", "INCWORD", "RES", - "WORD", "BYTE", "LDA", "LDX", "LDY", "STA", "STX", "STY", "AND", "ORA", - "EOR", "ADC", "SBC", "CMP", "CPX", "CPY", "TSX", "TXS", "PHA", "PLA", - "PHP", "PLP", "SEI", "CLI", "NOP", "TYA", "TAY", "TXA", "TAX", "CLC", - "SEC", "RTS", "JSR", "JMP", "BEQ", "BNE", "BCC", "BCS", "BPL", "BMI", - "BVC", "BVS", "INX", "DEX", "INY", "DEY", "INC", "DEC", "LSR", "ASL", - "ROR", "ROL", "SYMBOL", "STRING", "LAND", "LOR", "LNOT", "LPAREN", - "RPAREN", "COMMA", "COLON", "X", "Y", "HASH", "PLUS", "MINUS", "MULT", - "DIV", "MOD", "LT", "GT", "EQ", "NEQ", "ASSIGN", "NUMBER", "vNEG", - "$accept", "stmts", "stmt", "atom", "exprs", "op", "am_im", "am_a", - "am_ax", "am_ay", "am_zp", "am_zpx", "am_zpy", "am_ix", "am_iy", "expr", - "lexpr", 0 -}; -#endif - -# ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ -static const unsigned short int yytoknum[] = -{ - 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, - 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, - 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, - 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, - 335, 336, 337, 338, 339, 340, 341, 342, 343, 344 -}; -# endif - -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const unsigned char yyr1[] = -{ - 0, 90, 91, 91, 92, 92, 92, 92, 92, 92, - 92, 92, 92, 92, 93, 93, 93, 93, 93, 93, - 93, 94, 94, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, - 95, 95, 95, 95, 95, 95, 96, 97, 98, 99, - 100, 101, 102, 103, 104, 105, 105, 105, 105, 105, - 105, 105, 105, 105, 105, 106, 106, 106, 106, 106, - 106, 106, 106, 106 -}; - -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const unsigned char yyr2[] = -{ - 0, 2, 2, 1, 2, 3, 4, 4, 4, 4, - 4, 4, 1, 1, 1, 6, 4, 4, 4, 6, - 8, 3, 1, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 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, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, - 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, - 2, 1, 2, 2, 2, 2, 2, 1, 3, 3, - 2, 4, 4, 5, 5, 3, 3, 3, 3, 3, - 2, 3, 6, 1, 1, 3, 3, 2, 3, 3, - 3, 3, 3, 4 -}; - -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ -static const unsigned char yydefact[] = -{ - 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 109, 108, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, - 122, 123, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 134, 135, 136, 137, 0, 0, 146, 151, - 156, 161, 0, 0, 3, 12, 14, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 184, 0, - 0, 0, 0, 183, 23, 26, 27, 28, 24, 25, - 29, 30, 167, 0, 0, 31, 34, 35, 32, 33, - 167, 36, 39, 40, 37, 38, 43, 44, 45, 41, - 42, 46, 47, 50, 48, 49, 167, 53, 51, 52, - 54, 57, 58, 59, 55, 56, 60, 61, 62, 65, - 66, 67, 63, 64, 68, 69, 70, 73, 74, 75, - 71, 72, 76, 77, 78, 81, 82, 83, 79, 80, - 84, 85, 86, 89, 90, 91, 87, 88, 92, 93, - 94, 97, 98, 99, 95, 96, 100, 101, 0, 102, - 104, 103, 105, 107, 106, 124, 125, 126, 127, 128, - 129, 130, 131, 132, 133, 140, 141, 138, 139, 167, - 144, 145, 142, 143, 149, 150, 147, 148, 154, 155, - 152, 153, 159, 160, 157, 158, 164, 165, 162, 163, - 4, 0, 1, 2, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 22, 0, 0, - 0, 166, 180, 170, 0, 0, 0, 0, 0, 0, - 0, 170, 0, 170, 0, 5, 10, 0, 187, 0, - 0, 0, 0, 0, 0, 0, 0, 6, 11, 7, - 8, 9, 18, 0, 0, 16, 0, 17, 0, 181, - 0, 0, 168, 169, 175, 176, 177, 178, 179, 181, - 0, 0, 188, 189, 190, 191, 192, 186, 185, 0, - 0, 21, 0, 0, 0, 171, 172, 193, 19, 0, - 15, 0, 174, 173, 0, 182, 20 -}; - -/* YYDEFGOTO[NTERM-NUM]. */ -static const short int yydefgoto[] = -{ - -1, 63, 64, 65, 226, 66, 84, 85, 86, 87, - 88, 89, 99, 90, 91, 116, 219 -}; - -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -202 -static const short int yypact[] = -{ - 339, -67, -28, -14, -202, -10, -6, -5, 1, 4, - 5, 9, 8, 22, 23, 41, 48, 59, 8, 8, - 8, 8, 8, 8, 38, 38, -202, -202, -202, -202, - -202, -202, -202, -202, -202, -202, -202, -202, -202, -202, - -202, -202, 78, 78, 78, 78, 78, 78, 78, 78, - 78, 78, -202, -202, -202, -202, 59, 59, 59, 59, - 59, 59, -69, 275, -202, -202, -202, -8, 7, 16, - 78, 17, 25, 30, 78, 78, 78, 27, -202, 78, - 78, 78, 78, -202, -202, -202, -202, -202, -202, -202, - -202, -202, 441, 78, 78, -202, -202, -202, -202, -202, - 451, -202, -202, -202, -202, -202, -202, -202, -202, -202, - -202, -202, -202, -202, -202, -202, 102, -202, -202, -202, - -202, -202, -202, -202, -202, -202, -202, -202, -202, -202, - -202, -202, -202, -202, -202, -202, -202, -202, -202, -202, - -202, -202, -202, -202, -202, -202, -202, -202, -202, -202, - -202, -202, -202, -202, -202, -202, -202, -202, -202, -202, - -202, -202, -202, -202, -202, -202, -202, -202, 78, -202, - -202, -202, -202, -202, -202, -202, -202, -202, -202, -202, - -202, -202, -202, -202, -202, -202, -202, -202, -202, 461, - -202, -202, -202, -202, -202, -202, -202, -202, -202, -202, - -202, -202, -202, -202, -202, -202, -202, -202, -202, -202, - -202, 78, -202, -202, 31, 37, 7, 7, 188, 65, - 44, 399, 46, 50, -59, 471, -51, 102, -36, 56, - -40, 102, -202, 481, -24, 78, 78, 78, 78, 78, - 410, 491, 52, 102, 57, 102, -202, 47, -202, -55, - 71, 78, 78, 78, 78, 7, 7, -202, -202, -202, - -202, -202, -202, 78, 78, -202, 78, -202, 62, 68, - 73, 80, -202, -202, 70, 70, -202, -202, -202, -202, - 69, 74, -202, 102, 102, 102, 102, -202, 117, 394, - 415, 102, 78, 112, 124, -202, -202, -202, -202, 78, - -202, 426, -202, -202, 431, -202, -202 -}; - -/* YYPGOTO[NTERM-NUM]. */ -static const short int yypgoto[] = -{ - -202, -202, 134, -202, 122, -202, 140, 393, 404, 242, - 154, 172, 184, 559, 568, -12, -201 -}; - -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -1 -static const unsigned short int yytable[] = -{ - 92, 100, 100, 92, 67, 210, 92, 92, 92, 92, - 92, 92, 215, 262, 263, 248, 250, 279, 211, 77, - 77, 265, 266, 235, 236, 237, 238, 239, 251, 252, - 253, 254, 269, 270, 77, 77, 267, 266, 235, 236, - 237, 238, 239, 68, 189, 189, 189, 189, 189, 189, - 77, 272, 273, 77, 287, 288, 218, 69, 221, 214, - 77, 70, 225, 227, 227, 71, 72, 230, 231, 232, - 233, 77, 73, 78, 78, 74, 75, 216, 217, 79, - 76, 240, 241, 220, 222, 80, 81, 81, 78, 78, - 77, 82, 223, 93, 93, 83, 83, 224, 229, 80, - 80, 81, 81, 246, 78, 94, 82, 78, 247, 93, - 83, 83, 79, 281, 78, 80, 258, 81, 260, 93, - 81, 168, 261, 268, 82, 78, 83, 81, 273, 83, - 93, 94, 272, 255, 256, 292, 83, 257, 81, 255, - 256, 293, 82, 282, 78, 296, 297, 83, 294, 93, - 237, 238, 239, 95, 101, 295, 243, 81, 120, 128, - 136, 144, 152, 160, 169, 172, 83, 98, 104, 109, - 114, 118, 124, 132, 140, 148, 156, 164, 171, 174, - 235, 236, 237, 238, 239, 255, 105, 110, 302, 119, - 125, 133, 141, 149, 157, 165, 303, 213, 228, 245, - 115, 0, 0, 0, 218, 249, 0, 0, 0, 0, - 187, 192, 196, 200, 204, 208, 0, 0, 0, 0, - 0, 0, 0, 274, 275, 276, 277, 278, 188, 193, - 197, 201, 205, 209, 0, 0, 0, 0, 0, 283, - 284, 285, 286, 218, 218, 0, 0, 0, 0, 0, - 0, 289, 290, 0, 291, 97, 103, 108, 0, 0, - 123, 131, 139, 147, 155, 163, 235, 236, 237, 238, - 239, 251, 252, 253, 254, 212, 0, 0, 1, 2, - 301, 3, 4, 5, 6, 7, 8, 304, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 1, 2, 0, 3, 4, 5, 6, 7, - 8, 0, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, - 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, - 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - 57, 58, 59, 60, 61, 62, 96, 102, 106, 113, - 117, 121, 129, 137, 145, 153, 161, 170, 173, 107, - 0, 0, 122, 130, 138, 146, 154, 162, 0, 0, - 0, 0, 0, 0, 0, 175, 176, 177, 178, 179, - 180, 181, 182, 183, 184, 0, 0, 0, 0, 185, - 190, 194, 198, 202, 206, 0, 0, 0, 0, 0, - 186, 191, 195, 199, 203, 207, 298, 299, 0, 0, - 0, 259, 235, 236, 237, 238, 239, 235, 236, 237, - 238, 239, 279, 0, 0, 0, 0, 300, 235, 236, - 237, 238, 239, 235, 236, 237, 238, 239, 305, 0, - 0, 0, 0, 306, 235, 236, 237, 238, 239, 235, - 236, 237, 238, 239, 234, 0, 0, 0, 0, 235, - 236, 237, 238, 239, 242, 0, 0, 0, 0, 235, - 236, 237, 238, 239, 244, 0, 0, 0, 0, 235, - 236, 237, 238, 239, 264, 0, 0, 0, 0, 235, - 236, 237, 238, 239, 271, 0, 0, 0, 0, 235, - 236, 237, 238, 239, 280, 0, 0, 0, 0, 235, - 236, 237, 238, 239, 111, 0, 0, 126, 134, 142, - 150, 158, 166, 112, 0, 0, 127, 135, 143, 151, - 159, 167 -}; - -static const short int yycheck[] = -{ - 12, 13, 14, 15, 71, 74, 18, 19, 20, 21, - 22, 23, 5, 72, 73, 216, 217, 72, 87, 12, - 12, 72, 73, 78, 79, 80, 81, 82, 83, 84, - 85, 86, 72, 73, 12, 12, 72, 73, 78, 79, - 80, 81, 82, 71, 56, 57, 58, 59, 60, 61, - 12, 75, 76, 12, 255, 256, 68, 71, 70, 67, - 12, 71, 74, 75, 76, 71, 71, 79, 80, 81, - 82, 12, 71, 66, 66, 71, 71, 70, 71, 71, - 71, 93, 94, 67, 67, 77, 79, 79, 66, 66, - 12, 83, 67, 71, 71, 88, 88, 67, 71, 77, - 77, 79, 79, 72, 66, 83, 83, 66, 71, 71, - 88, 88, 71, 66, 66, 77, 72, 79, 72, 71, - 79, 83, 72, 67, 83, 66, 88, 79, 76, 88, - 71, 83, 75, 68, 69, 73, 88, 72, 79, 68, - 69, 73, 83, 72, 66, 76, 72, 88, 75, 71, - 80, 81, 82, 13, 14, 75, 168, 79, 18, 19, - 20, 21, 22, 23, 24, 25, 88, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 78, 79, 80, 81, 82, 68, 14, 15, 76, 17, - 18, 19, 20, 21, 22, 23, 72, 63, 76, 211, - 16, -1, -1, -1, 216, 217, -1, -1, -1, -1, - 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, - -1, -1, -1, 235, 236, 237, 238, 239, 56, 57, - 58, 59, 60, 61, -1, -1, -1, -1, -1, 251, - 252, 253, 254, 255, 256, -1, -1, -1, -1, -1, - -1, 263, 264, -1, 266, 13, 14, 15, -1, -1, - 18, 19, 20, 21, 22, 23, 78, 79, 80, 81, - 82, 83, 84, 85, 86, 0, -1, -1, 3, 4, - 292, 6, 7, 8, 9, 10, 11, 299, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 3, 4, -1, 6, 7, 8, 9, 10, - 11, -1, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 15, - -1, -1, 18, 19, 20, 21, 22, 23, -1, -1, - -1, -1, -1, -1, -1, 42, 43, 44, 45, 46, - 47, 48, 49, 50, 51, -1, -1, -1, -1, 56, - 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, - 56, 57, 58, 59, 60, 61, 72, 73, -1, -1, - -1, 72, 78, 79, 80, 81, 82, 78, 79, 80, - 81, 82, 72, -1, -1, -1, -1, 72, 78, 79, - 80, 81, 82, 78, 79, 80, 81, 82, 72, -1, - -1, -1, -1, 72, 78, 79, 80, 81, 82, 78, - 79, 80, 81, 82, 73, -1, -1, -1, -1, 78, - 79, 80, 81, 82, 73, -1, -1, -1, -1, 78, - 79, 80, 81, 82, 73, -1, -1, -1, -1, 78, - 79, 80, 81, 82, 73, -1, -1, -1, -1, 78, - 79, 80, 81, 82, 73, -1, -1, -1, -1, 78, - 79, 80, 81, 82, 73, -1, -1, -1, -1, 78, - 79, 80, 81, 82, 15, -1, -1, 18, 19, 20, - 21, 22, 23, 15, -1, -1, 18, 19, 20, 21, - 22, 23 -}; - -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const unsigned char yystos[] = -{ - 0, 3, 4, 6, 7, 8, 9, 10, 11, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 91, 92, 93, 95, 71, 71, 71, - 71, 71, 71, 71, 71, 71, 71, 12, 66, 71, - 77, 79, 83, 88, 96, 97, 98, 99, 100, 101, - 103, 104, 105, 71, 83, 96, 97, 99, 100, 102, - 105, 96, 97, 99, 100, 101, 97, 98, 99, 100, - 101, 103, 104, 97, 100, 102, 105, 97, 100, 101, - 96, 97, 98, 99, 100, 101, 103, 104, 96, 97, - 98, 99, 100, 101, 103, 104, 96, 97, 98, 99, - 100, 101, 103, 104, 96, 97, 98, 99, 100, 101, - 103, 104, 96, 97, 98, 99, 100, 101, 103, 104, - 96, 97, 98, 99, 100, 101, 103, 104, 83, 96, - 97, 100, 96, 97, 100, 97, 97, 97, 97, 97, - 97, 97, 97, 97, 97, 97, 98, 100, 101, 105, - 97, 98, 100, 101, 97, 98, 100, 101, 97, 98, - 100, 101, 97, 98, 100, 101, 97, 98, 100, 101, - 74, 87, 0, 92, 67, 5, 70, 71, 105, 106, - 67, 105, 67, 67, 67, 105, 94, 105, 94, 71, - 105, 105, 105, 105, 73, 78, 79, 80, 81, 82, - 105, 105, 73, 105, 73, 105, 72, 71, 106, 105, - 106, 83, 84, 85, 86, 68, 69, 72, 72, 72, - 72, 72, 72, 73, 73, 72, 73, 72, 67, 72, - 73, 73, 75, 76, 105, 105, 105, 105, 105, 72, - 73, 66, 72, 105, 105, 105, 105, 106, 106, 105, - 105, 105, 73, 73, 75, 75, 76, 72, 72, 73, - 72, 105, 76, 72, 105, 72, 72 -}; - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab - - -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ - -#define YYFAIL goto yyerrlab - -#define YYRECOVERING() (!!yyerrstatus) - -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (0) - - -#define YYTERROR 1 -#define YYERRCODE 256 - - -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (N) \ - { \ - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC (Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC (Rhs, 0).last_column; \ - } \ - while (0) -#endif - - -/* YY_LOCATION_PRINT -- Print the location on the stream. - This macro was not mandated originally: define only if we know - we won't break user code: when these are the locations we know. */ - -#ifndef YY_LOCATION_PRINT -# if YYLTYPE_IS_TRIVIAL -# define YY_LOCATION_PRINT(File, Loc) \ - fprintf (File, "%d.%d-%d.%d", \ - (Loc).first_line, (Loc).first_column, \ - (Loc).last_line, (Loc).last_column) -# else -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -# endif -#endif - - -/* YYLEX -- calling `yylex' with the right arguments. */ - -#ifdef YYLEX_PARAM -# define YYLEX yylex (YYLEX_PARAM) -#else -# define YYLEX yylex () -#endif - -/* 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, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yysymprint (stderr, \ - Type, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (0) - -/*------------------------------------------------------------------. -| yy_stack_print -- Print the state stack from its BOTTOM up to its | -| TOP (included). | -`------------------------------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yy_stack_print (short int *bottom, short int *top) -#else -static void -yy_stack_print (bottom, top) - short int *bottom; - short int *top; -#endif -{ - YYFPRINTF (stderr, "Stack now"); - for (/* Nothing. */; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); - 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. | -`------------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yy_reduce_print (int yyrule) -#else -static void -yy_reduce_print (yyrule) - int yyrule; -#endif -{ - int yyi; - unsigned long int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ", - yyrule - 1, yylno); - /* Print the symbols being reduced, and their result. */ - for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) - YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); - YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]); -} - -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (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) -# define YY_SYMBOL_PRINT(Title, Type, 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 - - - -#if YYERROR_VERBOSE - -# ifndef yystrlen -# if defined (__GLIBC__) && defined (_STRING_H) -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -static YYSIZE_T -# if defined (__STDC__) || defined (__cplusplus) -yystrlen (const char *yystr) -# else -yystrlen (yystr) - const char *yystr; -# endif -{ - const char *yys = yystr; - - while (*yys++ != '\0') - continue; - - return yys - yystr - 1; -} -# 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 * -# if defined (__STDC__) || defined (__cplusplus) -yystpcpy (char *yydest, const char *yysrc) -# else -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -# endif -{ - 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 YYSIZE_T -yytnamerr (char *yyres, const char *yystr) -{ - if (*yystr == '"') - { - size_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; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes: ; - } - - if (! yyres) - return yystrlen (yystr); - - return yystpcpy (yyres, yystr) - yyres; -} -# endif - -#endif /* YYERROR_VERBOSE */ - - - -#if YYDEBUG -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) -#else -static void -yysymprint (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE *yyvaluep; -#endif -{ - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; - - if (yytype < YYNTOKENS) - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - - -# ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# endif - switch (yytype) - { - default: - break; - } - YYFPRINTF (yyoutput, ")"); -} - -#endif /* ! YYDEBUG */ -/*-----------------------------------------------. -| Release the memory associated to this symbol. | -`-----------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) -#else -static void -yydestruct (yymsg, yytype, yyvaluep) - const char *yymsg; - int yytype; - YYSTYPE *yyvaluep; -#endif -{ - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; - - if (!yymsg) - yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - - switch (yytype) - { - - default: - break; - } -} - - -/* Prevent warnings from -Wmissing-prototypes. */ - -#ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM); -# else -int yyparse (); -# endif -#else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) -int yyparse (void); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ - -void yycleanup(); - -/* The look-ahead symbol. */ -int yychar; - -/* The semantic value of the look-ahead symbol. */ -YYSTYPE yylval; - -/* Number of syntax errors so far. */ -int yynerrs; - - - -/*----------. -| yyparse. | -`----------*/ - -#ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM) -# else -int yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -# endif -#else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) -int -yyparse (void) -#else -int -yyparse () - ; -#endif -#endif -{ - - int yystate; - int yyn; - int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ - int yytoken = 0; - - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - short int yyssa[YYINITDEPTH]; - short int *yyss = yyssa; - short int *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp; - - - -#define YYPOPSTACK (yyvsp--, yyssp--) - - YYSIZE_T yystacksize = YYINITDEPTH; - - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - - - /* When reducing, the number of symbols on the RHS of the reduced - rule. */ - int yylen; - - YYDPRINTF ((stderr, "Starting parse\n")); - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - - yyssp = yyss; - yyvsp = yyvs; - - 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: - *yyssp = yystate; - - if (yyss + yystacksize - 1 <= yyssp) - { - /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; - -#ifdef 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. */ - YYSTYPE *yyvs1 = yyvs; - short int *yyss1 = yyss; - - - /* 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 * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - - &yystacksize); - - yyss = yyss1; - yyvs = yyvs1; - } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else - /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; - yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; - - { - short int *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif -#endif /* no yyoverflow */ - - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; - - - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); - - if (yyss + yystacksize - 1 <= yyssp) - YYABORT; - } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - - goto yybackup; - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: - -/* Do appropriate processing given the current state. */ -/* Read a look-ahead token if we need one and don't already have one. */ -/* yyresume: */ - - /* First try to decide what to do without reference to look-ahead token. */ - - yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) - goto yydefault; - - /* Not known => get a look-ahead token if don't already have one. */ - - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ - if (yychar == YYEMPTY) - { - YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; - } - - if (yychar <= YYEOF) - { - yychar = yytoken = YYEOF; - YYDPRINTF ((stderr, "Now at end of input.\n")); - } - 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 (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - - if (yyn == YYFINAL) - YYACCEPT; - - /* Shift the look-ahead token. */ - YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the token being shifted unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - *++yyvsp = yylval; - - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; - - yystate = yyn; - 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 4: -// #line 145 "asm.y" - { new_label((yyvsp[-1].str)); ;} - break; - - case 5: -// #line 146 "asm.y" - { new_symbol_expr((yyvsp[-2].str), (yyvsp[0].expr)); ;} - break; - - case 6: -// #line 147 "asm.y" - { push_if_state((yyvsp[-1].expr)); ;} - break; - - case 7: -// #line 148 "asm.y" - { set_org((yyvsp[-1].expr)); ;} - break; - - case 8: -// #line 149 "asm.y" - { asm_error((yyvsp[-1].str)); ;} - break; - - case 9: -// #line 150 "asm.y" - { asm_echo((yyvsp[-1].str)); ;} - break; - - case 10: -// #line 151 "asm.y" - { asm_include((yyvsp[-1].str)); ;} - break; - - case 11: -// #line 152 "asm.y" - { push_macro_state((yyvsp[-1].str)); ;} - break; - - case 12: -// #line 153 "asm.y" - { vec_push(asm_atoms, &(yyvsp[0].atom)); ;} - break; - - case 13: -// #line 154 "asm.y" - { macro_append((yyvsp[0].str)) ;} - break; - - case 14: -// #line 156 "asm.y" - { (yyval.atom) = (yyvsp[0].atom);} - break; - - case 15: -// #line 157 "asm.y" - { (yyval.atom) = new_res((yyvsp[-3].expr), (yyvsp[-1].expr)); ;} - break; - - case 16: -// #line 158 "asm.y" - { (yyval.atom) = exprs_to_word_exprs((yyvsp[-1].atom)); ;} - break; - - case 17: -// #line 159 "asm.y" - { (yyval.atom) = exprs_to_byte_exprs((yyvsp[-1].atom)); ;} - break; - - case 18: -// #line 160 "asm.y" - { - (yyval.atom) = new_incbin((yyvsp[-1].str), NULL, NULL); ;} - break; - - case 19: -// #line 162 "asm.y" - { - (yyval.atom) = new_incbin((yyvsp[-3].str), (yyvsp[-1].expr), NULL); ;} - break; - - case 20: -// #line 164 "asm.y" - { - (yyval.atom) = new_incbin((yyvsp[-5].str), (yyvsp[-3].expr), (yyvsp[-1].expr)); ;} - break; - - case 21: -// #line 167 "asm.y" - { (yyval.atom) = exprs_add((yyvsp[-2].atom), (yyvsp[0].expr)); ;} - break; - - case 22: -// #line 168 "asm.y" - { (yyval.atom) = new_exprs((yyvsp[0].expr)); ;} - break; - - case 23: -// #line 170 "asm.y" - { (yyval.atom) = new_op(0xA9, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); ;} - break; - - case 24: -// #line 171 "asm.y" - { (yyval.atom) = new_op(0xA5, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 25: -// #line 172 "asm.y" - { (yyval.atom) = new_op(0xB5, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 26: -// #line 173 "asm.y" - { (yyval.atom) = new_op(0xAD, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 27: -// #line 174 "asm.y" - { (yyval.atom) = new_op(0xBD, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 28: -// #line 175 "asm.y" - { (yyval.atom) = new_op(0xB9, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 29: -// #line 176 "asm.y" - { (yyval.atom) = new_op(0xA1, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 30: -// #line 177 "asm.y" - { (yyval.atom) = new_op(0xB1, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 31: -// #line 179 "asm.y" - { (yyval.atom) = new_op(0xA2, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); ;} - break; - - case 32: -// #line 180 "asm.y" - { (yyval.atom) = new_op(0xA6, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 33: -// #line 181 "asm.y" - { (yyval.atom) = new_op(0xB6, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 34: -// #line 182 "asm.y" - { (yyval.atom) = new_op(0xAE, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 35: -// #line 183 "asm.y" - { (yyval.atom) = new_op(0xBE, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 36: -// #line 185 "asm.y" - { (yyval.atom) = new_op(0xA0, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); ;} - break; - - case 37: -// #line 186 "asm.y" - { (yyval.atom) = new_op(0xA4, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 38: -// #line 187 "asm.y" - { (yyval.atom) = new_op(0xB4, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 39: -// #line 188 "asm.y" - { (yyval.atom) = new_op(0xAC, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 40: -// #line 189 "asm.y" - { (yyval.atom) = new_op(0xBC, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 41: -// #line 191 "asm.y" - { (yyval.atom) = new_op(0x85, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 42: -// #line 192 "asm.y" - { (yyval.atom) = new_op(0x95, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 43: -// #line 193 "asm.y" - { (yyval.atom) = new_op(0x8D, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 44: -// #line 194 "asm.y" - { (yyval.atom) = new_op(0x9D, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 45: -// #line 195 "asm.y" - { (yyval.atom) = new_op(0x99, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 46: -// #line 196 "asm.y" - { (yyval.atom) = new_op(0x81, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 47: -// #line 197 "asm.y" - { (yyval.atom) = new_op(0x91, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 48: -// #line 199 "asm.y" - { (yyval.atom) = new_op(0x86, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 49: -// #line 200 "asm.y" - { (yyval.atom) = new_op(0x96, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 50: -// #line 201 "asm.y" - { (yyval.atom) = new_op(0x8e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 51: -// #line 203 "asm.y" - { (yyval.atom) = new_op(0x84, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 52: -// #line 204 "asm.y" - { (yyval.atom) = new_op(0x94, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 53: -// #line 205 "asm.y" - { (yyval.atom) = new_op(0x8c, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 54: -// #line 207 "asm.y" - { (yyval.atom) = new_op(0x29, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); ;} - break; - - case 55: -// #line 208 "asm.y" - { (yyval.atom) = new_op(0x25, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 56: -// #line 209 "asm.y" - { (yyval.atom) = new_op(0x35, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 57: -// #line 210 "asm.y" - { (yyval.atom) = new_op(0x2d, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 58: -// #line 211 "asm.y" - { (yyval.atom) = new_op(0x3d, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 59: -// #line 212 "asm.y" - { (yyval.atom) = new_op(0x39, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 60: -// #line 213 "asm.y" - { (yyval.atom) = new_op(0x21, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 61: -// #line 214 "asm.y" - { (yyval.atom) = new_op(0x31, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 62: -// #line 216 "asm.y" - { (yyval.atom) = new_op(0x09, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); ;} - break; - - case 63: -// #line 217 "asm.y" - { (yyval.atom) = new_op(0x05, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 64: -// #line 218 "asm.y" - { (yyval.atom) = new_op(0x15, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 65: -// #line 219 "asm.y" - { (yyval.atom) = new_op(0x0d, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 66: -// #line 220 "asm.y" - { (yyval.atom) = new_op(0x1d, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 67: -// #line 221 "asm.y" - { (yyval.atom) = new_op(0x19, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 68: -// #line 222 "asm.y" - { (yyval.atom) = new_op(0x01, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 69: -// #line 223 "asm.y" - { (yyval.atom) = new_op(0x11, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 70: -// #line 225 "asm.y" - { (yyval.atom) = new_op(0x49, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); ;} - break; - - case 71: -// #line 226 "asm.y" - { (yyval.atom) = new_op(0x45, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 72: -// #line 227 "asm.y" - { (yyval.atom) = new_op(0x55, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 73: -// #line 228 "asm.y" - { (yyval.atom) = new_op(0x4d, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 74: -// #line 229 "asm.y" - { (yyval.atom) = new_op(0x5d, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 75: -// #line 230 "asm.y" - { (yyval.atom) = new_op(0x59, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 76: -// #line 231 "asm.y" - { (yyval.atom) = new_op(0x41, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 77: -// #line 232 "asm.y" - { (yyval.atom) = new_op(0x51, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 78: -// #line 234 "asm.y" - { (yyval.atom) = new_op(0x69, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); ;} - break; - - case 79: -// #line 235 "asm.y" - { (yyval.atom) = new_op(0x65, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 80: -// #line 236 "asm.y" - { (yyval.atom) = new_op(0x75, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 81: -// #line 237 "asm.y" - { (yyval.atom) = new_op(0x6D, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 82: -// #line 238 "asm.y" - { (yyval.atom) = new_op(0x7D, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 83: -// #line 239 "asm.y" - { (yyval.atom) = new_op(0x79, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 84: -// #line 240 "asm.y" - { (yyval.atom) = new_op(0x61, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 85: -// #line 241 "asm.y" - { (yyval.atom) = new_op(0x71, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 86: -// #line 243 "asm.y" - { (yyval.atom) = new_op(0xe9, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); ;} - break; - - case 87: -// #line 244 "asm.y" - { (yyval.atom) = new_op(0xe5, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 88: -// #line 245 "asm.y" - { (yyval.atom) = new_op(0xf5, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 89: -// #line 246 "asm.y" - { (yyval.atom) = new_op(0xeD, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 90: -// #line 247 "asm.y" - { (yyval.atom) = new_op(0xfD, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 91: -// #line 248 "asm.y" - { (yyval.atom) = new_op(0xf9, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 92: -// #line 249 "asm.y" - { (yyval.atom) = new_op(0xe1, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 93: -// #line 250 "asm.y" - { (yyval.atom) = new_op(0xf1, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 94: -// #line 252 "asm.y" - { (yyval.atom) = new_op(0xc9, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); ;} - break; - - case 95: -// #line 253 "asm.y" - { (yyval.atom) = new_op(0xc5, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 96: -// #line 254 "asm.y" - { (yyval.atom) = new_op(0xd5, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 97: -// #line 255 "asm.y" - { (yyval.atom) = new_op(0xcD, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 98: -// #line 256 "asm.y" - { (yyval.atom) = new_op(0xdD, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 99: -// #line 257 "asm.y" - { (yyval.atom) = new_op(0xd9, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 100: -// #line 258 "asm.y" - { (yyval.atom) = new_op(0xc1, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 101: -// #line 259 "asm.y" - { (yyval.atom) = new_op(0xd1, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 102: -// #line 261 "asm.y" - { (yyval.atom) = new_op(0xe0, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 103: -// #line 262 "asm.y" - { (yyval.atom) = new_op(0xe4, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 104: -// #line 263 "asm.y" - { (yyval.atom) = new_op(0xec, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 105: -// #line 264 "asm.y" - { (yyval.atom) = new_op(0xc0, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 106: -// #line 265 "asm.y" - { (yyval.atom) = new_op(0xc4, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 107: -// #line 266 "asm.y" - { (yyval.atom) = new_op(0xcc, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 108: -// #line 268 "asm.y" - { (yyval.atom) = new_op0(0x9A); ;} - break; - - case 109: -// #line 269 "asm.y" - { (yyval.atom) = new_op0(0xBA); ;} - break; - - case 110: -// #line 270 "asm.y" - { (yyval.atom) = new_op0(0x48); ;} - break; - - case 111: -// #line 271 "asm.y" - { (yyval.atom) = new_op0(0x68); ;} - break; - - case 112: -// #line 272 "asm.y" - { (yyval.atom) = new_op0(0x08); ;} - break; - - case 113: -// #line 273 "asm.y" - { (yyval.atom) = new_op0(0x28); ;} - break; - - case 114: -// #line 274 "asm.y" - { (yyval.atom) = new_op0(0x78); ;} - break; - - case 115: -// #line 275 "asm.y" - { (yyval.atom) = new_op0(0x58); ;} - break; - - case 116: -// #line 276 "asm.y" - { (yyval.atom) = new_op0(0xea); ;} - break; - - case 117: -// #line 277 "asm.y" - { (yyval.atom) = new_op0(0x98); ;} - break; - - case 118: -// #line 278 "asm.y" - { (yyval.atom) = new_op0(0xa8); ;} - break; - - case 119: -// #line 279 "asm.y" - { (yyval.atom) = new_op0(0x8a); ;} - break; - - case 120: -// #line 280 "asm.y" - { (yyval.atom) = new_op0(0xaa); ;} - break; - - case 121: -// #line 281 "asm.y" - { (yyval.atom) = new_op0(0x18); ;} - break; - - case 122: -// #line 282 "asm.y" - { (yyval.atom) = new_op0(0x38); ;} - break; - - case 123: -// #line 283 "asm.y" - { (yyval.atom) = new_op0(0x60); ;} - break; - - case 124: -// #line 285 "asm.y" - { (yyval.atom) = new_op(0x20, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 125: -// #line 286 "asm.y" - { (yyval.atom) = new_op(0x4c, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 126: -// #line 287 "asm.y" - { (yyval.atom) = new_op(0xf0, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); ;} - break; - - case 127: -// #line 288 "asm.y" - { (yyval.atom) = new_op(0xd0, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); ;} - break; - - case 128: -// #line 289 "asm.y" - { (yyval.atom) = new_op(0x90, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); ;} - break; - - case 129: -// #line 290 "asm.y" - { (yyval.atom) = new_op(0xb0, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); ;} - break; - - case 130: -// #line 291 "asm.y" - { (yyval.atom) = new_op(0x10, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); ;} - break; - - case 131: -// #line 292 "asm.y" - { (yyval.atom) = new_op(0x30, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); ;} - break; - - case 132: -// #line 293 "asm.y" - { (yyval.atom) = new_op(0x50, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); ;} - break; - - case 133: -// #line 294 "asm.y" - { (yyval.atom) = new_op(0x70, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); ;} - break; - - case 134: -// #line 296 "asm.y" - { (yyval.atom) = new_op0(0xe8); ;} - break; - - case 135: -// #line 297 "asm.y" - { (yyval.atom) = new_op0(0xca); ;} - break; - - case 136: -// #line 298 "asm.y" - { (yyval.atom) = new_op0(0xc8); ;} - break; - - case 137: -// #line 299 "asm.y" - { (yyval.atom) = new_op0(0x88); ;} - break; - - case 138: -// #line 301 "asm.y" - { (yyval.atom) = new_op(0xe6, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 139: -// #line 302 "asm.y" - { (yyval.atom) = new_op(0xf6, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 140: -// #line 303 "asm.y" - { (yyval.atom) = new_op(0xee, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 141: -// #line 304 "asm.y" - { (yyval.atom) = new_op(0xfe, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 142: -// #line 306 "asm.y" - { (yyval.atom) = new_op(0xc6, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 143: -// #line 307 "asm.y" - { (yyval.atom) = new_op(0xd6, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 144: -// #line 308 "asm.y" - { (yyval.atom) = new_op(0xce, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 145: -// #line 309 "asm.y" - { (yyval.atom) = new_op(0xde, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 146: -// #line 311 "asm.y" - { (yyval.atom) = new_op0(0x4a); ;} - break; - - case 147: -// #line 312 "asm.y" - { (yyval.atom) = new_op(0x46, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 148: -// #line 313 "asm.y" - { (yyval.atom) = new_op(0x56, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 149: -// #line 314 "asm.y" - { (yyval.atom) = new_op(0x4e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 150: -// #line 315 "asm.y" - { (yyval.atom) = new_op(0x5e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 151: -// #line 317 "asm.y" - { (yyval.atom) = new_op0(0x0a); ;} - break; - - case 152: -// #line 318 "asm.y" - { (yyval.atom) = new_op(0x06, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 153: -// #line 319 "asm.y" - { (yyval.atom) = new_op(0x16, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 154: -// #line 320 "asm.y" - { (yyval.atom) = new_op(0x0e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 155: -// #line 321 "asm.y" - { (yyval.atom) = new_op(0x1e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 156: -// #line 323 "asm.y" - { (yyval.atom) = new_op0(0x6a); ;} - break; - - case 157: -// #line 324 "asm.y" - { (yyval.atom) = new_op(0x66, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 158: -// #line 325 "asm.y" - { (yyval.atom) = new_op(0x76, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 159: -// #line 326 "asm.y" - { (yyval.atom) = new_op(0x6e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 160: -// #line 327 "asm.y" - { (yyval.atom) = new_op(0x7e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 161: -// #line 329 "asm.y" - { (yyval.atom) = new_op0(0x2a); ;} - break; - - case 162: -// #line 330 "asm.y" - { (yyval.atom) = new_op(0x26, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 163: -// #line 331 "asm.y" - { (yyval.atom) = new_op(0x36, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); ;} - break; - - case 164: -// #line 332 "asm.y" - { (yyval.atom) = new_op(0x2e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 165: -// #line 333 "asm.y" - { (yyval.atom) = new_op(0x3e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); ;} - break; - - case 166: -// #line 335 "asm.y" - { (yyval.expr) = (yyvsp[0].expr); ;} - break; - - case 167: -// #line 336 "asm.y" - { (yyval.expr) = (yyvsp[0].expr); ;} - break; - - case 168: -// #line 337 "asm.y" - { (yyval.expr) = (yyvsp[-2].expr); ;} - break; - - case 169: -// #line 338 "asm.y" - { (yyval.expr) = (yyvsp[-2].expr); ;} - break; - - case 170: -// #line 339 "asm.y" - { (yyval.expr) = (yyvsp[0].expr); ;} - break; - - case 171: -// #line 340 "asm.y" - { (yyval.expr) = (yyvsp[-2].expr); ;} - break; - - case 172: -// #line 341 "asm.y" - { (yyval.expr) = (yyvsp[-2].expr); ;} - break; - - case 173: -// #line 342 "asm.y" - { (yyval.expr) = (yyvsp[-3].expr); ;} - break; - - case 174: -// #line 343 "asm.y" - { (yyval.expr) = (yyvsp[-3].expr); ;} - break; - - case 175: -// #line 345 "asm.y" - { (yyval.expr) = new_expr_op2(PLUS, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 176: -// #line 346 "asm.y" - { (yyval.expr) = new_expr_op2(MINUS, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 177: -// #line 347 "asm.y" - { (yyval.expr) = new_expr_op2(MULT, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 178: -// #line 348 "asm.y" - { (yyval.expr) = new_expr_op2(DIV, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 179: -// #line 349 "asm.y" - { (yyval.expr) = new_expr_op2(MOD, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 180: -// #line 350 "asm.y" - { (yyval.expr) = new_expr_op1(vNEG, (yyvsp[0].expr)); ;} - break; - - case 181: -// #line 351 "asm.y" - { (yyval.expr) = (yyvsp[-1].expr); ;} - break; - - case 182: -// #line 352 "asm.y" - { - (yyval.expr) = new_expr_incword((yyvsp[-3].str), (yyvsp[-1].expr)); ;} - break; - - case 183: -// #line 354 "asm.y" - { (yyval.expr) = new_expr_number((yyvsp[0].num)); ;} - break; - - case 184: -// #line 355 "asm.y" - { (yyval.expr) = new_expr_symref((yyvsp[0].str)); ;} - break; - - case 185: -// #line 357 "asm.y" - { (yyval.expr) = new_expr_op2(LOR, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 186: -// #line 358 "asm.y" - { (yyval.expr) = new_expr_op2(LAND, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 187: -// #line 359 "asm.y" - { (yyval.expr) = new_expr_op1(LNOT, (yyvsp[0].expr)); ;} - break; - - case 188: -// #line 360 "asm.y" - { (yyval.expr) = (yyvsp[-1].expr); ;} - break; - - case 189: -// #line 361 "asm.y" - { (yyval.expr) = new_expr_op2(LT, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 190: -// #line 362 "asm.y" - { (yyval.expr) = new_expr_op2(GT, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 191: -// #line 363 "asm.y" - { (yyval.expr) = new_expr_op2(EQ, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 192: -// #line 364 "asm.y" - { (yyval.expr) = new_expr_op2(NEQ, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} - break; - - case 193: -// #line 366 "asm.y" - { (yyval.expr) = new_is_defined((yyvsp[-1].str)); ;} - break; - - - default: break; - } - -/* Line 1126 of yacc.c. */ -// #line 2596 "asm.tab.c" - - yyvsp -= yylen; - yyssp -= yylen; - - - YY_STACK_PRINT (yyss, yyssp); - - *++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. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; - - goto yynewstate; - - -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ -yyerrlab: - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) - { - ++yynerrs; -#if YYERROR_VERBOSE - yyn = yypact[yystate]; - - if (YYPACT_NINF < yyn && yyn < YYLAST) - { - int yytype = YYTRANSLATE (yychar); - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - int yysize_overflow = 0; - char *yymsg = 0; -# define YYERROR_VERBOSE_ARGS_MAXIMUM 5 - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - int yyx; - -#if 0 - /* This is so xgettext sees the translatable formats that are - constructed on the fly. */ - YY_("syntax error, unexpected %s"); - YY_("syntax error, unexpected %s, expecting %s"); - YY_("syntax error, unexpected %s, expecting %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); -#endif - char *yyfmt; - char const *yyf; - static char const yyunexpected[] = "syntax error, unexpected %s"; - static char const yyexpecting[] = ", expecting %s"; - static char const yyor[] = " or %s"; - char yyformat[sizeof yyunexpected - + sizeof yyexpecting - 1 - + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) - * (sizeof yyor - 1))]; - char const *yyprefix = yyexpecting; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 1; - - yyarg[0] = yytname[yytype]; - yyfmt = yystpcpy (yyformat, yyunexpected); - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - yyformat[sizeof yyunexpected - 1] = '\0'; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - yysize_overflow |= yysize1 < yysize; - yysize = yysize1; - yyfmt = yystpcpy (yyfmt, yyprefix); - yyprefix = yyor; - } - - yyf = YY_(yyformat); - yysize1 = yysize + yystrlen (yyf); - yysize_overflow |= yysize1 < yysize; - yysize = yysize1; - - if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM) - yymsg = (char *) YYSTACK_ALLOC (yysize); - if (yymsg) - { - /* 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 = *yyf)) - { - if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyf += 2; - } - else - { - yyp++; - yyf++; - } - } - yyerror (yymsg); - YYSTACK_FREE (yymsg); - } - else - { - yyerror (YY_("syntax error")); - goto yyexhaustedlab; - } - } - else -#endif /* YYERROR_VERBOSE */ - yyerror (YY_("syntax error")); - } - - - - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse look-ahead 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 look-ahead token after shifting the error - token. */ - goto yyerrlab1; - - -/*---------------------------------------------------. -| yyerrorlab -- error raised explicitly by YYERROR. | -`---------------------------------------------------*/ -yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (0) - goto yyerrorlab; - -yyvsp -= yylen; - yyssp -= yylen; - yystate = *yyssp; - goto yyerrlab1; - - -/*-------------------------------------------------------------. -| yyerrlab1 -- common code for both syntax error and YYERROR. | -`-------------------------------------------------------------*/ -yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ - - for (;;) - { - yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - 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", yystos[yystate], yyvsp); - YYPOPSTACK; - yystate = *yyssp; - YY_STACK_PRINT (yyss, yyssp); - } - - if (yyn == YYFINAL) - YYACCEPT; - - *++yyvsp = yylval; - - - /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); - - yystate = yyn; - goto yynewstate; - - -/*-------------------------------------. -| yyacceptlab -- YYACCEPT comes here. | -`-------------------------------------*/ -yyacceptlab: - yyresult = 0; - goto yyreturn; - -/*-----------------------------------. -| yyabortlab -- YYABORT comes here. | -`-----------------------------------*/ -yyabortlab: - yyresult = 1; - goto yyreturn; - -#ifndef yyoverflow -/*-------------------------------------------------. -| yyexhaustedlab -- memory exhaustion comes here. | -`-------------------------------------------------*/ -yyexhaustedlab: - yyerror (YY_("memory exhausted")); - yyresult = 2; - /* Fall through. */ -#endif - -yyreturn: - if (yychar != YYEOF && yychar != YYEMPTY) - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval); - while (yyssp != yyss) - { - yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); - YYPOPSTACK; - } -#ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); -#endif - return yyresult; -} - - -// #line 368 "asm.y" - - -int -yyerror (char *s) -{ - fprintf (stderr, "line %d, %s\n", num_lines, s); - return 0; -} - -void asm_set_source(struct membuf *buffer); - -int assemble(struct membuf *source, struct membuf *dest) -{ - int val; - - LOG_INIT_CONSOLE(LOG_NORMAL); - parse_init(); - yydebug = 0; - asm_src_buffer_push(source); - vec_init(asm_atoms, sizeof(struct atom*)); - val = yyparse(); - if(val == 0) - { - output_atoms(dest, asm_atoms); - } - parse_free(); - vec_free(asm_atoms, NULL); - yycleanup(); - LOG_FREE; - - return val; -} - diff --git a/src/asm/asmtab.h b/src/asm/asmtab.h deleted file mode 100644 index e4657c0..0000000 --- a/src/asm/asmtab.h +++ /dev/null @@ -1,232 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.1. */ - -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* Tokens. */ -# define YYTOKENTYPE -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - INCLUDE = 258, - IF = 259, - DEFINED = 260, - MACRO = 261, - MACRO_STRING = 262, - ORG = 263, - ASMERROR = 264, - ECHO = 265, - INCBIN = 266, - INCWORD = 267, - RES = 268, - WORD = 269, - BYTE = 270, - LDA = 271, - LDX = 272, - LDY = 273, - STA = 274, - STX = 275, - STY = 276, - AND = 277, - ORA = 278, - EOR = 279, - ADC = 280, - SBC = 281, - CMP = 282, - CPX = 283, - CPY = 284, - TSX = 285, - TXS = 286, - PHA = 287, - PLA = 288, - PHP = 289, - PLP = 290, - SEI = 291, - CLI = 292, - NOP = 293, - TYA = 294, - TAY = 295, - TXA = 296, - TAX = 297, - CLC = 298, - SEC = 299, - RTS = 300, - JSR = 301, - JMP = 302, - BEQ = 303, - BNE = 304, - BCC = 305, - BCS = 306, - BPL = 307, - BMI = 308, - BVC = 309, - BVS = 310, - INX = 311, - DEX = 312, - INY = 313, - DEY = 314, - INC = 315, - DEC = 316, - LSR = 317, - ASL = 318, - ROR = 319, - ROL = 320, - SYMBOL = 321, - STRING = 322, - LAND = 323, - LOR = 324, - LNOT = 325, - LPAREN = 326, - RPAREN = 327, - COMMA = 328, - COLON = 329, - X = 330, - Y = 331, - HASH = 332, - PLUS = 333, - MINUS = 334, - MULT = 335, - DIV = 336, - MOD = 337, - LT = 338, - GT = 339, - EQ = 340, - NEQ = 341, - ASSIGN = 342, - NUMBER = 343, - vNEG = 344 - }; -#endif -/* Tokens. */ -#define INCLUDE 258 -#define IF 259 -#define DEFINED 260 -#define MACRO 261 -#define MACRO_STRING 262 -#define ORG 263 -#define ASMERROR 264 -#define ECHO 265 -#define INCBIN 266 -#define INCWORD 267 -#define RES 268 -#define WORD 269 -#define BYTE 270 -#define LDA 271 -#define LDX 272 -#define LDY 273 -#define STA 274 -#define STX 275 -#define STY 276 -#define AND 277 -#define ORA 278 -#define EOR 279 -#define ADC 280 -#define SBC 281 -#define CMP 282 -#define CPX 283 -#define CPY 284 -#define TSX 285 -#define TXS 286 -#define PHA 287 -#define PLA 288 -#define PHP 289 -#define PLP 290 -#define SEI 291 -#define CLI 292 -#define NOP 293 -#define TYA 294 -#define TAY 295 -#define TXA 296 -#define TAX 297 -#define CLC 298 -#define SEC 299 -#define RTS 300 -#define JSR 301 -#define JMP 302 -#define BEQ 303 -#define BNE 304 -#define BCC 305 -#define BCS 306 -#define BPL 307 -#define BMI 308 -#define BVC 309 -#define BVS 310 -#define INX 311 -#define DEX 312 -#define INY 313 -#define DEY 314 -#define INC 315 -#define DEC 316 -#define LSR 317 -#define ASL 318 -#define ROR 319 -#define ROL 320 -#define SYMBOL 321 -#define STRING 322 -#define LAND 323 -#define LOR 324 -#define LNOT 325 -#define LPAREN 326 -#define RPAREN 327 -#define COMMA 328 -#define COLON 329 -#define X 330 -#define Y 331 -#define HASH 332 -#define PLUS 333 -#define MINUS 334 -#define MULT 335 -#define DIV 336 -#define MOD 337 -#define LT 338 -#define GT 339 -#define EQ 340 -#define NEQ 341 -#define ASSIGN 342 -#define NUMBER 343 -#define vNEG 344 - - - - -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 110 "asm.y" -typedef union YYSTYPE { - i32 num; - char *str; - struct atom *atom; - struct expr *expr; -} YYSTYPE; -/* Line 1447 of yacc.c. */ -#line 223 "asm.tab.h" -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif - -extern YYSTYPE yylval; - - - diff --git a/src/asm/callback.h b/src/asm/callback.h index 02b1901..5c73dbd 100644 --- a/src/asm/callback.h +++ b/src/asm/callback.h @@ -28,7 +28,10 @@ * */ +#include + typedef int cb_cmp(const void *a, const void *b); typedef void cb_free(void *a); +typedef void cb_fprint(FILE *f, const void *a); #endif diff --git a/src/asm/chnkpool.c b/src/asm/chunkpool.c similarity index 54% rename from src/asm/chnkpool.c rename to src/asm/chunkpool.c index 6da2ae0..3cf9c53 100644 --- a/src/asm/chnkpool.c +++ b/src/asm/chunkpool.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003 - 2005 Magnus Lind. + * Copyright (c) 2003 - 2005, 2015 Magnus Lind. * * This software is provided 'as-is', without any express or implied warranty. * In no event will the authors be held liable for any damages arising from @@ -25,42 +25,56 @@ * */ -#include "chnkpool.h" +#include "chunkpool.h" #include "log.h" #include #include - void -chunkpool_init(struct chunkpool *ctx, int size) +chunkpool_init(struct chunkpool *ctx, int item_size) { - ctx->chunk_size = size; - ctx->chunk = -1; - ctx->chunk_max = (0x1fffff / size) * size; - ctx->chunk_pos = ctx->chunk_max; + ctx->item_size = item_size; + ctx->item_end = (0x1fffff / item_size) * item_size; + ctx->item_pos = ctx->item_end; + ctx->current_chunk = NULL; + vec_init(&ctx->used_chunks, sizeof(void*)); } -void -chunkpool_free2(struct chunkpool *ctx, cb_free *f) +static void chunk_free(void *chunks, int item_pos, int item_size, cb_free *f) { - while(ctx->chunk >= 0) + if (chunks != NULL && f != NULL) { - if(f != NULL) + do { - do - { - ctx->chunk_pos -= ctx->chunk_size; - f((char*)ctx->chunks[ctx->chunk] + ctx->chunk_pos); - } - while(ctx->chunk_pos > 0); - ctx->chunk_pos = ctx->chunk_max; + item_pos -= item_size; + f((char*)chunks + item_pos); } - free(ctx->chunks[ctx->chunk]); - ctx->chunk -= 1; + while(item_pos > 0); + } +} + +void +chunkpool_free2(struct chunkpool *ctx, cb_free *f) +{ + void **chunkp; + struct vec_iterator i; + if (ctx->current_chunk != NULL) + { + chunk_free(ctx->current_chunk, ctx->item_pos, ctx->item_size, f); + free(ctx->current_chunk); + } + vec_get_iterator(&ctx->used_chunks, &i); + while ((chunkp = vec_iterator_next(&i)) != NULL) + { + chunk_free(*chunkp, ctx->item_end, ctx->item_size, f); + free(*chunkp); } - ctx->chunk_size = -1; - ctx->chunk_max = -1; - ctx->chunk_pos = -1; + + ctx->item_size = -1; + ctx->item_end = -1; + ctx->item_pos = -1; + ctx->current_chunk = NULL; + vec_free(&ctx->used_chunks, NULL); } void @@ -73,32 +87,23 @@ void * chunkpool_malloc(struct chunkpool *ctx) { void *p; - if(ctx->chunk_pos == ctx->chunk_max) + if(ctx->item_pos == ctx->item_end) { void *m; - if(ctx->chunk == CHUNKPOOL_CHUNKS_MAX - 1) - { - LOG(LOG_ERROR, ("out of chunks in file %s, line %d\n", - __FILE__, __LINE__)); - LOG(LOG_BRIEF, ("chunk_size %d\n", ctx->chunk_size)); - LOG(LOG_BRIEF, ("chunk_max %d\n", ctx->chunk_max)); - LOG(LOG_BRIEF, ("chunk %d\n", ctx->chunk)); - exit(-1); - } - m = malloc(ctx->chunk_max); + m = malloc(ctx->item_end); LOG(LOG_DEBUG, ("allocating new chunk %p\n", m)); if (m == NULL) { LOG(LOG_ERROR, ("out of memory error in file %s, line %d\n", __FILE__, __LINE__)); - exit(-1); + exit(1); } - ctx->chunk += 1; - ctx->chunks[ctx->chunk] = m; - ctx->chunk_pos = 0; + vec_push(&ctx->used_chunks, &ctx->current_chunk); + ctx->current_chunk = m; + ctx->item_pos = 0; } - p = (char*)ctx->chunks[ctx->chunk] + ctx->chunk_pos; - ctx->chunk_pos += ctx->chunk_size; + p = (char*)ctx->current_chunk + ctx->item_pos; + ctx->item_pos += ctx->item_size; return p; } @@ -106,6 +111,6 @@ void * chunkpool_calloc(struct chunkpool *ctx) { void *p = chunkpool_malloc(ctx); - memset(p, 0, ctx->chunk_size); + memset(p, 0, ctx->item_size); return p; } diff --git a/src/asm/chnkpool.h b/src/asm/chunkpool.h similarity index 85% rename from src/asm/chnkpool.h rename to src/asm/chunkpool.h index cbc9016..2f864ba 100644 --- a/src/asm/chnkpool.h +++ b/src/asm/chunkpool.h @@ -2,7 +2,7 @@ #define ALREADY_INCLUDED_CHUNKPOOL /* - * Copyright (c) 2003 -2005 Magnus Lind. + * Copyright (c) 2003 - 2005, 2015 Magnus Lind. * * This software is provided 'as-is', without any express or implied warranty. * In no event will the authors be held liable for any damages arising from @@ -29,19 +29,18 @@ */ #include "callback.h" - -#define CHUNKPOOL_CHUNKS_MAX 64 +#include "vec.h" struct chunkpool { - int chunk_size; - int chunk; - int chunk_pos; - int chunk_max; - void *chunks[64]; + int item_size; + int item_pos; + int item_end; + void *current_chunk; + struct vec used_chunks; }; void -chunkpool_init(struct chunkpool *ctx, int size); +chunkpool_init(struct chunkpool *ctx, int item_size); void chunkpool_free(struct chunkpool *ctx); diff --git a/src/asm/expr.c b/src/asm/expr.c index ef631a4..d6ed757 100644 --- a/src/asm/expr.c +++ b/src/asm/expr.c @@ -26,12 +26,11 @@ */ #include "expr.h" -#include "chnkpool.h" +#include "chunkpool.h" #include "log.h" #include - static struct chunkpool s_expr_pool[1]; void expr_init() @@ -57,14 +56,14 @@ void expr_dump(int level, struct expr *e) case vNEG: LOG(level, ("expr %p unary op %d, referring to %p\n", (void*)e, e->expr_op, (void*)e->type.arg1)); - /* fall through */ case LNOT: LOG(level, ("expr %p unary op %d, referring to %p\n", (void*)e, e->expr_op, (void*)e->type.arg1)); break; default: LOG(level, ("expr %p binary op %d, arg1 %p, arg2 %p\n", - (void*)e, e->expr_op, (void*)e->type.arg1, (void*)e->expr_arg2)); + (void*)e, e->expr_op, (void*)e->type.arg1, + (void*)e->expr_arg2)); } } diff --git a/src/asm/expr.h b/src/asm/expr.h index 47809ac..258b358 100644 --- a/src/asm/expr.h +++ b/src/asm/expr.h @@ -29,7 +29,7 @@ */ #include "int.h" -#include "asmtab.h" +#include "asm.tab.h" union expr_type { diff --git a/src/asm/int.h b/src/asm/int.h index 3290b43..5b6a7c8 100644 --- a/src/asm/int.h +++ b/src/asm/int.h @@ -28,9 +28,9 @@ * */ -typedef char i8; -typedef short int i16; -typedef int i32; +typedef signed char i8; +typedef signed short int i16; +typedef signed int i32; typedef unsigned char u8; typedef unsigned short int u16; diff --git a/src/asm/lex.yy.c b/src/asm/lex.yy.c new file mode 100644 index 0000000..bac04e6 --- /dev/null +++ b/src/asm/lex.yy.c @@ -0,0 +1,2748 @@ + +#line 2 "lex.yy.c" + +#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 115 +#define YY_END_OF_BUFFER 116 +/* 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[260] = + { 0, + 0, 0, 0, 0, 0, 0, 111, 111, 0, 0, + 0, 0, 116, 97, 96, 95, 97, 76, 17, 83, + 97, 88, 97, 79, 80, 86, 84, 81, 85, 97, + 87, 70, 82, 18, 72, 89, 73, 97, 94, 94, + 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, + 94, 94, 94, 91, 92, 97, 103, 102, 103, 103, + 110, 109, 110, 110, 111, 112, 114, 113, 114, 106, + 105, 95, 75, 71, 77, 0, 0, 0, 0, 0, + 0, 0, 0, 70, 74, 90, 94, 93, 94, 94, + 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, + + 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, + 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, + 94, 78, 102, 0, 0, 109, 0, 0, 111, 113, + 106, 105, 0, 0, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 28, 25, 66, 53, 54, + 51, 69, 56, 52, 55, 57, 58, 46, 40, 30, + 31, 32, 64, 60, 62, 27, 63, 59, 61, 50, + 49, 19, 20, 21, 65, 41, 26, 35, 37, 36, + 38, 68, 67, 48, 29, 47, 39, 22, 23, 24, + 45, 43, 33, 44, 34, 42, 0, 0, 98, 0, + + 107, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 8, 14, 0, 0, 0, 0, 0, 0, 16, + 0, 10, 2, 3, 0, 0, 0, 0, 0, 0, + 15, 99, 100, 0, 0, 0, 0, 4, 9, 0, + 0, 0, 0, 6, 101, 108, 0, 0, 11, 12, + 0, 0, 0, 7, 5, 13, 0, 104, 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, 5, 6, 7, 8, 9, 10, 1, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 20, 21, 22, + 23, 24, 25, 1, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 36, + 1, 1, 1, 1, 51, 1, 52, 53, 54, 55, + + 56, 57, 58, 59, 60, 61, 36, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 36, 1, 76, 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, 1 + } ; + +static const YY_CHAR yy_meta[77] = + { 0, + 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 3, 1, 4, 5, + 1, 1, 1, 1, 1, 4, 4, 4, 4, 4, + 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 4, 4, 4, 4, 4, 4, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 1 + } ; + +static const flex_int16_t yy_base[269] = + { 0, + 0, 0, 74, 76, 78, 80, 584, 583, 82, 84, + 571, 570, 586, 591, 591, 591, 582, 561, 591, 591, + 0, 591, 573, 591, 591, 591, 591, 591, 591, 71, + 591, 563, 591, 591, 591, 558, 591, 557, 74, 125, + 84, 72, 70, 559, 69, 79, 129, 76, 131, 134, + 92, 150, 166, 558, 557, 500, 591, 591, 572, 122, + 591, 591, 571, 153, 0, 591, 591, 591, 570, 0, + 177, 591, 591, 0, 591, 65, 145, 180, 173, 150, + 122, 170, 171, 553, 591, 591, 551, 591, 201, 202, + 208, 218, 185, 194, 229, 223, 230, 231, 248, 240, + + 241, 245, 254, 260, 257, 258, 287, 284, 264, 291, + 292, 305, 304, 227, 204, 320, 329, 301, 318, 333, + 343, 591, 591, 345, 272, 591, 306, 311, 0, 591, + 0, 553, 325, 320, 329, 340, 353, 359, 340, 591, + 363, 365, 362, 352, 355, 549, 548, 547, 546, 545, + 544, 543, 542, 541, 540, 539, 538, 537, 536, 533, + 527, 497, 495, 494, 492, 489, 488, 486, 484, 482, + 479, 478, 476, 474, 468, 437, 428, 409, 336, 312, + 308, 273, 266, 263, 249, 246, 236, 234, 205, 149, + 148, 141, 140, 110, 100, 87, 366, 372, 591, 376, + + 591, 377, 381, 378, 375, 385, 388, 390, 388, 406, + 387, 591, 591, 396, 403, 406, 405, 407, 407, 591, + 407, 591, 591, 591, 416, 406, 418, 426, 418, 421, + 591, 591, 591, 432, 433, 440, 439, 591, 591, 436, + 437, 448, 437, 591, 591, 591, 453, 455, 591, 591, + 455, 458, 448, 591, 591, 591, 453, 591, 591, 518, + 523, 528, 533, 538, 102, 540, 545, 550 + } ; + +static const flex_int16_t yy_def[269] = + { 0, + 259, 1, 260, 260, 261, 261, 262, 262, 263, 263, + 264, 264, 259, 259, 259, 259, 259, 259, 259, 259, + 265, 259, 259, 259, 259, 259, 259, 259, 259, 259, + 259, 259, 259, 259, 259, 259, 259, 259, 266, 266, + 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, + 266, 266, 266, 266, 266, 259, 259, 259, 259, 259, + 259, 259, 259, 259, 267, 259, 259, 259, 259, 268, + 259, 259, 259, 265, 259, 259, 259, 259, 259, 259, + 259, 259, 259, 259, 259, 259, 266, 259, 266, 266, + 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, + + 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, + 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, + 266, 259, 259, 259, 259, 259, 259, 259, 267, 259, + 268, 259, 259, 259, 259, 259, 259, 259, 259, 259, + 259, 259, 259, 259, 259, 266, 266, 266, 266, 266, + 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, + 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, + 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, + 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, + 266, 266, 266, 266, 266, 266, 259, 259, 259, 259, + + 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, + 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, + 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, + 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, + 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, + 259, 259, 259, 259, 259, 259, 259, 259, 0, 259, + 259, 259, 259, 259, 259, 259, 259, 259 + } ; + +static const flex_int16_t yy_nxt[668] = + { 0, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, + 44, 44, 44, 45, 46, 44, 47, 44, 48, 49, + 50, 44, 51, 52, 53, 44, 44, 44, 54, 55, + 14, 39, 40, 41, 42, 43, 44, 44, 44, 45, + 46, 47, 44, 48, 49, 50, 44, 51, 52, 53, + 44, 44, 44, 54, 55, 56, 58, 59, 58, 59, + 62, 63, 62, 63, 68, 69, 68, 69, 88, 88, + 60, 88, 60, 88, 64, 88, 64, 76, 88, 77, + + 78, 102, 89, 88, 79, 74, 88, 104, 80, 103, + 81, 88, 90, 82, 134, 109, 105, 91, 83, 88, + 99, 100, 106, 76, 101, 77, 78, 102, 89, 88, + 79, 113, 104, 80, 103, 81, 114, 90, 82, 134, + 109, 105, 91, 83, 88, 99, 100, 106, 88, 101, + 88, 124, 92, 88, 93, 125, 113, 107, 94, 88, + 88, 114, 95, 96, 143, 97, 111, 88, 88, 88, + 112, 98, 108, 110, 135, 142, 115, 124, 92, 116, + 93, 125, 127, 107, 94, 88, 128, 95, 96, 143, + 97, 118, 111, 132, 117, 112, 98, 108, 110, 144, + + 135, 142, 115, 140, 88, 116, 133, 136, 127, 119, + 145, 141, 128, 88, 120, 121, 137, 118, 138, 117, + 88, 88, 139, 88, 88, 144, 151, 88, 146, 140, + 147, 185, 133, 136, 119, 145, 141, 88, 152, 120, + 121, 137, 88, 138, 148, 149, 88, 139, 88, 88, + 88, 151, 154, 88, 146, 88, 147, 185, 156, 88, + 88, 150, 153, 152, 88, 88, 155, 88, 88, 148, + 184, 149, 163, 88, 157, 158, 88, 88, 154, 88, + 160, 159, 88, 88, 156, 88, 150, 167, 153, 161, + 162, 155, 88, 164, 165, 184, 166, 170, 163, 157, + + 171, 158, 199, 88, 176, 160, 88, 159, 168, 169, + 88, 88, 172, 167, 161, 162, 177, 178, 164, 165, + 88, 166, 170, 88, 88, 171, 175, 88, 199, 176, + 180, 88, 179, 168, 169, 173, 174, 88, 172, 88, + 182, 201, 177, 178, 200, 181, 183, 186, 88, 191, + 192, 175, 88, 187, 188, 88, 180, 179, 194, 204, + 173, 174, 88, 202, 203, 182, 193, 201, 196, 200, + 181, 183, 205, 186, 191, 192, 195, 189, 190, 187, + 188, 197, 209, 198, 194, 204, 206, 208, 202, 203, + 210, 193, 211, 212, 196, 213, 207, 214, 205, 215, + + 217, 195, 189, 190, 218, 219, 197, 209, 198, 216, + 220, 221, 206, 208, 222, 223, 210, 224, 211, 212, + 213, 207, 214, 225, 231, 215, 217, 226, 88, 230, + 218, 219, 227, 232, 216, 233, 220, 221, 234, 222, + 235, 223, 228, 224, 236, 237, 238, 88, 239, 225, + 231, 240, 226, 229, 230, 241, 88, 243, 227, 232, + 244, 233, 245, 246, 234, 247, 235, 228, 248, 236, + 237, 242, 238, 239, 249, 250, 251, 240, 229, 252, + 253, 241, 243, 254, 255, 244, 256, 88, 245, 246, + 257, 247, 258, 88, 248, 88, 242, 88, 88, 249, + + 250, 88, 251, 88, 252, 88, 253, 88, 88, 254, + 255, 88, 256, 88, 88, 257, 88, 258, 57, 57, + 57, 57, 57, 61, 61, 61, 61, 61, 65, 65, + 65, 65, 65, 67, 67, 67, 67, 67, 70, 70, + 70, 70, 70, 87, 87, 129, 88, 129, 129, 129, + 131, 131, 88, 131, 131, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 132, + 88, 84, 130, 126, 123, 122, 88, 88, 88, 86, + 85, 84, 75, 73, 72, 259, 71, 71, 66, 66, + 13, 259, 259, 259, 259, 259, 259, 259, 259, 259, + + 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, + 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, + 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, + 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, + 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, + 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, + 259, 259, 259, 259, 259, 259, 259 + } ; + +static const flex_int16_t yy_chk[668] = + { 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, 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, 3, 3, 4, 4, + 5, 5, 6, 6, 9, 9, 10, 10, 45, 43, + 3, 42, 4, 39, 5, 48, 6, 30, 46, 30, + + 30, 42, 39, 41, 30, 265, 196, 45, 30, 43, + 30, 51, 39, 30, 76, 48, 46, 39, 30, 195, + 41, 41, 46, 30, 41, 30, 30, 42, 39, 194, + 30, 51, 45, 30, 43, 30, 51, 39, 30, 76, + 48, 46, 39, 30, 40, 41, 41, 46, 47, 41, + 49, 60, 40, 50, 40, 60, 51, 47, 40, 193, + 192, 51, 40, 40, 81, 40, 50, 191, 190, 52, + 50, 40, 47, 49, 77, 80, 52, 60, 40, 52, + 40, 60, 64, 47, 40, 53, 64, 40, 40, 81, + 40, 53, 50, 71, 52, 50, 40, 47, 49, 82, + + 77, 80, 52, 79, 93, 52, 71, 78, 64, 53, + 83, 79, 64, 94, 53, 53, 78, 53, 78, 52, + 89, 90, 78, 115, 189, 82, 93, 91, 89, 79, + 90, 115, 71, 78, 53, 83, 79, 92, 94, 53, + 53, 78, 96, 78, 91, 92, 114, 78, 95, 97, + 98, 93, 96, 188, 89, 187, 90, 115, 98, 100, + 101, 92, 95, 94, 102, 186, 97, 99, 185, 91, + 114, 92, 102, 103, 98, 99, 105, 106, 96, 104, + 100, 99, 184, 109, 98, 183, 92, 104, 95, 101, + 101, 97, 182, 102, 102, 114, 103, 105, 102, 98, + + 106, 99, 125, 108, 109, 100, 107, 99, 104, 104, + 110, 111, 107, 104, 101, 101, 110, 111, 102, 102, + 118, 103, 105, 113, 112, 106, 108, 181, 125, 109, + 112, 180, 111, 104, 104, 107, 107, 119, 107, 116, + 113, 128, 110, 111, 127, 112, 113, 116, 117, 118, + 118, 108, 120, 116, 117, 179, 112, 111, 120, 135, + 107, 107, 121, 133, 134, 113, 119, 128, 121, 127, + 112, 113, 136, 116, 118, 118, 120, 117, 117, 116, + 117, 124, 139, 124, 120, 135, 137, 138, 133, 134, + 141, 119, 142, 143, 121, 144, 137, 145, 136, 197, + + 198, 120, 117, 117, 200, 202, 124, 139, 124, 197, + 203, 204, 137, 138, 205, 206, 141, 207, 142, 143, + 144, 137, 145, 208, 214, 197, 198, 209, 178, 211, + 200, 202, 210, 215, 197, 216, 203, 204, 217, 205, + 218, 206, 210, 207, 219, 221, 225, 177, 226, 208, + 214, 227, 209, 210, 211, 228, 176, 229, 210, 215, + 230, 216, 234, 235, 217, 236, 218, 210, 237, 219, + 221, 228, 225, 226, 240, 241, 242, 227, 210, 243, + 247, 228, 229, 248, 251, 230, 252, 175, 234, 235, + 253, 236, 257, 174, 237, 173, 228, 172, 171, 240, + + 241, 170, 242, 169, 243, 168, 247, 167, 166, 248, + 251, 165, 252, 164, 163, 253, 162, 257, 260, 260, + 260, 260, 260, 261, 261, 261, 261, 261, 262, 262, + 262, 262, 262, 263, 263, 263, 263, 263, 264, 264, + 264, 264, 264, 266, 266, 267, 161, 267, 267, 267, + 268, 268, 160, 268, 268, 159, 158, 157, 156, 155, + 154, 153, 152, 151, 150, 149, 148, 147, 146, 132, + 87, 84, 69, 63, 59, 56, 55, 54, 44, 38, + 36, 32, 23, 18, 17, 13, 12, 11, 8, 7, + 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, + + 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, + 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, + 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, + 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, + 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, + 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, + 259, 259, 259, 259, 259, 259, 259 + } ; + +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 "asm.yy" +/* + * Copyright (c) 2002 - 2005 Magnus Lind. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software, alter it and re- + * distribute it freely for any non-commercial, non-profit purpose subject to + * the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not + * be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any distribution. + * + * 4. The names of this software and/or it's copyright holders may not be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + */ +/* scanner for a simple assembler */ +#line 30 "asm.yy" +#include +#include +#include "int.h" +#include "membuf.h" +#include "parse.h" +#include "asm.tab.h" + +#define MAX_SRC_BUFFER_DEPTH 10 +static YY_BUFFER_STATE src_buffers[MAX_SRC_BUFFER_DEPTH]; +static int src_buffer_depth = 0; + +static char *strdupped_get(char *text); +static int strdupped_cmp(const void *a, const void *b); +static void strdupped_free(void *a); + +int num_lines = 1; +int push_state_skip = 0; +int push_state_init = 0; +int push_state_macro = 0; +struct vec strdupped[1]; + +#line 726 "lex.yy.c" + +#line 728 "lex.yy.c" + +#define INITIAL 0 +#define SKIP 1 +#define SKIP_ALL 2 +#define QUOTED_STRING 3 +#define SKIP_LINE 4 +#define MACROO 5 + +#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 + + static int yy_start_stack_ptr = 0; + static int yy_start_stack_depth = 0; + static int *yy_start_stack = NULL; + + static void yy_push_state ( int _new_state ); + + static void yy_pop_state ( void ); + + static int yy_top_state ( void ); + +/* 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 59 "asm.yy" + + +#line 62 "asm.yy" + if(push_state_init) + {push_state_init = 0; yy_push_state(INITIAL); } + if(push_state_skip) + {push_state_skip = 0; yy_push_state(SKIP); } + if(push_state_macro) + {push_state_macro = 0; yy_push_state(MACROO); } + +#line 971 "lex.yy.c" + + 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 >= 260 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_current_state != 259 ); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + +yy_find_action: + 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 69 "asm.yy" +return IF; + YY_BREAK +case 2: +YY_RULE_SETUP +#line 70 "asm.yy" +BEGIN(SKIP_ALL); + YY_BREAK +case 3: +YY_RULE_SETUP +#line 71 "asm.yy" +BEGIN(SKIP); + YY_BREAK +case 4: +YY_RULE_SETUP +#line 72 "asm.yy" +yy_pop_state(); + YY_BREAK +case 5: +YY_RULE_SETUP +#line 74 "asm.yy" +return INCLUDE; + YY_BREAK +case 6: +YY_RULE_SETUP +#line 75 "asm.yy" +return MACRO; + YY_BREAK +case 7: +YY_RULE_SETUP +#line 77 "asm.yy" +return DEFINED; + YY_BREAK +case 8: +YY_RULE_SETUP +#line 78 "asm.yy" +return ORG; + YY_BREAK +case 9: +YY_RULE_SETUP +#line 79 "asm.yy" +return ERROR; + YY_BREAK +case 10: +YY_RULE_SETUP +#line 80 "asm.yy" +return ECHO1; + YY_BREAK +case 11: +YY_RULE_SETUP +#line 81 "asm.yy" +return INCBIN; + YY_BREAK +case 12: +YY_RULE_SETUP +#line 82 "asm.yy" +return INCLEN; + YY_BREAK +case 13: +YY_RULE_SETUP +#line 83 "asm.yy" +return INCWORD; + YY_BREAK +case 14: +YY_RULE_SETUP +#line 84 "asm.yy" +return RES; + YY_BREAK +case 15: +YY_RULE_SETUP +#line 85 "asm.yy" +return WORD; + YY_BREAK +case 16: +YY_RULE_SETUP +#line 86 "asm.yy" +return BYTE; + YY_BREAK +case 17: +YY_RULE_SETUP +#line 88 "asm.yy" +BEGIN(QUOTED_STRING); + YY_BREAK +case 18: +YY_RULE_SETUP +#line 89 "asm.yy" +BEGIN(SKIP_LINE); + YY_BREAK +case 19: +YY_RULE_SETUP +#line 91 "asm.yy" +return LDA; + YY_BREAK +case 20: +YY_RULE_SETUP +#line 92 "asm.yy" +return LDX; + YY_BREAK +case 21: +YY_RULE_SETUP +#line 93 "asm.yy" +return LDY; + YY_BREAK +case 22: +YY_RULE_SETUP +#line 94 "asm.yy" +return STA; + YY_BREAK +case 23: +YY_RULE_SETUP +#line 95 "asm.yy" +return STX; + YY_BREAK +case 24: +YY_RULE_SETUP +#line 96 "asm.yy" +return STY; + YY_BREAK +case 25: +YY_RULE_SETUP +#line 97 "asm.yy" +return AND; + YY_BREAK +case 26: +YY_RULE_SETUP +#line 98 "asm.yy" +return ORA; + YY_BREAK +case 27: +YY_RULE_SETUP +#line 99 "asm.yy" +return EOR; + YY_BREAK +case 28: +YY_RULE_SETUP +#line 100 "asm.yy" +return ADC; + YY_BREAK +case 29: +YY_RULE_SETUP +#line 101 "asm.yy" +return SBC; + YY_BREAK +case 30: +YY_RULE_SETUP +#line 102 "asm.yy" +return CMP; + YY_BREAK +case 31: +YY_RULE_SETUP +#line 103 "asm.yy" +return CPX; + YY_BREAK +case 32: +YY_RULE_SETUP +#line 104 "asm.yy" +return CPY; + YY_BREAK +case 33: +YY_RULE_SETUP +#line 106 "asm.yy" +return TSX; + YY_BREAK +case 34: +YY_RULE_SETUP +#line 107 "asm.yy" +return TXS; + YY_BREAK +case 35: +YY_RULE_SETUP +#line 108 "asm.yy" +return PHA; + YY_BREAK +case 36: +YY_RULE_SETUP +#line 109 "asm.yy" +return PLA; + YY_BREAK +case 37: +YY_RULE_SETUP +#line 110 "asm.yy" +return PHP; + YY_BREAK +case 38: +YY_RULE_SETUP +#line 111 "asm.yy" +return PLP; + YY_BREAK +case 39: +YY_RULE_SETUP +#line 112 "asm.yy" +return SEI; + YY_BREAK +case 40: +YY_RULE_SETUP +#line 113 "asm.yy" +return CLI; + YY_BREAK +case 41: +YY_RULE_SETUP +#line 114 "asm.yy" +return NOP; + YY_BREAK +case 42: +YY_RULE_SETUP +#line 115 "asm.yy" +return TYA; + YY_BREAK +case 43: +YY_RULE_SETUP +#line 116 "asm.yy" +return TAY; + YY_BREAK +case 44: +YY_RULE_SETUP +#line 117 "asm.yy" +return TXA; + YY_BREAK +case 45: +YY_RULE_SETUP +#line 118 "asm.yy" +return TAX; + YY_BREAK +case 46: +YY_RULE_SETUP +#line 119 "asm.yy" +return CLC; + YY_BREAK +case 47: +YY_RULE_SETUP +#line 120 "asm.yy" +return SEC; + YY_BREAK +case 48: +YY_RULE_SETUP +#line 121 "asm.yy" +return RTS; + YY_BREAK +case 49: +YY_RULE_SETUP +#line 123 "asm.yy" +return JSR; + YY_BREAK +case 50: +YY_RULE_SETUP +#line 124 "asm.yy" +return JMP; + YY_BREAK +case 51: +YY_RULE_SETUP +#line 125 "asm.yy" +return BEQ; + YY_BREAK +case 52: +YY_RULE_SETUP +#line 126 "asm.yy" +return BNE; + YY_BREAK +case 53: +YY_RULE_SETUP +#line 127 "asm.yy" +return BCC; + YY_BREAK +case 54: +YY_RULE_SETUP +#line 128 "asm.yy" +return BCS; + YY_BREAK +case 55: +YY_RULE_SETUP +#line 129 "asm.yy" +return BPL; + YY_BREAK +case 56: +YY_RULE_SETUP +#line 130 "asm.yy" +return BMI; + YY_BREAK +case 57: +YY_RULE_SETUP +#line 131 "asm.yy" +return BVC; + YY_BREAK +case 58: +YY_RULE_SETUP +#line 132 "asm.yy" +return BCS; + YY_BREAK +case 59: +YY_RULE_SETUP +#line 133 "asm.yy" +return INX; + YY_BREAK +case 60: +YY_RULE_SETUP +#line 134 "asm.yy" +return DEX; + YY_BREAK +case 61: +YY_RULE_SETUP +#line 135 "asm.yy" +return INY; + YY_BREAK +case 62: +YY_RULE_SETUP +#line 136 "asm.yy" +return DEY; + YY_BREAK +case 63: +YY_RULE_SETUP +#line 137 "asm.yy" +return INC; + YY_BREAK +case 64: +YY_RULE_SETUP +#line 138 "asm.yy" +return DEC; + YY_BREAK +case 65: +YY_RULE_SETUP +#line 139 "asm.yy" +return LSR; + YY_BREAK +case 66: +YY_RULE_SETUP +#line 140 "asm.yy" +return ASL; + YY_BREAK +case 67: +YY_RULE_SETUP +#line 141 "asm.yy" +return ROR; + YY_BREAK +case 68: +YY_RULE_SETUP +#line 142 "asm.yy" +return ROL; + YY_BREAK +case 69: +YY_RULE_SETUP +#line 143 "asm.yy" +return BIT; + YY_BREAK +case 70: +YY_RULE_SETUP +#line 145 "asm.yy" +{ yylval.num = atoi(yytext); return NUMBER; } + YY_BREAK +case 71: +YY_RULE_SETUP +#line 147 "asm.yy" +{ yylval.num = strtol(yytext + 1, NULL, 16); return NUMBER; } + YY_BREAK +case 72: +YY_RULE_SETUP +#line 149 "asm.yy" +return LT; + YY_BREAK +case 73: +YY_RULE_SETUP +#line 150 "asm.yy" +return GT; + YY_BREAK +case 74: +YY_RULE_SETUP +#line 151 "asm.yy" +return EQ; + YY_BREAK +case 75: +YY_RULE_SETUP +#line 152 "asm.yy" +return NEQ; + YY_BREAK +case 76: +YY_RULE_SETUP +#line 153 "asm.yy" +return LNOT; + YY_BREAK +case 77: +YY_RULE_SETUP +#line 154 "asm.yy" +return LAND; + YY_BREAK +case 78: +YY_RULE_SETUP +#line 155 "asm.yy" +return LOR; + YY_BREAK +case 79: +YY_RULE_SETUP +#line 157 "asm.yy" +return LPAREN; + YY_BREAK +case 80: +YY_RULE_SETUP +#line 158 "asm.yy" +return RPAREN; + YY_BREAK +case 81: +YY_RULE_SETUP +#line 159 "asm.yy" +return COMMA; + YY_BREAK +case 82: +YY_RULE_SETUP +#line 160 "asm.yy" +return COLON; + YY_BREAK +case 83: +YY_RULE_SETUP +#line 161 "asm.yy" +return HASH; + YY_BREAK +case 84: +YY_RULE_SETUP +#line 162 "asm.yy" +return PLUS; + YY_BREAK +case 85: +YY_RULE_SETUP +#line 163 "asm.yy" +return MINUS; + YY_BREAK +case 86: +YY_RULE_SETUP +#line 164 "asm.yy" +return MULT; + YY_BREAK +case 87: +YY_RULE_SETUP +#line 165 "asm.yy" +return DIV; + YY_BREAK +case 88: +YY_RULE_SETUP +#line 166 "asm.yy" +return MOD; + YY_BREAK +case 89: +YY_RULE_SETUP +#line 168 "asm.yy" +return ASSIGN; + YY_BREAK +case 90: +YY_RULE_SETUP +#line 169 "asm.yy" +return GUESS; + YY_BREAK +case 91: +YY_RULE_SETUP +#line 171 "asm.yy" +return X; + YY_BREAK +case 92: +YY_RULE_SETUP +#line 172 "asm.yy" +return Y; + YY_BREAK +case 93: +*yy_cp = (yy_hold_char); /* undo effects of setting up yytext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up yytext again */ +YY_RULE_SETUP +#line 174 "asm.yy" +{ yylval.str = strdupped_get(yytext); return LABEL; } + YY_BREAK +case 94: +YY_RULE_SETUP +#line 175 "asm.yy" +{ yylval.str = strdupped_get(yytext); return SYMBOL; } + YY_BREAK +case 95: +/* rule 95 can match eol */ +YY_RULE_SETUP +#line 177 "asm.yy" +++num_lines; + YY_BREAK +case 96: +YY_RULE_SETUP +#line 179 "asm.yy" +/* eat whitespace */ + YY_BREAK +case 97: +YY_RULE_SETUP +#line 181 "asm.yy" +printf("unknown character found %s\n", yytext); + YY_BREAK +case 98: +YY_RULE_SETUP +#line 183 "asm.yy" +yy_push_state(SKIP_ALL); + YY_BREAK +case 99: +YY_RULE_SETUP +#line 184 "asm.yy" +{ yy_pop_state(); return IF; } + YY_BREAK +case 100: +YY_RULE_SETUP +#line 185 "asm.yy" +BEGIN(INITIAL); + YY_BREAK +case 101: +YY_RULE_SETUP +#line 186 "asm.yy" +yy_pop_state(); + YY_BREAK +case 102: +/* rule 102 can match eol */ +YY_RULE_SETUP +#line 187 "asm.yy" +++num_lines; + YY_BREAK +case 103: +YY_RULE_SETUP +#line 188 "asm.yy" + + YY_BREAK +case 104: +YY_RULE_SETUP +#line 190 "asm.yy" +yy_pop_state(); + YY_BREAK +case 105: +YY_RULE_SETUP +#line 191 "asm.yy" +{ yylval.str = yytext; return MACRO_STRING; } + YY_BREAK +case 106: +/* rule 106 can match eol */ +YY_RULE_SETUP +#line 192 "asm.yy" +{ yylval.str = yytext; return MACRO_STRING; } + YY_BREAK +case 107: +YY_RULE_SETUP +#line 194 "asm.yy" +yy_push_state(SKIP_ALL); + YY_BREAK +case 108: +YY_RULE_SETUP +#line 195 "asm.yy" +yy_pop_state(); + YY_BREAK +case 109: +/* rule 109 can match eol */ +YY_RULE_SETUP +#line 196 "asm.yy" +++num_lines; + YY_BREAK +case 110: +YY_RULE_SETUP +#line 197 "asm.yy" + + YY_BREAK +case 111: +/* rule 111 can match eol */ +YY_RULE_SETUP +#line 199 "asm.yy" +{ + /* multi-line string with correct line count */ + char *p = strdupped_get(yytext); + yylval.str = p; + while (*p != '\0') + { + if (*p++ == '\n') + { + ++num_lines; + } + } + return STRING; +} + YY_BREAK +case 112: +YY_RULE_SETUP +#line 212 "asm.yy" +BEGIN(INITIAL); + YY_BREAK +case 113: +/* rule 113 can match eol */ +YY_RULE_SETUP +#line 214 "asm.yy" +{ ++num_lines; BEGIN(INITIAL); } + YY_BREAK +case 114: +YY_RULE_SETUP +#line 215 "asm.yy" + + YY_BREAK +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(SKIP): +case YY_STATE_EOF(SKIP_ALL): +case YY_STATE_EOF(QUOTED_STRING): +case YY_STATE_EOF(SKIP_LINE): +case YY_STATE_EOF(MACROO): +#line 217 "asm.yy" +{ + if(--src_buffer_depth == 0) + { + yyterminate(); + } + else + { + yy_delete_buffer(YY_CURRENT_BUFFER); + yy_switch_to_buffer(src_buffers[src_buffer_depth]); + } + } + YY_BREAK +case 115: +YY_RULE_SETUP +#line 229 "asm.yy" +ECHO; + YY_BREAK +#line 1639 "lex.yy.c" + + 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_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + 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 >= 260 ) + 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 >= 260 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 259); + + 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; +} + + static void 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); +} + + static void yy_pop_state (void) +{ + if ( --(yy_start_stack_ptr) < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); +} + + static int yy_top_state (void) +{ + return (yy_start_stack)[(yy_start_stack_ptr) - 1]; +} + +#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; + + (yy_start_stack_ptr) = 0; + (yy_start_stack_depth) = 0; + (yy_start_stack) = NULL; + +/* 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; + + /* Destroy the start condition stack. */ + yyfree( (yy_start_stack) ); + (yy_start_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 229 "asm.yy" + + +void scanner_init(void) +{ + vec_init(strdupped, sizeof(char*)); +} + +void asm_src_buffer_push(struct membuf *buffer) +{ + if(src_buffer_depth == MAX_SRC_BUFFER_DEPTH) + { + fprintf(stderr, "source buffers nested too deep\n"); + exit(1); + } + src_buffers[src_buffer_depth++] = YY_CURRENT_BUFFER; + yy_scan_bytes(membuf_get(buffer), membuf_memlen(buffer)); +} + +static char *strdupped_get(char *text) +{ + char **pp; + /*printf("get \"%s\" => ", text);*/ + if(vec_insert_uniq(strdupped, strdupped_cmp, &text, (void*)&pp)) + { + /* replace the pointer to since will be reused */ + *pp = strdup(text); + } + /*printf("%p\n", *pp);*/ + return *pp; +} + +static void strdupped_free(void *a) +{ + char *b = *(char**)a; + /*printf("free => %p \"%s\"\n", b, b);*/ + free(b); +} + +static int strdupped_cmp(const void *a, const void *b) +{ + char *c = *(char**)a; + char *d = *(char**)b; + + return strcmp(c, d); +} + +void scanner_free(void) +{ + vec_free(strdupped, strdupped_free); +} + + +void silence_warnings_about_unused_functions(void) +{ + yyunput(0, NULL); + input(); + yy_top_state(); +} + diff --git a/src/asm/lexyy.c b/src/asm/lexyy.c deleted file mode 100644 index e87c444..0000000 --- a/src/asm/lexyy.c +++ /dev/null @@ -1,2323 +0,0 @@ -/* A lexical scanner generated by flex */ - -/* Scanner skeleton version: - * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $ - */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 - -#include -#include - - -/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ -#ifdef c_plusplus -#ifndef __cplusplus -#define __cplusplus -#endif -#endif - - -#ifdef __cplusplus - -#include - -/* Use prototypes in function declarations. */ -#define YY_USE_PROTOS - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -#if __STDC__ - -#define YY_USE_PROTOS -#define YY_USE_CONST - -#endif /* __STDC__ */ -#endif /* ! __cplusplus */ - -#ifdef __TURBOC__ - #pragma warn -rch - #pragma warn -use -#include -#include -#define YY_USE_CONST -#define YY_USE_PROTOS -#endif - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - - -#ifdef YY_USE_PROTOS -#define YY_PROTO(proto) proto -#else -#define YY_PROTO(proto) () -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned 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. */ -#define YY_BUF_SIZE 16384 - -typedef struct yy_buffer_state *YY_BUFFER_STATE; - -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 - -/* The funky do-while in the following #define is used to turn the definition - * int a single C statement (which needs a semi-colon terminator). This - * avoids problems with code like: - * - * if ( condition_holds ) - * yyless( 5 ); - * else - * do_something_else(); - * - * Prior to using the do-while the compiler would get upset at the - * "else" because it interpreted the "if" statement as being all - * done when it reached the ';' after the yyless() call. - */ - -/* Return all but the first 'n' matched characters back to the input stream. */ - -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - *yy_cp = yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, yytext_ptr ) - -/* The following is because we cannot portably get our hands on size_t - * (without autoconf's help, which isn't available because we want - * flex-generated scanners to compile on their own). - */ -typedef unsigned int yy_size_t; - - -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. - */ - yy_size_t 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; - - /* 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 - }; - -static YY_BUFFER_STATE yy_current_buffer = 0; - -/* 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". - */ -#define YY_CURRENT_BUFFER yy_current_buffer - - -/* 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 = (char *) 0; -static int yy_init = 1; /* 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 YY_PROTO(( FILE *input_file )); - -void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); -void yy_load_buffer_state YY_PROTO(( void )); -YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); -void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); -void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); -void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); -#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) - -YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); -YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); -YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); - -static void *yy_flex_alloc YY_PROTO(( yy_size_t )); -static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); -static void yy_flex_free YY_PROTO(( void * )); - -#define yy_new_buffer yy_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! yy_current_buffer ) \ - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ - yy_current_buffer->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! yy_current_buffer ) \ - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ - yy_current_buffer->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) - - -#define yywrap() 1 -#define YY_SKIP_YYWRAP -typedef unsigned char YY_CHAR; -FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; -typedef int yy_state_type; -extern char *yytext; -#define yytext_ptr yytext - -static yy_state_type yy_get_previous_state YY_PROTO(( void )); -static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); -static int yy_get_next_buffer YY_PROTO(( void )); -static void yy_fatal_error YY_PROTO(( yyconst 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 111 -#define YY_END_OF_BUFFER 112 -static yyconst short int yy_accept[256] = - { 0, - 0, 0, 0, 0, 0, 0, 107, 107, 0, 0, - 0, 0, 112, 93, 92, 91, 93, 74, 16, 81, - 93, 86, 93, 77, 78, 84, 82, 79, 83, 93, - 85, 68, 80, 17, 70, 87, 71, 90, 90, 90, - 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 90, 90, 88, 89, 93, 99, 98, 99, 99, 106, - 105, 106, 106, 107, 107, 107, 109, 111, 110, 111, - 102, 101, 91, 73, 69, 75, 0, 0, 0, 0, - 0, 0, 0, 0, 68, 72, 90, 90, 90, 90, - 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - - 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, - 90, 90, 90, 90, 90, 90, 90, 90, 90, 76, - 98, 0, 0, 105, 0, 0, 107, 107, 110, 102, - 101, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 27, 24, 65, 52, 53, 50, - 55, 51, 54, 56, 57, 45, 39, 29, 30, 31, - 63, 59, 61, 26, 62, 58, 60, 49, 48, 18, - 19, 20, 64, 40, 25, 34, 36, 35, 37, 67, - 66, 47, 28, 46, 38, 21, 22, 23, 44, 42, - 32, 43, 33, 41, 0, 0, 94, 0, 103, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, - 13, 0, 0, 0, 0, 0, 0, 15, 0, 10, - 2, 3, 0, 0, 0, 0, 0, 0, 14, 95, - 96, 0, 0, 0, 0, 4, 9, 0, 0, 0, - 6, 97, 104, 0, 0, 11, 0, 0, 0, 7, - 5, 12, 0, 100, 0 - } ; - -static yyconst int 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, 5, 6, 7, 8, 9, 10, 1, 11, - 12, 13, 14, 15, 16, 17, 18, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 20, 21, 22, - 23, 24, 1, 1, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42, 43, 44, 45, 46, 47, 48, 49, 50, 36, - 1, 1, 1, 1, 25, 1, 26, 27, 28, 29, - - 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 50, 36, 1, 51, 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, 1 - } ; - -static yyconst int yy_meta[52] = - { 0, - 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 3, 1, 4, 1, - 1, 1, 1, 1, 5, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 1 - } ; - -static yyconst short int yy_base[265] = - { 0, - 0, 0, 49, 51, 53, 55, 57, 61, 70, 72, - 275, 274, 290, 293, 293, 293, 286, 265, 293, 293, - 0, 293, 277, 293, 293, 293, 293, 293, 293, 50, - 293, 267, 293, 293, 293, 262, 293, 42, 61, 66, - 254, 243, 0, 243, 57, 53, 241, 237, 50, 65, - 79, 68, 0, 0, 228, 293, 293, 275, 62, 293, - 293, 274, 81, 0, 0, 273, 293, 293, 293, 272, - 0, 96, 293, 293, 0, 293, 224, 243, 86, 88, - 246, 228, 240, 229, 249, 293, 0, 239, 237, 228, - 34, 222, 229, 232, 224, 41, 88, 219, 71, 100, - - 216, 102, 217, 214, 105, 213, 214, 228, 106, 107, - 97, 209, 224, 107, 110, 88, 202, 113, 224, 293, - 293, 105, 218, 293, 209, 216, 0, 0, 293, 0, - 229, 206, 199, 212, 209, 109, 212, 197, 293, 211, - 210, 205, 192, 192, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 112, 205, 293, 204, 293, 203, - - 201, 196, 189, 197, 197, 192, 185, 131, 181, 293, - 293, 194, 191, 191, 186, 185, 180, 293, 178, 293, - 293, 293, 183, 165, 144, 131, 136, 135, 293, 293, - 293, 143, 142, 146, 141, 293, 293, 131, 140, 124, - 293, 293, 293, 138, 136, 293, 134, 134, 119, 293, - 293, 293, 121, 293, 293, 179, 184, 189, 194, 199, - 141, 201, 206, 211 - } ; - -static yyconst short int yy_def[265] = - { 0, - 255, 1, 256, 256, 257, 257, 258, 258, 259, 259, - 260, 260, 255, 255, 255, 255, 255, 255, 255, 255, - 261, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 262, 262, 262, - 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, - 262, 262, 262, 262, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 263, 263, 263, 255, 255, 255, 255, - 264, 255, 255, 255, 261, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 262, 262, 262, 262, - 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, - - 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, - 262, 262, 262, 262, 262, 262, 262, 262, 262, 255, - 255, 255, 255, 255, 255, 255, 263, 263, 255, 264, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 262, 262, 262, 262, 262, 262, - 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, - 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, - 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, - 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, - 262, 262, 262, 262, 255, 255, 255, 255, 255, 255, - - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, - 255, 255, 255, 255 - } ; - -static yyconst short int yy_nxt[345] = - { 0, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 14, 38, 39, 40, 41, 42, - 43, 43, 43, 44, 45, 43, 46, 43, 47, 48, - 49, 43, 50, 51, 52, 43, 43, 43, 53, 54, - 55, 57, 58, 57, 58, 61, 62, 61, 62, 65, - 66, 148, 67, 65, 66, 59, 67, 59, 154, 63, - 88, 63, 69, 70, 69, 70, 77, 149, 78, 79, - 89, 105, 109, 80, 155, 90, 110, 81, 91, 82, - 92, 122, 83, 116, 103, 123, 106, 84, 93, 94, - - 104, 95, 97, 98, 111, 113, 99, 96, 114, 112, - 125, 117, 131, 135, 126, 156, 118, 119, 139, 159, - 160, 157, 136, 115, 137, 132, 140, 161, 138, 165, - 170, 176, 178, 180, 184, 186, 189, 190, 192, 181, - 185, 195, 204, 196, 75, 213, 177, 179, 162, 163, - 166, 167, 205, 171, 172, 214, 193, 225, 187, 188, - 254, 253, 252, 251, 250, 249, 248, 226, 247, 246, - 245, 244, 243, 242, 241, 240, 239, 238, 227, 56, - 56, 56, 56, 56, 60, 60, 60, 60, 60, 64, - 64, 64, 64, 64, 68, 68, 68, 68, 68, 71, - - 71, 71, 71, 71, 87, 87, 127, 237, 127, 127, - 127, 130, 130, 236, 130, 130, 235, 234, 233, 232, - 231, 230, 229, 228, 224, 223, 222, 221, 220, 219, - 218, 217, 216, 215, 212, 211, 210, 209, 208, 207, - 206, 203, 202, 201, 200, 131, 199, 198, 197, 194, - 191, 183, 182, 175, 174, 173, 169, 168, 164, 158, - 153, 152, 151, 150, 147, 146, 145, 85, 144, 143, - 142, 141, 134, 133, 129, 128, 124, 121, 120, 108, - 107, 102, 101, 100, 86, 85, 76, 74, 73, 255, - 72, 72, 13, 255, 255, 255, 255, 255, 255, 255, - - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255 - } ; - -static yyconst short int yy_chk[345] = - { 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, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 3, 3, 4, 4, 5, 5, 6, 6, 7, - 7, 91, 7, 8, 8, 3, 8, 4, 96, 5, - 38, 6, 9, 9, 10, 10, 30, 91, 30, 30, - 38, 46, 49, 30, 96, 38, 49, 30, 39, 30, - 39, 59, 30, 52, 45, 59, 46, 30, 39, 39, - - 45, 39, 40, 40, 50, 51, 40, 39, 51, 50, - 63, 52, 72, 79, 63, 97, 52, 52, 80, 99, - 99, 97, 79, 51, 79, 72, 80, 100, 79, 102, - 105, 109, 110, 111, 114, 115, 116, 116, 118, 111, - 114, 122, 136, 122, 261, 195, 109, 110, 100, 100, - 102, 102, 136, 105, 105, 195, 118, 208, 115, 115, - 253, 249, 248, 247, 245, 244, 240, 208, 239, 238, - 235, 234, 233, 232, 228, 227, 226, 225, 208, 256, - 256, 256, 256, 256, 257, 257, 257, 257, 257, 258, - 258, 258, 258, 258, 259, 259, 259, 259, 259, 260, - - 260, 260, 260, 260, 262, 262, 263, 224, 263, 263, - 263, 264, 264, 223, 264, 264, 219, 217, 216, 215, - 214, 213, 212, 209, 207, 206, 205, 204, 203, 202, - 201, 200, 198, 196, 144, 143, 142, 141, 140, 138, - 137, 135, 134, 133, 132, 131, 126, 125, 123, 119, - 117, 113, 112, 108, 107, 106, 104, 103, 101, 98, - 95, 94, 93, 92, 90, 89, 88, 85, 84, 83, - 82, 81, 78, 77, 70, 66, 62, 58, 55, 48, - 47, 44, 42, 41, 36, 32, 23, 18, 17, 13, - 12, 11, 255, 255, 255, 255, 255, 255, 255, 255, - - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255 - } ; - -static yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; - -/* 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 "asm.yy" -#define INITIAL 0 -/* scanner for a simple assembler */ -// #line 3 "asm.yy" -#include -#include -#include "int.h" -#include "membuf.h" -#include "parse.h" -#include "asmtab.h" - - - -#define MAX_SRC_BUFFER_DEPTH 10 -static YY_BUFFER_STATE src_buffers[MAX_SRC_BUFFER_DEPTH]; -static int src_buffer_depth = 0; - -static char *strdupped_get(char *text); -static int strdupped_cmp(const void *a, const void *b); -static void strdupped_free(void *a); - -int num_lines = 1; -int push_state_skip = 0; -int push_state_init = 0; -int push_state_macro = 0; -struct vec strdupped[1]; - -#define SKIP 1 -#define SKIP_ALL 2 -#define QUOTED_STRING 3 -#define SKIP_LINE 4 -#define MACROO 5 - -#define YY_STACK_USED 1 -// #line 558 "lex.yy.c" - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap YY_PROTO(( void )); -#else -extern int yywrap YY_PROTO(( void )); -#endif -#endif - -#ifndef YY_NO_UNPUT -static void yyunput YY_PROTO(( int c, char *buf_ptr )); -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen YY_PROTO(( yyconst char * )); -#endif - -#ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput YY_PROTO(( void )); -#else -static int input YY_PROTO(( void )); -#endif -#endif - -#if YY_STACK_USED -static int yy_start_stack_ptr = 0; -static int yy_start_stack_depth = 0; -static int *yy_start_stack = 0; -#ifndef YY_NO_PUSH_STATE -static void yy_push_state YY_PROTO(( int new_state )); -#endif -#ifndef YY_NO_POP_STATE -static void yy_pop_state YY_PROTO(( void )); -#endif -#ifndef YY_NO_TOP_STATE -static int yy_top_state YY_PROTO(( void )); -#endif - -#else -#define YY_NO_PUSH_STATE 1 -#define YY_NO_POP_STATE 1 -#define YY_NO_TOP_STATE 1 -#endif - -#ifdef YY_MALLOC_DECL -YY_MALLOC_DECL -#else -#if __STDC__ -#ifndef __cplusplus -#include -#endif -#else -/* Just try to get by without declaring the routines. This will fail - * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) - * or sizeof(void*) != sizeof(int). - */ -#endif -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#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 (void) fwrite( yytext, yyleng, 1, yyout ) -#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->yy_is_interactive ) \ - { \ - int c = '*', 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 if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ - && ferror( yyin ) ) \ - 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) yy_fatal_error( msg ) -#endif - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL int yylex YY_PROTO(( void )) -#endif - -/* 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 break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -YY_DECL - { - register yy_state_type yy_current_state; - register char *yy_cp = NULL, *yy_bp = NULL; - register int yy_act; - -// #line 32 "asm.yy" - - - if(push_state_init) - {push_state_init = 0; yy_push_state(INITIAL); } - if(push_state_skip) - {push_state_skip = 0; yy_push_state(SKIP); } - if(push_state_macro) - {push_state_macro = 0; yy_push_state(MACROO); } - -// #line 719 "lex.yy.c" - - if ( yy_init ) - { - yy_init = 0; - -#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 ) - yy_current_buffer = - yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_load_buffer_state(); - } - - while ( 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 - { - register 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 >= 256 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - ++yy_cp; - } - while ( yy_current_state != 255 ); - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - -yy_find_action: - 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 41 "asm.yy" -return IF; - YY_BREAK -case 2: -YY_RULE_SETUP -// #line 42 "asm.yy" -BEGIN(SKIP_ALL); - YY_BREAK -case 3: -YY_RULE_SETUP -// #line 43 "asm.yy" -BEGIN(SKIP); - YY_BREAK -case 4: -YY_RULE_SETUP -// #line 44 "asm.yy" -yy_pop_state(); - YY_BREAK -case 5: -YY_RULE_SETUP -// #line 46 "asm.yy" -return INCLUDE; - YY_BREAK -case 6: -YY_RULE_SETUP -// #line 47 "asm.yy" -return MACRO; - YY_BREAK -case 7: -YY_RULE_SETUP -// #line 49 "asm.yy" -return DEFINED; - YY_BREAK -case 8: -YY_RULE_SETUP -// #line 50 "asm.yy" -return ORG; - YY_BREAK -case 9: -YY_RULE_SETUP -// #line 51 "asm.yy" -return ASMERROR; - YY_BREAK -case 10: -YY_RULE_SETUP -// #line 52 "asm.yy" -return ECHO; - YY_BREAK -case 11: -YY_RULE_SETUP -// #line 53 "asm.yy" -return INCBIN; - YY_BREAK -case 12: -YY_RULE_SETUP -// #line 54 "asm.yy" -return INCWORD; - YY_BREAK -case 13: -YY_RULE_SETUP -// #line 55 "asm.yy" -return RES; - YY_BREAK -case 14: -YY_RULE_SETUP -// #line 56 "asm.yy" -return WORD; - YY_BREAK -case 15: -YY_RULE_SETUP -// #line 57 "asm.yy" -return BYTE; - YY_BREAK -case 16: -YY_RULE_SETUP -// #line 59 "asm.yy" -BEGIN(QUOTED_STRING); - YY_BREAK -case 17: -YY_RULE_SETUP -// #line 60 "asm.yy" -BEGIN(SKIP_LINE); - YY_BREAK -case 18: -YY_RULE_SETUP -// #line 62 "asm.yy" -return LDA; - YY_BREAK -case 19: -YY_RULE_SETUP -// #line 63 "asm.yy" -return LDX; - YY_BREAK -case 20: -YY_RULE_SETUP -// #line 64 "asm.yy" -return LDY; - YY_BREAK -case 21: -YY_RULE_SETUP -// #line 65 "asm.yy" -return STA; - YY_BREAK -case 22: -YY_RULE_SETUP -// #line 66 "asm.yy" -return STX; - YY_BREAK -case 23: -YY_RULE_SETUP -// #line 67 "asm.yy" -return STY; - YY_BREAK -case 24: -YY_RULE_SETUP -// #line 68 "asm.yy" -return AND; - YY_BREAK -case 25: -YY_RULE_SETUP -// #line 69 "asm.yy" -return ORA; - YY_BREAK -case 26: -YY_RULE_SETUP -// #line 70 "asm.yy" -return EOR; - YY_BREAK -case 27: -YY_RULE_SETUP -// #line 71 "asm.yy" -return ADC; - YY_BREAK -case 28: -YY_RULE_SETUP -// #line 72 "asm.yy" -return SBC; - YY_BREAK -case 29: -YY_RULE_SETUP -// #line 73 "asm.yy" -return CMP; - YY_BREAK -case 30: -YY_RULE_SETUP -// #line 74 "asm.yy" -return CPX; - YY_BREAK -case 31: -YY_RULE_SETUP -// #line 75 "asm.yy" -return CPY; - YY_BREAK -case 32: -YY_RULE_SETUP -// #line 77 "asm.yy" -return TSX; - YY_BREAK -case 33: -YY_RULE_SETUP -// #line 78 "asm.yy" -return TXS; - YY_BREAK -case 34: -YY_RULE_SETUP -// #line 79 "asm.yy" -return PHA; - YY_BREAK -case 35: -YY_RULE_SETUP -// #line 80 "asm.yy" -return PLA; - YY_BREAK -case 36: -YY_RULE_SETUP -// #line 81 "asm.yy" -return PHP; - YY_BREAK -case 37: -YY_RULE_SETUP -// #line 82 "asm.yy" -return PLP; - YY_BREAK -case 38: -YY_RULE_SETUP -// #line 83 "asm.yy" -return SEI; - YY_BREAK -case 39: -YY_RULE_SETUP -// #line 84 "asm.yy" -return CLI; - YY_BREAK -case 40: -YY_RULE_SETUP -// #line 85 "asm.yy" -return NOP; - YY_BREAK -case 41: -YY_RULE_SETUP -// #line 86 "asm.yy" -return TYA; - YY_BREAK -case 42: -YY_RULE_SETUP -// #line 87 "asm.yy" -return TAY; - YY_BREAK -case 43: -YY_RULE_SETUP -// #line 88 "asm.yy" -return TXA; - YY_BREAK -case 44: -YY_RULE_SETUP -// #line 89 "asm.yy" -return TAX; - YY_BREAK -case 45: -YY_RULE_SETUP -// #line 90 "asm.yy" -return CLC; - YY_BREAK -case 46: -YY_RULE_SETUP -// #line 91 "asm.yy" -return SEC; - YY_BREAK -case 47: -YY_RULE_SETUP -// #line 92 "asm.yy" -return RTS; - YY_BREAK -case 48: -YY_RULE_SETUP -// #line 94 "asm.yy" -return JSR; - YY_BREAK -case 49: -YY_RULE_SETUP -// #line 95 "asm.yy" -return JMP; - YY_BREAK -case 50: -YY_RULE_SETUP -// #line 96 "asm.yy" -return BEQ; - YY_BREAK -case 51: -YY_RULE_SETUP -// #line 97 "asm.yy" -return BNE; - YY_BREAK -case 52: -YY_RULE_SETUP -// #line 98 "asm.yy" -return BCC; - YY_BREAK -case 53: -YY_RULE_SETUP -// #line 99 "asm.yy" -return BCS; - YY_BREAK -case 54: -YY_RULE_SETUP -// #line 100 "asm.yy" -return BPL; - YY_BREAK -case 55: -YY_RULE_SETUP -// #line 101 "asm.yy" -return BMI; - YY_BREAK -case 56: -YY_RULE_SETUP -// #line 102 "asm.yy" -return BVC; - YY_BREAK -case 57: -YY_RULE_SETUP -// #line 103 "asm.yy" -return BCS; - YY_BREAK -case 58: -YY_RULE_SETUP -// #line 104 "asm.yy" -return INX; - YY_BREAK -case 59: -YY_RULE_SETUP -// #line 105 "asm.yy" -return DEX; - YY_BREAK -case 60: -YY_RULE_SETUP -// #line 106 "asm.yy" -return INY; - YY_BREAK -case 61: -YY_RULE_SETUP -// #line 107 "asm.yy" -return DEY; - YY_BREAK -case 62: -YY_RULE_SETUP -// #line 108 "asm.yy" -return INC; - YY_BREAK -case 63: -YY_RULE_SETUP -// #line 109 "asm.yy" -return DEC; - YY_BREAK -case 64: -YY_RULE_SETUP -// #line 110 "asm.yy" -return LSR; - YY_BREAK -case 65: -YY_RULE_SETUP -// #line 111 "asm.yy" -return ASL; - YY_BREAK -case 66: -YY_RULE_SETUP -// #line 112 "asm.yy" -return ROR; - YY_BREAK -case 67: -YY_RULE_SETUP -// #line 113 "asm.yy" -return ROL; - YY_BREAK -case 68: -YY_RULE_SETUP -// #line 115 "asm.yy" -{ yylval.num = atoi(yytext); return NUMBER; } - YY_BREAK -case 69: -YY_RULE_SETUP -// #line 117 "asm.yy" -{ yylval.num = strtol(yytext + 1, NULL, 16); return NUMBER; } - YY_BREAK -case 70: -YY_RULE_SETUP -// #line 119 "asm.yy" -return LT; - YY_BREAK -case 71: -YY_RULE_SETUP -// #line 120 "asm.yy" -return GT; - YY_BREAK -case 72: -YY_RULE_SETUP -// #line 121 "asm.yy" -return EQ; - YY_BREAK -case 73: -YY_RULE_SETUP -// #line 122 "asm.yy" -return NEQ; - YY_BREAK -case 74: -YY_RULE_SETUP -// #line 123 "asm.yy" -return LNOT; - YY_BREAK -case 75: -YY_RULE_SETUP -// #line 124 "asm.yy" -return LAND; - YY_BREAK -case 76: -YY_RULE_SETUP -// #line 125 "asm.yy" -return LOR; - YY_BREAK -case 77: -YY_RULE_SETUP -// #line 127 "asm.yy" -return LPAREN; - YY_BREAK -case 78: -YY_RULE_SETUP -// #line 128 "asm.yy" -return RPAREN; - YY_BREAK -case 79: -YY_RULE_SETUP -// #line 129 "asm.yy" -return COMMA; - YY_BREAK -case 80: -YY_RULE_SETUP -// #line 130 "asm.yy" -return COLON; - YY_BREAK -case 81: -YY_RULE_SETUP -// #line 131 "asm.yy" -return HASH; - YY_BREAK -case 82: -YY_RULE_SETUP -// #line 132 "asm.yy" -return PLUS; - YY_BREAK -case 83: -YY_RULE_SETUP -// #line 133 "asm.yy" -return MINUS; - YY_BREAK -case 84: -YY_RULE_SETUP -// #line 134 "asm.yy" -return MULT; - YY_BREAK -case 85: -YY_RULE_SETUP -// #line 135 "asm.yy" -return DIV; - YY_BREAK -case 86: -YY_RULE_SETUP -// #line 136 "asm.yy" -return MOD; - YY_BREAK -case 87: -YY_RULE_SETUP -// #line 138 "asm.yy" -return ASSIGN; - YY_BREAK -case 88: -YY_RULE_SETUP -// #line 140 "asm.yy" -return X; - YY_BREAK -case 89: -YY_RULE_SETUP -// #line 141 "asm.yy" -return Y; - YY_BREAK -case 90: -YY_RULE_SETUP -// #line 143 "asm.yy" -{ yylval.str = strdupped_get(yytext); return SYMBOL; } - YY_BREAK -case 91: -YY_RULE_SETUP -// #line 145 "asm.yy" -++num_lines; - YY_BREAK -case 92: -YY_RULE_SETUP -// #line 147 "asm.yy" -/* eat whitespace */ - YY_BREAK -case 93: -YY_RULE_SETUP -// #line 149 "asm.yy" -printf("unknown character found %s\n", yytext); - YY_BREAK -case 94: -YY_RULE_SETUP -// #line 151 "asm.yy" -yy_push_state(SKIP_ALL); - YY_BREAK -case 95: -YY_RULE_SETUP -// #line 152 "asm.yy" -{ yy_pop_state(); return IF; } - YY_BREAK -case 96: -YY_RULE_SETUP -// #line 153 "asm.yy" -BEGIN(INITIAL); - YY_BREAK -case 97: -YY_RULE_SETUP -// #line 154 "asm.yy" -yy_pop_state(); - YY_BREAK -case 98: -YY_RULE_SETUP -// #line 155 "asm.yy" -++num_lines; - YY_BREAK -case 99: -YY_RULE_SETUP -// #line 156 "asm.yy" - - YY_BREAK -case 100: -YY_RULE_SETUP -// #line 158 "asm.yy" -yy_pop_state(); - YY_BREAK -case 101: -YY_RULE_SETUP -// #line 159 "asm.yy" -{ yylval.str = yytext; return MACRO_STRING; } - YY_BREAK -case 102: -YY_RULE_SETUP -// #line 160 "asm.yy" -{ yylval.str = yytext; return MACRO_STRING; } - YY_BREAK -case 103: -YY_RULE_SETUP -// #line 162 "asm.yy" -yy_push_state(SKIP_ALL); - YY_BREAK -case 104: -YY_RULE_SETUP -// #line 163 "asm.yy" -yy_pop_state(); - YY_BREAK -case 105: -YY_RULE_SETUP -// #line 164 "asm.yy" -++num_lines; - YY_BREAK -case 106: -YY_RULE_SETUP -// #line 165 "asm.yy" - - YY_BREAK -case 107: -YY_RULE_SETUP -// #line 167 "asm.yy" -{ - yylval.str = strdupped_get(yytext); - return STRING; -} - YY_BREAK -case 108: -YY_RULE_SETUP -// #line 171 "asm.yy" -++num_lines; - YY_BREAK -case 109: -YY_RULE_SETUP -// #line 172 "asm.yy" -BEGIN(INITIAL); - YY_BREAK -case 110: -YY_RULE_SETUP -// #line 174 "asm.yy" -{ ++num_lines; BEGIN(INITIAL); } - YY_BREAK -case YY_STATE_EOF(INITIAL): -case YY_STATE_EOF(SKIP): -case YY_STATE_EOF(SKIP_ALL): -case YY_STATE_EOF(QUOTED_STRING): -case YY_STATE_EOF(SKIP_LINE): -case YY_STATE_EOF(MACROO): -// #line 176 "asm.yy" -{ - if(--src_buffer_depth == 0) - { - yyterminate(); - } - else - { - yy_delete_buffer(YY_CURRENT_BUFFER); - yy_switch_to_buffer(src_buffers[src_buffer_depth]); - } - } - YY_BREAK -case 111: -YY_RULE_SETUP -// #line 188 "asm.yy" -ECHO; - YY_BREAK -// #line 1375 "lex.yy.c" - - 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->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->yy_n_chars; - yy_current_buffer->yy_input_file = yyin; - yy_current_buffer->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->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_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - 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->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 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() - { - register char *dest = yy_current_buffer->yy_ch_buf; - register char *source = yytext_ptr; - register int number_to_move, i; - int ret_val; - - if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( yy_current_buffer->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->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->yy_n_chars = yy_n_chars = 0; - - else - { - int num_to_read = - yy_current_buffer->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ -#ifdef YY_USES_REJECT - YY_FATAL_ERROR( -"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); -#else - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = yy_current_buffer; - - 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. */ - yy_flex_realloc( (void *) b->yy_ch_buf, - b->yy_buf_size + 2 ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - 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->yy_buf_size - - number_to_move - 1; -#endif - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), - yy_n_chars, num_to_read ); - - yy_current_buffer->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->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - yy_n_chars += number_to_move; - yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; - yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yytext_ptr = &yy_current_buffer->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() - { - register yy_state_type yy_current_state; - register char *yy_cp; - - yy_current_state = yy_start; - - for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) - { - register 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 >= 256 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) 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 ); - */ - -#ifdef YY_USE_PROTOS -static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) -#else -static yy_state_type yy_try_NUL_trans( yy_current_state ) -yy_state_type yy_current_state; -#endif - { - register int yy_is_jam; - register char *yy_cp = yy_c_buf_p; - - register 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 >= 256 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 255); - - return yy_is_jam ? 0 : yy_current_state; - } - - -#ifndef YY_NO_UNPUT -#ifdef YY_USE_PROTOS -static void yyunput( int c, register char *yy_bp ) -#else -static void yyunput( c, yy_bp ) -int c; -register char *yy_bp; -#endif - { - register char *yy_cp = yy_c_buf_p; - - /* undo effects of setting up yytext */ - *yy_cp = yy_hold_char; - - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register int number_to_move = yy_n_chars + 2; - register char *dest = &yy_current_buffer->yy_ch_buf[ - yy_current_buffer->yy_buf_size + 2]; - register char *source = - &yy_current_buffer->yy_ch_buf[number_to_move]; - - while ( source > yy_current_buffer->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - yy_current_buffer->yy_n_chars = - yy_n_chars = yy_current_buffer->yy_buf_size; - - if ( yy_cp < yy_current_buffer->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_UNPUT */ - - -#ifdef __cplusplus -static int yyinput() -#else -static int input() -#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->yy_ch_buf[yy_n_chars] ) - /* This was really a NUL. */ - *yy_c_buf_p = '\0'; - - else - { /* need more input */ - int offset = 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 ); - - /* fall through */ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap() ) - return EOF; - - 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; - } - - -#ifdef YY_USE_PROTOS -void yyrestart( FILE *input_file ) -#else -void yyrestart( input_file ) -FILE *input_file; -#endif - { - if ( ! yy_current_buffer ) - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_init_buffer( yy_current_buffer, input_file ); - yy_load_buffer_state(); - } - - -#ifdef YY_USE_PROTOS -void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) -#else -void yy_switch_to_buffer( new_buffer ) -YY_BUFFER_STATE new_buffer; -#endif - { - 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->yy_buf_pos = yy_c_buf_p; - yy_current_buffer->yy_n_chars = yy_n_chars; - } - - yy_current_buffer = 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; - } - - -#ifdef YY_USE_PROTOS -void yy_load_buffer_state( void ) -#else -void yy_load_buffer_state() -#endif - { - yy_n_chars = yy_current_buffer->yy_n_chars; - yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; - yyin = yy_current_buffer->yy_input_file; - yy_hold_char = *yy_c_buf_p; - } - - -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) -#else -YY_BUFFER_STATE yy_create_buffer( file, size ) -FILE *file; -int size; -#endif - { - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yy_flex_alloc( 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 *) yy_flex_alloc( 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; - } - - -#ifdef YY_USE_PROTOS -void yy_delete_buffer( YY_BUFFER_STATE b ) -#else -void yy_delete_buffer( b ) -YY_BUFFER_STATE b; -#endif - { - - if ( ! b ) - return; - - if ( b == yy_current_buffer ) - yy_current_buffer = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yy_flex_free( (void *) b->yy_ch_buf ); - - yy_flex_free( (void *) b ); - } - - - -#ifdef YY_USE_PROTOS -void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) -#else -void yy_init_buffer( b, file ) -YY_BUFFER_STATE b; -FILE *file; -#endif - - - { - yy_flush_buffer( b ); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - -#if YY_ALWAYS_INTERACTIVE - b->yy_is_interactive = 1; -#else -#if YY_NEVER_INTERACTIVE - b->yy_is_interactive = 0; -#else - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; -#endif -#endif - } - - -#ifdef YY_USE_PROTOS -void yy_flush_buffer( YY_BUFFER_STATE b ) -#else -void yy_flush_buffer( b ) -YY_BUFFER_STATE b; -#endif - - { - 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(); - } - - -#ifndef YY_NO_SCAN_BUFFER -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) -#else -YY_BUFFER_STATE yy_scan_buffer( base, size ) -char *base; -yy_size_t size; -#endif - { - 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 0; - - b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = 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 = 0; - 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; - } -#endif - - -#ifndef YY_NO_SCAN_STRING -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) -#else -YY_BUFFER_STATE yy_scan_string( yy_str ) -yyconst char *yy_str; -#endif - { - int len; - for ( len = 0; yy_str[len]; ++len ) - ; - - return yy_scan_bytes( yy_str, len ); - } -#endif - - -#ifndef YY_NO_SCAN_BYTES -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) -#else -YY_BUFFER_STATE yy_scan_bytes( bytes, len ) -yyconst char *bytes; -int len; -#endif - { - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = len + 2; - buf = (char *) yy_flex_alloc( n ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < len; ++i ) - buf[i] = bytes[i]; - - buf[len] = buf[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; - } -#endif - - -#ifndef YY_NO_PUSH_STATE -#ifdef YY_USE_PROTOS -static void yy_push_state( int new_state ) -#else -static void yy_push_state( new_state ) -int new_state; -#endif - { - 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_start_stack_depth * sizeof( int ); - - if ( ! yy_start_stack ) - yy_start_stack = (int *) yy_flex_alloc( new_size ); - - else - yy_start_stack = (int *) yy_flex_realloc( - (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); - } -#endif - - -#ifndef YY_NO_POP_STATE -static void yy_pop_state() - { - if ( --yy_start_stack_ptr < 0 ) - YY_FATAL_ERROR( "start-condition stack underflow" ); - - BEGIN(yy_start_stack[yy_start_stack_ptr]); - } -#endif - - -#ifndef YY_NO_TOP_STATE -static int yy_top_state() - { - return yy_start_stack[yy_start_stack_ptr - 1]; - } -#endif - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -#ifdef YY_USE_PROTOS -static void yy_fatal_error( yyconst char msg[] ) -#else -static void yy_fatal_error( msg ) -char msg[]; -#endif - { - (void) 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. */ \ - yytext[yyleng] = yy_hold_char; \ - yy_c_buf_p = yytext + n; \ - yy_hold_char = *yy_c_buf_p; \ - *yy_c_buf_p = '\0'; \ - yyleng = n; \ - } \ - while ( 0 ) - - -/* Internal utility routines. */ - -#ifndef yytext_ptr -#ifdef YY_USE_PROTOS -static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) -#else -static void yy_flex_strncpy( s1, s2, n ) -char *s1; -yyconst char *s2; -int n; -#endif - { - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; - } -#endif - -#ifdef YY_NEED_STRLEN -#ifdef YY_USE_PROTOS -static int yy_flex_strlen( yyconst char *s ) -#else -static int yy_flex_strlen( s ) -yyconst char *s; -#endif - { - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; - } -#endif - - -#ifdef YY_USE_PROTOS -static void *yy_flex_alloc( yy_size_t size ) -#else -static void *yy_flex_alloc( size ) -yy_size_t size; -#endif - { - return (void *) malloc( size ); - } - -#ifdef YY_USE_PROTOS -static void *yy_flex_realloc( void *ptr, yy_size_t size ) -#else -static void *yy_flex_realloc( ptr, size ) -void *ptr; -yy_size_t size; -#endif - { - /* 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 (void *) realloc( (char *) ptr, size ); - } - -#ifdef YY_USE_PROTOS -static void yy_flex_free( void *ptr ) -#else -static void yy_flex_free( ptr ) -void *ptr; -#endif - { - free( ptr ); - } - -#if YY_MAIN -int main() - { - yylex(); - return 0; - } -#endif -// #line 188 "asm.yy" - - -void scanner_init() -{ - vec_init(strdupped, sizeof(char*)); -} - -void asm_src_buffer_push(struct membuf *buffer) -{ - if(src_buffer_depth == MAX_SRC_BUFFER_DEPTH) - { - fprintf(stderr, "source buffers nested too deep\n"); - exit(-1); - } - src_buffers[src_buffer_depth++] = YY_CURRENT_BUFFER; - yy_scan_bytes(membuf_get(buffer), membuf_memlen(buffer)); -} - -static char *strdupped_get(char *text) -{ - char **pp; - /*printf("get \"%s\" => ", text);*/ - if(vec_insert_uniq(strdupped, strdupped_cmp, &text, (void*)&pp)) - { - /* replace the pointer to since will be reused */ - *pp = strdup(text); - } - /*printf("%p\n", *pp);*/ - return *pp; -} - -static void strdupped_free(void *a) -{ - char *b = *(char**)a; - /*printf("free => %p \"%s\"\n", b, b);*/ - free(b); -} - -static int strdupped_cmp(const void *a, const void *b) -{ - char *c = *(char**)a; - char *d = *(char**)b; - - return strcmp(c, d); -} - -void scanner_free() -{ - vec_free(strdupped, strdupped_free); -} - -void yycleanup() -{ - if (YY_CURRENT_BUFFER) - yy_delete_buffer(YY_CURRENT_BUFFER); - if (yy_start_stack) - { - yy_flex_free(yy_start_stack); - yy_start_stack = 0; - yy_start_stack_ptr = 0; - yy_start_stack_depth = 0; - } -} - - diff --git a/src/asm/log.c b/src/asm/log.c index a01afcd..5f0a1b4 100644 --- a/src/asm/log.c +++ b/src/asm/log.c @@ -26,25 +26,22 @@ * This file is a part of the Exomizer v1.1 release * */ - -// Modified for GoatTracker2 to compile with -Werror=format-security #include #include +#include +#include #include "log.h" - #ifdef WIN32 #define vsnprintf _vsnprintf #endif -#ifdef DJGPP -#define vsnprintf(A, B, C, D) vsprintf((A),(C),(D)) -#endif struct log_output { enum log_level min; enum log_level max; FILE *stream; + int isatty; log_formatter_f *f; }; @@ -57,8 +54,9 @@ struct log_ctx { }; struct log_ctx *G_log_ctx = NULL; -enum log_level G_log_level = 0; +enum log_level G_log_level = LOG_MIN; enum log_level G_log_log_level = 0; +int G_log_tty_only = 0; struct log_ctx *log_new(void) { @@ -126,6 +124,7 @@ void log_add_output_stream(struct log_ctx *ctx, /* IN/OUT */ out->min = min; out->max = max; out->stream = out_stream; + out->isatty = isatty(fileno(out_stream)); out->f = default_f; } @@ -178,7 +177,8 @@ void log_vlog(struct log_ctx *ctx, /* IN */ struct log_output *o = &ctx->out[i]; log_formatter_f *of = f; - if (level >= o->min && level <= o->max) + if (level >= o->min && level <= o->max && + (G_log_tty_only == 0 || o->isatty != 0)) { /* generate log for this output */ if (of == NULL) @@ -217,3 +217,32 @@ void log_log(struct log_ctx *ctx, /* IN */ va_start(argp, printf_str); log_vlog(ctx, level, context, f, printf_str, argp); } + +void hex_dump(int level, unsigned char *p, int len) +{ + int i; + int j; + for(i = 0; i < len;) + { + LOG(level, ("%02x", p[i])); + ++i; + if(i == len || (i & 15) == 0) + { + LOG(level, ("\t\"")); + for(j = (i - 1) & ~15; j < i; ++j) + { + unsigned char c = p[j]; + if(!isprint(c)) + { + c = '.'; + } + LOG(level, ("%c", c)); + } + LOG(level, ("\"\n")); + } + else + { + LOG(level, (",")); + } + } +} diff --git a/src/asm/log.h b/src/asm/log.h index 704ccc2..78a3dda 100644 --- a/src/asm/log.h +++ b/src/asm/log.h @@ -30,6 +30,10 @@ #include #include +#ifndef __GNUC__ +#define __attribute__(x) /*NOTHING*/ +#endif + enum log_level { LOG_MIN = -99, LOG_FATAL = -40, @@ -88,13 +92,15 @@ void log_vlog(struct log_ctx *ctx, /* IN */ void log_log_default(const char *printf_str, /* IN */ - ...); + ...) + __attribute__((format(printf,1,2))); /* some helper macros */ extern struct log_ctx *G_log_ctx; extern enum log_level G_log_level; extern enum log_level G_log_log_level; +extern int G_log_tty_only; #define LOG_SET_LEVEL(L) \ do { \ @@ -126,8 +132,20 @@ do { \ do { \ if(IS_LOGGABLE(L)) { \ G_log_log_level = (L); \ + G_log_tty_only = 0; \ + log_log_default M; \ + } \ +} while(0) + +#define LOG_TTY(L, M) \ +do { \ + if(IS_LOGGABLE(L)) { \ + G_log_log_level = (L); \ + G_log_tty_only = 1; \ log_log_default M; \ } \ } while(0) +void hex_dump(int level, unsigned char *p, int len); + #endif diff --git a/src/asm/map.c b/src/asm/map.c new file mode 100644 index 0000000..ff0af28 --- /dev/null +++ b/src/asm/map.c @@ -0,0 +1,186 @@ +/* + * Copyright (c) 2006 Magnus Lind. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software, alter it and re- + * distribute it freely for any non-commercial, non-profit purpose subject to + * the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not + * be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any distribution. + * + * 4. The names of this software and/or it's copyright holders may not be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + */ + +#include "map.h" +#include "log.h" +#include + +static int map_entry_cmp(const void *a, const void *b) +{ + struct map_entry *entry_a; + struct map_entry *entry_b; + int val; + + entry_a = (struct map_entry*)a; + entry_b = (struct map_entry*)b; + + val = strcmp(entry_a->key, entry_b->key); + + return val; +} + +void map_init(struct map *m) +{ + vec_init(&m->vec, sizeof(struct map_entry)); +} +void map_clear(struct map *m) +{ + vec_clear(&m->vec, NULL); +} + +void map_free(struct map *m) +{ + vec_free(&m->vec, NULL); +} + +void *map_put(struct map *m, const char *key, void *value) +{ + struct map_entry e[1]; + int pos; + void *prev_value = NULL; + + e->key = key; + e->value = value; + pos = vec_find(&m->vec, map_entry_cmp, e); + if(pos == -1) + { + /* error, find failed */ + LOG(LOG_ERROR, ("map_put: vec_find() internal error\n")); + exit(1); + } + if(pos >= 0) + { + /* previous value exists, get value then set */ + struct map_entry *prev_e; + prev_e = vec_get(&m->vec, pos); + prev_value = prev_e->value; + vec_set(&m->vec, pos, e); + } + else + { + /* no value exists, insert */ + vec_insert(&m->vec, -(pos + 2), e); + } + return prev_value; +} + +static struct map_entry *get(const struct map *m, const char *key) +{ + struct map_entry e[1]; + int pos; + struct map_entry *out = NULL; + + e->key = key; + pos = vec_find(&m->vec, map_entry_cmp, e); + if(pos == -1) + { + /* error, find failed */ + LOG(LOG_ERROR, ("map_put: vec_find() internal error\n")); + exit(1); + } + if(pos >= 0) + { + out = vec_get(&m->vec, pos); + } + return out; +} + +int map_contains_key(const struct map *m, const char *key) +{ + return get(m, key) != NULL; +} + +void *map_get(const struct map *m, const char *key) +{ + struct map_entry *e = get(m, key); + void *value = NULL; + if(e != NULL) + { + value = e->value; + } + return value; +} + +void map_put_all(struct map *m, const struct map *source) +{ + struct map_iterator i[1]; + const struct map_entry *e; + for(map_get_iterator(source, i); (e = map_iterator_next(i)) != NULL;) + { + map_put(m, e->key, e->value); + } +} + +int map_contains(const struct map *m1, const struct map *m2, cb_cmp *f) +{ + struct map_iterator i[1]; + const struct map_entry *e; + + for(map_get_iterator(m2, i); (e = map_iterator_next(i)) != NULL;) + { + int pos; + pos = vec_find(&m1->vec, map_entry_cmp, e); + if(pos == -1) + { + /* error, find failed */ + LOG(LOG_ERROR, ("map_put: vec_find() internal error\n")); + exit(1); + } + if(pos < 0) + { + /* not found, break */ + break; + } + else if(f != NULL) + { + struct map_entry *e2; + /* compare the values too */ + e2 = vec_get(&m1->vec, pos); + if(f(e2->value, e->value)) + { + /* values not equal, break */ + break; + } + } + } + return e == NULL; +} + +int map_equals(const struct map *m1, const struct map *m2, cb_cmp *f) +{ + return map_contains(m1, m2, f) && map_contains(m2, m1, f); +} + +void map_get_iterator(const struct map *m, struct map_iterator *i) +{ + vec_get_iterator(&m->vec, &i->vec); +} + +const struct map_entry *map_iterator_next(struct map_iterator *i) +{ + return vec_iterator_next(&i->vec); +} diff --git a/src/asm/map.h b/src/asm/map.h new file mode 100644 index 0000000..df41281 --- /dev/null +++ b/src/asm/map.h @@ -0,0 +1,69 @@ +#ifndef ALREADY_INCLUDED_MAP +#define ALREADY_INCLUDED_MAP + +/* + * Copyright (c) 2006 Magnus Lind. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software, alter it and re- + * distribute it freely for any non-commercial, non-profit purpose subject to + * the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not + * be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any distribution. + * + * 4. The names of this software and/or it's copyright holders may not be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + */ + +#include "vec.h" +#include "callback.h" + +struct map_entry { + const char *key; + void *value; +}; + +#define STATIC_MAP_INIT {STATIC_VEC_INIT(sizeof(struct map_entry))} + +struct map { + struct vec vec; +}; + +struct map_iterator { + struct vec_iterator vec; +}; + +void map_init(struct map *m); +void map_clear(struct map *m); +void map_free(struct map *m); + +void *map_put(struct map *m, const char *key, void *value); +void *map_get(const struct map *m, const char *key); +int map_contains_key(const struct map *m, const char *key); +void map_put_all(struct map *m, const struct map *source); + +int map_contains(const struct map *m1, const struct map *m2, cb_cmp *f); + +/** + * If f is NULL, only the keys will be compared. + * returns -1 on error, 1 on equality and 0 otherwise, + **/ +int map_equals(const struct map *m1, const struct map *m2, cb_cmp *f); + +void map_get_iterator(const struct map *p, struct map_iterator *i); +const struct map_entry *map_iterator_next(struct map_iterator *i); + +#endif diff --git a/src/asm/membuf.c b/src/asm/membuf.c index 5af2dbc..08c8e33 100644 --- a/src/asm/membuf.c +++ b/src/asm/membuf.c @@ -30,6 +30,11 @@ #include #include +#include + +#ifdef WIN32 +#define vsnprintf _vsnprintf +#endif void membuf_init(struct membuf *sb) { @@ -62,7 +67,6 @@ void membuf_new(struct membuf **sbp) fprintf(stderr, "error, can't allocate memory\n"); exit(1); } - sb->buf = NULL; sb->len = 0; sb->size = 0; @@ -81,7 +85,7 @@ void membuf_delete(struct membuf **sbp) *sbp = sb; } -int membuf_memlen(struct membuf *sb) +int membuf_memlen(const struct membuf *sb) { return sb->len; } @@ -109,12 +113,15 @@ int membuf_trim(struct membuf *sb, int pos) return sb->len; } -void *membuf_memcpy(struct membuf *sb, const void *mem, int len) +void *membuf_memcpy(struct membuf *sb, int offset, const void *mem, int len) { - membuf_atleast(sb, len); - memcpy(sb->buf, mem, len); - return sb->buf; + char *buf; + membuf_atleast(sb, offset + len); + buf = (char*)sb->buf + offset; + memcpy(buf, mem, len); + return buf; } + void *membuf_append(struct membuf *sb, const void *mem, int len) { int newlen; @@ -153,14 +160,32 @@ void *membuf_insert(struct membuf *sb, int offset, const void *mem, int len) void *to; newlen = sb->len + len; membuf_atleast(sb, newlen); - from = (char *) sb->buf + offset; + from = (char *)sb->buf + offset; to = (char *)from + len; memmove(to, from, sb->len - offset); - memcpy(from, mem, len); + if(mem == NULL) + { + memset(from, 0, len); + } + else + { + memcpy(from, mem, len); + } sb->len = newlen; return from; } +void membuf_remove(struct membuf *sb, int offset, int len) +{ + void *from; + void *to; + to = (char *)sb->buf + offset; + from = (char *)to + len; + sb->len -= len; + memmove(to, from, sb->len - offset); + +} + void membuf_atleast(struct membuf *sb, int len) { int size; @@ -206,11 +231,37 @@ void membuf_atmost(struct membuf *sb, int len) } } -int membuf_get_size(struct membuf *sb) +int membuf_get_size(const struct membuf *sb) { return sb->size; } -void *membuf_get(struct membuf *sb) +void *membuf_get(const struct membuf *sb) { return sb->buf; } +void membuf_printf(struct membuf *sb, const char *format, ...) +{ + int pos; + int printed; + va_list args; + + pos = sb->len; + + va_start(args, format); + printed = vsnprintf((char*)membuf_get(sb) + pos, sb->size - pos, + format, args); + va_end(args); + + if (printed >= sb->size - pos) + { + va_list args2; + + membuf_atleast(sb, pos + printed + 1); + + va_start(args2, format); + printed = vsnprintf((char*)membuf_get(sb) + pos, sb->size - pos, + format, args2); + va_end(args2); + } + sb->len += printed; +} diff --git a/src/asm/membuf.h b/src/asm/membuf.h index 769731b..445ce97 100644 --- a/src/asm/membuf.h +++ b/src/asm/membuf.h @@ -41,19 +41,28 @@ void membuf_clear(struct membuf *sb); void membuf_free(struct membuf *sb); void membuf_new(struct membuf **sbp); void membuf_delete(struct membuf **sbp); -int membuf_memlen(struct membuf *sb); +/* Gets the length of data put into the membuf */ +int membuf_memlen(const struct membuf *sb); void membuf_truncate(struct membuf *sb, int len); /* returns the new len or < 0 if failure */ int membuf_trim(struct membuf *sb, int pos); -void *membuf_memcpy(struct membuf *sb, const void *mem, int len); +void *membuf_memcpy(struct membuf *sb, int offset, const void *mem, int len); void *membuf_append(struct membuf *sb, const void *mem, int len); void *membuf_append_char(struct membuf *sb, char c); void *membuf_insert(struct membuf *sb, int offset, const void *mem, int len); +void membuf_remove(struct membuf *sb, int offset, int len); +/* Grows the capacity if it's less than the given size */ void membuf_atleast(struct membuf *sb, int size); +/* Skrinks the capacity if it's greater than the given size */ void membuf_atmost(struct membuf *sb, int size); -int membuf_get_size(struct membuf *sb); -void *membuf_get(struct membuf *sb); +/* Gets the current capacity of the membuf */ +int membuf_get_size(const struct membuf *sb); +/* Gets a pointer to the internal buffer. Don't dereferece it beyond + * its size. */ +void *membuf_get(const struct membuf *sb); +/* Appends a printf formatted string to */ +void membuf_printf(struct membuf *sb, const char *format, ...); #endif diff --git a/src/asm/membufio.c b/src/asm/membuf_io.c similarity index 96% rename from src/asm/membufio.c rename to src/asm/membuf_io.c index 6ecd5ea..f4734d7 100644 --- a/src/asm/membufio.c +++ b/src/asm/membuf_io.c @@ -25,12 +25,11 @@ * */ -#include "membufio.h" +#include "membuf_io.h" #include "log.h" #include #include - void read_file(const char *name, struct membuf *buf) { char block[1024]; @@ -41,7 +40,7 @@ void read_file(const char *name, struct membuf *buf) if(in == NULL) { LOG(LOG_ERROR, ("Can't open file \"%s\" for input.\n", name)); - exit(-1); + exit(1); } do { @@ -60,7 +59,7 @@ void write_file(const char *name, struct membuf *buf) if(out == NULL) { LOG(LOG_ERROR, ("Can't open file \"%s\" for output.\n", name)); - exit(-1); + exit(1); } fwrite(membuf_get(buf), 1, membuf_memlen(buf), out); fclose(out); diff --git a/src/asm/membufio.h b/src/asm/membuf_io.h similarity index 100% rename from src/asm/membufio.h rename to src/asm/membuf_io.h diff --git a/src/asm/namedbuf.c b/src/asm/named_buffer.c similarity index 52% rename from src/asm/namedbuf.c rename to src/asm/named_buffer.c index 9eaf65b..4187b30 100644 --- a/src/asm/namedbuf.c +++ b/src/asm/named_buffer.c @@ -25,98 +25,71 @@ * */ -#include "namedbuf.h" +#include "named_buffer.h" #include "log.h" -#include "vec.h" -#include "membufio.h" +#include "chunkpool.h" +#include "membuf_io.h" #include - -struct sbe +void named_buffer_init(struct named_buffer *nb) { - const char *name; - struct membuf mb[1]; -}; - -static struct vec s_sbe_table[1]; + map_init(&nb->map); + chunkpool_init(&nb->buf, sizeof(struct membuf)); +} -static int sbe_cmp(const void *a, const void *b) +void named_buffer_free(struct named_buffer *nb) { - struct sbe *sbe_a; - struct sbe *sbe_b; - int val; - - sbe_a = (struct sbe*)a; - sbe_b = (struct sbe*)b; - - val = strcmp(sbe_a->name, sbe_b->name); + typedef void cb_free(void *a); - return val; + chunkpool_free2(&nb->buf, (cb_free*)membuf_free); + map_free(&nb->map); } -void sbe_free(struct sbe *e) +void named_buffer_clear(struct named_buffer *nb) { - membuf_free(e->mb); + named_buffer_free(nb); + named_buffer_init(nb); } -void named_buffer_init() +void named_buffer_copy(struct named_buffer *nb, + const struct named_buffer *source) { - vec_init(s_sbe_table, sizeof(struct sbe)); -} + struct map_iterator i[1]; + const struct map_entry *e; -void named_buffer_free() -{ - typedef void cb_free(void *a); - - vec_free(s_sbe_table, (cb_free*)sbe_free); + for(map_get_iterator(&source->map, i); (e = map_iterator_next(i)) != NULL;) + { + /* don't allocate copies of the entries */ + map_put(&nb->map, e->key, e->value); + } } -struct membuf *new_named_buffer(const char *name) +struct membuf *new_named_buffer(struct named_buffer *nb, const char *name) { - int pos; - struct sbe e[1]; - struct sbe *ep; struct membuf *mp; + mp = chunkpool_malloc(&nb->buf); /* name is already strdup:ped */ - e->name = name; - pos = vec_find(s_sbe_table, sbe_cmp, e); - if(pos >= 0) + if(map_put(&nb->map, name, mp) != NULL) { /* found */ LOG(LOG_ERROR, ("buffer already exists.\n")); - exit(-1); + exit(1); } - membuf_init(e->mb); - ep = vec_insert(s_sbe_table, -(pos + 2), e); - mp = ep->mb; - + membuf_init(mp); return mp; } -struct membuf *get_named_buffer(const char *name) +struct membuf *get_named_buffer(struct named_buffer *nb, const char *name) { - int pos; - struct sbe e[1]; - struct sbe *ep; struct membuf *mp; - /* name is already strdup:ped */ - e->name = name; - pos = vec_find(s_sbe_table, sbe_cmp, e); - if(pos >= 0) - { - /* found */ - ep = vec_get(s_sbe_table, pos); - } - else + mp = map_get(&nb->map, name); + if(mp == NULL) { - membuf_init(e->mb); - read_file(name, e->mb); - ep = vec_insert(s_sbe_table, -(pos + 2), e); + mp = new_named_buffer(nb, name); } - mp = ep->mb; return mp; } diff --git a/src/asm/namedbuf.h b/src/asm/named_buffer.h similarity index 69% rename from src/asm/namedbuf.h rename to src/asm/named_buffer.h index 9dc1300..b38cff2 100644 --- a/src/asm/namedbuf.h +++ b/src/asm/named_buffer.h @@ -29,11 +29,22 @@ */ #include "membuf.h" +#include "chunkpool.h" +#include "map.h" -void named_buffer_init(); -void named_buffer_free(); +struct named_buffer { + struct map map; + struct chunkpool buf; +}; -struct membuf *new_named_buffer(const char *name); -struct membuf *get_named_buffer(const char *name); +void named_buffer_init(struct named_buffer *nb); +void named_buffer_free(struct named_buffer *nb); +void named_buffer_clear(struct named_buffer *nb); + +void named_buffer_copy(struct named_buffer *nb, + const struct named_buffer *source); + +struct membuf *new_named_buffer(struct named_buffer *nb, const char *name); +struct membuf *get_named_buffer(struct named_buffer *nb, const char *name); #endif diff --git a/src/asm/parse.c b/src/asm/parse.c index 5972fe8..841721f 100644 --- a/src/asm/parse.c +++ b/src/asm/parse.c @@ -26,52 +26,52 @@ */ #include "parse.h" -#include "asmtab.h" +#include "asm.tab.h" #include "log.h" -#include "chnkpool.h" -#include "namedbuf.h" +#include "chunkpool.h" +#include "named_buffer.h" #include "pc.h" +#include "map.h" #include - -static struct chunkpool s_atom_pool[1]; -static struct chunkpool s_vec_pool[1]; -static struct vec s_sym_table[1]; -static const char *s_macro_name; - -struct sym_entry -{ - const char *symbol; - struct expr *expr; +struct parse { + /* pools */ + struct chunkpool atom_pool[1]; + struct chunkpool vec_pool[1]; + /* one pass data only */ + struct map sym_table[1]; + struct named_buffer named_buffer[1]; + const char *macro_name; + /* history of the multi pass */ + struct map *guesses; + /* initial arguments */ + struct map initial_symbols[1]; + struct named_buffer initial_named_buffer[1]; }; -static int sym_entry_cmp(const void *a, const void *b) -{ - struct sym_entry *sym_a; - struct sym_entry *sym_b; - int val; - - sym_a = (struct sym_entry*)a; - sym_b = (struct sym_entry*)b; - - val = strcmp(sym_a->symbol, sym_b->symbol); - - return val; -} +static struct parse s[1]; void scanner_init(void); void scanner_free(void); -void parse_init() +void parse_init(void) { - scanner_init(); - chunkpool_init(s_atom_pool, sizeof(struct atom)); - chunkpool_init(s_vec_pool, sizeof(struct vec)); expr_init(); - vec_init(s_sym_table, sizeof(struct sym_entry)); - pc_unset(); - named_buffer_init(); + scanner_init(); + chunkpool_init(s->atom_pool, sizeof(struct atom)); + chunkpool_init(s->vec_pool, sizeof(struct vec)); + map_init(s->sym_table); + named_buffer_init(s->named_buffer); + + map_init(s->initial_symbols); + named_buffer_init(s->initial_named_buffer); +} + +static void parse_reset(void) +{ + map_clear(s->sym_table); + named_buffer_clear(s->named_buffer); } static void free_vec_pool(struct vec *v) @@ -79,14 +79,18 @@ static void free_vec_pool(struct vec *v) vec_free(v, NULL); } -void parse_free() +void parse_free(void) { - named_buffer_free(); - chunkpool_free(s_atom_pool); - chunkpool_free2(s_vec_pool, (cb_free*)free_vec_pool); - expr_free(); - vec_free(s_sym_table, NULL); + named_buffer_free(s->initial_named_buffer); + map_free(s->initial_symbols); + + named_buffer_free(s->named_buffer); + chunkpool_free(s->atom_pool); + chunkpool_free2(s->vec_pool, (cb_free*)free_vec_pool); + named_buffer_free(s->named_buffer); + map_free(s->sym_table); scanner_free(); + expr_free(); } int is_valid_i8(i32 value) @@ -114,96 +118,56 @@ int is_valid_ui16(i32 value) return (value >= -32768 && value <= 65535); } -void dump_sym_entry(int level, struct sym_entry *se) -{ - LOG(level, ("sym_entry %p symbol %s, expr %p\n", - (void*)se, se->symbol, (void*)se->expr)); -} - struct expr *new_is_defined(const char *symbol) { - struct expr *val; - struct sym_entry e[1]; - int pos; - int expr_val = 0; - - e->symbol = symbol; - pos = vec_find(s_sym_table, sym_entry_cmp, e); - if(pos >= 0) - { - /* found */ - expr_val = 1; - } - val = new_expr_number(expr_val); - return val; + int expr_val = (map_get(s->sym_table, symbol) != NULL); + return new_expr_number(expr_val); } void new_symbol_expr(const char *symbol, struct expr *arg) { - struct sym_entry e[1]; - struct sym_entry *se; - int pos; - - e->symbol = symbol; - pos = vec_find(s_sym_table, sym_entry_cmp, e); - if(pos > -1) + if(map_put(s->sym_table, symbol, arg) != NULL) { /* error, symbol redefinition not allowed */ LOG(LOG_ERROR, ("not allowed to redefine symbol %s\n", symbol)); exit(1); } - if(pos == -1) - { - /* error, find failed */ - LOG(LOG_ERROR, ("new_symbol_expr: vec_find() internal error\n")); - exit(1); - } - e->expr = arg; - - se = vec_insert(s_sym_table, -(pos + 2), e); - LOG(LOG_DEBUG, ("creating symdef: ")); - dump_sym_entry(LOG_DEBUG, se); } -void new_symbol(const char *symbol, i32 value) +void new_symbol_expr_guess(const char *symbol, struct expr *arg) { - struct expr *e; - - e = new_expr_number(value); - new_symbol_expr(symbol, e); + /* Set a soft symbol only if it is not set */ + if(map_get(s->guesses, symbol) == NULL) + { + map_put(s->guesses, symbol, arg); + } } -const char *find_symref(const char *symbol, struct expr **expp) +const char *find_symref(const char *symbol, + struct expr **expp) { - struct sym_entry e[1]; - struct sym_entry *ep; struct expr *exp; - int pos; const char *p; + exp = NULL; p = NULL; - e->symbol = symbol; - pos = vec_find(s_sym_table, sym_entry_cmp, e); - if(pos < -1) + if(s->guesses != NULL) { - static char buf[1024]; - /* error, symbol not found */ - sprintf(buf, "symbol %s not found", symbol); - p = buf; - LOG(LOG_DEBUG, ("%s\n", p)); - return p; + exp = map_get(s->guesses, symbol); } - if(pos == -1) + if(exp == NULL) { - /* error, find failed */ - LOG(LOG_ERROR, ("find_symref: vec_find() internal error\n")); - exit(-1); + exp = map_get(s->sym_table, symbol); + if(exp == NULL) + { + static char buf[1024]; + /* error, symbol not found */ + sprintf(buf, "symbol %s not found", symbol); + p = buf; + LOG(LOG_DEBUG, ("%s\n", p)); + return p; + } } - ep = vec_get(s_sym_table, pos); - exp = ep->expr; - - LOG(LOG_DEBUG, ("found: ")); - dump_sym_entry(LOG_DEBUG, ep); if(expp != NULL) { @@ -215,44 +179,42 @@ const char *find_symref(const char *symbol, struct expr **expp) void new_label(const char *label) { - struct sym_entry e[1]; - struct sym_entry *se; - int pos; + struct expr *e = pc_get(); + new_symbol_expr(label, e); +} - e->symbol = label; - pos = vec_find(s_sym_table, sym_entry_cmp, e); - if(pos > -1) - { - /* error, symbol redefinition not allowed */ - LOG(LOG_ERROR, ("not allowed to redefine label %s\n", label)); - exit(1); - } - if(pos == -1) +static void dump_sym_table(int level, struct map *m) +{ + struct map_iterator i[1]; + const struct map_entry *e; + + for(map_get_iterator(m, i); (e = map_iterator_next(i)) != NULL;) { - /* error, find failed */ - LOG(LOG_ERROR, ("new_label: vec_find() internal error\n")); - exit(1); + LOG(level, ("sym_table: %s ", e->key)); + expr_dump(level, e->value); } - - e->expr = pc_get(); - - se = vec_insert(s_sym_table, -(pos + 2), e); - LOG(LOG_DEBUG, ("creating label: ")); - dump_sym_entry(LOG_DEBUG, se); } -static void dump_sym_table(int level, struct vec *v) +void set_initial_symbol(const char *symbol, i32 value) { - struct vec_iterator i[1]; - struct sym_entry *se; + struct expr *e = new_expr_number(value); + map_put(s->initial_symbols, symbol, e); +} - vec_get_iterator(v, i); - while((se = vec_iterator_next(i)) != NULL) +void set_initial_symbol_soft(const char *symbol, i32 value) +{ + if (!map_contains_key(s->initial_symbols, symbol)) { - LOG(level, ("sym_table: %s\n", se->symbol)); + struct expr *e = new_expr_number(value); + map_put(s->initial_symbols, symbol, e); } } +struct membuf *new_initial_named_buffer(const char *name) +{ + return new_named_buffer(s->initial_named_buffer, name); +} + static const char *resolve_expr2(struct expr *e, i32 *valp) { struct expr *e2; @@ -282,7 +244,12 @@ static const char *resolve_expr2(struct expr *e, i32 *valp) value = !value; break; case SYMBOL: - p = find_symref(e->type.symref, &e2); + p = NULL; + e2 = NULL; + if(s != NULL) + { + p = find_symref(e->type.symref, &e2); + } if(p != NULL) break; if(e2 == NULL) { @@ -382,12 +349,26 @@ static i32 resolve_expr(struct expr *e) if(p != NULL) { LOG(LOG_ERROR, ("%s\n", p)); - exit(-1); + exit(1); } return val; } -struct expr *new_expr_incword(const char *name, struct expr *skip) +struct expr *new_expr_inclen(const char *name) +{ + long length; + struct membuf *in; + struct expr *expr; + + in = get_named_buffer(s->named_buffer, name); + length = membuf_memlen(in); + + expr = new_expr_number((i32)length); + return expr; +} + +struct expr *new_expr_incword(const char *name, + struct expr *skip) { i32 word; i32 offset; @@ -397,7 +378,7 @@ struct expr *new_expr_incword(const char *name, struct expr *skip) unsigned char *p; offset = resolve_expr(skip); - in = get_named_buffer(name); + in = get_named_buffer(s->named_buffer, name); length = membuf_memlen(in); if(offset < 0) { @@ -408,7 +389,7 @@ struct expr *new_expr_incword(const char *name, struct expr *skip) LOG(LOG_ERROR, ("Can't read word from offset %d in file \"%s\".\n", offset, name)); - exit(-1); + exit(1); } p = membuf_get(in); p += offset; @@ -429,9 +410,9 @@ void set_org(struct expr *arg) void push_macro_state(const char *name) { - s_macro_name = name; + s->macro_name = name; push_state_macro = 1; - new_named_buffer(name); + new_named_buffer(s->named_buffer, name); } void macro_append(const char *text) @@ -440,7 +421,7 @@ void macro_append(const char *text) LOG(LOG_DEBUG, ("appending >>%s<< to macro\n", text)); - mb = get_named_buffer(s_macro_name); + mb = get_named_buffer(s->named_buffer, s->macro_name); membuf_append(mb, text, strlen(text)); } @@ -460,11 +441,12 @@ void push_if_state(struct expr *arg) } } -struct atom *new_op(u8 op_code, u8 atom_op_type, struct expr *op_arg) +struct atom *new_op(u8 op_code, u8 atom_op_type, + struct expr *op_arg) { struct atom *atom; - atom = chunkpool_malloc(s_atom_pool); + atom = chunkpool_malloc(s->atom_pool); atom->type = atom_op_type; atom->u.op.code = op_code; atom->u.op.arg = op_arg; @@ -507,9 +489,9 @@ struct atom *new_exprs(struct expr *arg) { struct atom *atom; - atom = chunkpool_malloc(s_atom_pool); + atom = chunkpool_malloc(s->atom_pool); atom->type = ATOM_TYPE_EXPRS; - atom->u.exprs = chunkpool_malloc(s_vec_pool); + atom->u.exprs = chunkpool_malloc(s->vec_pool); vec_init(atom->u.exprs, sizeof(struct expr*)); exprs_add(atom, arg); return atom; @@ -558,7 +540,7 @@ struct atom *new_res(struct expr *len, struct expr *value) { struct atom *atom; - atom = chunkpool_malloc(s_atom_pool); + atom = chunkpool_malloc(s->atom_pool); atom->type = ATOM_TYPE_RES; atom->u.res.length = len; atom->u.res.value = value; @@ -567,7 +549,8 @@ struct atom *new_res(struct expr *len, struct expr *value) return atom; } -struct atom *new_incbin(const char *name, struct expr *skip, struct expr *len) +struct atom *new_incbin(const char *name, + struct expr *skip, struct expr *len) { struct atom *atom; long length; @@ -576,7 +559,7 @@ struct atom *new_incbin(const char *name, struct expr *skip, struct expr *len) struct membuf *in; /* find out how long the file is */ - in = get_named_buffer(name); + in = get_named_buffer(s->named_buffer, name); length = membuf_memlen(in); skip32 = 0; @@ -592,7 +575,7 @@ struct atom *new_incbin(const char *name, struct expr *skip, struct expr *len) { LOG(LOG_ERROR, ("Can't read from offset %d in file \"%s\".\n", skip32, name)); - exit(-1); + exit(1); } length -= skip32; @@ -610,10 +593,10 @@ struct atom *new_incbin(const char *name, struct expr *skip, struct expr *len) LOG(LOG_ERROR, ("Can't read %d bytes from offset %d from file \"%s\".\n", len32, skip32, name)); - exit(-1); + exit(1); } - atom = chunkpool_malloc(s_atom_pool); + atom = chunkpool_malloc(s->atom_pool); atom->type = ATOM_TYPE_BUFFER; atom->u.buffer.name = name; atom->u.buffer.length = len32; @@ -633,30 +616,111 @@ void asm_error(const char *msg) exit(1); } -void asm_echo(const char *msg) +void asm_echo(const char *msg, struct atom *atom) { - fprintf(stdout, "%s\n", msg); + struct vec_iterator i[1]; + struct expr **exprp; + int count = 0; + i32 e[10]; + + if(atom != NULL) + { + if(atom->type != ATOM_TYPE_EXPRS || vec_count(atom->u.exprs) > 10) + { + LOG(LOG_ERROR, ("echo arguments must be a string followed by none " + "or at most ten expressions.\n")); + exit(1); + } + + vec_get_iterator(atom->u.exprs, i); + while((exprp = vec_iterator_next(i)) != NULL) + { + e[count++] = resolve_expr(*exprp); + } + } + for(; count < 10; ++count) + { + e[count] = 0; + } + fprintf(stdout, msg, e[0], e[1], e[2], e[3], + e[4], e[5], e[6], e[7], e[8], e[9]); + fprintf(stdout, "\n"); } void asm_include(const char *msg) { struct membuf *src; - src = get_named_buffer(msg); + src = get_named_buffer(s->named_buffer, msg); asm_src_buffer_push(src); } -void symbol_dump_resolved(int level, const char *symbol) +void initial_symbol_dump(int level, const char *symbol) { i32 value; - struct expr *e; + struct expr *expr; + + expr = map_get(s->initial_symbols, symbol); + if(expr != NULL) + { + value = resolve_expr(expr); + LOG(level, ("symbol \"%s\" resolves to %d ($%04X)\n", + symbol, value, value)); + } + else + { + if(map_contains_key(s->initial_symbols, symbol)) + { + LOG(level, ("symbol \"%s\" defined but has no value\n", symbol)); + } + else + { + LOG(level, ("symbol \"%s\" not found\n", symbol)); + } + } +} + +int resolve_symbol(const char *symbol, int *has_valuep, i32 *valuep) +{ + int found = 0; + int has_value = 0; + i32 value = 0; + struct expr *e = NULL; const char *p; + p = find_symref(symbol, &e); if(p == NULL) { if(e != NULL) { value = resolve_expr(e); + has_value = 1; + } + found = 1; + } + if(found) + { + if(has_valuep != NULL) + { + *has_valuep = has_value; + } + if(has_value && valuep != NULL) + { + *valuep = value; + } + } + return found; +} + +void symbol_dump_resolved(int level, const char *symbol) +{ + int has_value; + i32 value; + + if(resolve_symbol(symbol, &has_value, &value)) + { + if(has_value) + { LOG(level, ("symbol \"%s\" resolves to %d ($%04X)\n", symbol, value, value)); } @@ -685,7 +749,7 @@ void output_atoms(struct membuf *out, struct vec *atoms) i32 value; i32 value2; - dump_sym_table(LOG_DEBUG, s_sym_table); + dump_sym_table(LOG_DEBUG, s->sym_table); vec_get_iterator(atoms, i); while((atomp = vec_iterator_next(i)) != NULL) @@ -706,7 +770,7 @@ void output_atoms(struct membuf *out, struct vec *atoms) if(!is_valid_u8(value)) { LOG(LOG_ERROR, ("value %d out of range for op $%02X @%p\n", - value, atom->u.op.code, atom)); + value, atom->u.op.code, (void*)atom)); exit(1); } LOG(LOG_DEBUG, ("output: $%02X $%02X\n", @@ -720,7 +784,7 @@ void output_atoms(struct membuf *out, struct vec *atoms) if(!is_valid_i8(value)) { LOG(LOG_ERROR, ("value %d out of range for op $%02X @%p\n", - value, atom->u.op.code, atom)); + value, atom->u.op.code, (void*)atom)); exit(1); } LOG(LOG_DEBUG, ("output: $%02X $%02X\n", @@ -734,7 +798,7 @@ void output_atoms(struct membuf *out, struct vec *atoms) if(!is_valid_ui8(value)) { LOG(LOG_ERROR, ("value %d out of range for op $%02X @%p\n", - value, atom->u.op.code, atom)); + value, atom->u.op.code, (void*)atom)); exit(1); } LOG(LOG_DEBUG, ("output: $%02X $%02X\n", @@ -748,7 +812,7 @@ void output_atoms(struct membuf *out, struct vec *atoms) if(!is_valid_u16(value)) { LOG(LOG_ERROR, ("value %d out of range for op $%02X @%p\n", - value, atom->u.op.code, atom)); + value, atom->u.op.code, (void*)atom)); exit(1); } value2 = value / 256; @@ -800,7 +864,7 @@ void output_atoms(struct membuf *out, struct vec *atoms) } LOG(LOG_DEBUG, ("output: .INCBIN \"%s\", %d, %d\n", atom->u.buffer.name, value, value2)); - in = get_named_buffer(atom->u.buffer.name); + in = get_named_buffer(s->named_buffer, atom->u.buffer.name); p = membuf_get(in); p += value; while(--value2 >= 0) @@ -843,8 +907,139 @@ void output_atoms(struct membuf *out, struct vec *atoms) break; default: LOG(LOG_ERROR, ("invalid atom_type %d @%p\n", - atom->type, atom)); + atom->type, (void*)atom)); exit(1); } } } + +static int expr_cmp_cb(const void *a, const void *b) +{ + int result = 0; + i32 e1v = resolve_expr((struct expr*)a); + i32 e2v = resolve_expr((struct expr*)b); + + if(e1v < e2v) + { + result = -1; + } + else if(e1v > e2v) + { + result = 1; + } + return result; +} + +static int loopDetect(struct vec *guesses_history) +{ + int result = 0; + struct vec_iterator i[1]; + struct map *m; + for(vec_get_iterator(guesses_history, i); + (m = vec_iterator_next(i)) != NULL;) + { + if(map_equals(m, s->guesses, expr_cmp_cb)) + { + result = 1; + break; + } + } + return result; +} + +static int wasFinalPass(void) +{ + int result = 1; + struct map_iterator i[1]; + struct map_entry *me; + for(map_get_iterator(s->guesses, i); + (me = (struct map_entry*)map_iterator_next(i)) != NULL;) + { + struct expr *guess_expr; + struct expr *sym_expr; + + LOG(LOG_VERBOSE, ("Checking guessed symbol %s: ", me->key)); + /* Was this guessed symbol used in this pass? */ + if((sym_expr = map_get(s->sym_table, me->key)) == NULL) + { + /* No, skip it */ + continue; + } + guess_expr = me->value; + LOG(LOG_VERBOSE, ("expected %d, actual %d\n", + resolve_expr(guess_expr), + resolve_expr(sym_expr))); + + if(expr_cmp_cb(me->value, sym_expr) != 0) + { + /* Not the same, not the last pass. + * copy the actual value from the sym table */ + me->value = sym_expr; + result = 0; + } + } + return result; +} + +int assemble(struct membuf *source, struct membuf *dest) +{ + struct vec guesses_history[1]; + struct map guesses_storage[1]; + int dest_pos; + int result; + + dump_sym_table(LOG_DEBUG, s->initial_symbols); + + vec_init(guesses_history, sizeof(struct map)); + s->guesses = NULL; + dest_pos = membuf_memlen(dest); + for(;;) + { + + map_put_all(s->sym_table, s->initial_symbols); + named_buffer_copy(s->named_buffer, s->initial_named_buffer); + map_init(guesses_storage); + + if(s->guesses != NULL) + { + /* copy updated guesses from latest pass */ + map_put_all(guesses_storage, s->guesses); + } + s->guesses = guesses_storage; + + result = assembleSinglePass(source, dest); + if(result != 0) + { + /* the assemble pass failed */ + break; + } + + /* check if any guessed symbols was wrong and update them + * to their actual value */ + if(wasFinalPass()) + { + /* The assemble pass succeeded without any wrong guesses, + * we're done */ + break; + } + if(loopDetect(guesses_history)) + { + /* More passes would only get us into a loop */ + LOG(LOG_VERBOSE, ("Aborting due to loop.\n")); + result = -1; + break; + } + + LOG(LOG_VERBOSE, ("Trying another pass.\n")); + + /* allocate storage for the guesses in the history vector */ + s->guesses = vec_push(guesses_history, s->guesses); + + parse_reset(); + membuf_truncate(dest, dest_pos); + } + map_free(guesses_storage); + vec_free(guesses_history, (cb_free*)map_free); + s->guesses = NULL; + return result; +} diff --git a/src/asm/parse.h b/src/asm/parse.h index d0939b2..5c07938 100644 --- a/src/asm/parse.h +++ b/src/asm/parse.h @@ -32,6 +32,10 @@ #include "vec.h" #include "membuf.h" #include "expr.h" +#include "map.h" +#include "named_buffer.h" +#include "chunkpool.h" +#include "pc.h" #define ATOM_TYPE_OP_ARG_NONE 0 /* uses u.op */ #define ATOM_TYPE_OP_ARG_U8 1 /* uses u.op */ @@ -80,8 +84,18 @@ extern int push_state_macro; extern int push_state_init; extern int num_lines; -void parse_init(); -void parse_free(); +void parse_init(void); +void parse_free(void); + +void set_initial_symbol(const char *symbol, i32 value); +void set_initial_symbol_soft(const char *symbol, i32 value); +void initial_symbol_dump(int level, const char *symbol); + +struct membuf *new_initial_named_buffer(const char *name); + +int assemble(struct membuf *source, struct membuf *dest); + +/* start of internal functions */ struct atom *new_op(u8 op_code, u8 op_size, struct expr *arg); struct atom *new_op0(u8 op_code); @@ -92,17 +106,22 @@ struct atom *exprs_to_byte_exprs(struct atom *atom); struct atom *exprs_to_word_exprs(struct atom *atom); struct atom *new_res(struct expr *len, struct expr *value); -struct atom *new_incbin(const char *name, struct expr *skip, struct expr *len); +struct atom *new_incbin(const char *name, + struct expr *skip, struct expr *len); struct expr *new_is_defined(const char *symbol); -struct expr *new_expr_incword(const char *name, struct expr *skip); +struct expr *new_expr_inclen(const char *name); +struct expr *new_expr_incword(const char *name, + struct expr *skip); -void new_symbol(const char *symbol, i32 value); void new_symbol_expr(const char *symbol, struct expr *arg); +void new_symbol_expr_guess(const char *symbol, struct expr *arg); /* returns NULL if found, not otherwise, expp may be NULL. */ -const char *find_symref(const char *symbol, struct expr **expp); +const char *find_symref(const char *symbol, + struct expr **expp); +int resolve_symbol(const char *symbol, int *has_valuep, i32 *valuep); void symbol_dump_resolved(int level, const char *symbol); void new_label(const char *label); @@ -111,11 +130,12 @@ void push_if_state(struct expr *arg); void push_macro_state(const char *name); void macro_append(const char *text); void asm_error(const char *msg); -void asm_echo(const char *msg); +void asm_echo(const char *msg, struct atom *atom); void asm_include(const char *msg); -int assemble(struct membuf *source, struct membuf *dest); void output_atoms(struct membuf *out, struct vec *mem); void asm_src_buffer_push(struct membuf *buf); +int assembleSinglePass(struct membuf *source, struct membuf *dest); + #endif diff --git a/src/asm/pc.c b/src/asm/pc.c index b77becc..396890a 100644 --- a/src/asm/pc.c +++ b/src/asm/pc.c @@ -29,10 +29,13 @@ #include "log.h" #include +struct pc { + struct expr *pc1; + int pc2; +}; static struct expr unset_value[1]; -static struct expr *s_pc1; -static int s_pc2; +static struct pc p[1] = {{unset_value, 0}}; void pc_dump(int level) { @@ -40,44 +43,44 @@ void pc_dump(int level) void pc_set(int pc) { - s_pc1 = NULL; - s_pc2 = pc; + p->pc1 = NULL; + p->pc2 = pc; } void pc_set_expr(struct expr *pc) { - s_pc1 = pc; - s_pc2 = 0; + p->pc1 = pc; + p->pc2 = 0; } -struct expr *pc_get() +struct expr *pc_get(void) { struct expr *old_pc1; - if(s_pc1 == unset_value) + if(p->pc1 == unset_value) { LOG(LOG_ERROR, ("PC must be set by a .org(pc) call.\n")); - exit(-1); + exit(1); } - if(s_pc1 == NULL || s_pc2 != 0) + if(p->pc1 == NULL || p->pc2 != 0) { - old_pc1 = s_pc1; - s_pc1 = new_expr_number(s_pc2); - s_pc2 = 0; + old_pc1 = p->pc1; + p->pc1 = new_expr_number(p->pc2); + p->pc2 = 0; if(old_pc1 != NULL) { - s_pc1 = new_expr_op2(PLUS, s_pc1, old_pc1); + p->pc1 = new_expr_op2(PLUS, p->pc1, old_pc1); } } - return s_pc1; + return p->pc1; } void pc_add(int offset) { - if(s_pc1 != unset_value) + if(p->pc1 != unset_value) { - s_pc2 += offset; + p->pc2 += offset; } } @@ -85,18 +88,18 @@ void pc_add_expr(struct expr *pc) { struct expr *old_pc1; - if(s_pc1 != unset_value) + if(p->pc1 != unset_value) { - old_pc1 = s_pc1; - s_pc1 = pc; + old_pc1 = p->pc1; + p->pc1 = pc; if(old_pc1 != NULL) { - s_pc1 = new_expr_op2(PLUS, s_pc1, old_pc1); + p->pc1 = new_expr_op2(PLUS, p->pc1, old_pc1); } } } -void pc_unset() +void pc_unset(void) { pc_set_expr(unset_value); } diff --git a/src/asm/vec.c b/src/asm/vec.c index e63ef65..5ba9213 100644 --- a/src/asm/vec.c +++ b/src/asm/vec.c @@ -28,11 +28,11 @@ #include "vec.h" #include - #define VEC_FLAG_SORTED 1 void vec_init(struct vec *p, size_t elsize) { + //printf("vec_init %ld\n", elsize); p->elsize = elsize; membuf_init(&p->buf); p->flags = VEC_FLAG_SORTED; @@ -41,7 +41,7 @@ void vec_init(struct vec *p, size_t elsize) void vec_clear(struct vec *p, cb_free * f) { struct vec_iterator i; - void *d; + const void *d; vec_get_iterator(p, &i); @@ -49,11 +49,12 @@ void vec_clear(struct vec *p, cb_free * f) { while ((d = vec_iterator_next(&i)) != NULL) { - f(d); + f((void*)d); } } membuf_clear(&p->buf); p->flags = VEC_FLAG_SORTED; + } void vec_free(struct vec *p, cb_free * f) @@ -62,23 +63,39 @@ void vec_free(struct vec *p, cb_free * f) membuf_free(&p->buf); } -int vec_count(struct vec *p) +int vec_count(const struct vec *p) { + //printf("vec_count %ld\n", p->elsize); int count; count = membuf_memlen(&p->buf) / p->elsize; return count; } -void *vec_get(struct vec *p, int index) +void *vec_get(const struct vec *p, int index) { - char *buf; + char *buf = NULL; - buf = (char *) membuf_get(&p->buf); - buf += index * p->elsize; + if(index < vec_count(p)) + { + buf = (char *) membuf_get(&p->buf); + buf += index * p->elsize; + } return (void *)buf; } +void *vec_set(struct vec *p, int index, const void *in) +{ + void *buf = NULL; + + if(index < vec_count(p)) + { + buf = membuf_memcpy(&p->buf, index * p->elsize, in, p->elsize); + } + + return buf; +} + void *vec_insert(struct vec *p, int index, const void *in) { void *buf; @@ -88,6 +105,11 @@ void *vec_insert(struct vec *p, int index, const void *in) return buf; } +void vec_remove(struct vec *p, int index) +{ + membuf_remove(&p->buf, index * p->elsize, p->elsize); +} + void *vec_push(struct vec *p, const void *in) { void *out; @@ -97,7 +119,7 @@ void *vec_push(struct vec *p, const void *in) return out; } -int vec_find(struct vec *p, cb_cmp * f, const void *in) +int vec_find(const struct vec *p, cb_cmp * f, const void *in) { int lo; @@ -133,7 +155,7 @@ int vec_find(struct vec *p, cb_cmp * f, const void *in) return -(lo + 2); } -void *vec_find2(struct vec *p, cb_cmp * f, const void *key) +void *vec_find2(const struct vec *p, cb_cmp * f, const void *key) { void *out = NULL; int pos = vec_find(p, f, key); @@ -180,7 +202,7 @@ void vec_sort(struct vec *p, cb_cmp * f) } -void vec_get_iterator(struct vec *p, struct vec_iterator *i) +void vec_get_iterator(const struct vec *p, struct vec_iterator *i) { i->vec = p; i->pos = 0; @@ -198,3 +220,50 @@ void *vec_iterator_next(struct vec_iterator *i) i->pos += 1; return out; } + +void vec_fprint(FILE *f, const struct vec *a, cb_fprint *fprint) +{ + struct vec_iterator i[1]; + int *e; + char *glue = "["; + + vec_get_iterator(a, i); + while((e = vec_iterator_next(i)) != NULL) + { + fprintf(f, "%s", glue); + fprint(f, e); + glue = ", "; + } + fprintf(f, "]"); +} + +int vec_equals(const struct vec *a, const struct vec *b, cb_cmp *cmp) +{ + struct vec_iterator ia[1]; + struct vec_iterator ib[1]; + void *ea; + void *eb; + int equal = 1; + + vec_get_iterator(a, ia); + vec_get_iterator(b, ib); + + while(equal) + { + ea = vec_iterator_next(ia); + eb = vec_iterator_next(ib); + + if(ea == NULL && eb == NULL) + { + break; + } + + if((ea == NULL) ^ (eb == NULL)) + { + equal = 0; + break; + } + equal = !cmp(ea, eb); + } + return equal; +} diff --git a/src/asm/vec.h b/src/asm/vec.h index 1ca8795..6dc12f5 100644 --- a/src/asm/vec.h +++ b/src/asm/vec.h @@ -31,7 +31,7 @@ #include "callback.h" #include "membuf.h" #include - +#include #define STATIC_VEC_INIT(EL_SIZE) {(EL_SIZE), STATIC_MEMBUF_INIT, 1} @@ -42,7 +42,7 @@ struct vec { }; struct vec_iterator { - struct vec *vec; + const struct vec *vec; int pos; }; @@ -50,35 +50,46 @@ void vec_init(struct vec *p, size_t elsize); void vec_clear(struct vec *p, cb_free * f); void vec_free(struct vec *p, cb_free * f); -int vec_count(struct vec *p); -void *vec_get(struct vec *p, int index); +int vec_count(const struct vec *p); +void *vec_get(const struct vec *p, int index); + +/** + * Returns a pointer to the set area or null if the index is out of + * bounds. + **/ +void *vec_set(struct vec *p, int index, const void *in); void *vec_insert(struct vec *p, int index, const void *in); +void vec_remove(struct vec *p, int index); + void *vec_push(struct vec *p, const void *in); + /** * Gets the position where the key is stored in the vector. The vector * needs to be sorted for this function to work. Returns the position, * -1 on error or a negative number that can be converted to where * it should have been if it had been inserted. insert_pos = -(val + 2) **/ -int vec_find(struct vec *p, cb_cmp * f, const void *key); +int vec_find(const struct vec *p, cb_cmp * f, const void *key); /** * Gets a pointer to the element that the key points to. * Returns a pointer that may be null if not found. **/ -void *vec_find2(struct vec *p, cb_cmp * f, const void *key); +void *vec_find2(const struct vec *p, cb_cmp * f, const void *key); /** * Inserts the in element in its correct position in a sorted vector. * returns 1 if insertion is successful, 0 if element is already - * inserted or -1 on error. If out is not NULL it will be - * dereferenced and set to the inserted element. + * present or -1 on error. If out is not NULL it will be + * dereferenced and set to the inserted or present element. **/ int vec_insert_uniq(struct vec *p, cb_cmp * f, const void *in, void **out); void vec_sort(struct vec *p, cb_cmp * f); -void vec_get_iterator(struct vec *p, struct vec_iterator *i); +void vec_get_iterator(const struct vec *p, struct vec_iterator *i); void *vec_iterator_next(struct vec_iterator *i); +int vec_equals(const struct vec *a, const struct vec *b, cb_cmp *equals); +void vec_fprint(FILE *, const struct vec *a, cb_fprint *fprint); #endif diff --git a/src/data/altplayer.s b/src/data/altplayer.s index f86eff5..7318476 100644 --- a/src/data/altplayer.s +++ b/src/data/altplayer.s @@ -433,7 +433,7 @@ mt_effectnum: .ENDIF .ENDIF .IF (NOTONEPORTA == 0) - ldy mt_chnnote,y + ldy mt_chnnote,x .IF (GHOSTREGS == 0) lda mt_chnfreqlo,x ;Calculate offset to the sbc mt_freqtbllo-FIRSTNOTE,y ;right frequency @@ -506,7 +506,7 @@ mt_effect_3_found: lda mt_chnnote,x jmp mt_wavenoteabs .ELSE - ldy mt_chnnote,y + ldy mt_chnnote,x jmp mt_wavenote .ENDIF .ENDIF @@ -762,7 +762,7 @@ mt_repeatdone: mt_tick0: .IF (NOEFFECTS == 0) - ldy mt_chnnewfx,y ;Setup tick 0 FX jumps + ldy mt_chnnewfx,x ;Setup tick 0 FX jumps lda mt_tick0jumptbl,y sta mt_tick0jump1+1 sta mt_tick0jump2+1 @@ -774,12 +774,12 @@ mt_checknewpatt: lda mt_chnpattptr,x ;Fetch next pattern? bne mt_nonewpatt mt_sequencer: - ldy mt_chnsongnum,y + ldy mt_chnsongnum,x lda mt_songtbllo,y ;Get address of sequence sta Date: Sun, 19 Jul 2026 15:51:06 +0200 Subject: [PATCH 2/2] Update Exomizer to version 3.1.2 --- CMakeLists.txt | 4 +- README.md | 2 +- src/asm/Makefile | 23 +- src/asm/asm.tab.c | 3248 ++++++++++++++--------------- src/asm/asm.tab.h | 209 +- src/asm/asm.y | 28 +- src/asm/asm.yy | 23 +- src/asm/buf.c | 403 ++++ src/asm/buf.h | 144 ++ src/asm/{membuf_io.c => buf_io.c} | 20 +- src/asm/{membuf_io.h => buf_io.h} | 26 +- src/asm/callback.h | 16 +- src/asm/chunkpool.c | 14 +- src/asm/chunkpool.h | 17 +- src/asm/expr.c | 24 +- src/asm/expr.h | 16 +- src/asm/int.h | 16 +- src/asm/lex.yy.c | 892 ++++---- src/asm/log.c | 10 +- src/asm/log.h | 27 +- src/asm/map.c | 36 +- src/asm/map.h | 16 +- src/asm/membuf.c | 267 --- src/asm/membuf.h | 68 - src/asm/named_buffer.c | 31 +- src/asm/named_buffer.h | 22 +- src/asm/parse.c | 285 +-- src/asm/parse.h | 29 +- src/asm/pc.c | 50 +- src/asm/pc.h | 16 +- src/asm/vec.c | 77 +- src/asm/vec.h | 47 +- src/reloc.cpp | 46 +- 33 files changed, 3154 insertions(+), 2998 deletions(-) create mode 100644 src/asm/buf.c create mode 100644 src/asm/buf.h rename src/asm/{membuf_io.c => buf_io.c} (68%) rename src/asm/{membuf_io.h => buf_io.h} (55%) delete mode 100644 src/asm/membuf.c delete mode 100644 src/asm/membuf.h diff --git a/CMakeLists.txt b/CMakeLists.txt index d99aa7f..5a1db4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,8 +39,8 @@ set(LOADTRK_SOURCES src/asm/lex.yy.c src/asm/log.c src/asm/map.c - src/asm/membuf.c - src/asm/membuf_io.c + src/asm/buf.c + src/asm/buf_io.c src/asm/named_buffer.c src/asm/parse.c src/asm/pc.c diff --git a/README.md b/README.md index e9c5605..9c22582 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ _You should have received a copy of the GNU General Public License https://github.com/thestk/rtmidi distributed under MIT license -* Exomizer 2.0.11 +* Exomizer 3.1.2 https://bitbucket.org/magli143/exomizer/ distributed under ZLIB license diff --git a/src/asm/Makefile b/src/asm/Makefile index 2ccd367..dc6d240 100644 --- a/src/asm/Makefile +++ b/src/asm/Makefile @@ -1,21 +1,21 @@ # # Makefile for exomizer # -WFLAGS = --std=c89 -Wall -Wstrict-prototypes -CFLAGS = $(WFLAGS) -O3 -ffast-math -fomit-frame-pointer -fgcse -pedantic -D_XOPEN_SOURCE=500 +WFLAGS = -std=c89 -Wall -Wstrict-prototypes -D_XOPEN_SOURCE=600 -pedantic +CFLAGS = $(WFLAGS) -O3 -ffast-math -fomit-frame-pointer LDFLAGS = -s #CFLAGS = -g $(WFLAGS) #LDFLAGS = -g -SHARED_OBJS = getflag.o log.o membuf.o -RAW_OBJS = match.o search.o exo_raw.o optimal.o output.o membuf_io.o \ +SHARED_OBJS = getflag.o log.o buf.o +RAW_OBJS = match.o search.o exo_raw.o optimal.o output.o buf_io.o \ chunkpool.o radix.o exo_helper.o exodec.o progress.o exo_util.o \ vec.o -EXO_OBJS = match.o search.o exo_main.o optimal.o output.o membuf_io.o \ +EXO_OBJS = match.o search.o exo_main.o optimal.o output.o buf_io.o \ chunkpool.o radix.o exo_helper.o exodec.o progress.o asm.tab.o \ lex.yy.o parse.o expr.o pc.o vec.o named_buffer.o map.o desfx.o \ - 6502emu.o exo_util.o sfxdecr.o + 6502emu.o exo_util.o areatrace.o sfxdecr.o table.o perf.o BAS_OBJS = bas_main.o bprg_renumber.o bprg_link_patch.o bprg_trampoline.o \ bprg.o vec.o ALL_OBJS = $(EXO_OBJS) $(RAW_OBJS) $(BAS_OBJS) $(SHARED_OBJS) @@ -23,7 +23,7 @@ ALL_OBJS = $(EXO_OBJS) $(RAW_OBJS) $(BAS_OBJS) $(SHARED_OBJS) #.SILENT: .PHONY: build clean -.INTERMEDIATE: b2membuf exoraw +.INTERMEDIATE: b2buf exoraw build: $(MAKEFILE) exomizer exobasic @@ -42,7 +42,7 @@ exobasic: deps $(BAS_OBJS) $(SHARED_OBJS) clean: @echo "Cleaning project" -@$(RM) $(EXO_OBJS) $(RAW_OBJS) $(BAS_OBJS) $(SHARED_OBJS) - -@$(RM) b2membuf.o b2membuf b2membuf.exe sfxdecr sfxdecr.c deps + -@$(RM) b2buf.o b2buf b2buf.exe sfxdecr sfxdecr.c deps -@$(RM) exomizer exoraw exobasic exomizer.exe exoraw.exe exobasic.exe @@ -52,8 +52,8 @@ asm.tab.h asm.tab.c: asm.y lex.yy.c: asm.yy flex -B asm.yy -sfxdecr.c: sfxdecr b2membuf - @./b2membuf sfxdecr >sfxdecr.c +sfxdecr.c: sfxdecr b2buf + @./b2buf sfxdecr >sfxdecr.c sfxdecr: sfxdecr.s exoraw @echo "Compressing $<" @@ -71,3 +71,6 @@ deps: $(wildcard *.h) asm.tab.h %: %.o @$(CC) $(LDFLAGS) $< -o $@ + +tabletest: table.o tabletest.o vec.o buf.o + @$(CC) $(CFLAGS) $^ -o $@ diff --git a/src/asm/asm.tab.c b/src/asm/asm.tab.c index 1c35b37..2addee7 100644 --- a/src/asm/asm.tab.c +++ b/src/asm/asm.tab.c @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 3.7.2. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 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 @@ -33,6 +34,10 @@ /* 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. @@ -44,7 +49,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.0.4" +#define YYBISON_VERSION "3.7.2" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -61,13 +66,13 @@ -/* Copy the first part of user declarations. */ -#line 28 "asm.y" /* yacc.c:339 */ +/* First part of user prologue. */ +#line 28 "asm.y" #include "int.h" #include "parse.h" #include "vec.h" -#include "membuf.h" +#include "buf.h" #include "log.h" #include #define YYERROR_VERBOSE @@ -79,192 +84,228 @@ int yylex(void); void yyerror(const char *s); -#line 83 "asm.tab.c" /* yacc.c:339 */ +#line 88 "asm.tab.c" +# 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 && 201103L <= __cplusplus -# define YY_NULLPTR nullptr +# if defined __cplusplus +# if 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif # else -# define YY_NULLPTR 0 +# define YY_NULLPTR ((void*)0) # endif # endif -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif - -/* In a future release of Bison, this section will be replaced - by #include "asm.tab.h". */ -#ifndef YY_YY_ASM_TAB_H_INCLUDED -# define YY_YY_ASM_TAB_H_INCLUDED -/* Debug traces. */ -#ifndef YYDEBUG -# define YYDEBUG 1 -#endif -#if YYDEBUG -extern int yydebug; -#endif - -/* Token type. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - enum yytokentype - { - INCLUDE = 258, - IF = 259, - DEFINED = 260, - MACRO = 261, - MACRO_STRING = 262, - ORG = 263, - ERROR = 264, - ECHO1 = 265, - INCBIN = 266, - INCLEN = 267, - INCWORD = 268, - RES = 269, - WORD = 270, - BYTE = 271, - LDA = 272, - LDX = 273, - LDY = 274, - STA = 275, - STX = 276, - STY = 277, - AND = 278, - ORA = 279, - EOR = 280, - ADC = 281, - SBC = 282, - CMP = 283, - CPX = 284, - CPY = 285, - TSX = 286, - TXS = 287, - PHA = 288, - PLA = 289, - PHP = 290, - PLP = 291, - SEI = 292, - CLI = 293, - NOP = 294, - TYA = 295, - TAY = 296, - TXA = 297, - TAX = 298, - CLC = 299, - SEC = 300, - RTS = 301, - JSR = 302, - JMP = 303, - BEQ = 304, - BNE = 305, - BCC = 306, - BCS = 307, - BPL = 308, - BMI = 309, - BVC = 310, - BVS = 311, - INX = 312, - DEX = 313, - INY = 314, - DEY = 315, - INC = 316, - DEC = 317, - LSR = 318, - ASL = 319, - ROR = 320, - ROL = 321, - BIT = 322, - SYMBOL = 323, - STRING = 324, - LAND = 325, - LOR = 326, - LNOT = 327, - LPAREN = 328, - RPAREN = 329, - COMMA = 330, - COLON = 331, - X = 332, - Y = 333, - HASH = 334, - PLUS = 335, - MINUS = 336, - MULT = 337, - DIV = 338, - MOD = 339, - LT = 340, - GT = 341, - EQ = 342, - NEQ = 343, - ASSIGN = 344, - GUESS = 345, - NUMBER = 346, - vNEG = 347, - LABEL = 348 - }; -#endif - -/* Value type. */ -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED - -union YYSTYPE +#include "asm.tab.h" +/* Symbol kind. */ +enum yysymbol_kind_t { -#line 145 "asm.y" /* yacc.c:355 */ - - i32 num; - char *str; - struct atom *atom; - struct expr *expr; - -#line 224 "asm.tab.c" /* yacc.c:355 */ + YYSYMBOL_YYEMPTY = -2, + YYSYMBOL_YYEOF = 0, /* "end of file" */ + YYSYMBOL_YYerror = 1, /* error */ + YYSYMBOL_YYUNDEF = 2, /* "invalid token" */ + YYSYMBOL_INCLUDE = 3, /* INCLUDE */ + YYSYMBOL_IF = 4, /* IF */ + YYSYMBOL_DEFINED = 5, /* DEFINED */ + YYSYMBOL_MACRO = 6, /* MACRO */ + YYSYMBOL_MACRO_STRING = 7, /* MACRO_STRING */ + YYSYMBOL_ORG = 8, /* ORG */ + YYSYMBOL_ERROR = 9, /* ERROR */ + YYSYMBOL_ECHO1 = 10, /* ECHO1 */ + YYSYMBOL_INCBIN = 11, /* INCBIN */ + YYSYMBOL_INCLEN = 12, /* INCLEN */ + YYSYMBOL_INCWORD = 13, /* INCWORD */ + YYSYMBOL_RES = 14, /* RES */ + YYSYMBOL_WORD = 15, /* WORD */ + YYSYMBOL_BYTE = 16, /* BYTE */ + YYSYMBOL_TEXT = 17, /* TEXT */ + YYSYMBOL_LDA = 18, /* LDA */ + YYSYMBOL_LDX = 19, /* LDX */ + YYSYMBOL_LDY = 20, /* LDY */ + YYSYMBOL_STA = 21, /* STA */ + YYSYMBOL_STX = 22, /* STX */ + YYSYMBOL_STY = 23, /* STY */ + YYSYMBOL_AND = 24, /* AND */ + YYSYMBOL_ORA = 25, /* ORA */ + YYSYMBOL_EOR = 26, /* EOR */ + YYSYMBOL_ADC = 27, /* ADC */ + YYSYMBOL_SBC = 28, /* SBC */ + YYSYMBOL_CMP = 29, /* CMP */ + YYSYMBOL_CPX = 30, /* CPX */ + YYSYMBOL_CPY = 31, /* CPY */ + YYSYMBOL_TSX = 32, /* TSX */ + YYSYMBOL_TXS = 33, /* TXS */ + YYSYMBOL_PHA = 34, /* PHA */ + YYSYMBOL_PLA = 35, /* PLA */ + YYSYMBOL_PHP = 36, /* PHP */ + YYSYMBOL_PLP = 37, /* PLP */ + YYSYMBOL_SEI = 38, /* SEI */ + YYSYMBOL_CLI = 39, /* CLI */ + YYSYMBOL_NOP = 40, /* NOP */ + YYSYMBOL_TYA = 41, /* TYA */ + YYSYMBOL_TAY = 42, /* TAY */ + YYSYMBOL_TXA = 43, /* TXA */ + YYSYMBOL_TAX = 44, /* TAX */ + YYSYMBOL_CLC = 45, /* CLC */ + YYSYMBOL_SEC = 46, /* SEC */ + YYSYMBOL_RTS = 47, /* RTS */ + YYSYMBOL_CLV = 48, /* CLV */ + YYSYMBOL_CLD = 49, /* CLD */ + YYSYMBOL_SED = 50, /* SED */ + YYSYMBOL_JSR = 51, /* JSR */ + YYSYMBOL_JMP = 52, /* JMP */ + YYSYMBOL_BEQ = 53, /* BEQ */ + YYSYMBOL_BNE = 54, /* BNE */ + YYSYMBOL_BCC = 55, /* BCC */ + YYSYMBOL_BCS = 56, /* BCS */ + YYSYMBOL_BPL = 57, /* BPL */ + YYSYMBOL_BMI = 58, /* BMI */ + YYSYMBOL_BVC = 59, /* BVC */ + YYSYMBOL_BVS = 60, /* BVS */ + YYSYMBOL_INX = 61, /* INX */ + YYSYMBOL_DEX = 62, /* DEX */ + YYSYMBOL_INY = 63, /* INY */ + YYSYMBOL_DEY = 64, /* DEY */ + YYSYMBOL_INC = 65, /* INC */ + YYSYMBOL_DEC = 66, /* DEC */ + YYSYMBOL_LSR = 67, /* LSR */ + YYSYMBOL_ASL = 68, /* ASL */ + YYSYMBOL_ROR = 69, /* ROR */ + YYSYMBOL_ROL = 70, /* ROL */ + YYSYMBOL_BIT = 71, /* BIT */ + YYSYMBOL_SYMBOL = 72, /* SYMBOL */ + YYSYMBOL_STRING = 73, /* STRING */ + YYSYMBOL_LAND = 74, /* LAND */ + YYSYMBOL_LOR = 75, /* LOR */ + YYSYMBOL_LNOT = 76, /* LNOT */ + YYSYMBOL_LPAREN = 77, /* LPAREN */ + YYSYMBOL_RPAREN = 78, /* RPAREN */ + YYSYMBOL_COMMA = 79, /* COMMA */ + YYSYMBOL_COLON = 80, /* COLON */ + YYSYMBOL_X = 81, /* X */ + YYSYMBOL_Y = 82, /* Y */ + YYSYMBOL_HASH = 83, /* HASH */ + YYSYMBOL_PLUS = 84, /* PLUS */ + YYSYMBOL_MINUS = 85, /* MINUS */ + YYSYMBOL_MULT = 86, /* MULT */ + YYSYMBOL_DIV = 87, /* DIV */ + YYSYMBOL_MOD = 88, /* MOD */ + YYSYMBOL_LT = 89, /* LT */ + YYSYMBOL_GT = 90, /* GT */ + YYSYMBOL_EQ = 91, /* EQ */ + YYSYMBOL_NEQ = 92, /* NEQ */ + YYSYMBOL_ASSIGN = 93, /* ASSIGN */ + YYSYMBOL_GUESS = 94, /* GUESS */ + YYSYMBOL_NUMBER = 95, /* NUMBER */ + YYSYMBOL_vNEG = 96, /* vNEG */ + YYSYMBOL_LABEL = 97, /* LABEL */ + YYSYMBOL_YYACCEPT = 98, /* $accept */ + YYSYMBOL_stmts = 99, /* stmts */ + YYSYMBOL_stmt = 100, /* stmt */ + YYSYMBOL_atom = 101, /* atom */ + YYSYMBOL_exprs = 102, /* exprs */ + YYSYMBOL_op = 103, /* op */ + YYSYMBOL_am_im = 104, /* am_im */ + YYSYMBOL_am_a = 105, /* am_a */ + YYSYMBOL_am_ax = 106, /* am_ax */ + YYSYMBOL_am_ay = 107, /* am_ay */ + YYSYMBOL_am_zp = 108, /* am_zp */ + YYSYMBOL_am_zpx = 109, /* am_zpx */ + YYSYMBOL_am_zpy = 110, /* am_zpy */ + YYSYMBOL_am_ix = 111, /* am_ix */ + YYSYMBOL_am_iy = 112, /* am_iy */ + YYSYMBOL_expr = 113, /* expr */ + YYSYMBOL_lexpr = 114 /* lexpr */ }; +typedef enum yysymbol_kind_t yysymbol_kind_t; -typedef union YYSTYPE YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 -# define YYSTYPE_IS_DECLARED 1 -#endif -extern YYSTYPE yylval; -int yyparse (void); +#ifdef short +# undef short +#endif -#endif /* !YY_YY_ASM_TAB_H_INCLUDED */ +/* 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. */ -/* Copy the second part of user declarations. */ +#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 -#line 241 "asm.tab.c" /* yacc.c:358 */ +/* 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 short -# undef short +#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 YYTYPE_UINT8 -typedef YYTYPE_UINT8 yytype_uint8; +#ifdef __INT_LEAST16_MAX__ +typedef __INT_LEAST16_TYPE__ yytype_int16; +#elif defined YY_STDINT_H +typedef int_least16_t yytype_int16; #else -typedef unsigned char yytype_uint8; +typedef short yytype_int16; #endif -#ifdef YYTYPE_INT8 -typedef YYTYPE_INT8 yytype_int8; +#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 signed char yytype_int8; +typedef short yytype_uint8; #endif -#ifdef YYTYPE_UINT16 -typedef YYTYPE_UINT16 yytype_uint16; +#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 unsigned short int yytype_uint16; +typedef int yytype_uint16; #endif -#ifdef YYTYPE_INT16 -typedef YYTYPE_INT16 yytype_int16; -#else -typedef short int yytype_int16; +#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 @@ -272,15 +313,28 @@ typedef short int yytype_int16; # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t -# elif ! defined YYSIZE_T +# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else -# define YYSIZE_T unsigned int +# define YYSIZE_T unsigned # endif #endif -#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) +#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_int16 yy_state_t; + +/* State numbers in computations. */ +typedef int yy_state_fast_t; #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS @@ -294,30 +348,20 @@ typedef short int yytype_int16; # endif #endif -#ifndef YY_ATTRIBUTE -# if (defined __GNUC__ \ - && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ - || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C -# define YY_ATTRIBUTE(Spec) __attribute__(Spec) -# else -# define YY_ATTRIBUTE(Spec) /* empty */ -# endif -#endif #ifndef YY_ATTRIBUTE_PURE -# define YY_ATTRIBUTE_PURE 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 -# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) -#endif - -#if !defined _Noreturn \ - && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) -# if defined _MSC_VER && 1200 <= _MSC_VER -# define _Noreturn __declspec (noreturn) +# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) # else -# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +# define YY_ATTRIBUTE_UNUSED # endif #endif @@ -328,13 +372,13 @@ typedef short int yytype_int16; # define YYUSE(E) /* empty */ #endif -#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") -# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ _Pragma ("GCC diagnostic pop") #else # define YY_INITIAL_VALUE(Value) Value @@ -347,8 +391,22 @@ typedef short int yytype_int16; # 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 -#if ! defined yyoverflow || YYERROR_VERBOSE + +#define YY_ASSERT(E) ((void) (0 && (E))) + +#if !defined yyoverflow /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -413,8 +471,7 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # endif -#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ - +#endif /* !defined yyoverflow */ #if (! defined yyoverflow \ && (! defined __cplusplus \ @@ -423,17 +480,17 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss_alloc; + 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 (sizeof (union yyalloc) - 1) +# 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) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) # define YYCOPY_NEEDED 1 @@ -446,11 +503,11 @@ union yyalloc # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ - YYSIZE_T yynewbytes; \ + YYPTRDIFF_T yynewbytes; \ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ + yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / YYSIZEOF (*yyptr); \ } \ while (0) @@ -462,12 +519,12 @@ union yyalloc # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(Dst, Src, Count) \ - __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) + __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src))) # else # define YYCOPY(Dst, Src, Count) \ do \ { \ - YYSIZE_T yyi; \ + YYPTRDIFF_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (Dst)[yyi] = (Src)[yyi]; \ } \ @@ -477,30 +534,33 @@ union yyalloc #endif /* !YYCOPY_NEEDED */ /* YYFINAL -- State number of the termination state. */ -#define YYFINAL 218 +#define YYFINAL 223 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 646 +#define YYLAST 663 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 94 +#define YYNTOKENS 98 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 17 /* YYNRULES -- Number of rules. */ -#define YYNRULES 198 +#define YYNRULES 202 /* YYNSTATES -- Number of states. */ -#define YYNSTATES 320 +#define YYNSTATES 327 + +/* YYMAXUTOK -- Last valid token kind. */ +#define YYMAXUTOK 352 -/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned - by yylex, with out-of-bounds checking. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 348 -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) +/* 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, without out-of-bounds checking. */ -static const yytype_uint8 yytranslate[] = + 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, @@ -536,61 +596,77 @@ static const yytype_uint8 yytranslate[] = 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, - 85, 86, 87, 88, 89, 90, 91, 92, 93 + 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, + 95, 96, 97 }; #if YYDEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ -static const yytype_uint16 yyrline[] = +static const yytype_int16 yyrline[] = { - 0, 182, 182, 182, 183, 184, 185, 186, 187, 188, - 189, 190, 191, 192, 193, 194, 196, 197, 198, 199, - 200, 202, 204, 207, 208, 210, 211, 212, 213, 214, - 215, 216, 217, 219, 220, 221, 222, 223, 225, 226, - 227, 228, 229, 231, 232, 233, 234, 235, 236, 237, - 239, 240, 241, 243, 244, 245, 247, 248, 249, 250, - 251, 252, 253, 254, 256, 257, 258, 259, 260, 261, - 262, 263, 265, 266, 267, 268, 269, 270, 271, 272, - 274, 275, 276, 277, 278, 279, 280, 281, 283, 284, - 285, 286, 287, 288, 289, 290, 292, 293, 294, 295, - 296, 297, 298, 299, 301, 302, 303, 304, 305, 306, - 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, - 318, 319, 320, 321, 322, 323, 325, 326, 327, 328, - 329, 330, 331, 332, 333, 334, 336, 337, 338, 339, - 341, 342, 343, 344, 346, 347, 348, 349, 351, 352, - 353, 354, 355, 357, 358, 359, 360, 361, 363, 364, - 365, 366, 367, 369, 370, 371, 372, 373, 375, 376, - 378, 379, 380, 381, 382, 383, 384, 385, 386, 388, - 389, 390, 391, 392, 393, 394, 395, 396, 398, 399, - 401, 402, 403, 404, 405, 406, 407, 408, 410 + 0, 186, 186, 186, 187, 188, 189, 190, 191, 192, + 193, 194, 195, 196, 197, 198, 200, 201, 202, 203, + 204, 205, 207, 209, 212, 213, 215, 216, 217, 218, + 219, 220, 221, 222, 224, 225, 226, 227, 228, 230, + 231, 232, 233, 234, 236, 237, 238, 239, 240, 241, + 242, 244, 245, 246, 248, 249, 250, 252, 253, 254, + 255, 256, 257, 258, 259, 261, 262, 263, 264, 265, + 266, 267, 268, 270, 271, 272, 273, 274, 275, 276, + 277, 279, 280, 281, 282, 283, 284, 285, 286, 288, + 289, 290, 291, 292, 293, 294, 295, 297, 298, 299, + 300, 301, 302, 303, 304, 306, 307, 308, 309, 310, + 311, 313, 314, 315, 316, 317, 318, 319, 320, 321, + 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, + 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, + 344, 345, 346, 347, 349, 350, 351, 352, 354, 355, + 356, 357, 359, 360, 361, 362, 363, 365, 366, 367, + 368, 369, 371, 372, 373, 374, 375, 377, 378, 379, + 380, 381, 383, 384, 386, 387, 388, 389, 390, 391, + 392, 393, 394, 396, 397, 398, 399, 400, 401, 402, + 403, 404, 406, 407, 409, 410, 411, 412, 413, 414, + 415, 416, 418 }; #endif -#if YYDEBUG || YYERROR_VERBOSE || 0 +/** Accessing symbol of state STATE. */ +#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State]) + +#if YYDEBUG || 0 +/* 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", "error", "$undefined", "INCLUDE", "IF", "DEFINED", "MACRO", - "MACRO_STRING", "ORG", "ERROR", "ECHO1", "INCBIN", "INCLEN", "INCWORD", - "RES", "WORD", "BYTE", "LDA", "LDX", "LDY", "STA", "STX", "STY", "AND", - "ORA", "EOR", "ADC", "SBC", "CMP", "CPX", "CPY", "TSX", "TXS", "PHA", - "PLA", "PHP", "PLP", "SEI", "CLI", "NOP", "TYA", "TAY", "TXA", "TAX", - "CLC", "SEC", "RTS", "JSR", "JMP", "BEQ", "BNE", "BCC", "BCS", "BPL", - "BMI", "BVC", "BVS", "INX", "DEX", "INY", "DEY", "INC", "DEC", "LSR", - "ASL", "ROR", "ROL", "BIT", "SYMBOL", "STRING", "LAND", "LOR", "LNOT", - "LPAREN", "RPAREN", "COMMA", "COLON", "X", "Y", "HASH", "PLUS", "MINUS", - "MULT", "DIV", "MOD", "LT", "GT", "EQ", "NEQ", "ASSIGN", "GUESS", - "NUMBER", "vNEG", "LABEL", "$accept", "stmts", "stmt", "atom", "exprs", - "op", "am_im", "am_a", "am_ax", "am_ay", "am_zp", "am_zpx", "am_zpy", - "am_ix", "am_iy", "expr", "lexpr", YY_NULLPTR + "\"end of file\"", "error", "\"invalid token\"", "INCLUDE", "IF", + "DEFINED", "MACRO", "MACRO_STRING", "ORG", "ERROR", "ECHO1", "INCBIN", + "INCLEN", "INCWORD", "RES", "WORD", "BYTE", "TEXT", "LDA", "LDX", "LDY", + "STA", "STX", "STY", "AND", "ORA", "EOR", "ADC", "SBC", "CMP", "CPX", + "CPY", "TSX", "TXS", "PHA", "PLA", "PHP", "PLP", "SEI", "CLI", "NOP", + "TYA", "TAY", "TXA", "TAX", "CLC", "SEC", "RTS", "CLV", "CLD", "SED", + "JSR", "JMP", "BEQ", "BNE", "BCC", "BCS", "BPL", "BMI", "BVC", "BVS", + "INX", "DEX", "INY", "DEY", "INC", "DEC", "LSR", "ASL", "ROR", "ROL", + "BIT", "SYMBOL", "STRING", "LAND", "LOR", "LNOT", "LPAREN", "RPAREN", + "COMMA", "COLON", "X", "Y", "HASH", "PLUS", "MINUS", "MULT", "DIV", + "MOD", "LT", "GT", "EQ", "NEQ", "ASSIGN", "GUESS", "NUMBER", "vNEG", + "LABEL", "$accept", "stmts", "stmt", "atom", "exprs", "op", "am_im", + "am_a", "am_ax", "am_ay", "am_zp", "am_zpx", "am_zpy", "am_ix", "am_iy", + "expr", "lexpr", YY_NULLPTR }; + +static const char * +yysymbol_name (yysymbol_kind_t yysymbol) +{ + return yytname[yysymbol]; +} #endif -# ifdef YYPRINT +#ifdef YYPRINT /* YYTOKNUM[NUM] -- (External) token number corresponding to the (internal) symbol number NUM (which must be that of a token). */ -static const yytype_uint16 yytoknum[] = +static const yytype_int16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, @@ -601,56 +677,57 @@ static const yytype_uint16 yytoknum[] = 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, - 345, 346, 347, 348 + 345, 346, 347, 348, 349, 350, 351, 352 }; -# endif +#endif -#define YYPACT_NINF -211 +#define YYPACT_NINF (-216) -#define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-211))) +#define yypact_value_is_default(Yyn) \ + ((Yyn) == YYPACT_NINF) -#define YYTABLE_NINF -1 +#define YYTABLE_NINF (-1) -#define yytable_value_is_error(Yytable_value) \ +#define yytable_value_is_error(Yyn) \ 0 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ static const yytype_int16 yypact[] = { - 287, -68, -23, -14, -211, -4, 15, 84, 85, 92, - 105, 107, 186, 189, 344, 363, 366, 377, 186, 186, - 186, 186, 186, 186, 347, 347, -211, -211, -211, -211, - -211, -211, -211, -211, -211, -211, -211, -211, -211, -211, - -211, -211, 208, 208, 208, 208, 208, 208, 208, 208, - 208, 208, -211, -211, -211, -211, 377, 377, 377, 377, - 377, 377, 388, -33, 112, 83, -211, -211, -211, 120, - 154, 121, 208, 122, 123, 124, 208, 208, 208, 108, - 127, -211, 208, 208, 208, 208, -211, -211, -211, -211, - -211, -211, -211, -211, -211, 494, 208, 208, -211, -211, - -211, -211, -211, 504, -211, -211, -211, -211, -211, 514, - -211, -211, -211, -211, -211, -211, -211, -211, -211, -211, - -65, -211, -211, -211, -211, -211, -211, -211, -211, -211, - -211, -211, -211, -211, -211, -211, -211, -211, -211, -211, - -211, -211, -211, -211, -211, -211, -211, -211, -211, -211, - -211, -211, -211, -211, -211, -211, -211, -211, -211, -211, - -211, -211, -211, -211, -211, -211, -211, -211, -211, -211, - -211, -211, 208, -211, -211, -211, -211, -211, -211, -211, - -211, -211, -211, -211, -211, -211, -211, -211, -211, -211, - -211, -211, -211, -211, -211, -211, -211, -211, -211, -211, - -211, -211, -211, -211, -211, -211, -211, -211, -211, -211, - -211, -211, -211, -211, -211, 208, 208, -211, -211, -211, - 131, 135, 154, 154, 156, -19, 143, 303, 144, -45, - -7, 524, 7, -65, 21, 125, 126, 132, -65, -211, - 534, 77, 208, 208, 208, 208, 208, 314, 544, 119, - 142, -65, -65, -65, -211, 141, -211, -60, 82, 208, - 208, 208, 208, 154, 154, -211, -211, -211, -211, -211, - 208, -211, 208, 208, -211, 208, -211, 149, 153, 171, - 147, 148, -211, -211, -21, -21, -211, -211, -211, -211, - 151, 179, -211, -65, -65, -65, -65, -211, 185, 87, - 204, 468, -65, -211, 208, 178, 190, -211, -211, -211, - -211, -211, 208, -211, 473, -211, -211, 484, -211, -211 + 293, -72, -24, -11, -216, 15, 86, 92, 104, 106, + 114, 115, 116, 187, 190, 354, 373, 376, 387, 187, + 187, 187, 187, 187, 187, 357, 357, -216, -216, -216, + -216, -216, -216, -216, -216, -216, -216, -216, -216, -216, + -216, -216, -216, -216, -216, -216, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, -216, -216, -216, -216, + 387, 387, 387, 387, 387, 387, 398, -48, 117, 87, + -216, -216, -216, 121, 155, 122, 149, 123, 128, 131, + 149, 149, 149, 133, 135, 136, -216, 149, 149, 149, + 149, -216, -216, -216, -216, -216, -216, -216, -216, -216, + 507, 149, 149, -216, -216, -216, -216, -216, 517, -216, + -216, -216, -216, -216, 527, -216, -216, -216, -216, -216, + -216, -216, -216, -216, -216, -69, -216, -216, -216, -216, + -216, -216, -216, -216, -216, -216, -216, -216, -216, -216, + -216, -216, -216, -216, -216, -216, -216, -216, -216, -216, + -216, -216, -216, -216, -216, -216, -216, -216, -216, -216, + -216, -216, -216, -216, -216, -216, -216, -216, -216, -216, + -216, -216, -216, -216, -216, -216, -216, 149, -216, -216, + -216, -216, -216, -216, -216, -216, -216, -216, -216, -216, + -216, -216, -216, -216, -216, -216, -216, -216, -216, -216, + -216, -216, -216, -216, -216, -216, -216, -216, -216, -216, + -216, -216, -216, -216, -216, -216, -216, -216, -216, -216, + 149, 149, -216, -216, -216, 127, 145, 155, 155, 433, + -18, 146, 309, 147, -14, -8, 537, -6, -69, 7, + 150, 156, 157, 132, -69, -216, 547, 97, 149, 149, + 149, 149, 149, 320, 557, 141, 152, -69, -69, -69, + -216, 137, -216, -64, -16, 149, 149, 149, 149, 155, + 155, -216, -216, -216, -216, -216, 149, -216, 149, 149, + -216, 149, -216, -216, 163, 164, 167, 161, 168, -216, + -216, -57, -57, -216, -216, -216, -216, 165, 170, -216, + -69, -69, -69, -69, -216, 171, 21, 202, 481, -69, + -216, 149, 169, 180, -216, -216, -216, -216, -216, 149, + -216, 486, -216, -216, 497, -216, -216 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. @@ -660,196 +737,201 @@ static const yytype_uint8 yydefact[] = { 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 111, 110, 112, 113, + 0, 0, 0, 0, 0, 0, 0, 112, 111, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, - 124, 125, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 136, 137, 138, 139, 0, 0, 148, 153, - 158, 163, 0, 0, 0, 0, 3, 14, 16, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 189, 0, 0, 0, 0, 188, 25, 28, 29, - 30, 26, 27, 31, 32, 171, 0, 0, 33, 36, - 37, 34, 35, 171, 38, 41, 42, 39, 40, 171, - 45, 46, 47, 43, 44, 48, 49, 52, 50, 51, - 171, 55, 53, 54, 56, 59, 60, 61, 57, 58, - 62, 63, 64, 67, 68, 69, 65, 66, 70, 71, - 72, 75, 76, 77, 73, 74, 78, 79, 80, 83, - 84, 85, 81, 82, 86, 87, 88, 91, 92, 93, - 89, 90, 94, 95, 96, 99, 100, 101, 97, 98, - 102, 103, 0, 104, 106, 105, 107, 109, 108, 126, - 127, 128, 129, 130, 131, 132, 133, 134, 135, 142, - 143, 140, 141, 146, 147, 144, 145, 151, 152, 149, - 150, 156, 157, 154, 155, 161, 162, 159, 160, 166, - 167, 164, 165, 169, 168, 0, 0, 4, 1, 2, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 24, 0, 0, 0, 0, 170, 184, - 174, 0, 0, 0, 0, 0, 0, 0, 174, 0, - 0, 174, 5, 6, 12, 0, 192, 0, 0, 0, - 0, 0, 0, 0, 0, 7, 13, 8, 9, 10, - 0, 20, 0, 0, 18, 0, 19, 0, 0, 185, - 0, 0, 172, 173, 179, 180, 181, 182, 183, 185, - 0, 0, 193, 194, 195, 196, 197, 191, 190, 0, - 0, 0, 23, 186, 0, 0, 0, 175, 176, 198, - 11, 21, 0, 17, 0, 178, 177, 0, 187, 22 + 124, 125, 126, 127, 128, 129, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 140, 141, 142, 143, + 0, 0, 152, 157, 162, 167, 0, 0, 0, 0, + 3, 14, 16, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 193, 0, 0, 0, + 0, 192, 26, 29, 30, 31, 27, 28, 32, 33, + 175, 0, 0, 34, 37, 38, 35, 36, 175, 39, + 42, 43, 40, 41, 175, 46, 47, 48, 44, 45, + 49, 50, 53, 51, 52, 175, 56, 54, 55, 57, + 60, 61, 62, 58, 59, 63, 64, 65, 68, 69, + 70, 66, 67, 71, 72, 73, 76, 77, 78, 74, + 75, 79, 80, 81, 84, 85, 86, 82, 83, 87, + 88, 89, 92, 93, 94, 90, 91, 95, 96, 97, + 100, 101, 102, 98, 99, 103, 104, 0, 105, 107, + 106, 108, 110, 109, 130, 131, 132, 133, 134, 135, + 136, 137, 138, 139, 146, 147, 144, 145, 150, 151, + 148, 149, 155, 156, 153, 154, 160, 161, 158, 159, + 165, 166, 163, 164, 170, 171, 168, 169, 173, 172, + 0, 0, 4, 1, 2, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 25, 0, + 0, 0, 0, 0, 174, 188, 178, 0, 0, 0, + 0, 0, 0, 0, 178, 0, 0, 178, 5, 6, + 12, 0, 196, 0, 0, 0, 0, 0, 0, 0, + 0, 7, 13, 8, 9, 10, 0, 21, 0, 0, + 18, 0, 19, 20, 0, 0, 189, 0, 0, 176, + 177, 183, 184, 185, 186, 187, 189, 0, 0, 197, + 198, 199, 200, 201, 195, 194, 0, 0, 0, 24, + 190, 0, 0, 0, 179, 180, 202, 11, 22, 0, + 17, 0, 182, 181, 0, 191, 23 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -211, -211, 201, -211, -74, -211, 150, 467, 479, 164, - 18, 348, 253, 614, 623, -12, -210 + -216, -216, 191, -216, -78, -216, 151, 480, 492, 166, + 18, 356, 244, 630, 639, -13, -215 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { - -1, 65, 66, 67, 232, 68, 87, 88, 89, 90, - 91, 92, 102, 93, 94, 120, 225 + -1, 69, 70, 71, 237, 72, 92, 93, 94, 95, + 96, 97, 107, 98, 99, 125, 230 }; /* 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_uint16 yytable[] = +static const yytype_int16 yytable[] = { - 95, 103, 109, 95, 234, 69, 95, 95, 95, 95, - 95, 95, 256, 258, 289, 242, 243, 244, 245, 246, - 242, 243, 244, 245, 246, 259, 260, 261, 262, 269, - 270, 101, 107, 113, 118, 122, 128, 136, 144, 152, - 160, 168, 175, 178, 109, 109, 109, 109, 109, 109, - 70, 263, 264, 297, 298, 265, 215, 216, 224, 71, - 227, 244, 245, 246, 231, 233, 233, 271, 272, 72, - 237, 238, 239, 240, 191, 195, 199, 203, 207, 211, - 214, 274, 275, 218, 247, 248, 1, 2, 73, 3, - 4, 5, 6, 7, 8, 276, 275, 9, 10, 11, + 100, 108, 114, 100, 239, 73, 100, 100, 100, 100, + 100, 100, 262, 264, 296, 248, 249, 250, 251, 252, + 248, 249, 250, 251, 252, 265, 266, 267, 268, 250, + 251, 252, 106, 112, 118, 123, 127, 133, 141, 149, + 157, 165, 173, 180, 183, 220, 221, 114, 114, 114, + 114, 114, 114, 74, 304, 305, 269, 270, 269, 270, + 271, 229, 299, 232, 275, 276, 75, 236, 238, 238, + 277, 278, 280, 281, 243, 244, 245, 246, 196, 200, + 204, 208, 212, 216, 219, 282, 281, 223, 253, 254, + 1, 2, 76, 3, 4, 5, 6, 7, 8, 317, + 281, 9, 10, 11, 12, 13, 14, 15, 16, 17, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 226, 84, 85, 77, 257, 103, 109, 84, 85, 78, + 129, 137, 145, 153, 161, 169, 178, 181, 289, 290, + 105, 79, 117, 80, 68, 132, 140, 148, 156, 164, + 172, 81, 82, 83, 225, 231, 233, 222, 306, 84, + 85, 234, 84, 85, 235, 260, 240, 258, 259, 298, + 286, 287, 241, 242, 229, 263, 248, 249, 250, 251, + 252, 86, 261, 290, 272, 274, 101, 86, 283, 284, + 285, 227, 228, 289, 89, 291, 292, 293, 294, 295, + 89, 310, 313, 311, 91, 269, 312, 315, 316, 314, + 91, 322, 300, 301, 302, 303, 229, 229, 323, 86, + 224, 124, 86, 238, 87, 307, 308, 101, 309, 0, + 88, 0, 89, 88, 0, 89, 90, 0, 0, 102, + 318, 319, 91, 0, 0, 91, 248, 249, 250, 251, + 252, 0, 0, 0, 0, 0, 1, 2, 321, 3, + 4, 5, 6, 7, 8, 0, 324, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, - 62, 63, 263, 264, 282, 283, 292, 74, 75, 221, - 251, 310, 275, 98, 104, 76, 79, 80, 124, 132, - 140, 148, 156, 164, 173, 176, 64, 100, 77, 112, - 78, 235, 127, 135, 143, 151, 159, 167, 217, 220, - 226, 228, 229, 230, 277, 278, 299, 283, 79, 80, - 236, 79, 80, 252, 253, 254, 279, 280, 255, 291, - 224, 257, 242, 243, 244, 245, 246, 266, 268, 282, - 79, 80, 81, 303, 306, 307, 222, 223, 304, 308, - 284, 285, 286, 287, 288, 84, 242, 243, 244, 245, - 246, 259, 260, 261, 262, 86, 305, 293, 294, 295, - 296, 224, 224, 309, 81, 263, 315, 81, 233, 82, - 300, 301, 96, 302, 316, 83, 219, 84, 83, 119, - 84, 85, 0, 0, 97, 0, 81, 86, 311, 312, - 86, 96, 0, 0, 242, 243, 244, 245, 246, 84, - 1, 2, 314, 3, 4, 5, 6, 7, 8, 86, - 317, 9, 10, 11, 12, 13, 14, 15, 16, 17, - 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, - 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 79, 80, 0, 79, - 80, 0, 108, 114, 0, 123, 129, 137, 145, 153, - 161, 169, 0, 0, 0, 79, 80, 267, 79, 80, - 64, 0, 0, 242, 243, 244, 245, 246, 289, 79, - 80, 0, 0, 0, 242, 243, 244, 245, 246, 0, - 79, 80, 0, 0, 192, 196, 200, 204, 208, 212, - 0, 0, 81, 0, 0, 81, 0, 96, 0, 0, - 96, 0, 0, 83, 0, 84, 83, 0, 84, 85, - 0, 81, 172, 0, 81, 86, 82, 0, 86, 96, - 0, 0, 0, 0, 84, 81, 0, 84, 85, 0, - 96, 97, 0, 0, 86, 0, 81, 86, 84, 0, - 0, 96, 85, 0, 0, 0, 0, 0, 86, 84, - 0, 0, 0, 172, 0, 0, 0, 0, 0, 86, - 99, 105, 110, 117, 121, 125, 133, 141, 149, 157, - 165, 174, 177, 106, 111, 0, 0, 126, 134, 142, - 150, 158, 166, 0, 0, 0, 0, 0, 0, 179, - 180, 181, 182, 183, 184, 185, 186, 187, 188, 0, - 0, 0, 0, 189, 193, 197, 201, 205, 209, 213, - 0, 0, 0, 0, 0, 190, 194, 198, 202, 206, - 210, 0, 313, 0, 0, 0, 0, 318, 242, 243, - 244, 245, 246, 242, 243, 244, 245, 246, 319, 0, - 0, 0, 0, 0, 242, 243, 244, 245, 246, 241, - 0, 0, 0, 0, 242, 243, 244, 245, 246, 249, - 0, 0, 0, 0, 242, 243, 244, 245, 246, 250, - 0, 0, 0, 0, 242, 243, 244, 245, 246, 273, - 0, 0, 0, 0, 242, 243, 244, 245, 246, 281, - 0, 0, 0, 0, 242, 243, 244, 245, 246, 290, - 0, 0, 0, 0, 242, 243, 244, 245, 246, 115, - 0, 0, 130, 138, 146, 154, 162, 170, 116, 0, - 0, 131, 139, 147, 155, 163, 171 + 62, 63, 64, 65, 66, 67, 84, 85, 0, 84, + 85, 113, 119, 0, 128, 134, 142, 150, 158, 166, + 174, 0, 0, 0, 0, 84, 85, 273, 84, 85, + 68, 0, 0, 248, 249, 250, 251, 252, 296, 84, + 85, 0, 0, 0, 248, 249, 250, 251, 252, 0, + 84, 85, 0, 0, 0, 0, 197, 201, 205, 209, + 213, 217, 0, 0, 0, 0, 86, 0, 0, 86, + 0, 101, 0, 0, 101, 0, 0, 88, 0, 89, + 88, 0, 89, 90, 0, 86, 177, 0, 86, 91, + 87, 0, 91, 101, 0, 0, 0, 0, 89, 86, + 0, 89, 90, 0, 101, 102, 0, 0, 91, 0, + 86, 91, 89, 0, 0, 101, 90, 0, 0, 0, + 0, 0, 91, 89, 0, 0, 0, 177, 0, 0, + 0, 0, 0, 91, 104, 110, 115, 122, 126, 130, + 138, 146, 154, 162, 170, 179, 182, 111, 116, 0, + 0, 131, 139, 147, 155, 163, 171, 248, 249, 250, + 251, 252, 265, 266, 267, 268, 184, 185, 186, 187, + 188, 189, 190, 191, 192, 193, 0, 0, 0, 0, + 194, 198, 202, 206, 210, 214, 218, 0, 0, 0, + 0, 0, 195, 199, 203, 207, 211, 215, 0, 320, + 0, 0, 0, 0, 325, 248, 249, 250, 251, 252, + 248, 249, 250, 251, 252, 326, 0, 0, 0, 0, + 0, 248, 249, 250, 251, 252, 247, 0, 0, 0, + 0, 248, 249, 250, 251, 252, 255, 0, 0, 0, + 0, 248, 249, 250, 251, 252, 256, 0, 0, 0, + 0, 248, 249, 250, 251, 252, 279, 0, 0, 0, + 0, 248, 249, 250, 251, 252, 288, 0, 0, 0, + 0, 248, 249, 250, 251, 252, 297, 0, 0, 0, + 0, 248, 249, 250, 251, 252, 120, 0, 0, 135, + 143, 151, 159, 167, 175, 121, 0, 0, 136, 144, + 152, 160, 168, 176 }; static const yytype_int16 yycheck[] = { - 12, 13, 14, 15, 78, 73, 18, 19, 20, 21, - 22, 23, 222, 223, 74, 80, 81, 82, 83, 84, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 74, - 75, 13, 14, 15, 16, 17, 18, 19, 20, 21, - 22, 23, 24, 25, 56, 57, 58, 59, 60, 61, - 73, 70, 71, 263, 264, 74, 89, 90, 70, 73, - 72, 82, 83, 84, 76, 77, 78, 74, 75, 73, - 82, 83, 84, 85, 56, 57, 58, 59, 60, 61, - 62, 74, 75, 0, 96, 97, 3, 4, 73, 6, - 7, 8, 9, 10, 11, 74, 75, 14, 15, 16, + 13, 14, 15, 16, 82, 77, 19, 20, 21, 22, + 23, 24, 227, 228, 78, 84, 85, 86, 87, 88, + 84, 85, 86, 87, 88, 89, 90, 91, 92, 86, + 87, 88, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 93, 94, 60, 61, 62, + 63, 64, 65, 77, 269, 270, 74, 75, 74, 75, + 78, 74, 78, 76, 78, 79, 77, 80, 81, 82, + 78, 79, 78, 79, 87, 88, 89, 90, 60, 61, + 62, 63, 64, 65, 66, 78, 79, 0, 101, 102, + 3, 4, 77, 6, 7, 8, 9, 10, 11, 78, + 79, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 5, 12, 13, 77, 177, 14, 15, 12, 13, 77, + 19, 20, 21, 22, 23, 24, 25, 26, 81, 82, + 14, 77, 16, 77, 97, 19, 20, 21, 22, 23, + 24, 77, 77, 77, 73, 73, 73, 80, 276, 12, + 13, 73, 12, 13, 73, 78, 73, 220, 221, 72, + 78, 79, 77, 77, 227, 228, 84, 85, 86, 87, + 88, 72, 77, 82, 78, 78, 77, 72, 78, 73, + 73, 76, 77, 81, 85, 248, 249, 250, 251, 252, + 85, 78, 81, 79, 95, 74, 79, 82, 78, 81, + 95, 82, 265, 266, 267, 268, 269, 270, 78, 72, + 69, 17, 72, 276, 77, 278, 279, 77, 281, -1, + 83, -1, 85, 83, -1, 85, 89, -1, -1, 89, + 78, 79, 95, -1, -1, 95, 84, 85, 86, 87, + 88, -1, -1, -1, -1, -1, 3, 4, 311, 6, + 7, 8, 9, 10, 11, -1, 319, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 70, 71, 77, 78, 74, 73, 73, 5, - 172, 74, 75, 13, 14, 73, 12, 13, 18, 19, - 20, 21, 22, 23, 24, 25, 93, 13, 73, 15, - 73, 73, 18, 19, 20, 21, 22, 23, 76, 69, - 69, 69, 69, 69, 69, 69, 270, 78, 12, 13, - 73, 12, 13, 215, 216, 74, 74, 75, 73, 68, - 222, 223, 80, 81, 82, 83, 84, 74, 74, 77, - 12, 13, 68, 74, 77, 77, 72, 73, 75, 78, - 242, 243, 244, 245, 246, 81, 80, 81, 82, 83, - 84, 85, 86, 87, 88, 91, 75, 259, 260, 261, - 262, 263, 264, 74, 68, 70, 78, 68, 270, 73, - 272, 273, 73, 275, 74, 79, 65, 81, 79, 16, - 81, 85, -1, -1, 85, -1, 68, 91, 74, 75, - 91, 73, -1, -1, 80, 81, 82, 83, 84, 81, - 3, 4, 304, 6, 7, 8, 9, 10, 11, 91, - 312, 14, 15, 16, 17, 18, 19, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 12, 13, -1, 12, - 13, -1, 14, 15, -1, 17, 18, 19, 20, 21, - 22, 23, -1, -1, -1, 12, 13, 74, 12, 13, - 93, -1, -1, 80, 81, 82, 83, 84, 74, 12, - 13, -1, -1, -1, 80, 81, 82, 83, 84, -1, - 12, 13, -1, -1, 56, 57, 58, 59, 60, 61, - -1, -1, 68, -1, -1, 68, -1, 73, -1, -1, - 73, -1, -1, 79, -1, 81, 79, -1, 81, 85, - -1, 68, 85, -1, 68, 91, 73, -1, 91, 73, - -1, -1, -1, -1, 81, 68, -1, 81, 85, -1, - 73, 85, -1, -1, 91, -1, 68, 91, 81, -1, - -1, 73, 85, -1, -1, -1, -1, -1, 91, 81, - -1, -1, -1, 85, -1, -1, -1, -1, -1, 91, - 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, - 23, 24, 25, 14, 15, -1, -1, 18, 19, 20, - 21, 22, 23, -1, -1, -1, -1, -1, -1, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, - -1, -1, -1, 56, 57, 58, 59, 60, 61, 62, - -1, -1, -1, -1, -1, 56, 57, 58, 59, 60, - 61, -1, 74, -1, -1, -1, -1, 74, 80, 81, - 82, 83, 84, 80, 81, 82, 83, 84, 74, -1, - -1, -1, -1, -1, 80, 81, 82, 83, 84, 75, - -1, -1, -1, -1, 80, 81, 82, 83, 84, 75, - -1, -1, -1, -1, 80, 81, 82, 83, 84, 75, - -1, -1, -1, -1, 80, 81, 82, 83, 84, 75, - -1, -1, -1, -1, 80, 81, 82, 83, 84, 75, - -1, -1, -1, -1, 80, 81, 82, 83, 84, 75, - -1, -1, -1, -1, 80, 81, 82, 83, 84, 15, - -1, -1, 18, 19, 20, 21, 22, 23, 15, -1, - -1, 18, 19, 20, 21, 22, 23 + 67, 68, 69, 70, 71, 72, 12, 13, -1, 12, + 13, 15, 16, -1, 18, 19, 20, 21, 22, 23, + 24, -1, -1, -1, -1, 12, 13, 78, 12, 13, + 97, -1, -1, 84, 85, 86, 87, 88, 78, 12, + 13, -1, -1, -1, 84, 85, 86, 87, 88, -1, + 12, 13, -1, -1, -1, -1, 60, 61, 62, 63, + 64, 65, -1, -1, -1, -1, 72, -1, -1, 72, + -1, 77, -1, -1, 77, -1, -1, 83, -1, 85, + 83, -1, 85, 89, -1, 72, 89, -1, 72, 95, + 77, -1, 95, 77, -1, -1, -1, -1, 85, 72, + -1, 85, 89, -1, 77, 89, -1, -1, 95, -1, + 72, 95, 85, -1, -1, 77, 89, -1, -1, -1, + -1, -1, 95, 85, -1, -1, -1, 89, -1, -1, + -1, -1, -1, 95, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 15, 16, -1, + -1, 19, 20, 21, 22, 23, 24, 84, 85, 86, + 87, 88, 89, 90, 91, 92, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, -1, -1, -1, -1, + 60, 61, 62, 63, 64, 65, 66, -1, -1, -1, + -1, -1, 60, 61, 62, 63, 64, 65, -1, 78, + -1, -1, -1, -1, 78, 84, 85, 86, 87, 88, + 84, 85, 86, 87, 88, 78, -1, -1, -1, -1, + -1, 84, 85, 86, 87, 88, 79, -1, -1, -1, + -1, 84, 85, 86, 87, 88, 79, -1, -1, -1, + -1, 84, 85, 86, 87, 88, 79, -1, -1, -1, + -1, 84, 85, 86, 87, 88, 79, -1, -1, -1, + -1, 84, 85, 86, 87, 88, 79, -1, -1, -1, + -1, 84, 85, 86, 87, 88, 79, -1, -1, -1, + -1, 84, 85, 86, 87, 88, 16, -1, -1, 19, + 20, 21, 22, 23, 24, 16, -1, -1, 19, 20, + 21, 22, 23, 24 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ -static const yytype_uint8 yystos[] = +static const yytype_int8 yystos[] = { 0, 3, 4, 6, 7, 8, 9, 10, 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, @@ -857,65 +939,67 @@ static const yytype_uint8 yystos[] = 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 93, 95, 96, 97, 99, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 12, - 13, 68, 73, 79, 81, 85, 91, 100, 101, 102, - 103, 104, 105, 107, 108, 109, 73, 85, 100, 101, - 103, 104, 106, 109, 100, 101, 102, 104, 105, 109, - 101, 102, 103, 104, 105, 107, 108, 101, 104, 106, - 109, 101, 104, 105, 100, 101, 102, 103, 104, 105, - 107, 108, 100, 101, 102, 103, 104, 105, 107, 108, - 100, 101, 102, 103, 104, 105, 107, 108, 100, 101, - 102, 103, 104, 105, 107, 108, 100, 101, 102, 103, - 104, 105, 107, 108, 100, 101, 102, 103, 104, 105, - 107, 108, 85, 100, 101, 104, 100, 101, 104, 101, - 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, - 102, 104, 105, 101, 102, 104, 105, 101, 102, 104, - 105, 101, 102, 104, 105, 101, 102, 104, 105, 101, - 102, 104, 105, 101, 104, 89, 90, 76, 0, 96, - 69, 5, 72, 73, 109, 110, 69, 109, 69, 69, - 69, 109, 98, 109, 98, 73, 73, 109, 109, 109, - 109, 75, 80, 81, 82, 83, 84, 109, 109, 75, - 75, 109, 109, 109, 74, 73, 110, 109, 110, 85, - 86, 87, 88, 70, 71, 74, 74, 74, 74, 74, - 75, 74, 75, 75, 74, 75, 74, 69, 69, 74, - 75, 75, 77, 78, 109, 109, 109, 109, 109, 74, - 75, 68, 74, 109, 109, 109, 109, 110, 110, 98, - 109, 109, 109, 74, 75, 75, 77, 77, 78, 74, - 74, 74, 75, 74, 109, 78, 74, 109, 74, 74 + 65, 66, 67, 68, 69, 70, 71, 72, 97, 99, + 100, 101, 103, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 12, 13, 72, 77, 83, 85, + 89, 95, 104, 105, 106, 107, 108, 109, 111, 112, + 113, 77, 89, 104, 105, 107, 108, 110, 113, 104, + 105, 106, 108, 109, 113, 105, 106, 107, 108, 109, + 111, 112, 105, 108, 110, 113, 105, 108, 109, 104, + 105, 106, 107, 108, 109, 111, 112, 104, 105, 106, + 107, 108, 109, 111, 112, 104, 105, 106, 107, 108, + 109, 111, 112, 104, 105, 106, 107, 108, 109, 111, + 112, 104, 105, 106, 107, 108, 109, 111, 112, 104, + 105, 106, 107, 108, 109, 111, 112, 89, 104, 105, + 108, 104, 105, 108, 105, 105, 105, 105, 105, 105, + 105, 105, 105, 105, 105, 106, 108, 109, 105, 106, + 108, 109, 105, 106, 108, 109, 105, 106, 108, 109, + 105, 106, 108, 109, 105, 106, 108, 109, 105, 108, + 93, 94, 80, 0, 100, 73, 5, 76, 77, 113, + 114, 73, 113, 73, 73, 73, 113, 102, 113, 102, + 73, 77, 77, 113, 113, 113, 113, 79, 84, 85, + 86, 87, 88, 113, 113, 79, 79, 113, 113, 113, + 78, 77, 114, 113, 114, 89, 90, 91, 92, 74, + 75, 78, 78, 78, 78, 78, 79, 78, 79, 79, + 78, 79, 78, 78, 73, 73, 78, 79, 79, 81, + 82, 113, 113, 113, 113, 113, 78, 79, 72, 78, + 113, 113, 113, 113, 114, 114, 102, 113, 113, 113, + 78, 79, 79, 81, 81, 82, 78, 78, 78, 79, + 78, 113, 82, 78, 113, 78, 78 }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = +static const yytype_int8 yyr1[] = { - 0, 94, 95, 95, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 97, 97, 97, 97, - 97, 97, 97, 98, 98, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, - 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, - 110, 110, 110, 110, 110, 110, 110, 110, 110 + 0, 98, 99, 99, 100, 100, 100, 100, 100, 100, + 100, 100, 100, 100, 100, 100, 101, 101, 101, 101, + 101, 101, 101, 101, 102, 102, 103, 103, 103, 103, + 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, + 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, + 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, + 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, + 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, + 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, + 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, + 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, + 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, + 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, + 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, + 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, + 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, + 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, + 103, 103, 103, 103, 104, 105, 106, 107, 108, 109, + 110, 111, 112, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 113, 113, 114, 114, 114, 114, 114, 114, + 114, 114, 114 }; /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = +static const yytype_int8 yyr2[] = { 0, 2, 2, 1, 2, 3, 3, 4, 4, 4, 4, 6, 4, 4, 1, 1, 1, 6, 4, 4, - 4, 6, 8, 3, 1, 2, 2, 2, 2, 2, + 4, 4, 6, 8, 3, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -924,22 +1008,23 @@ static const yytype_uint8 yyr2[] = 2, 2, 2, 2, 2, 2, 2, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, - 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, - 2, 2, 2, 1, 2, 2, 2, 2, 1, 2, - 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, - 2, 1, 3, 3, 2, 4, 4, 5, 5, 3, - 3, 3, 3, 3, 2, 3, 4, 6, 1, 1, - 3, 3, 2, 3, 3, 3, 3, 3, 4 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, + 2, 2, 1, 2, 2, 2, 2, 1, 2, 2, + 2, 2, 1, 2, 2, 2, 2, 1, 2, 2, + 2, 2, 2, 2, 2, 1, 3, 3, 2, 4, + 4, 5, 5, 3, 3, 3, 3, 3, 2, 3, + 4, 6, 1, 1, 3, 3, 2, 3, 3, 3, + 3, 3, 4 }; +enum { YYENOMEM = -2 }; + #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab @@ -948,27 +1033,26 @@ static const yytype_uint8 yyr2[] = #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) - -/* Error token number */ -#define YYTERROR 1 -#define YYERRCODE 256 - +#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. */ @@ -986,54 +1070,58 @@ do { \ } while (0) /* This macro is provided for backward compatibility. */ -#ifndef YY_LOCATION_PRINT -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -#endif +# ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ - Type, Value); \ + Kind, Value); \ YYFPRINTF (stderr, "\n"); \ } \ } while (0) -/*----------------------------------------. -| Print this symbol's value on YYOUTPUT. | -`----------------------------------------*/ +/*-----------------------------------. +| Print this symbol's value on YYO. | +`-----------------------------------*/ static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +yy_symbol_value_print (FILE *yyo, + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) { - FILE *yyo = yyoutput; - YYUSE (yyo); + FILE *yyoutput = yyo; + YYUSE (yyoutput); if (!yyvaluep) return; # ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); + if (yykind < YYNTOKENS) + YYPRINT (yyo, yytoknum[yykind], *yyvaluep); # endif - YYUSE (yytype); + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YYUSE (yykind); + YY_IGNORE_MAYBE_UNINITIALIZED_END } -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ +/*---------------------------. +| Print this symbol on YYO. | +`---------------------------*/ static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +yy_symbol_print (FILE *yyo, + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) { - YYFPRINTF (yyoutput, "%s %s (", - yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); + YYFPRINTF (yyo, "%s %s (", + yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind)); - yy_symbol_value_print (yyoutput, yytype, yyvaluep); - YYFPRINTF (yyoutput, ")"); + yy_symbol_value_print (yyo, yykind, yyvaluep); + YYFPRINTF (yyo, ")"); } /*------------------------------------------------------------------. @@ -1042,7 +1130,7 @@ yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) `------------------------------------------------------------------*/ static void -yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop) { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) @@ -1065,21 +1153,21 @@ do { \ `------------------------------------------------*/ static void -yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) +yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, + int yyrule) { - unsigned long int yylno = yyrline[yyrule]; + int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + 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, - yystos[yyssp[yyi + 1 - yynrhs]], - &(yyvsp[(yyi + 1) - (yynrhs)]) - ); + YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]), + &yyvsp[(yyi + 1) - (yynrhs)]); YYFPRINTF (stderr, "\n"); } } @@ -1094,8 +1182,8 @@ do { \ multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# 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 */ @@ -1118,249 +1206,30 @@ int yydebug; #endif -#if YYERROR_VERBOSE -# ifndef yystrlen -# if defined __GLIBC__ && defined _STRING_H -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -static YYSIZE_T -yystrlen (const char *yystr) -{ - YYSIZE_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 YYSIZE_T -yytnamerr (char *yyres, const char *yystr) -{ - if (*yystr == '"') - { - YYSIZE_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; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes: ; - } - - if (! yyres) - return yystrlen (yystr); - - return yystpcpy (yyres, yystr) - yyres; -} -# endif - -/* 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 2 if the - required number of bytes is too large to store. */ -static int -yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, - yytype_int16 *yyssp, int yytoken) -{ - YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); - YYSIZE_T yysize = yysize0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - /* Internationalized format string. */ - const char *yyformat = YY_NULLPTR; - /* Arguments of yyformat. */ - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - /* Number of reported tokens (one for the "unexpected", one per - "expected"). */ - 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 (yytoken != YYEMPTY) - { - int yyn = yypact[*yyssp]; - yyarg[yycount++] = yytname[yytoken]; - 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 != YYTERROR - && !yytable_value_is_error (yytable[yyx + yyn])) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - break; - } - yyarg[yycount++] = yytname[yyx]; - { - YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - } - } - } - - switch (yycount) - { -# define YYCASE_(N, S) \ - case N: \ - yyformat = S; \ - break - 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_ - } - - { - YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - - 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, yyarg[yyi++]); - yyformat += 2; - } - else - { - yyp++; - yyformat++; - } - } - return 0; -} -#endif /* YYERROR_VERBOSE */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +yydestruct (const char *yymsg, + yysymbol_kind_t yykind, YYSTYPE *yyvaluep) { YYUSE (yyvaluep); if (!yymsg) yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp); YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - YYUSE (yytype); + YYUSE (yykind); YY_IGNORE_MAYBE_UNINITIALIZED_END } - - -/* The lookahead symbol. */ +/* Lookahead token kind. */ int yychar; /* The semantic value of the lookahead symbol. */ @@ -1369,6 +1238,8 @@ YYSTYPE yylval; int yynerrs; + + /*----------. | yyparse. | `----------*/ @@ -1376,43 +1247,36 @@ int yynerrs; int yyparse (void) { - int yystate; + yy_state_fast_t yystate = 0; /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - - /* The stacks and their tools: - 'yyss': related to states. - 'yyvs': related to semantic values. + int yyerrstatus = 0; - Refer to the stacks through separate pointers, to allow yyoverflow + /* Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss; - yytype_int16 *yyssp; + /* Their size. */ + YYPTRDIFF_T yystacksize = YYINITDEPTH; - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs; - YYSTYPE *yyvsp; + /* The state stack: array, bottom, top. */ + yy_state_t yyssa[YYINITDEPTH]; + yy_state_t *yyss = yyssa; + yy_state_t *yyssp = yyss; - YYSIZE_T yystacksize; + /* 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 token as an internal (translated) token number. */ - int yytoken = 0; + /* Lookahead symbol kind. */ + yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif + #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) @@ -1420,58 +1284,60 @@ yyparse (void) Keep to zero when no symbol should be popped. */ int yylen = 0; - yyssp = yyss = yyssa; - yyvsp = yyvs = yyvsa; - yystacksize = YYINITDEPTH; - YYDPRINTF ((stderr, "Starting parse\n")); - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ goto yysetstate; + /*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | +| yynewstate -- push a new state, which is found in yystate. | `------------------------------------------------------------*/ - yynewstate: +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: - *yyssp = yystate; + +/*--------------------------------------------------------------------. +| 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 + goto yyexhaustedlab; +#else { /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; + YYPTRDIFF_T yysize = yyssp - yyss + 1; -#ifdef yyoverflow +# 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; - yytype_int16 *yyss1 = yyss; /* 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 * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), + &yyss1, yysize * YYSIZEOF (*yyssp), + &yyvs1, yysize * YYSIZEOF (*yyvsp), &yystacksize); - yyss = yyss1; yyvs = yyvs1; } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else +# else /* defined YYSTACK_RELOCATE */ /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; @@ -1480,9 +1346,10 @@ yyparse (void) yystacksize = YYMAXDEPTH; { - yytype_int16 *yyss1 = yyss; + yy_state_t *yyss1 = yyss; union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + YY_CAST (union yyalloc *, + YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize)))); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); @@ -1492,30 +1359,30 @@ yyparse (void) YYSTACK_FREE (yyss1); } # endif -#endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + 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; } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); +#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. */ @@ -1526,18 +1393,29 @@ yyparse (void) /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */ if (yychar == YYEMPTY) { - YYDPRINTF ((stderr, "Reading a token: ")); + YYDPRINTF ((stderr, "Reading a token\n")); yychar = yylex (); } if (yychar <= YYEOF) { - yychar = yytoken = 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); @@ -1565,15 +1443,13 @@ yyparse (void) /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the shifted token. */ - yychar = YYEMPTY; - yystate = yyn; YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END + /* Discard the shifted token. */ + yychar = YYEMPTY; goto yynewstate; @@ -1588,7 +1464,7 @@ yyparse (void) /*-----------------------------. -| yyreduce -- Do a reduction. | +| yyreduce -- do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ @@ -1608,1182 +1484,1207 @@ yyparse (void) YY_REDUCE_PRINT (yyn); switch (yyn) { - case 4: -#line 183 "asm.y" /* yacc.c:1646 */ - { new_label((yyvsp[-1].str)); } -#line 1615 "asm.tab.c" /* yacc.c:1646 */ + case 4: /* stmt: LABEL COLON */ +#line 187 "asm.y" + { new_label((yyvsp[-1].str)); } +#line 1491 "asm.tab.c" break; - case 5: -#line 184 "asm.y" /* yacc.c:1646 */ - { new_symbol_expr((yyvsp[-2].str), (yyvsp[0].expr)); } -#line 1621 "asm.tab.c" /* yacc.c:1646 */ + case 5: /* stmt: SYMBOL ASSIGN expr */ +#line 188 "asm.y" + { new_symbol_expr((yyvsp[-2].str), (yyvsp[0].expr)); } +#line 1497 "asm.tab.c" break; - case 6: -#line 185 "asm.y" /* yacc.c:1646 */ - { new_symbol_expr_guess((yyvsp[-2].str), (yyvsp[0].expr)); } -#line 1627 "asm.tab.c" /* yacc.c:1646 */ + case 6: /* stmt: SYMBOL GUESS expr */ +#line 189 "asm.y" + { new_symbol_expr_guess((yyvsp[-2].str), (yyvsp[0].expr)); } +#line 1503 "asm.tab.c" break; - case 7: -#line 186 "asm.y" /* yacc.c:1646 */ - { push_if_state((yyvsp[-1].expr)); } -#line 1633 "asm.tab.c" /* yacc.c:1646 */ + case 7: /* stmt: IF LPAREN lexpr RPAREN */ +#line 190 "asm.y" + { push_if_state((yyvsp[-1].expr)); } +#line 1509 "asm.tab.c" break; - case 8: -#line 187 "asm.y" /* yacc.c:1646 */ - { set_org((yyvsp[-1].expr)); } -#line 1639 "asm.tab.c" /* yacc.c:1646 */ + case 8: /* stmt: ORG LPAREN expr RPAREN */ +#line 191 "asm.y" + { set_org((yyvsp[-1].expr)); } +#line 1515 "asm.tab.c" break; - case 9: -#line 188 "asm.y" /* yacc.c:1646 */ - { asm_error((yyvsp[-1].str)); } -#line 1645 "asm.tab.c" /* yacc.c:1646 */ + case 9: /* stmt: ERROR LPAREN STRING RPAREN */ +#line 192 "asm.y" + { asm_error((yyvsp[-1].str)); } +#line 1521 "asm.tab.c" break; - case 10: -#line 189 "asm.y" /* yacc.c:1646 */ - { asm_echo((yyvsp[-1].str), NULL); } -#line 1651 "asm.tab.c" /* yacc.c:1646 */ + case 10: /* stmt: ECHO1 LPAREN STRING RPAREN */ +#line 193 "asm.y" + { asm_echo((yyvsp[-1].str), NULL); } +#line 1527 "asm.tab.c" break; - case 11: -#line 190 "asm.y" /* yacc.c:1646 */ - { asm_echo((yyvsp[-3].str), (yyvsp[-1].atom)); } -#line 1657 "asm.tab.c" /* yacc.c:1646 */ + case 11: /* stmt: ECHO1 LPAREN STRING COMMA exprs RPAREN */ +#line 194 "asm.y" + { asm_echo((yyvsp[-3].str), (yyvsp[-1].atom)); } +#line 1533 "asm.tab.c" break; - case 12: -#line 191 "asm.y" /* yacc.c:1646 */ - { asm_include((yyvsp[-1].str)); } -#line 1663 "asm.tab.c" /* yacc.c:1646 */ + case 12: /* stmt: INCLUDE LPAREN STRING RPAREN */ +#line 195 "asm.y" + { asm_include((yyvsp[-1].str)); } +#line 1539 "asm.tab.c" break; - case 13: -#line 192 "asm.y" /* yacc.c:1646 */ - { push_macro_state((yyvsp[-1].str)); } -#line 1669 "asm.tab.c" /* yacc.c:1646 */ + case 13: /* stmt: MACRO LPAREN STRING RPAREN */ +#line 196 "asm.y" + { push_macro_state((yyvsp[-1].str)); } +#line 1545 "asm.tab.c" break; - case 14: -#line 193 "asm.y" /* yacc.c:1646 */ - { vec_push(asm_atoms, &(yyvsp[0].atom)); } -#line 1675 "asm.tab.c" /* yacc.c:1646 */ + case 14: /* stmt: atom */ +#line 197 "asm.y" + { vec_push(asm_atoms, &(yyvsp[0].atom)); } +#line 1551 "asm.tab.c" break; - case 15: -#line 194 "asm.y" /* yacc.c:1646 */ - { macro_append((yyvsp[0].str)); } -#line 1681 "asm.tab.c" /* yacc.c:1646 */ + case 15: /* stmt: MACRO_STRING */ +#line 198 "asm.y" + { macro_append((yyvsp[0].str)); } +#line 1557 "asm.tab.c" break; - case 16: -#line 196 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = (yyvsp[0].atom); } -#line 1687 "asm.tab.c" /* yacc.c:1646 */ + case 16: /* atom: op */ +#line 200 "asm.y" + { (yyval.atom) = (yyvsp[0].atom); } +#line 1563 "asm.tab.c" break; - case 17: -#line 197 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_res((yyvsp[-3].expr), (yyvsp[-1].expr)); } -#line 1693 "asm.tab.c" /* yacc.c:1646 */ + case 17: /* atom: RES LPAREN expr COMMA expr RPAREN */ +#line 201 "asm.y" + { (yyval.atom) = new_res((yyvsp[-3].expr), (yyvsp[-1].expr)); } +#line 1569 "asm.tab.c" break; - case 18: -#line 198 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = exprs_to_word_exprs((yyvsp[-1].atom)); } -#line 1699 "asm.tab.c" /* yacc.c:1646 */ + case 18: /* atom: WORD LPAREN exprs RPAREN */ +#line 202 "asm.y" + { (yyval.atom) = exprs_to_word_exprs((yyvsp[-1].atom)); } +#line 1575 "asm.tab.c" break; - case 19: -#line 199 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = exprs_to_byte_exprs((yyvsp[-1].atom)); } -#line 1705 "asm.tab.c" /* yacc.c:1646 */ + case 19: /* atom: BYTE LPAREN exprs RPAREN */ +#line 203 "asm.y" + { (yyval.atom) = exprs_to_byte_exprs((yyvsp[-1].atom)); } +#line 1581 "asm.tab.c" break; - case 20: -#line 200 "asm.y" /* yacc.c:1646 */ - { + case 20: /* atom: TEXT LPAREN STRING RPAREN */ +#line 204 "asm.y" + { (yyval.atom) = text_to_byte_exprs((yyvsp[-1].str)); } +#line 1587 "asm.tab.c" + break; + + case 21: /* atom: INCBIN LPAREN STRING RPAREN */ +#line 205 "asm.y" + { (yyval.atom) = new_incbin((yyvsp[-1].str), NULL, NULL); } -#line 1712 "asm.tab.c" /* yacc.c:1646 */ +#line 1594 "asm.tab.c" break; - case 21: -#line 202 "asm.y" /* yacc.c:1646 */ - { + case 22: /* atom: INCBIN LPAREN STRING COMMA expr RPAREN */ +#line 207 "asm.y" + { (yyval.atom) = new_incbin((yyvsp[-3].str), (yyvsp[-1].expr), NULL); } -#line 1719 "asm.tab.c" /* yacc.c:1646 */ +#line 1601 "asm.tab.c" break; - case 22: -#line 204 "asm.y" /* yacc.c:1646 */ - { + case 23: /* atom: INCBIN LPAREN STRING COMMA expr COMMA expr RPAREN */ +#line 209 "asm.y" + { (yyval.atom) = new_incbin((yyvsp[-5].str), (yyvsp[-3].expr), (yyvsp[-1].expr)); } -#line 1726 "asm.tab.c" /* yacc.c:1646 */ +#line 1608 "asm.tab.c" break; - case 23: -#line 207 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = exprs_add((yyvsp[-2].atom), (yyvsp[0].expr)); } -#line 1732 "asm.tab.c" /* yacc.c:1646 */ + case 24: /* exprs: exprs COMMA expr */ +#line 212 "asm.y" + { (yyval.atom) = exprs_add((yyvsp[-2].atom), (yyvsp[0].expr)); } +#line 1614 "asm.tab.c" break; - case 24: -#line 208 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_exprs((yyvsp[0].expr)); } -#line 1738 "asm.tab.c" /* yacc.c:1646 */ + case 25: /* exprs: expr */ +#line 213 "asm.y" + { (yyval.atom) = new_exprs((yyvsp[0].expr)); } +#line 1620 "asm.tab.c" break; - case 25: -#line 210 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xA9, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); } -#line 1744 "asm.tab.c" /* yacc.c:1646 */ + case 26: /* op: LDA am_im */ +#line 215 "asm.y" + { (yyval.atom) = new_op(0xA9, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); } +#line 1626 "asm.tab.c" break; - case 26: -#line 211 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xA5, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 1750 "asm.tab.c" /* yacc.c:1646 */ + case 27: /* op: LDA am_zp */ +#line 216 "asm.y" + { (yyval.atom) = new_op(0xA5, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1632 "asm.tab.c" break; - case 27: -#line 212 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xB5, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 1756 "asm.tab.c" /* yacc.c:1646 */ + case 28: /* op: LDA am_zpx */ +#line 217 "asm.y" + { (yyval.atom) = new_op(0xB5, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1638 "asm.tab.c" break; - case 28: -#line 213 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xAD, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 1762 "asm.tab.c" /* yacc.c:1646 */ + case 29: /* op: LDA am_a */ +#line 218 "asm.y" + { (yyval.atom) = new_op(0xAD, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1644 "asm.tab.c" break; - case 29: -#line 214 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xBD, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 1768 "asm.tab.c" /* yacc.c:1646 */ + case 30: /* op: LDA am_ax */ +#line 219 "asm.y" + { (yyval.atom) = new_op(0xBD, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1650 "asm.tab.c" break; - case 30: -#line 215 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xB9, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 1774 "asm.tab.c" /* yacc.c:1646 */ + case 31: /* op: LDA am_ay */ +#line 220 "asm.y" + { (yyval.atom) = new_op(0xB9, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1656 "asm.tab.c" break; - case 31: -#line 216 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xA1, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 1780 "asm.tab.c" /* yacc.c:1646 */ + case 32: /* op: LDA am_ix */ +#line 221 "asm.y" + { (yyval.atom) = new_op(0xA1, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1662 "asm.tab.c" break; - case 32: -#line 217 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xB1, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 1786 "asm.tab.c" /* yacc.c:1646 */ + case 33: /* op: LDA am_iy */ +#line 222 "asm.y" + { (yyval.atom) = new_op(0xB1, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1668 "asm.tab.c" break; - case 33: -#line 219 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xA2, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); } -#line 1792 "asm.tab.c" /* yacc.c:1646 */ + case 34: /* op: LDX am_im */ +#line 224 "asm.y" + { (yyval.atom) = new_op(0xA2, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); } +#line 1674 "asm.tab.c" break; - case 34: -#line 220 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xA6, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 1798 "asm.tab.c" /* yacc.c:1646 */ + case 35: /* op: LDX am_zp */ +#line 225 "asm.y" + { (yyval.atom) = new_op(0xA6, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1680 "asm.tab.c" break; - case 35: -#line 221 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xB6, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 1804 "asm.tab.c" /* yacc.c:1646 */ + case 36: /* op: LDX am_zpy */ +#line 226 "asm.y" + { (yyval.atom) = new_op(0xB6, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1686 "asm.tab.c" break; - case 36: -#line 222 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xAE, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 1810 "asm.tab.c" /* yacc.c:1646 */ + case 37: /* op: LDX am_a */ +#line 227 "asm.y" + { (yyval.atom) = new_op(0xAE, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1692 "asm.tab.c" break; - case 37: -#line 223 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xBE, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 1816 "asm.tab.c" /* yacc.c:1646 */ + case 38: /* op: LDX am_ay */ +#line 228 "asm.y" + { (yyval.atom) = new_op(0xBE, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1698 "asm.tab.c" break; - case 38: -#line 225 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xA0, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); } -#line 1822 "asm.tab.c" /* yacc.c:1646 */ + case 39: /* op: LDY am_im */ +#line 230 "asm.y" + { (yyval.atom) = new_op(0xA0, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); } +#line 1704 "asm.tab.c" break; - case 39: -#line 226 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xA4, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 1828 "asm.tab.c" /* yacc.c:1646 */ + case 40: /* op: LDY am_zp */ +#line 231 "asm.y" + { (yyval.atom) = new_op(0xA4, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1710 "asm.tab.c" break; - case 40: -#line 227 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xB4, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 1834 "asm.tab.c" /* yacc.c:1646 */ + case 41: /* op: LDY am_zpx */ +#line 232 "asm.y" + { (yyval.atom) = new_op(0xB4, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1716 "asm.tab.c" break; - case 41: -#line 228 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xAC, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 1840 "asm.tab.c" /* yacc.c:1646 */ + case 42: /* op: LDY am_a */ +#line 233 "asm.y" + { (yyval.atom) = new_op(0xAC, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1722 "asm.tab.c" break; - case 42: -#line 229 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xBC, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 1846 "asm.tab.c" /* yacc.c:1646 */ + case 43: /* op: LDY am_ax */ +#line 234 "asm.y" + { (yyval.atom) = new_op(0xBC, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1728 "asm.tab.c" break; - case 43: -#line 231 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x85, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 1852 "asm.tab.c" /* yacc.c:1646 */ + case 44: /* op: STA am_zp */ +#line 236 "asm.y" + { (yyval.atom) = new_op(0x85, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1734 "asm.tab.c" break; - case 44: -#line 232 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x95, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 1858 "asm.tab.c" /* yacc.c:1646 */ + case 45: /* op: STA am_zpx */ +#line 237 "asm.y" + { (yyval.atom) = new_op(0x95, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1740 "asm.tab.c" break; - case 45: -#line 233 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x8D, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 1864 "asm.tab.c" /* yacc.c:1646 */ + case 46: /* op: STA am_a */ +#line 238 "asm.y" + { (yyval.atom) = new_op(0x8D, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1746 "asm.tab.c" break; - case 46: -#line 234 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x9D, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 1870 "asm.tab.c" /* yacc.c:1646 */ + case 47: /* op: STA am_ax */ +#line 239 "asm.y" + { (yyval.atom) = new_op(0x9D, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1752 "asm.tab.c" break; - case 47: -#line 235 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x99, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 1876 "asm.tab.c" /* yacc.c:1646 */ + case 48: /* op: STA am_ay */ +#line 240 "asm.y" + { (yyval.atom) = new_op(0x99, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1758 "asm.tab.c" break; - case 48: -#line 236 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x81, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 1882 "asm.tab.c" /* yacc.c:1646 */ + case 49: /* op: STA am_ix */ +#line 241 "asm.y" + { (yyval.atom) = new_op(0x81, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1764 "asm.tab.c" break; - case 49: -#line 237 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x91, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 1888 "asm.tab.c" /* yacc.c:1646 */ + case 50: /* op: STA am_iy */ +#line 242 "asm.y" + { (yyval.atom) = new_op(0x91, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1770 "asm.tab.c" break; - case 50: -#line 239 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x86, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 1894 "asm.tab.c" /* yacc.c:1646 */ + case 51: /* op: STX am_zp */ +#line 244 "asm.y" + { (yyval.atom) = new_op(0x86, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1776 "asm.tab.c" break; - case 51: -#line 240 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x96, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 1900 "asm.tab.c" /* yacc.c:1646 */ + case 52: /* op: STX am_zpy */ +#line 245 "asm.y" + { (yyval.atom) = new_op(0x96, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1782 "asm.tab.c" break; - case 52: -#line 241 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x8e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 1906 "asm.tab.c" /* yacc.c:1646 */ + case 53: /* op: STX am_a */ +#line 246 "asm.y" + { (yyval.atom) = new_op(0x8e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1788 "asm.tab.c" break; - case 53: -#line 243 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x84, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 1912 "asm.tab.c" /* yacc.c:1646 */ + case 54: /* op: STY am_zp */ +#line 248 "asm.y" + { (yyval.atom) = new_op(0x84, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1794 "asm.tab.c" break; - case 54: -#line 244 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x94, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 1918 "asm.tab.c" /* yacc.c:1646 */ + case 55: /* op: STY am_zpx */ +#line 249 "asm.y" + { (yyval.atom) = new_op(0x94, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1800 "asm.tab.c" break; - case 55: -#line 245 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x8c, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 1924 "asm.tab.c" /* yacc.c:1646 */ + case 56: /* op: STY am_a */ +#line 250 "asm.y" + { (yyval.atom) = new_op(0x8c, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1806 "asm.tab.c" break; - case 56: -#line 247 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x29, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); } -#line 1930 "asm.tab.c" /* yacc.c:1646 */ + case 57: /* op: AND am_im */ +#line 252 "asm.y" + { (yyval.atom) = new_op(0x29, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); } +#line 1812 "asm.tab.c" break; - case 57: -#line 248 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x25, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 1936 "asm.tab.c" /* yacc.c:1646 */ + case 58: /* op: AND am_zp */ +#line 253 "asm.y" + { (yyval.atom) = new_op(0x25, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1818 "asm.tab.c" break; - case 58: -#line 249 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x35, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 1942 "asm.tab.c" /* yacc.c:1646 */ + case 59: /* op: AND am_zpx */ +#line 254 "asm.y" + { (yyval.atom) = new_op(0x35, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1824 "asm.tab.c" break; - case 59: -#line 250 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x2d, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 1948 "asm.tab.c" /* yacc.c:1646 */ + case 60: /* op: AND am_a */ +#line 255 "asm.y" + { (yyval.atom) = new_op(0x2d, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1830 "asm.tab.c" break; - case 60: -#line 251 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x3d, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 1954 "asm.tab.c" /* yacc.c:1646 */ + case 61: /* op: AND am_ax */ +#line 256 "asm.y" + { (yyval.atom) = new_op(0x3d, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1836 "asm.tab.c" break; - case 61: -#line 252 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x39, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 1960 "asm.tab.c" /* yacc.c:1646 */ + case 62: /* op: AND am_ay */ +#line 257 "asm.y" + { (yyval.atom) = new_op(0x39, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1842 "asm.tab.c" break; - case 62: -#line 253 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x21, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 1966 "asm.tab.c" /* yacc.c:1646 */ + case 63: /* op: AND am_ix */ +#line 258 "asm.y" + { (yyval.atom) = new_op(0x21, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1848 "asm.tab.c" break; - case 63: -#line 254 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x31, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 1972 "asm.tab.c" /* yacc.c:1646 */ + case 64: /* op: AND am_iy */ +#line 259 "asm.y" + { (yyval.atom) = new_op(0x31, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1854 "asm.tab.c" break; - case 64: -#line 256 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x09, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); } -#line 1978 "asm.tab.c" /* yacc.c:1646 */ + case 65: /* op: ORA am_im */ +#line 261 "asm.y" + { (yyval.atom) = new_op(0x09, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); } +#line 1860 "asm.tab.c" break; - case 65: -#line 257 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x05, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 1984 "asm.tab.c" /* yacc.c:1646 */ + case 66: /* op: ORA am_zp */ +#line 262 "asm.y" + { (yyval.atom) = new_op(0x05, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1866 "asm.tab.c" break; - case 66: -#line 258 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x15, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 1990 "asm.tab.c" /* yacc.c:1646 */ + case 67: /* op: ORA am_zpx */ +#line 263 "asm.y" + { (yyval.atom) = new_op(0x15, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1872 "asm.tab.c" break; - case 67: -#line 259 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x0d, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 1996 "asm.tab.c" /* yacc.c:1646 */ + case 68: /* op: ORA am_a */ +#line 264 "asm.y" + { (yyval.atom) = new_op(0x0d, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1878 "asm.tab.c" break; - case 68: -#line 260 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x1d, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2002 "asm.tab.c" /* yacc.c:1646 */ + case 69: /* op: ORA am_ax */ +#line 265 "asm.y" + { (yyval.atom) = new_op(0x1d, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1884 "asm.tab.c" break; - case 69: -#line 261 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x19, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2008 "asm.tab.c" /* yacc.c:1646 */ + case 70: /* op: ORA am_ay */ +#line 266 "asm.y" + { (yyval.atom) = new_op(0x19, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1890 "asm.tab.c" break; - case 70: -#line 262 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x01, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2014 "asm.tab.c" /* yacc.c:1646 */ + case 71: /* op: ORA am_ix */ +#line 267 "asm.y" + { (yyval.atom) = new_op(0x01, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1896 "asm.tab.c" break; - case 71: -#line 263 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x11, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2020 "asm.tab.c" /* yacc.c:1646 */ + case 72: /* op: ORA am_iy */ +#line 268 "asm.y" + { (yyval.atom) = new_op(0x11, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1902 "asm.tab.c" break; - case 72: -#line 265 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x49, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); } -#line 2026 "asm.tab.c" /* yacc.c:1646 */ + case 73: /* op: EOR am_im */ +#line 270 "asm.y" + { (yyval.atom) = new_op(0x49, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); } +#line 1908 "asm.tab.c" break; - case 73: -#line 266 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x45, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2032 "asm.tab.c" /* yacc.c:1646 */ + case 74: /* op: EOR am_zp */ +#line 271 "asm.y" + { (yyval.atom) = new_op(0x45, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1914 "asm.tab.c" break; - case 74: -#line 267 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x55, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2038 "asm.tab.c" /* yacc.c:1646 */ + case 75: /* op: EOR am_zpx */ +#line 272 "asm.y" + { (yyval.atom) = new_op(0x55, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1920 "asm.tab.c" break; - case 75: -#line 268 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x4d, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2044 "asm.tab.c" /* yacc.c:1646 */ + case 76: /* op: EOR am_a */ +#line 273 "asm.y" + { (yyval.atom) = new_op(0x4d, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1926 "asm.tab.c" break; - case 76: -#line 269 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x5d, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2050 "asm.tab.c" /* yacc.c:1646 */ + case 77: /* op: EOR am_ax */ +#line 274 "asm.y" + { (yyval.atom) = new_op(0x5d, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1932 "asm.tab.c" break; - case 77: -#line 270 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x59, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2056 "asm.tab.c" /* yacc.c:1646 */ + case 78: /* op: EOR am_ay */ +#line 275 "asm.y" + { (yyval.atom) = new_op(0x59, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1938 "asm.tab.c" break; - case 78: -#line 271 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x41, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2062 "asm.tab.c" /* yacc.c:1646 */ + case 79: /* op: EOR am_ix */ +#line 276 "asm.y" + { (yyval.atom) = new_op(0x41, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1944 "asm.tab.c" break; - case 79: -#line 272 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x51, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2068 "asm.tab.c" /* yacc.c:1646 */ + case 80: /* op: EOR am_iy */ +#line 277 "asm.y" + { (yyval.atom) = new_op(0x51, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1950 "asm.tab.c" break; - case 80: -#line 274 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x69, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); } -#line 2074 "asm.tab.c" /* yacc.c:1646 */ + case 81: /* op: ADC am_im */ +#line 279 "asm.y" + { (yyval.atom) = new_op(0x69, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); } +#line 1956 "asm.tab.c" break; - case 81: -#line 275 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x65, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2080 "asm.tab.c" /* yacc.c:1646 */ + case 82: /* op: ADC am_zp */ +#line 280 "asm.y" + { (yyval.atom) = new_op(0x65, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1962 "asm.tab.c" break; - case 82: -#line 276 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x75, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2086 "asm.tab.c" /* yacc.c:1646 */ + case 83: /* op: ADC am_zpx */ +#line 281 "asm.y" + { (yyval.atom) = new_op(0x75, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1968 "asm.tab.c" break; - case 83: -#line 277 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x6D, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2092 "asm.tab.c" /* yacc.c:1646 */ + case 84: /* op: ADC am_a */ +#line 282 "asm.y" + { (yyval.atom) = new_op(0x6D, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1974 "asm.tab.c" break; - case 84: -#line 278 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x7D, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2098 "asm.tab.c" /* yacc.c:1646 */ + case 85: /* op: ADC am_ax */ +#line 283 "asm.y" + { (yyval.atom) = new_op(0x7D, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1980 "asm.tab.c" break; - case 85: -#line 279 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x79, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2104 "asm.tab.c" /* yacc.c:1646 */ + case 86: /* op: ADC am_ay */ +#line 284 "asm.y" + { (yyval.atom) = new_op(0x79, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 1986 "asm.tab.c" break; - case 86: -#line 280 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x61, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2110 "asm.tab.c" /* yacc.c:1646 */ + case 87: /* op: ADC am_ix */ +#line 285 "asm.y" + { (yyval.atom) = new_op(0x61, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1992 "asm.tab.c" break; - case 87: -#line 281 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x71, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2116 "asm.tab.c" /* yacc.c:1646 */ + case 88: /* op: ADC am_iy */ +#line 286 "asm.y" + { (yyval.atom) = new_op(0x71, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 1998 "asm.tab.c" break; - case 88: -#line 283 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xe9, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); } -#line 2122 "asm.tab.c" /* yacc.c:1646 */ + case 89: /* op: SBC am_im */ +#line 288 "asm.y" + { (yyval.atom) = new_op(0xe9, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); } +#line 2004 "asm.tab.c" break; - case 89: -#line 284 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xe5, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2128 "asm.tab.c" /* yacc.c:1646 */ + case 90: /* op: SBC am_zp */ +#line 289 "asm.y" + { (yyval.atom) = new_op(0xe5, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2010 "asm.tab.c" break; - case 90: -#line 285 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xf5, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2134 "asm.tab.c" /* yacc.c:1646 */ + case 91: /* op: SBC am_zpx */ +#line 290 "asm.y" + { (yyval.atom) = new_op(0xf5, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2016 "asm.tab.c" break; - case 91: -#line 286 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xeD, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2140 "asm.tab.c" /* yacc.c:1646 */ + case 92: /* op: SBC am_a */ +#line 291 "asm.y" + { (yyval.atom) = new_op(0xeD, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2022 "asm.tab.c" break; - case 92: -#line 287 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xfD, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2146 "asm.tab.c" /* yacc.c:1646 */ + case 93: /* op: SBC am_ax */ +#line 292 "asm.y" + { (yyval.atom) = new_op(0xfD, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2028 "asm.tab.c" break; - case 93: -#line 288 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xf9, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2152 "asm.tab.c" /* yacc.c:1646 */ + case 94: /* op: SBC am_ay */ +#line 293 "asm.y" + { (yyval.atom) = new_op(0xf9, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2034 "asm.tab.c" break; - case 94: -#line 289 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xe1, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2158 "asm.tab.c" /* yacc.c:1646 */ + case 95: /* op: SBC am_ix */ +#line 294 "asm.y" + { (yyval.atom) = new_op(0xe1, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2040 "asm.tab.c" break; - case 95: -#line 290 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xf1, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2164 "asm.tab.c" /* yacc.c:1646 */ + case 96: /* op: SBC am_iy */ +#line 295 "asm.y" + { (yyval.atom) = new_op(0xf1, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2046 "asm.tab.c" break; - case 96: -#line 292 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xc9, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); } -#line 2170 "asm.tab.c" /* yacc.c:1646 */ + case 97: /* op: CMP am_im */ +#line 297 "asm.y" + { (yyval.atom) = new_op(0xc9, ATOM_TYPE_OP_ARG_UI8, (yyvsp[0].expr)); } +#line 2052 "asm.tab.c" break; - case 97: -#line 293 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xc5, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2176 "asm.tab.c" /* yacc.c:1646 */ + case 98: /* op: CMP am_zp */ +#line 298 "asm.y" + { (yyval.atom) = new_op(0xc5, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2058 "asm.tab.c" break; - case 98: -#line 294 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xd5, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2182 "asm.tab.c" /* yacc.c:1646 */ + case 99: /* op: CMP am_zpx */ +#line 299 "asm.y" + { (yyval.atom) = new_op(0xd5, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2064 "asm.tab.c" break; - case 99: -#line 295 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xcD, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2188 "asm.tab.c" /* yacc.c:1646 */ + case 100: /* op: CMP am_a */ +#line 300 "asm.y" + { (yyval.atom) = new_op(0xcD, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2070 "asm.tab.c" break; - case 100: -#line 296 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xdD, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2194 "asm.tab.c" /* yacc.c:1646 */ + case 101: /* op: CMP am_ax */ +#line 301 "asm.y" + { (yyval.atom) = new_op(0xdD, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2076 "asm.tab.c" break; - case 101: -#line 297 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xd9, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2200 "asm.tab.c" /* yacc.c:1646 */ + case 102: /* op: CMP am_ay */ +#line 302 "asm.y" + { (yyval.atom) = new_op(0xd9, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2082 "asm.tab.c" break; - case 102: -#line 298 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xc1, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2206 "asm.tab.c" /* yacc.c:1646 */ + case 103: /* op: CMP am_ix */ +#line 303 "asm.y" + { (yyval.atom) = new_op(0xc1, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2088 "asm.tab.c" break; - case 103: -#line 299 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xd1, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2212 "asm.tab.c" /* yacc.c:1646 */ + case 104: /* op: CMP am_iy */ +#line 304 "asm.y" + { (yyval.atom) = new_op(0xd1, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2094 "asm.tab.c" break; - case 104: -#line 301 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xe0, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2218 "asm.tab.c" /* yacc.c:1646 */ + case 105: /* op: CPX am_im */ +#line 306 "asm.y" + { (yyval.atom) = new_op(0xe0, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2100 "asm.tab.c" break; - case 105: -#line 302 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xe4, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2224 "asm.tab.c" /* yacc.c:1646 */ + case 106: /* op: CPX am_zp */ +#line 307 "asm.y" + { (yyval.atom) = new_op(0xe4, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2106 "asm.tab.c" break; - case 106: -#line 303 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xec, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2230 "asm.tab.c" /* yacc.c:1646 */ + case 107: /* op: CPX am_a */ +#line 308 "asm.y" + { (yyval.atom) = new_op(0xec, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2112 "asm.tab.c" break; - case 107: -#line 304 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xc0, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2236 "asm.tab.c" /* yacc.c:1646 */ + case 108: /* op: CPY am_im */ +#line 309 "asm.y" + { (yyval.atom) = new_op(0xc0, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2118 "asm.tab.c" break; - case 108: -#line 305 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xc4, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2242 "asm.tab.c" /* yacc.c:1646 */ + case 109: /* op: CPY am_zp */ +#line 310 "asm.y" + { (yyval.atom) = new_op(0xc4, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2124 "asm.tab.c" break; - case 109: -#line 306 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xcc, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2248 "asm.tab.c" /* yacc.c:1646 */ + case 110: /* op: CPY am_a */ +#line 311 "asm.y" + { (yyval.atom) = new_op(0xcc, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2130 "asm.tab.c" break; - case 110: -#line 308 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op0(0x9A); } -#line 2254 "asm.tab.c" /* yacc.c:1646 */ + case 111: /* op: TXS */ +#line 313 "asm.y" + { (yyval.atom) = new_op0(0x9A); } +#line 2136 "asm.tab.c" break; - case 111: -#line 309 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op0(0xBA); } -#line 2260 "asm.tab.c" /* yacc.c:1646 */ + case 112: /* op: TSX */ +#line 314 "asm.y" + { (yyval.atom) = new_op0(0xBA); } +#line 2142 "asm.tab.c" break; - case 112: -#line 310 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op0(0x48); } -#line 2266 "asm.tab.c" /* yacc.c:1646 */ + case 113: /* op: PHA */ +#line 315 "asm.y" + { (yyval.atom) = new_op0(0x48); } +#line 2148 "asm.tab.c" break; - case 113: -#line 311 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op0(0x68); } -#line 2272 "asm.tab.c" /* yacc.c:1646 */ + case 114: /* op: PLA */ +#line 316 "asm.y" + { (yyval.atom) = new_op0(0x68); } +#line 2154 "asm.tab.c" break; - case 114: -#line 312 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op0(0x08); } -#line 2278 "asm.tab.c" /* yacc.c:1646 */ + case 115: /* op: PHP */ +#line 317 "asm.y" + { (yyval.atom) = new_op0(0x08); } +#line 2160 "asm.tab.c" break; - case 115: -#line 313 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op0(0x28); } -#line 2284 "asm.tab.c" /* yacc.c:1646 */ + case 116: /* op: PLP */ +#line 318 "asm.y" + { (yyval.atom) = new_op0(0x28); } +#line 2166 "asm.tab.c" break; - case 116: -#line 314 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op0(0x78); } -#line 2290 "asm.tab.c" /* yacc.c:1646 */ + case 117: /* op: SEI */ +#line 319 "asm.y" + { (yyval.atom) = new_op0(0x78); } +#line 2172 "asm.tab.c" break; - case 117: -#line 315 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op0(0x58); } -#line 2296 "asm.tab.c" /* yacc.c:1646 */ + case 118: /* op: CLI */ +#line 320 "asm.y" + { (yyval.atom) = new_op0(0x58); } +#line 2178 "asm.tab.c" break; - case 118: -#line 316 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op0(0xea); } -#line 2302 "asm.tab.c" /* yacc.c:1646 */ + case 119: /* op: NOP */ +#line 321 "asm.y" + { (yyval.atom) = new_op0(0xea); } +#line 2184 "asm.tab.c" break; - case 119: -#line 317 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op0(0x98); } -#line 2308 "asm.tab.c" /* yacc.c:1646 */ + case 120: /* op: TYA */ +#line 322 "asm.y" + { (yyval.atom) = new_op0(0x98); } +#line 2190 "asm.tab.c" break; - case 120: -#line 318 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op0(0xa8); } -#line 2314 "asm.tab.c" /* yacc.c:1646 */ + case 121: /* op: TAY */ +#line 323 "asm.y" + { (yyval.atom) = new_op0(0xa8); } +#line 2196 "asm.tab.c" break; - case 121: -#line 319 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op0(0x8a); } -#line 2320 "asm.tab.c" /* yacc.c:1646 */ + case 122: /* op: TXA */ +#line 324 "asm.y" + { (yyval.atom) = new_op0(0x8a); } +#line 2202 "asm.tab.c" break; - case 122: -#line 320 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op0(0xaa); } -#line 2326 "asm.tab.c" /* yacc.c:1646 */ + case 123: /* op: TAX */ +#line 325 "asm.y" + { (yyval.atom) = new_op0(0xaa); } +#line 2208 "asm.tab.c" break; - case 123: -#line 321 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op0(0x18); } -#line 2332 "asm.tab.c" /* yacc.c:1646 */ + case 124: /* op: CLC */ +#line 326 "asm.y" + { (yyval.atom) = new_op0(0x18); } +#line 2214 "asm.tab.c" break; - case 124: -#line 322 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op0(0x38); } -#line 2338 "asm.tab.c" /* yacc.c:1646 */ + case 125: /* op: SEC */ +#line 327 "asm.y" + { (yyval.atom) = new_op0(0x38); } +#line 2220 "asm.tab.c" break; - case 125: -#line 323 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op0(0x60); } -#line 2344 "asm.tab.c" /* yacc.c:1646 */ + case 126: /* op: RTS */ +#line 328 "asm.y" + { (yyval.atom) = new_op0(0x60); } +#line 2226 "asm.tab.c" break; - case 126: -#line 325 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x20, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2350 "asm.tab.c" /* yacc.c:1646 */ + case 127: /* op: CLV */ +#line 329 "asm.y" + { (yyval.atom) = new_op0(0xb8); } +#line 2232 "asm.tab.c" break; - case 127: -#line 326 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x4c, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2356 "asm.tab.c" /* yacc.c:1646 */ + case 128: /* op: CLD */ +#line 330 "asm.y" + { (yyval.atom) = new_op0(0xd8); } +#line 2238 "asm.tab.c" break; - case 128: -#line 327 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xf0, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); } -#line 2362 "asm.tab.c" /* yacc.c:1646 */ + case 129: /* op: SED */ +#line 331 "asm.y" + { (yyval.atom) = new_op0(0xf0); } +#line 2244 "asm.tab.c" break; - case 129: -#line 328 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xd0, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); } -#line 2368 "asm.tab.c" /* yacc.c:1646 */ + case 130: /* op: JSR am_a */ +#line 333 "asm.y" + { (yyval.atom) = new_op(0x20, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2250 "asm.tab.c" break; - case 130: -#line 329 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x90, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); } -#line 2374 "asm.tab.c" /* yacc.c:1646 */ + case 131: /* op: JMP am_a */ +#line 334 "asm.y" + { (yyval.atom) = new_op(0x4c, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2256 "asm.tab.c" break; - case 131: -#line 330 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xb0, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); } -#line 2380 "asm.tab.c" /* yacc.c:1646 */ + case 132: /* op: BEQ am_a */ +#line 335 "asm.y" + { (yyval.atom) = new_op(0xf0, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); } +#line 2262 "asm.tab.c" break; - case 132: -#line 331 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x10, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); } -#line 2386 "asm.tab.c" /* yacc.c:1646 */ + case 133: /* op: BNE am_a */ +#line 336 "asm.y" + { (yyval.atom) = new_op(0xd0, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); } +#line 2268 "asm.tab.c" break; - case 133: -#line 332 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x30, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); } -#line 2392 "asm.tab.c" /* yacc.c:1646 */ + case 134: /* op: BCC am_a */ +#line 337 "asm.y" + { (yyval.atom) = new_op(0x90, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); } +#line 2274 "asm.tab.c" break; - case 134: -#line 333 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x50, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); } -#line 2398 "asm.tab.c" /* yacc.c:1646 */ + case 135: /* op: BCS am_a */ +#line 338 "asm.y" + { (yyval.atom) = new_op(0xb0, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); } +#line 2280 "asm.tab.c" break; - case 135: -#line 334 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x70, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); } -#line 2404 "asm.tab.c" /* yacc.c:1646 */ + case 136: /* op: BPL am_a */ +#line 339 "asm.y" + { (yyval.atom) = new_op(0x10, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); } +#line 2286 "asm.tab.c" break; - case 136: -#line 336 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op0(0xe8); } -#line 2410 "asm.tab.c" /* yacc.c:1646 */ + case 137: /* op: BMI am_a */ +#line 340 "asm.y" + { (yyval.atom) = new_op(0x30, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); } +#line 2292 "asm.tab.c" break; - case 137: -#line 337 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op0(0xca); } -#line 2416 "asm.tab.c" /* yacc.c:1646 */ + case 138: /* op: BVC am_a */ +#line 341 "asm.y" + { (yyval.atom) = new_op(0x50, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); } +#line 2298 "asm.tab.c" break; - case 138: -#line 338 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op0(0xc8); } -#line 2422 "asm.tab.c" /* yacc.c:1646 */ + case 139: /* op: BVS am_a */ +#line 342 "asm.y" + { (yyval.atom) = new_op(0x70, ATOM_TYPE_OP_ARG_I8, (yyvsp[0].expr)); } +#line 2304 "asm.tab.c" break; - case 139: -#line 339 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op0(0x88); } -#line 2428 "asm.tab.c" /* yacc.c:1646 */ + case 140: /* op: INX */ +#line 344 "asm.y" + { (yyval.atom) = new_op0(0xe8); } +#line 2310 "asm.tab.c" break; - case 140: -#line 341 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xe6, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2434 "asm.tab.c" /* yacc.c:1646 */ + case 141: /* op: DEX */ +#line 345 "asm.y" + { (yyval.atom) = new_op0(0xca); } +#line 2316 "asm.tab.c" break; - case 141: -#line 342 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xf6, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2440 "asm.tab.c" /* yacc.c:1646 */ + case 142: /* op: INY */ +#line 346 "asm.y" + { (yyval.atom) = new_op0(0xc8); } +#line 2322 "asm.tab.c" break; - case 142: -#line 343 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xee, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2446 "asm.tab.c" /* yacc.c:1646 */ + case 143: /* op: DEY */ +#line 347 "asm.y" + { (yyval.atom) = new_op0(0x88); } +#line 2328 "asm.tab.c" break; - case 143: -#line 344 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xfe, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2452 "asm.tab.c" /* yacc.c:1646 */ + case 144: /* op: INC am_zp */ +#line 349 "asm.y" + { (yyval.atom) = new_op(0xe6, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2334 "asm.tab.c" break; - case 144: -#line 346 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xc6, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2458 "asm.tab.c" /* yacc.c:1646 */ + case 145: /* op: INC am_zpx */ +#line 350 "asm.y" + { (yyval.atom) = new_op(0xf6, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2340 "asm.tab.c" break; - case 145: -#line 347 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xd6, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2464 "asm.tab.c" /* yacc.c:1646 */ + case 146: /* op: INC am_a */ +#line 351 "asm.y" + { (yyval.atom) = new_op(0xee, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2346 "asm.tab.c" break; - case 146: -#line 348 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xce, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2470 "asm.tab.c" /* yacc.c:1646 */ + case 147: /* op: INC am_ax */ +#line 352 "asm.y" + { (yyval.atom) = new_op(0xfe, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2352 "asm.tab.c" break; - case 147: -#line 349 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0xde, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2476 "asm.tab.c" /* yacc.c:1646 */ + case 148: /* op: DEC am_zp */ +#line 354 "asm.y" + { (yyval.atom) = new_op(0xc6, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2358 "asm.tab.c" break; - case 148: -#line 351 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op0(0x4a); } -#line 2482 "asm.tab.c" /* yacc.c:1646 */ + case 149: /* op: DEC am_zpx */ +#line 355 "asm.y" + { (yyval.atom) = new_op(0xd6, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2364 "asm.tab.c" break; - case 149: -#line 352 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x46, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2488 "asm.tab.c" /* yacc.c:1646 */ + case 150: /* op: DEC am_a */ +#line 356 "asm.y" + { (yyval.atom) = new_op(0xce, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2370 "asm.tab.c" break; - case 150: -#line 353 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x56, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2494 "asm.tab.c" /* yacc.c:1646 */ + case 151: /* op: DEC am_ax */ +#line 357 "asm.y" + { (yyval.atom) = new_op(0xde, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2376 "asm.tab.c" break; - case 151: -#line 354 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x4e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2500 "asm.tab.c" /* yacc.c:1646 */ + case 152: /* op: LSR */ +#line 359 "asm.y" + { (yyval.atom) = new_op0(0x4a); } +#line 2382 "asm.tab.c" break; - case 152: -#line 355 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x5e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2506 "asm.tab.c" /* yacc.c:1646 */ + case 153: /* op: LSR am_zp */ +#line 360 "asm.y" + { (yyval.atom) = new_op(0x46, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2388 "asm.tab.c" break; - case 153: -#line 357 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op0(0x0a); } -#line 2512 "asm.tab.c" /* yacc.c:1646 */ + case 154: /* op: LSR am_zpx */ +#line 361 "asm.y" + { (yyval.atom) = new_op(0x56, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2394 "asm.tab.c" break; - case 154: -#line 358 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x06, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2518 "asm.tab.c" /* yacc.c:1646 */ + case 155: /* op: LSR am_a */ +#line 362 "asm.y" + { (yyval.atom) = new_op(0x4e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2400 "asm.tab.c" break; - case 155: -#line 359 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x16, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2524 "asm.tab.c" /* yacc.c:1646 */ + case 156: /* op: LSR am_ax */ +#line 363 "asm.y" + { (yyval.atom) = new_op(0x5e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2406 "asm.tab.c" break; - case 156: -#line 360 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x0e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2530 "asm.tab.c" /* yacc.c:1646 */ + case 157: /* op: ASL */ +#line 365 "asm.y" + { (yyval.atom) = new_op0(0x0a); } +#line 2412 "asm.tab.c" break; - case 157: -#line 361 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x1e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2536 "asm.tab.c" /* yacc.c:1646 */ + case 158: /* op: ASL am_zp */ +#line 366 "asm.y" + { (yyval.atom) = new_op(0x06, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2418 "asm.tab.c" break; - case 158: -#line 363 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op0(0x6a); } -#line 2542 "asm.tab.c" /* yacc.c:1646 */ + case 159: /* op: ASL am_zpx */ +#line 367 "asm.y" + { (yyval.atom) = new_op(0x16, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2424 "asm.tab.c" break; - case 159: -#line 364 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x66, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2548 "asm.tab.c" /* yacc.c:1646 */ + case 160: /* op: ASL am_a */ +#line 368 "asm.y" + { (yyval.atom) = new_op(0x0e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2430 "asm.tab.c" break; - case 160: -#line 365 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x76, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2554 "asm.tab.c" /* yacc.c:1646 */ + case 161: /* op: ASL am_ax */ +#line 369 "asm.y" + { (yyval.atom) = new_op(0x1e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2436 "asm.tab.c" break; - case 161: -#line 366 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x6e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2560 "asm.tab.c" /* yacc.c:1646 */ + case 162: /* op: ROR */ +#line 371 "asm.y" + { (yyval.atom) = new_op0(0x6a); } +#line 2442 "asm.tab.c" break; - case 162: -#line 367 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x7e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2566 "asm.tab.c" /* yacc.c:1646 */ + case 163: /* op: ROR am_zp */ +#line 372 "asm.y" + { (yyval.atom) = new_op(0x66, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2448 "asm.tab.c" break; - case 163: -#line 369 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op0(0x2a); } -#line 2572 "asm.tab.c" /* yacc.c:1646 */ + case 164: /* op: ROR am_zpx */ +#line 373 "asm.y" + { (yyval.atom) = new_op(0x76, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2454 "asm.tab.c" break; - case 164: -#line 370 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x26, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2578 "asm.tab.c" /* yacc.c:1646 */ + case 165: /* op: ROR am_a */ +#line 374 "asm.y" + { (yyval.atom) = new_op(0x6e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2460 "asm.tab.c" break; - case 165: -#line 371 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x36, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2584 "asm.tab.c" /* yacc.c:1646 */ + case 166: /* op: ROR am_ax */ +#line 375 "asm.y" + { (yyval.atom) = new_op(0x7e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2466 "asm.tab.c" break; - case 166: -#line 372 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x2e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2590 "asm.tab.c" /* yacc.c:1646 */ + case 167: /* op: ROL */ +#line 377 "asm.y" + { (yyval.atom) = new_op0(0x2a); } +#line 2472 "asm.tab.c" break; - case 167: -#line 373 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x3e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2596 "asm.tab.c" /* yacc.c:1646 */ + case 168: /* op: ROL am_zp */ +#line 378 "asm.y" + { (yyval.atom) = new_op(0x26, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2478 "asm.tab.c" break; - case 168: -#line 375 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x24, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } -#line 2602 "asm.tab.c" /* yacc.c:1646 */ + case 169: /* op: ROL am_zpx */ +#line 379 "asm.y" + { (yyval.atom) = new_op(0x36, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2484 "asm.tab.c" break; - case 169: -#line 376 "asm.y" /* yacc.c:1646 */ - { (yyval.atom) = new_op(0x2c, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } -#line 2608 "asm.tab.c" /* yacc.c:1646 */ + case 170: /* op: ROL am_a */ +#line 380 "asm.y" + { (yyval.atom) = new_op(0x2e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2490 "asm.tab.c" break; - case 170: -#line 378 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = (yyvsp[0].expr); } -#line 2614 "asm.tab.c" /* yacc.c:1646 */ + case 171: /* op: ROL am_ax */ +#line 381 "asm.y" + { (yyval.atom) = new_op(0x3e, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2496 "asm.tab.c" break; - case 171: -#line 379 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = (yyvsp[0].expr); } -#line 2620 "asm.tab.c" /* yacc.c:1646 */ + case 172: /* op: BIT am_zp */ +#line 383 "asm.y" + { (yyval.atom) = new_op(0x24, ATOM_TYPE_OP_ARG_U8, (yyvsp[0].expr)); } +#line 2502 "asm.tab.c" break; - case 172: -#line 380 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = (yyvsp[-2].expr); } -#line 2626 "asm.tab.c" /* yacc.c:1646 */ + case 173: /* op: BIT am_a */ +#line 384 "asm.y" + { (yyval.atom) = new_op(0x2c, ATOM_TYPE_OP_ARG_U16, (yyvsp[0].expr)); } +#line 2508 "asm.tab.c" break; - case 173: -#line 381 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = (yyvsp[-2].expr); } -#line 2632 "asm.tab.c" /* yacc.c:1646 */ + case 174: /* am_im: HASH expr */ +#line 386 "asm.y" + { (yyval.expr) = (yyvsp[0].expr); } +#line 2514 "asm.tab.c" break; - case 174: -#line 382 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = (yyvsp[0].expr); } -#line 2638 "asm.tab.c" /* yacc.c:1646 */ + case 175: /* am_a: expr */ +#line 387 "asm.y" + { (yyval.expr) = (yyvsp[0].expr); } +#line 2520 "asm.tab.c" break; - case 175: -#line 383 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = (yyvsp[-2].expr); } -#line 2644 "asm.tab.c" /* yacc.c:1646 */ + case 176: /* am_ax: expr COMMA X */ +#line 388 "asm.y" + { (yyval.expr) = (yyvsp[-2].expr); } +#line 2526 "asm.tab.c" break; - case 176: -#line 384 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = (yyvsp[-2].expr); } -#line 2650 "asm.tab.c" /* yacc.c:1646 */ + case 177: /* am_ay: expr COMMA Y */ +#line 389 "asm.y" + { (yyval.expr) = (yyvsp[-2].expr); } +#line 2532 "asm.tab.c" break; - case 177: -#line 385 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = (yyvsp[-3].expr); } -#line 2656 "asm.tab.c" /* yacc.c:1646 */ + case 178: /* am_zp: LT expr */ +#line 390 "asm.y" + { (yyval.expr) = (yyvsp[0].expr); } +#line 2538 "asm.tab.c" break; - case 178: -#line 386 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = (yyvsp[-3].expr); } -#line 2662 "asm.tab.c" /* yacc.c:1646 */ + case 179: /* am_zpx: LT expr COMMA X */ +#line 391 "asm.y" + { (yyval.expr) = (yyvsp[-2].expr); } +#line 2544 "asm.tab.c" break; - case 179: -#line 388 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = new_expr_op2(PLUS, (yyvsp[-2].expr), (yyvsp[0].expr)); } -#line 2668 "asm.tab.c" /* yacc.c:1646 */ + case 180: /* am_zpy: LT expr COMMA Y */ +#line 392 "asm.y" + { (yyval.expr) = (yyvsp[-2].expr); } +#line 2550 "asm.tab.c" break; - case 180: -#line 389 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = new_expr_op2(MINUS, (yyvsp[-2].expr), (yyvsp[0].expr)); } -#line 2674 "asm.tab.c" /* yacc.c:1646 */ + case 181: /* am_ix: LPAREN expr COMMA X RPAREN */ +#line 393 "asm.y" + { (yyval.expr) = (yyvsp[-3].expr); } +#line 2556 "asm.tab.c" break; - case 181: -#line 390 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = new_expr_op2(MULT, (yyvsp[-2].expr), (yyvsp[0].expr)); } -#line 2680 "asm.tab.c" /* yacc.c:1646 */ + case 182: /* am_iy: LPAREN expr RPAREN COMMA Y */ +#line 394 "asm.y" + { (yyval.expr) = (yyvsp[-3].expr); } +#line 2562 "asm.tab.c" break; - case 182: -#line 391 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = new_expr_op2(DIV, (yyvsp[-2].expr), (yyvsp[0].expr)); } -#line 2686 "asm.tab.c" /* yacc.c:1646 */ + case 183: /* expr: expr PLUS expr */ +#line 396 "asm.y" + { (yyval.expr) = new_expr_op2(PLUS, (yyvsp[-2].expr), (yyvsp[0].expr)); } +#line 2568 "asm.tab.c" break; - case 183: -#line 392 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = new_expr_op2(MOD, (yyvsp[-2].expr), (yyvsp[0].expr)); } -#line 2692 "asm.tab.c" /* yacc.c:1646 */ + case 184: /* expr: expr MINUS expr */ +#line 397 "asm.y" + { (yyval.expr) = new_expr_op2(MINUS, (yyvsp[-2].expr), (yyvsp[0].expr)); } +#line 2574 "asm.tab.c" break; - case 184: -#line 393 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = new_expr_op1(vNEG, (yyvsp[0].expr)); } -#line 2698 "asm.tab.c" /* yacc.c:1646 */ + case 185: /* expr: expr MULT expr */ +#line 398 "asm.y" + { (yyval.expr) = new_expr_op2(MULT, (yyvsp[-2].expr), (yyvsp[0].expr)); } +#line 2580 "asm.tab.c" break; - case 185: -#line 394 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = (yyvsp[-1].expr); } -#line 2704 "asm.tab.c" /* yacc.c:1646 */ + case 186: /* expr: expr DIV expr */ +#line 399 "asm.y" + { (yyval.expr) = new_expr_op2(DIV, (yyvsp[-2].expr), (yyvsp[0].expr)); } +#line 2586 "asm.tab.c" break; - case 186: -#line 395 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = new_expr_inclen((yyvsp[-1].str)); } -#line 2710 "asm.tab.c" /* yacc.c:1646 */ + case 187: /* expr: expr MOD expr */ +#line 400 "asm.y" + { (yyval.expr) = new_expr_op2(MOD, (yyvsp[-2].expr), (yyvsp[0].expr)); } +#line 2592 "asm.tab.c" break; - case 187: -#line 396 "asm.y" /* yacc.c:1646 */ - { + case 188: /* expr: MINUS expr */ +#line 401 "asm.y" + { (yyval.expr) = new_expr_op1(vNEG, (yyvsp[0].expr)); } +#line 2598 "asm.tab.c" + break; + + case 189: /* expr: LPAREN expr RPAREN */ +#line 402 "asm.y" + { (yyval.expr) = (yyvsp[-1].expr); } +#line 2604 "asm.tab.c" + break; + + case 190: /* expr: INCLEN LPAREN STRING RPAREN */ +#line 403 "asm.y" + { (yyval.expr) = new_expr_inclen((yyvsp[-1].str)); } +#line 2610 "asm.tab.c" + break; + + case 191: /* expr: INCWORD LPAREN STRING COMMA expr RPAREN */ +#line 404 "asm.y" + { (yyval.expr) = new_expr_incword((yyvsp[-3].str), (yyvsp[-1].expr)); } -#line 2717 "asm.tab.c" /* yacc.c:1646 */ +#line 2617 "asm.tab.c" break; - case 188: -#line 398 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = new_expr_number((yyvsp[0].num)); } -#line 2723 "asm.tab.c" /* yacc.c:1646 */ + case 192: /* expr: NUMBER */ +#line 406 "asm.y" + { (yyval.expr) = new_expr_number((yyvsp[0].num)); } +#line 2623 "asm.tab.c" break; - case 189: -#line 399 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = new_expr_symref((yyvsp[0].str)); } -#line 2729 "asm.tab.c" /* yacc.c:1646 */ + case 193: /* expr: SYMBOL */ +#line 407 "asm.y" + { (yyval.expr) = new_expr_symref((yyvsp[0].str)); } +#line 2629 "asm.tab.c" break; - case 190: -#line 401 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = new_expr_op2(LOR, (yyvsp[-2].expr), (yyvsp[0].expr)); } -#line 2735 "asm.tab.c" /* yacc.c:1646 */ + case 194: /* lexpr: lexpr LOR lexpr */ +#line 409 "asm.y" + { (yyval.expr) = new_expr_op2(LOR, (yyvsp[-2].expr), (yyvsp[0].expr)); } +#line 2635 "asm.tab.c" break; - case 191: -#line 402 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = new_expr_op2(LAND, (yyvsp[-2].expr), (yyvsp[0].expr)); } -#line 2741 "asm.tab.c" /* yacc.c:1646 */ + case 195: /* lexpr: lexpr LAND lexpr */ +#line 410 "asm.y" + { (yyval.expr) = new_expr_op2(LAND, (yyvsp[-2].expr), (yyvsp[0].expr)); } +#line 2641 "asm.tab.c" break; - case 192: -#line 403 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = new_expr_op1(LNOT, (yyvsp[0].expr)); } -#line 2747 "asm.tab.c" /* yacc.c:1646 */ + case 196: /* lexpr: LNOT lexpr */ +#line 411 "asm.y" + { (yyval.expr) = new_expr_op1(LNOT, (yyvsp[0].expr)); } +#line 2647 "asm.tab.c" break; - case 193: -#line 404 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = (yyvsp[-1].expr); } -#line 2753 "asm.tab.c" /* yacc.c:1646 */ + case 197: /* lexpr: LPAREN lexpr RPAREN */ +#line 412 "asm.y" + { (yyval.expr) = (yyvsp[-1].expr); } +#line 2653 "asm.tab.c" break; - case 194: -#line 405 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = new_expr_op2(LT, (yyvsp[-2].expr), (yyvsp[0].expr)); } -#line 2759 "asm.tab.c" /* yacc.c:1646 */ + case 198: /* lexpr: expr LT expr */ +#line 413 "asm.y" + { (yyval.expr) = new_expr_op2(LT, (yyvsp[-2].expr), (yyvsp[0].expr)); } +#line 2659 "asm.tab.c" break; - case 195: -#line 406 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = new_expr_op2(GT, (yyvsp[-2].expr), (yyvsp[0].expr)); } -#line 2765 "asm.tab.c" /* yacc.c:1646 */ + case 199: /* lexpr: expr GT expr */ +#line 414 "asm.y" + { (yyval.expr) = new_expr_op2(GT, (yyvsp[-2].expr), (yyvsp[0].expr)); } +#line 2665 "asm.tab.c" break; - case 196: -#line 407 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = new_expr_op2(EQ, (yyvsp[-2].expr), (yyvsp[0].expr)); } -#line 2771 "asm.tab.c" /* yacc.c:1646 */ + case 200: /* lexpr: expr EQ expr */ +#line 415 "asm.y" + { (yyval.expr) = new_expr_op2(EQ, (yyvsp[-2].expr), (yyvsp[0].expr)); } +#line 2671 "asm.tab.c" break; - case 197: -#line 408 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = new_expr_op2(NEQ, (yyvsp[-2].expr), (yyvsp[0].expr)); } -#line 2777 "asm.tab.c" /* yacc.c:1646 */ + case 201: /* lexpr: expr NEQ expr */ +#line 416 "asm.y" + { (yyval.expr) = new_expr_op2(NEQ, (yyvsp[-2].expr), (yyvsp[0].expr)); } +#line 2677 "asm.tab.c" break; - case 198: -#line 410 "asm.y" /* yacc.c:1646 */ - { (yyval.expr) = new_is_defined((yyvsp[-1].str)); } -#line 2783 "asm.tab.c" /* yacc.c:1646 */ + case 202: /* lexpr: DEFINED LPAREN SYMBOL RPAREN */ +#line 418 "asm.y" + { (yyval.expr) = new_is_defined((yyvsp[-1].str)); } +#line 2683 "asm.tab.c" break; -#line 2787 "asm.tab.c" /* yacc.c:1646 */ +#line 2687 "asm.tab.c" + default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -2797,25 +2698,23 @@ yyparse (void) 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 ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; - YY_STACK_PRINT (yyss, yyssp); *++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. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; + { + 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; @@ -2826,50 +2725,14 @@ yyparse (void) yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ - yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); - + yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar); /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; -#if ! YYERROR_VERBOSE yyerror (YY_("syntax error")); -#else -# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ - yyssp, yytoken) - { - char const *yymsgp = YY_("syntax error"); - int yysyntax_error_status; - yysyntax_error_status = YYSYNTAX_ERROR; - if (yysyntax_error_status == 0) - yymsgp = yymsg; - else if (yysyntax_error_status == 1) - { - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); - if (!yymsg) - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - yysyntax_error_status = 2; - } - else - { - yysyntax_error_status = YYSYNTAX_ERROR; - yymsgp = yymsg; - } - } - yyerror (yymsgp); - if (yysyntax_error_status == 2) - goto yyexhaustedlab; - } -# undef YYSYNTAX_ERROR -#endif } - - if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an @@ -2898,12 +2761,10 @@ yyparse (void) | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; + /* Pacify compilers when the user code never invokes YYERROR and the + label yyerrorlab therefore never appears in user code. */ + if (0) + YYERROR; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ @@ -2920,13 +2781,14 @@ yyparse (void) 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 += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + yyn += YYSYMBOL_YYerror; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror) { yyn = yytable[yyn]; if (0 < yyn) @@ -2940,7 +2802,7 @@ yyparse (void) yydestruct ("Error: popping", - yystos[yystate], yyvsp); + YY_ACCESSING_SYMBOL (yystate), yyvsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); @@ -2952,7 +2814,7 @@ yyparse (void) /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp); yystate = yyn; goto yynewstate; @@ -2965,6 +2827,7 @@ yyparse (void) yyresult = 0; goto yyreturn; + /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ @@ -2972,16 +2835,21 @@ yyparse (void) yyresult = 1; goto yyreturn; -#if !defined yyoverflow || YYERROR_VERBOSE + +#if !defined yyoverflow /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: yyerror (YY_("memory exhausted")); yyresult = 2; - /* Fall through. */ + goto yyreturn; #endif + +/*-------------------------------------------------------. +| yyreturn -- parsing is finished, clean up and return. | +`-------------------------------------------------------*/ yyreturn: if (yychar != YYEMPTY) { @@ -2998,20 +2866,18 @@ yyparse (void) while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); + YY_ACCESSING_SYMBOL (+*yyssp), yyvsp); YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif -#if YYERROR_VERBOSE - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); -#endif + return yyresult; } -#line 412 "asm.y" /* yacc.c:1906 */ + +#line 420 "asm.y" void yyerror (const char *s) @@ -3019,9 +2885,9 @@ void yyerror (const char *s) fprintf (stderr, "line %d, %s\n", num_lines, s); } -void asm_set_source(struct membuf *buffer); +void asm_set_source(struct buf *buffer); -int assembleSinglePass(struct membuf *source, struct membuf *dest) +int assembleSinglePass(struct buf *source, struct buf *dest) { int val; diff --git a/src/asm/asm.tab.h b/src/asm/asm.tab.h index 9cfe51b..2c79304 100644 --- a/src/asm/asm.tab.h +++ b/src/asm/asm.tab.h @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 3.7.2. */ /* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 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 @@ -30,6 +31,10 @@ 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_ASM_TAB_H_INCLUDED # define YY_YY_ASM_TAB_H_INCLUDED /* Debug traces. */ @@ -40,120 +45,128 @@ extern int yydebug; #endif -/* Token type. */ +/* Token kinds. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE enum yytokentype { - INCLUDE = 258, - IF = 259, - DEFINED = 260, - MACRO = 261, - MACRO_STRING = 262, - ORG = 263, - ERROR = 264, - ECHO1 = 265, - INCBIN = 266, - INCLEN = 267, - INCWORD = 268, - RES = 269, - WORD = 270, - BYTE = 271, - LDA = 272, - LDX = 273, - LDY = 274, - STA = 275, - STX = 276, - STY = 277, - AND = 278, - ORA = 279, - EOR = 280, - ADC = 281, - SBC = 282, - CMP = 283, - CPX = 284, - CPY = 285, - TSX = 286, - TXS = 287, - PHA = 288, - PLA = 289, - PHP = 290, - PLP = 291, - SEI = 292, - CLI = 293, - NOP = 294, - TYA = 295, - TAY = 296, - TXA = 297, - TAX = 298, - CLC = 299, - SEC = 300, - RTS = 301, - JSR = 302, - JMP = 303, - BEQ = 304, - BNE = 305, - BCC = 306, - BCS = 307, - BPL = 308, - BMI = 309, - BVC = 310, - BVS = 311, - INX = 312, - DEX = 313, - INY = 314, - DEY = 315, - INC = 316, - DEC = 317, - LSR = 318, - ASL = 319, - ROR = 320, - ROL = 321, - BIT = 322, - SYMBOL = 323, - STRING = 324, - LAND = 325, - LOR = 326, - LNOT = 327, - LPAREN = 328, - RPAREN = 329, - COMMA = 330, - COLON = 331, - X = 332, - Y = 333, - HASH = 334, - PLUS = 335, - MINUS = 336, - MULT = 337, - DIV = 338, - MOD = 339, - LT = 340, - GT = 341, - EQ = 342, - NEQ = 343, - ASSIGN = 344, - GUESS = 345, - NUMBER = 346, - vNEG = 347, - LABEL = 348 + YYEMPTY = -2, + YYEOF = 0, /* "end of file" */ + YYerror = 256, /* error */ + YYUNDEF = 257, /* "invalid token" */ + INCLUDE = 258, /* INCLUDE */ + IF = 259, /* IF */ + DEFINED = 260, /* DEFINED */ + MACRO = 261, /* MACRO */ + MACRO_STRING = 262, /* MACRO_STRING */ + ORG = 263, /* ORG */ + ERROR = 264, /* ERROR */ + ECHO1 = 265, /* ECHO1 */ + INCBIN = 266, /* INCBIN */ + INCLEN = 267, /* INCLEN */ + INCWORD = 268, /* INCWORD */ + RES = 269, /* RES */ + WORD = 270, /* WORD */ + BYTE = 271, /* BYTE */ + TEXT = 272, /* TEXT */ + LDA = 273, /* LDA */ + LDX = 274, /* LDX */ + LDY = 275, /* LDY */ + STA = 276, /* STA */ + STX = 277, /* STX */ + STY = 278, /* STY */ + AND = 279, /* AND */ + ORA = 280, /* ORA */ + EOR = 281, /* EOR */ + ADC = 282, /* ADC */ + SBC = 283, /* SBC */ + CMP = 284, /* CMP */ + CPX = 285, /* CPX */ + CPY = 286, /* CPY */ + TSX = 287, /* TSX */ + TXS = 288, /* TXS */ + PHA = 289, /* PHA */ + PLA = 290, /* PLA */ + PHP = 291, /* PHP */ + PLP = 292, /* PLP */ + SEI = 293, /* SEI */ + CLI = 294, /* CLI */ + NOP = 295, /* NOP */ + TYA = 296, /* TYA */ + TAY = 297, /* TAY */ + TXA = 298, /* TXA */ + TAX = 299, /* TAX */ + CLC = 300, /* CLC */ + SEC = 301, /* SEC */ + RTS = 302, /* RTS */ + CLV = 303, /* CLV */ + CLD = 304, /* CLD */ + SED = 305, /* SED */ + JSR = 306, /* JSR */ + JMP = 307, /* JMP */ + BEQ = 308, /* BEQ */ + BNE = 309, /* BNE */ + BCC = 310, /* BCC */ + BCS = 311, /* BCS */ + BPL = 312, /* BPL */ + BMI = 313, /* BMI */ + BVC = 314, /* BVC */ + BVS = 315, /* BVS */ + INX = 316, /* INX */ + DEX = 317, /* DEX */ + INY = 318, /* INY */ + DEY = 319, /* DEY */ + INC = 320, /* INC */ + DEC = 321, /* DEC */ + LSR = 322, /* LSR */ + ASL = 323, /* ASL */ + ROR = 324, /* ROR */ + ROL = 325, /* ROL */ + BIT = 326, /* BIT */ + SYMBOL = 327, /* SYMBOL */ + STRING = 328, /* STRING */ + LAND = 329, /* LAND */ + LOR = 330, /* LOR */ + LNOT = 331, /* LNOT */ + LPAREN = 332, /* LPAREN */ + RPAREN = 333, /* RPAREN */ + COMMA = 334, /* COMMA */ + COLON = 335, /* COLON */ + X = 336, /* X */ + Y = 337, /* Y */ + HASH = 338, /* HASH */ + PLUS = 339, /* PLUS */ + MINUS = 340, /* MINUS */ + MULT = 341, /* MULT */ + DIV = 342, /* DIV */ + MOD = 343, /* MOD */ + LT = 344, /* LT */ + GT = 345, /* GT */ + EQ = 346, /* EQ */ + NEQ = 347, /* NEQ */ + ASSIGN = 348, /* ASSIGN */ + GUESS = 349, /* GUESS */ + NUMBER = 350, /* NUMBER */ + vNEG = 351, /* vNEG */ + LABEL = 352 /* LABEL */ }; + typedef enum yytokentype yytoken_kind_t; #endif /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED - union YYSTYPE { -#line 145 "asm.y" /* yacc.c:1909 */ +#line 149 "asm.y" i32 num; char *str; struct atom *atom; struct expr *expr; -#line 155 "asm.tab.h" /* yacc.c:1909 */ -}; +#line 168 "asm.tab.h" +}; typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 diff --git a/src/asm/asm.y b/src/asm/asm.y index 11b9e27..2dbcb1d 100644 --- a/src/asm/asm.y +++ b/src/asm/asm.y @@ -5,9 +5,9 @@ * In no event will the authors be held liable for any damages arising from * the use of this software. * - * Permission is granted to anyone to use this software, alter it and re- - * distribute it freely for any non-commercial, non-profit purpose subject to - * the following restrictions: + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software in a @@ -19,17 +19,13 @@ * * 3. This notice may not be removed or altered from any distribution. * - * 4. The names of this software and/or it's copyright holders may not be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * */ %{ #include "int.h" #include "parse.h" #include "vec.h" -#include "membuf.h" +#include "buf.h" #include "log.h" #include #define YYERROR_VERBOSE @@ -58,6 +54,7 @@ void yyerror(const char *s); %token RES %token WORD %token BYTE +%token TEXT %token LDA %token LDX @@ -90,6 +87,9 @@ void yyerror(const char *s); %token CLC %token SEC %token RTS +%token CLV +%token CLD +%token SED %token JSR %token JMP @@ -197,7 +197,8 @@ atom: op { $$ = $1; } | RES LPAREN expr COMMA expr RPAREN { $$ = new_res($3, $5); } | WORD LPAREN exprs RPAREN { $$ = exprs_to_word_exprs($3); } | BYTE LPAREN exprs RPAREN { $$ = exprs_to_byte_exprs($3); } | - INCBIN LPAREN STRING RPAREN { + TEXT LPAREN STRING RPAREN { $$ = text_to_byte_exprs($3); } | + INCBIN LPAREN STRING RPAREN { $$ = new_incbin($3, NULL, NULL); } | INCBIN LPAREN STRING COMMA expr RPAREN { $$ = new_incbin($3, $5, NULL); } | @@ -320,7 +321,10 @@ op: TXS { $$ = new_op0(0x9A); } | TAX { $$ = new_op0(0xaa); } | CLC { $$ = new_op0(0x18); } | SEC { $$ = new_op0(0x38); } | - RTS { $$ = new_op0(0x60); }; + RTS { $$ = new_op0(0x60); } | + CLV { $$ = new_op0(0xb8); } | + CLD { $$ = new_op0(0xd8); } | + SED { $$ = new_op0(0xf0); }; op: JSR am_a { $$ = new_op(0x20, ATOM_TYPE_OP_ARG_U16, $2); } | JMP am_a { $$ = new_op(0x4c, ATOM_TYPE_OP_ARG_U16, $2); } | @@ -416,9 +420,9 @@ void yyerror (const char *s) fprintf (stderr, "line %d, %s\n", num_lines, s); } -void asm_set_source(struct membuf *buffer); +void asm_set_source(struct buf *buffer); -int assembleSinglePass(struct membuf *source, struct membuf *dest) +int assembleSinglePass(struct buf *source, struct buf *dest) { int val; diff --git a/src/asm/asm.yy b/src/asm/asm.yy index 65b4b07..6ed5748 100644 --- a/src/asm/asm.yy +++ b/src/asm/asm.yy @@ -5,9 +5,9 @@ * In no event will the authors be held liable for any damages arising from * the use of this software. * - * Permission is granted to anyone to use this software, alter it and re- - * distribute it freely for any non-commercial, non-profit purpose subject to - * the following restrictions: + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software in a @@ -19,10 +19,6 @@ * * 3. This notice may not be removed or altered from any distribution. * - * 4. The names of this software and/or it's copyright holders may not be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * */ /* scanner for a simple assembler */ @@ -30,10 +26,11 @@ #include #include #include "int.h" -#include "membuf.h" +#include "buf.h" #include "parse.h" #include "asm.tab.h" +#define YY_EXIT_FAILURE 1 #define MAX_SRC_BUFFER_DEPTH 10 static YY_BUFFER_STATE src_buffers[MAX_SRC_BUFFER_DEPTH]; static int src_buffer_depth = 0; @@ -83,6 +80,7 @@ struct vec strdupped[1]; \.res return RES; \.word return WORD; \.byte return BYTE; +\.text return TEXT; \" BEGIN(QUOTED_STRING); \; BEGIN(SKIP_LINE); @@ -118,6 +116,9 @@ tax return TAX; clc return CLC; sec return SEC; rts return RTS; +clv return CLV; +cld return CLD; +sed return SED; jsr return JSR; jmp return JMP; @@ -128,7 +129,7 @@ bcs return BCS; bpl return BPL; bmi return BMI; bvc return BVC; -bvs return BCS; +bvs return BVS; inx return INX; dex return DEX; iny return INY; @@ -232,7 +233,7 @@ void scanner_init(void) vec_init(strdupped, sizeof(char*)); } -void asm_src_buffer_push(struct membuf *buffer) +void asm_src_buffer_push(struct buf *buffer) { if(src_buffer_depth == MAX_SRC_BUFFER_DEPTH) { @@ -240,7 +241,7 @@ void asm_src_buffer_push(struct membuf *buffer) exit(1); } src_buffers[src_buffer_depth++] = YY_CURRENT_BUFFER; - yy_scan_bytes(membuf_get(buffer), membuf_memlen(buffer)); + yy_scan_bytes(buf_data(buffer), buf_size(buffer)); } static char *strdupped_get(char *text) diff --git a/src/asm/buf.c b/src/asm/buf.c new file mode 100644 index 0000000..dfa2181 --- /dev/null +++ b/src/asm/buf.c @@ -0,0 +1,403 @@ +/* + * Copyright (c) 2002 2005 Magnus Lind. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not + * be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any distribution. + * + */ + +#include +#include +#include +#include +#include "buf.h" + +void buf_init(struct buf *b) +{ + b->data = NULL; + b->size = 0; + b->capacity = 0; +} + +void buf_free(struct buf *b) +{ + if (b->capacity == -1) + { + fprintf(stderr, "error, can't free a buf view\n"); + exit(1); + } + if (b->data != NULL) + { + free(b->data); + b->data = NULL; + } + b->size = 0; + b->capacity = 0; +} + +void buf_new(struct buf **bp) +{ + struct buf *b; + + b = malloc(sizeof(struct buf)); + if (b == NULL) + { + fprintf(stderr, "error, can't allocate memory\n"); + exit(1); + } + b->data = NULL; + b->size = 0; + b->capacity = 0; + + *bp = b; +} + +void buf_delete(struct buf **bp) +{ + struct buf *b; + + b = *bp; + buf_free(b); + free(b); + b = NULL; + *bp = b; +} + +int buf_size(const struct buf *b) +{ + return b->size; +} + +int buf_capacity(const struct buf *b) +{ + return b->capacity; +} + +void *buf_data(const struct buf *b) +{ + return b->data; +} + +void *buf_reserve(struct buf *b, int new_capacity) +{ + int capacity = b->capacity; + if (capacity == -1) + { + fprintf(stderr, "error, can't reserve capacity for a buf view\n"); + exit(1); + } + if (capacity == 0) + { + capacity = 1; + } + while (capacity < new_capacity) + { + capacity <<= 1; + } + if (capacity > b->capacity) + { + b->data = realloc(b->data, capacity); + if (b->data == NULL) + { + fprintf(stderr, "error, can't reallocate memory\n"); + exit(1); + } + b->capacity = capacity; + } + return b->data; +} + +void buf_clear(struct buf *b) +{ + buf_replace(b, 0, b->size, NULL, 0); +} + +void buf_remove(struct buf *b, int b_off, int b_n) +{ + buf_replace(b, b_off, b_n, NULL, 0); +} + +void *buf_insert(struct buf *b, int b_off, const void *m, int m_n) +{ + return buf_replace(b, b_off, 0, m, m_n); +} + +void *buf_append(struct buf *b, const void *m, int m_n) +{ + return buf_replace(b, b->size, 0, m, m_n); +} + +void buf_append_char(struct buf *b, char c) +{ + buf_replace(b, b->size, 0, &c, 1); +} + +void buf_append_str(struct buf *b, const char *str) +{ + buf_replace(b, b->size, 0, str, strlen(str)); +} + +void *buf_replace(struct buf *b, int b_off, int b_n, const void *m, int m_n) +{ + int new_size; + int rest_off; + int rest_n; + if (b->capacity == -1) + { + fprintf(stderr, "error, can't modify a buf view\n"); + exit(1); + } + if (b_off < 0) + { + b_off += b->size + 1; + } + if (b_n == -1) + { + b_n = b->size - b_off; + } + if(b_off < 0 || b_off > b->size) + { + fprintf(stderr, "error, b_off %d must be within [0 - %d].\n", + b_off, b->size); + exit(1); + } + if(b_n < 0 || b_n > b->size - b_off) + { + fprintf(stderr, + "error, b_n %d must be within [0 and %d] for b_off %d.\n", + b_n, b->size - b_off, b_off); + exit(1); + } + if (m_n < 0) + { + fprintf(stderr, "error, m_n %d must be >= 0.\n", m_n); + exit(1); + } + new_size = b->size - b_n + m_n; + if (new_size > b->capacity) + { + buf_reserve(b, new_size); + } + + rest_off = b_off + b_n; + rest_n = b->size - rest_off; + if (rest_n > 0) + { + memmove((char*)b->data + b_off + m_n, + (char*)b->data + rest_off, rest_n); + } + if (m_n > 0) + { + if (m != NULL) + { + memcpy((char*)b->data + b_off, m, m_n); + } + } + b->size = new_size; + return (char*)b->data + b_off; +} + +static void fskip(FILE *f, int off) +{ + int skip, remaining; + for (remaining = off; remaining > 0; remaining -= skip) + { + char buf[2048]; + if (remaining == 0) + { + /* done */ + break; + } + skip = remaining < 2048 ? remaining : 2048; + if (fread(buf, 1, skip, f) != skip) + { + if (feof(f)) + { + fprintf(stderr, + "Error: EOF occured while skipping %d bytes.\n", + off); + } + else + { + fprintf(stderr, + "Error: Error occured while skipping %d bytes.\n", + off); + } + exit(1); + } + } +} + +void *buf_freplace(struct buf *b, int b_off, int b_n, + FILE *f, int f_off, int f_n) +{ + char buf[2048]; + int read; + int len; + int pos; + + if (f == NULL) + { + fprintf(stderr, "Error: f must not be NULL.\n"); + exit(1); + } + if (b->capacity == -1) + { + fprintf(stderr, "error, can't modify a buf view\n"); + exit(1); + } + if (f_off < 0) + { + int f_size; + if(fseek(f, 0, SEEK_END)) + { + fprintf(stderr, "Error: can't seek to EOF in file.\n"); + exit(1); + } + f_size = ftell(f); + if(fseek(f, 0, SEEK_SET)) + { + fprintf(stderr, "Error: can't seek to start in file.\n"); + exit(1); + } + if (f_off < 0) + { + f_off += f_size + 1; + } + if (f_n == -1) + { + f_n = f_size - f_off; + } + if(f_off < 0 || f_off > f_size) + { + fprintf(stderr, "Error, f_off %d must be within [0 - %d].\n", + f_off, f_size); + exit(1); + } + if (f_n < 0 || f_n > f_size - f_off) + { + fprintf(stderr, + "Error, f_n %d must be within [0 and %d] for f_off %d.\n", + f_n, f_size - f_off, f_off); + exit(1); + } + } + + /* skip to f_off */ + fskip(f, f_off); + if (ferror(f)) + { + /* An error occured. */ + fprintf(stderr, "Error, failed to skip %d bytes in file.\n", f_off); + exit(1); + } + + len = (f_n == -1 || f_n > 2048) ? 2048 : f_n; + pos = b_off; + while ((read = fread(buf, 1, len, f)) == len) + { + buf_replace(b, pos, b_n, buf, read); + b_n = 0; + pos += len; + if (f_n != -1) + { + f_n -= len; + len = f_n > 2048 ? 2048 : f_n; + } + } + if (ferror(f)) + { + /* A read error occured. */ + fprintf(stderr, "Error, failed to read from file.\n"); + } + if (read > 0) + { + buf_replace(b, pos, b_n, buf, read); + } + return (char*)b->data + pos; +} + +const struct buf *buf_view(struct buf *v, + const struct buf *b, int b_off, int b_n) +{ + if (b_off < 0) + { + b_off += b->size + 1; + } + if (b_n == -1) + { + b_n = b->size - b_off; + } + if(b_off < 0 || b_off > b->size) + { + fprintf(stderr, "error, b_off %d must be within [0 - %d].\n", + b_off, b->size); + exit(1); + } + if(b_n < 0 || b_n > b->size - b_off) + { + fprintf(stderr, "error, b_n %d must be within [0 - %d].\n", + b_n, b->size - b_off); + exit(1); + } + if (b->data != NULL) + { + v->data = (char*)b->data + b_off; + } + else + { + v->data = NULL; + } + v->size = b_n; + v->capacity = -1; + + return v; +} + +void buf_printf(struct buf *b, const char *format, ...) +{ + int pos; + int printed; + va_list args; + + if (b->capacity == -1) + { + fprintf(stderr, "error, can't printf to a buf view\n"); + exit(1); + } + + pos = b->size; + + va_start(args, format); + printed = vsnprintf((char*)buf_data(b) + pos, b->capacity - pos, + format, args); + va_end(args); + + if (printed >= b->capacity - pos) + { + va_list args2; + + buf_reserve(b, pos + printed + 1); + + va_start(args2, format); + printed = vsnprintf((char*)buf_data(b) + pos, b->capacity - pos, + format, args2); + va_end(args2); + } + b->size += printed; +} diff --git a/src/asm/buf.h b/src/asm/buf.h new file mode 100644 index 0000000..ba65a5a --- /dev/null +++ b/src/asm/buf.h @@ -0,0 +1,144 @@ +#ifndef ALREADY_INCLUDED_BUF +#define ALREADY_INCLUDED_BUF +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Copyright (c) 2016 Magnus Lind. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not + * be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any distribution. + * + */ +#include +#ifndef __GNUC__ +#define __attribute__(x) /*NOTHING*/ +#endif + +#define STATIC_BUF_INIT {0, 0, 0} + +struct buf { + void *data; + int size; + int capacity; +}; + +void buf_init(struct buf *b); +void buf_free(struct buf *b); + +void buf_new(struct buf **bp); +void buf_delete(struct buf **bp); + +/* Gets the number of bytes currently in the buffer. Won't change the + * buffer content or size. Won't invalidate previously fetched + * internal buffer pointers. */ +int buf_size(const struct buf *b); + +/* Gets the current capacity of the buf. Won't change the buffer + * content or size. Won't invalidate previously fetched internal + * buffer pointers. */ +int buf_capacity(const struct buf *b); + +/* Gets a pointer to the internal buffer. Don't dereferece it beyond + * the size of the buffer. The returned pointer might be invalidated + * by any future modifying operation. Might return NULL for a just + * initiated buffer. */ +void *buf_data(const struct buf *b); + +/* Ensures that at least the requested capacity is available. Won't + * change the buffer content or size but might invalidate previously + * fetched internal buffer pointers. returns a pointer to the internal + * buffer like a buf_data call. */ +void *buf_reserve(struct buf *b, int capacity); + +/* Clears the given buffer. This will set its size to zero. Won't + * invalidate previously fetched internal buffer pointers. */ +void buf_clear(struct buf *b); + +/* Removes b_n number of bytes at offset b_off from the given + * buffer. A value of -1 for b_n is allowed and interpreted as "to the + * end of the buffer". Won't invalidate previously fetched internal + * buffer pointers. Returns a pointer to the internal buffer like a + * buf_data call. */ +void buf_remove(struct buf *b, int b_off, int b_n); + +/* Inserts b_n number of bytes, copied from mem, at offset b_off in + * the given buffer. Negative values for b_off are allowed and + * interpreted as size + b_off + 1. A value of NULL for m is allowed + * and will leave the target buffer area uninitialized. Might + * invalidate previously fetched internal buffer pointers. Returns a + * pointer to the inserted area in the internal buffer. */ +void *buf_insert(struct buf *b, int b_off, const void *m, int m_n); + +/* Appends to the end of the buffer. Returns a pointer to the internal + * buffer like a buf_data call. A value of NULL for m is allowed and + * will leave the target buffer area uninitialized. Might invalidate + * previously fetched internal buffer pointers. Returns a pointer to + * the appended area in the internal buffer.*/ +void *buf_append(struct buf *b, const void *m, int m_n); + +/* Appends a char to the end of the buffer. Might invalidate + * previously fetched internal buffer pointers. */ +void buf_append_char(struct buf *b, char c); + +/* Appends a zero terminated string to the end of the buffer excluding + * the zero terminator. Might invalidate previously fetched internal + * buffer pointers. */ +void buf_append_str(struct buf *b, const char *str); + +/* Performs inserts, deletes, appends, prepends and replacements. + * Negative values for b_off are allowed and interpreted as size + + * b_off + 1. A value of -1 for b_n is allowed and interpreted as size + * - b_off. A value of NULL for m is allowed and will leave the target + * buffer area uninitialized. Might invalidate previously fetched + * internal buffer pointers. Returns a pointer to the replaced area in + * the internal buffer. */ +void *buf_replace(struct buf *b, int b_off, int b_n, const void *m, int m_n); + +/* Performs inserts, deletes, appends, prepends and replacements from + * the given file f. A negative value for b_off is allowed and + * interpreted as size + b_off + 1. A value of -1 for b_n is allowed + * and interpreted as size - b_off. A negative value for f_off is + * allowed and interpreted as the file size + b_off + 1. A value of -1 + * for f_n is allowed and interpreted as the file size - f_off. Might + * invalidate previously fetched internal buffer pointers. Returns a + * pointer to the replaces area in the internal buffer like a buf_data + * call. */ +void *buf_freplace(struct buf *b, int b_off, int b_n, + FILE *f, int f_off, int f_n); + +/** + * Creates a read only view into another buf starting at the given + * offset and being of the given size. The view buf will not take + * ownership of the data and is not to be freed. + */ +const struct buf *buf_view(struct buf *v, + const struct buf *b, int b_off, int b_n); + +/* Prints formatted to the end of the buffer using the vsnsprintf + * function. Will place a zero byte string terminator in the + * position directly following the end of the buffer to make it + * printf-able. */ +void buf_printf(struct buf *b, const char *format, ...) + __attribute__((format(printf,2,3))); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/asm/membuf_io.c b/src/asm/buf_io.c similarity index 68% rename from src/asm/membuf_io.c rename to src/asm/buf_io.c index f4734d7..8155792 100644 --- a/src/asm/membuf_io.c +++ b/src/asm/buf_io.c @@ -5,9 +5,9 @@ * In no event will the authors be held liable for any damages arising from * the use of this software. * - * Permission is granted to anyone to use this software, alter it and re- - * distribute it freely for any non-commercial, non-profit purpose subject to - * the following restrictions: + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software in a @@ -19,18 +19,14 @@ * * 3. This notice may not be removed or altered from any distribution. * - * 4. The names of this software and/or it's copyright holders may not be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * */ -#include "membuf_io.h" +#include "buf_io.h" #include "log.h" #include #include -void read_file(const char *name, struct membuf *buf) +void read_file(const char *name, struct buf *buf) { char block[1024]; FILE *in; @@ -45,14 +41,14 @@ void read_file(const char *name, struct membuf *buf) do { len = fread(block, 1, 1024, in); - membuf_append(buf, block, len); + buf_append(buf, block, len); } while(len == 1024); LOG(LOG_DEBUG, ("read %d bytes from file\n", len)); fclose(in); } -void write_file(const char *name, struct membuf *buf) +void write_file(const char *name, struct buf *buf) { FILE *out; out = fopen(name, "wb"); @@ -61,6 +57,6 @@ void write_file(const char *name, struct membuf *buf) LOG(LOG_ERROR, ("Can't open file \"%s\" for output.\n", name)); exit(1); } - fwrite(membuf_get(buf), 1, membuf_memlen(buf), out); + fwrite(buf_data(buf), 1, buf_size(buf), out); fclose(out); } diff --git a/src/asm/membuf_io.h b/src/asm/buf_io.h similarity index 55% rename from src/asm/membuf_io.h rename to src/asm/buf_io.h index 36b565f..617bd7b 100644 --- a/src/asm/membuf_io.h +++ b/src/asm/buf_io.h @@ -1,5 +1,8 @@ -#ifndef MEMBUF_IO_ALREADY_INCLUDED -#define MEMBUF_IO_ALREADY_INCLUDED +#ifndef BUF_IO_ALREADY_INCLUDED +#define BUF_IO_ALREADY_INCLUDED +#ifdef __cplusplus +extern "C" { +#endif /* * Copyright (c) 2005 Magnus Lind. @@ -8,9 +11,9 @@ * In no event will the authors be held liable for any damages arising from * the use of this software. * - * Permission is granted to anyone to use this software, alter it and re- - * distribute it freely for any non-commercial, non-profit purpose subject to - * the following restrictions: + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software in a @@ -22,14 +25,13 @@ * * 3. This notice may not be removed or altered from any distribution. * - * 4. The names of this software and/or it's copyright holders may not be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * */ -#include "membuf.h" -void read_file(const char *name, struct membuf *buf); -void write_file(const char *name, struct membuf *buf); +#include "buf.h" +void read_file(const char *name, struct buf *buf); +void write_file(const char *name, struct buf *buf); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/asm/callback.h b/src/asm/callback.h index 5c73dbd..22ff2ef 100644 --- a/src/asm/callback.h +++ b/src/asm/callback.h @@ -1,5 +1,8 @@ #ifndef ALREADY_INCLUDED_CALLBACK #define ALREADY_INCLUDED_CALLBACK +#ifdef __cplusplus +extern "C" { +#endif /* * Copyright (c) 2005 Magnus Lind. @@ -8,9 +11,9 @@ * In no event will the authors be held liable for any damages arising from * the use of this software. * - * Permission is granted to anyone to use this software, alter it and re- - * distribute it freely for any non-commercial, non-profit purpose subject to - * the following restrictions: + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software in a @@ -22,10 +25,6 @@ * * 3. This notice may not be removed or altered from any distribution. * - * 4. The names of this software and/or it's copyright holders may not be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * */ #include @@ -34,4 +33,7 @@ typedef int cb_cmp(const void *a, const void *b); typedef void cb_free(void *a); typedef void cb_fprint(FILE *f, const void *a); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/asm/chunkpool.c b/src/asm/chunkpool.c index 3cf9c53..0ead27f 100644 --- a/src/asm/chunkpool.c +++ b/src/asm/chunkpool.c @@ -5,9 +5,9 @@ * In no event will the authors be held liable for any damages arising from * the use of this software. * - * Permission is granted to anyone to use this software, alter it and re- - * distribute it freely for any non-commercial, non-profit purpose subject to - * the following restrictions: + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software in a @@ -19,10 +19,6 @@ * * 3. This notice may not be removed or altered from any distribution. * - * 4. The names of this software and/or it's copyright holders may not be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * */ #include "chunkpool.h" @@ -38,6 +34,7 @@ chunkpool_init(struct chunkpool *ctx, int item_size) ctx->item_pos = ctx->item_end; ctx->current_chunk = NULL; vec_init(&ctx->used_chunks, sizeof(void*)); + ctx->alloc_count = 0; } static void chunk_free(void *chunks, int item_pos, int item_size, cb_free *f) @@ -96,6 +93,8 @@ chunkpool_malloc(struct chunkpool *ctx) { LOG(LOG_ERROR, ("out of memory error in file %s, line %d\n", __FILE__, __LINE__)); + LOG(LOG_ERROR, ("alloced %d items of size %d\n", + ctx->alloc_count, ctx->item_size)); exit(1); } vec_push(&ctx->used_chunks, &ctx->current_chunk); @@ -104,6 +103,7 @@ chunkpool_malloc(struct chunkpool *ctx) } p = (char*)ctx->current_chunk + ctx->item_pos; ctx->item_pos += ctx->item_size; + ++ctx->alloc_count; return p; } diff --git a/src/asm/chunkpool.h b/src/asm/chunkpool.h index 2f864ba..c4eb6c9 100644 --- a/src/asm/chunkpool.h +++ b/src/asm/chunkpool.h @@ -1,5 +1,8 @@ #ifndef ALREADY_INCLUDED_CHUNKPOOL #define ALREADY_INCLUDED_CHUNKPOOL +#ifdef __cplusplus +extern "C" { +#endif /* * Copyright (c) 2003 - 2005, 2015 Magnus Lind. @@ -8,9 +11,9 @@ * In no event will the authors be held liable for any damages arising from * the use of this software. * - * Permission is granted to anyone to use this software, alter it and re- - * distribute it freely for any non-commercial, non-profit purpose subject to - * the following restrictions: + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software in a @@ -22,10 +25,6 @@ * * 3. This notice may not be removed or altered from any distribution. * - * 4. The names of this software and/or it's copyright holders may not be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * */ #include "callback.h" @@ -37,6 +36,7 @@ struct chunkpool { int item_end; void *current_chunk; struct vec used_chunks; + int alloc_count; }; void @@ -54,4 +54,7 @@ chunkpool_malloc(struct chunkpool *ctx); void * chunkpool_calloc(struct chunkpool *ctx); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/asm/expr.c b/src/asm/expr.c index d6ed757..d8b465e 100644 --- a/src/asm/expr.c +++ b/src/asm/expr.c @@ -5,9 +5,9 @@ * In no event will the authors be held liable for any damages arising from * the use of this software. * - * Permission is granted to anyone to use this software, alter it and re- - * distribute it freely for any non-commercial, non-profit purpose subject to - * the following restrictions: + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software in a @@ -19,10 +19,6 @@ * * 3. This notice may not be removed or altered from any distribution. * - * 4. The names of this software and/or it's copyright holders may not be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * */ #include "expr.h" @@ -31,16 +27,16 @@ #include -static struct chunkpool s_expr_pool[1]; +static struct chunkpool s_expr_pool; void expr_init() { - chunkpool_init(s_expr_pool, sizeof(struct expr)); + chunkpool_init(&s_expr_pool, sizeof(struct expr)); } void expr_free() { - chunkpool_free(s_expr_pool); + chunkpool_free(&s_expr_pool); } void expr_dump(int level, struct expr *e) @@ -79,7 +75,7 @@ struct expr *new_expr_op1(i16 op, struct expr *arg) exit(1); } - val = chunkpool_malloc(s_expr_pool); + val = chunkpool_malloc(&s_expr_pool); val->expr_op = op; val->type.arg1 = arg; @@ -103,7 +99,7 @@ struct expr *new_expr_op2(i16 op, struct expr *arg1, struct expr *arg2) exit(1); } - val = chunkpool_malloc(s_expr_pool); + val = chunkpool_malloc(&s_expr_pool); val->expr_op = op; val->type.arg1 = arg1; val->expr_arg2 = arg2; @@ -117,7 +113,7 @@ struct expr *new_expr_symref(const char *symbol) { struct expr *val; - val = chunkpool_malloc(s_expr_pool); + val = chunkpool_malloc(&s_expr_pool); val->expr_op = SYMBOL; val->type.symref = symbol; @@ -132,7 +128,7 @@ struct expr *new_expr_number(i32 number) LOG(LOG_DEBUG, ("creating new number %d\n", number)); - val = chunkpool_malloc(s_expr_pool); + val = chunkpool_malloc(&s_expr_pool); val->expr_op = NUMBER; val->type.number = number; diff --git a/src/asm/expr.h b/src/asm/expr.h index 258b358..0def7c2 100644 --- a/src/asm/expr.h +++ b/src/asm/expr.h @@ -1,5 +1,8 @@ #ifndef ALREADY_INCLUDED_EXPR #define ALREADY_INCLUDED_EXPR +#ifdef __cplusplus +extern "C" { +#endif /* * Copyright (c) 2005 Magnus Lind. @@ -8,9 +11,9 @@ * In no event will the authors be held liable for any damages arising from * the use of this software. * - * Permission is granted to anyone to use this software, alter it and re- - * distribute it freely for any non-commercial, non-profit purpose subject to - * the following restrictions: + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software in a @@ -22,10 +25,6 @@ * * 3. This notice may not be removed or altered from any distribution. * - * 4. The names of this software and/or it's copyright holders may not be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * */ #include "int.h" @@ -54,4 +53,7 @@ struct expr *new_expr_symref(const char *symbol); struct expr *new_expr_number(i32 number); void expr_dump(int level, struct expr *e); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/asm/int.h b/src/asm/int.h index 5b6a7c8..5a06aea 100644 --- a/src/asm/int.h +++ b/src/asm/int.h @@ -1,5 +1,8 @@ #ifndef INCLUDED_INT #define INCLUDED_INT +#ifdef __cplusplus +extern "C" { +#endif /* * Copyright (c) 2005 Magnus Lind. @@ -8,9 +11,9 @@ * In no event will the authors be held liable for any damages arising from * the use of this software. * - * Permission is granted to anyone to use this software, alter it and re- - * distribute it freely for any non-commercial, non-profit purpose subject to - * the following restrictions: + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software in a @@ -22,10 +25,6 @@ * * 3. This notice may not be removed or altered from any distribution. * - * 4. The names of this software and/or it's copyright holders may not be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * */ typedef signed char i8; @@ -36,4 +35,7 @@ typedef unsigned char u8; typedef unsigned short int u16; typedef unsigned int u32; +#ifdef __cplusplus +} +#endif #endif diff --git a/src/asm/lex.yy.c b/src/asm/lex.yy.c index bac04e6..269de11 100644 --- a/src/asm/lex.yy.c +++ b/src/asm/lex.yy.c @@ -354,8 +354,8 @@ static void yynoreturn yy_fatal_error ( const char* msg ); (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; -#define YY_NUM_RULES 115 -#define YY_END_OF_BUFFER 116 +#define YY_NUM_RULES 119 +#define YY_END_OF_BUFFER 120 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -363,36 +363,37 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static const flex_int16_t yy_accept[260] = +static const flex_int16_t yy_accept[267] = { 0, - 0, 0, 0, 0, 0, 0, 111, 111, 0, 0, - 0, 0, 116, 97, 96, 95, 97, 76, 17, 83, - 97, 88, 97, 79, 80, 86, 84, 81, 85, 97, - 87, 70, 82, 18, 72, 89, 73, 97, 94, 94, - 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, - 94, 94, 94, 91, 92, 97, 103, 102, 103, 103, - 110, 109, 110, 110, 111, 112, 114, 113, 114, 106, - 105, 95, 75, 71, 77, 0, 0, 0, 0, 0, - 0, 0, 0, 70, 74, 90, 94, 93, 94, 94, - 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, - - 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, - 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, - 94, 78, 102, 0, 0, 109, 0, 0, 111, 113, - 106, 105, 0, 0, 0, 0, 0, 0, 0, 1, - 0, 0, 0, 0, 0, 28, 25, 66, 53, 54, - 51, 69, 56, 52, 55, 57, 58, 46, 40, 30, - 31, 32, 64, 60, 62, 27, 63, 59, 61, 50, - 49, 19, 20, 21, 65, 41, 26, 35, 37, 36, - 38, 68, 67, 48, 29, 47, 39, 22, 23, 24, - 45, 43, 33, 44, 34, 42, 0, 0, 98, 0, - - 107, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 8, 14, 0, 0, 0, 0, 0, 0, 16, - 0, 10, 2, 3, 0, 0, 0, 0, 0, 0, - 15, 99, 100, 0, 0, 0, 0, 4, 9, 0, - 0, 0, 0, 6, 101, 108, 0, 0, 11, 12, - 0, 0, 0, 7, 5, 13, 0, 104, 0 + 0, 0, 0, 0, 0, 0, 115, 115, 0, 0, + 0, 0, 120, 101, 100, 99, 101, 80, 18, 87, + 101, 92, 101, 83, 84, 90, 88, 85, 89, 101, + 91, 74, 86, 19, 76, 93, 77, 101, 98, 98, + 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, + 98, 98, 98, 95, 96, 101, 107, 106, 107, 107, + 114, 113, 114, 114, 115, 116, 118, 117, 118, 110, + 109, 99, 79, 75, 81, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 74, 78, 94, 98, 97, 98, + 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, + + 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, + 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, + 98, 98, 82, 106, 0, 0, 113, 0, 0, 115, + 117, 110, 109, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 29, 26, 70, + 57, 58, 55, 73, 60, 56, 59, 61, 62, 47, + 51, 41, 50, 31, 32, 33, 68, 64, 66, 28, + 67, 63, 65, 54, 53, 20, 21, 22, 69, 42, + 27, 36, 38, 37, 39, 72, 71, 49, 30, 48, + 52, 40, 23, 24, 25, 46, 44, 34, 45, 35, + + 43, 0, 0, 102, 0, 111, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 8, 14, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 10, 2, 3, + 0, 0, 0, 0, 0, 0, 17, 15, 103, 104, + 0, 0, 0, 0, 4, 9, 0, 0, 0, 0, + 6, 105, 112, 0, 0, 11, 12, 0, 0, 0, + 7, 5, 13, 0, 108, 0 } ; static const YY_CHAR yy_ec[256] = @@ -439,73 +440,75 @@ static const YY_CHAR yy_meta[77] = 5, 5, 5, 5, 5, 1 } ; -static const flex_int16_t yy_base[269] = +static const flex_int16_t yy_base[276] = { 0, - 0, 0, 74, 76, 78, 80, 584, 583, 82, 84, - 571, 570, 586, 591, 591, 591, 582, 561, 591, 591, - 0, 591, 573, 591, 591, 591, 591, 591, 591, 71, - 591, 563, 591, 591, 591, 558, 591, 557, 74, 125, - 84, 72, 70, 559, 69, 79, 129, 76, 131, 134, - 92, 150, 166, 558, 557, 500, 591, 591, 572, 122, - 591, 591, 571, 153, 0, 591, 591, 591, 570, 0, - 177, 591, 591, 0, 591, 65, 145, 180, 173, 150, - 122, 170, 171, 553, 591, 591, 551, 591, 201, 202, - 208, 218, 185, 194, 229, 223, 230, 231, 248, 240, - - 241, 245, 254, 260, 257, 258, 287, 284, 264, 291, - 292, 305, 304, 227, 204, 320, 329, 301, 318, 333, - 343, 591, 591, 345, 272, 591, 306, 311, 0, 591, - 0, 553, 325, 320, 329, 340, 353, 359, 340, 591, - 363, 365, 362, 352, 355, 549, 548, 547, 546, 545, - 544, 543, 542, 541, 540, 539, 538, 537, 536, 533, - 527, 497, 495, 494, 492, 489, 488, 486, 484, 482, - 479, 478, 476, 474, 468, 437, 428, 409, 336, 312, - 308, 273, 266, 263, 249, 246, 236, 234, 205, 149, - 148, 141, 140, 110, 100, 87, 366, 372, 591, 376, - - 591, 377, 381, 378, 375, 385, 388, 390, 388, 406, - 387, 591, 591, 396, 403, 406, 405, 407, 407, 591, - 407, 591, 591, 591, 416, 406, 418, 426, 418, 421, - 591, 591, 591, 432, 433, 440, 439, 591, 591, 436, - 437, 448, 437, 591, 591, 591, 453, 455, 591, 591, - 455, 458, 448, 591, 591, 591, 453, 591, 591, 518, - 523, 528, 533, 538, 102, 540, 545, 550 + 0, 0, 74, 76, 78, 80, 601, 600, 82, 84, + 588, 587, 603, 608, 608, 608, 599, 578, 608, 608, + 0, 608, 590, 608, 608, 608, 608, 608, 608, 71, + 608, 580, 608, 608, 608, 575, 608, 574, 74, 125, + 84, 72, 70, 576, 69, 79, 129, 92, 131, 134, + 142, 150, 166, 575, 574, 517, 608, 608, 589, 170, + 608, 608, 588, 171, 0, 608, 608, 608, 587, 0, + 191, 608, 608, 0, 608, 65, 100, 174, 193, 126, + 122, 138, 153, 174, 570, 608, 608, 568, 608, 205, + 214, 209, 224, 203, 217, 229, 228, 235, 236, 247, + + 233, 246, 263, 257, 278, 245, 265, 290, 283, 268, + 298, 303, 315, 311, 302, 329, 346, 310, 338, 294, + 350, 352, 608, 608, 352, 346, 608, 215, 351, 0, + 608, 0, 570, 322, 345, 361, 362, 363, 367, 356, + 608, 377, 381, 378, 373, 371, 382, 566, 565, 564, + 563, 562, 561, 560, 559, 558, 557, 556, 553, 547, + 517, 516, 514, 512, 511, 510, 507, 505, 504, 501, + 499, 495, 488, 477, 471, 460, 391, 378, 373, 343, + 327, 325, 295, 284, 272, 262, 253, 241, 240, 231, + 202, 199, 156, 155, 149, 141, 140, 117, 100, 87, + + 86, 393, 397, 608, 399, 608, 400, 400, 399, 398, + 403, 409, 406, 403, 421, 403, 608, 608, 402, 412, + 413, 419, 417, 427, 419, 608, 425, 608, 608, 608, + 442, 433, 444, 449, 441, 444, 608, 608, 608, 608, + 454, 455, 462, 460, 608, 608, 453, 454, 467, 455, + 608, 608, 608, 472, 473, 608, 608, 473, 478, 467, + 608, 608, 608, 473, 608, 608, 538, 543, 548, 553, + 558, 92, 560, 565, 570 } ; -static const flex_int16_t yy_def[269] = +static const flex_int16_t yy_def[276] = { 0, - 259, 1, 260, 260, 261, 261, 262, 262, 263, 263, - 264, 264, 259, 259, 259, 259, 259, 259, 259, 259, - 265, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 259, 259, 259, 259, 259, 259, 259, 266, 266, + 266, 1, 267, 267, 268, 268, 269, 269, 270, 270, + 271, 271, 266, 266, 266, 266, 266, 266, 266, 266, + 272, 266, 266, 266, 266, 266, 266, 266, 266, 266, + 266, 266, 266, 266, 266, 266, 266, 266, 273, 273, + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 266, 266, 266, 266, 266, + 266, 266, 266, 266, 274, 266, 266, 266, 266, 275, + 266, 266, 266, 272, 266, 266, 266, 266, 266, 266, + 266, 266, 266, 266, 266, 266, 266, 273, 266, 273, + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 266, 266, 266, 266, 266, 266, 266, 274, + 266, 275, 266, 266, 266, 266, 266, 266, 266, 266, + 266, 266, 266, 266, 266, 266, 266, 273, 273, 273, + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + + 273, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - 266, 266, 266, 266, 266, 259, 259, 259, 259, 259, - 259, 259, 259, 259, 267, 259, 259, 259, 259, 268, - 259, 259, 259, 265, 259, 259, 259, 259, 259, 259, - 259, 259, 259, 259, 259, 259, 266, 259, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - - 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - 266, 259, 259, 259, 259, 259, 259, 259, 267, 259, - 268, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 259, 259, 259, 259, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, - 266, 266, 266, 266, 266, 266, 259, 259, 259, 259, - - 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 259, 259, 259, 259, 259, 259, 259, 0, 259, - 259, 259, 259, 259, 259, 259, 259, 259 + 266, 266, 266, 266, 266, 0, 266, 266, 266, 266, + 266, 266, 266, 266, 266 } ; -static const flex_int16_t yy_nxt[668] = +static const flex_int16_t yy_nxt[685] = { 0, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, @@ -515,74 +518,76 @@ static const flex_int16_t yy_nxt[668] = 14, 39, 40, 41, 42, 43, 44, 44, 44, 45, 46, 47, 44, 48, 49, 50, 44, 51, 52, 53, 44, 44, 44, 54, 55, 56, 58, 59, 58, 59, - 62, 63, 62, 63, 68, 69, 68, 69, 88, 88, - 60, 88, 60, 88, 64, 88, 64, 76, 88, 77, - - 78, 102, 89, 88, 79, 74, 88, 104, 80, 103, - 81, 88, 90, 82, 134, 109, 105, 91, 83, 88, - 99, 100, 106, 76, 101, 77, 78, 102, 89, 88, - 79, 113, 104, 80, 103, 81, 114, 90, 82, 134, - 109, 105, 91, 83, 88, 99, 100, 106, 88, 101, - 88, 124, 92, 88, 93, 125, 113, 107, 94, 88, - 88, 114, 95, 96, 143, 97, 111, 88, 88, 88, - 112, 98, 108, 110, 135, 142, 115, 124, 92, 116, - 93, 125, 127, 107, 94, 88, 128, 95, 96, 143, - 97, 118, 111, 132, 117, 112, 98, 108, 110, 144, - - 135, 142, 115, 140, 88, 116, 133, 136, 127, 119, - 145, 141, 128, 88, 120, 121, 137, 118, 138, 117, - 88, 88, 139, 88, 88, 144, 151, 88, 146, 140, - 147, 185, 133, 136, 119, 145, 141, 88, 152, 120, - 121, 137, 88, 138, 148, 149, 88, 139, 88, 88, - 88, 151, 154, 88, 146, 88, 147, 185, 156, 88, - 88, 150, 153, 152, 88, 88, 155, 88, 88, 148, - 184, 149, 163, 88, 157, 158, 88, 88, 154, 88, - 160, 159, 88, 88, 156, 88, 150, 167, 153, 161, - 162, 155, 88, 164, 165, 184, 166, 170, 163, 157, - - 171, 158, 199, 88, 176, 160, 88, 159, 168, 169, - 88, 88, 172, 167, 161, 162, 177, 178, 164, 165, - 88, 166, 170, 88, 88, 171, 175, 88, 199, 176, - 180, 88, 179, 168, 169, 173, 174, 88, 172, 88, - 182, 201, 177, 178, 200, 181, 183, 186, 88, 191, - 192, 175, 88, 187, 188, 88, 180, 179, 194, 204, - 173, 174, 88, 202, 203, 182, 193, 201, 196, 200, - 181, 183, 205, 186, 191, 192, 195, 189, 190, 187, - 188, 197, 209, 198, 194, 204, 206, 208, 202, 203, - 210, 193, 211, 212, 196, 213, 207, 214, 205, 215, - - 217, 195, 189, 190, 218, 219, 197, 209, 198, 216, - 220, 221, 206, 208, 222, 223, 210, 224, 211, 212, - 213, 207, 214, 225, 231, 215, 217, 226, 88, 230, - 218, 219, 227, 232, 216, 233, 220, 221, 234, 222, - 235, 223, 228, 224, 236, 237, 238, 88, 239, 225, - 231, 240, 226, 229, 230, 241, 88, 243, 227, 232, - 244, 233, 245, 246, 234, 247, 235, 228, 248, 236, - 237, 242, 238, 239, 249, 250, 251, 240, 229, 252, - 253, 241, 243, 254, 255, 244, 256, 88, 245, 246, - 257, 247, 258, 88, 248, 88, 242, 88, 88, 249, - - 250, 88, 251, 88, 252, 88, 253, 88, 88, 254, - 255, 88, 256, 88, 88, 257, 88, 258, 57, 57, + 62, 63, 62, 63, 68, 69, 68, 69, 89, 89, + 60, 89, 60, 89, 64, 74, 64, 76, 89, 77, + + 78, 103, 90, 89, 79, 89, 89, 105, 80, 104, + 81, 89, 91, 82, 135, 83, 106, 92, 84, 89, + 100, 101, 107, 76, 102, 77, 78, 103, 90, 136, + 79, 110, 105, 80, 104, 81, 89, 91, 82, 135, + 83, 106, 92, 84, 89, 100, 101, 107, 89, 102, + 89, 143, 93, 89, 94, 136, 110, 108, 95, 89, + 89, 89, 96, 97, 144, 98, 112, 145, 89, 89, + 113, 99, 109, 111, 89, 89, 116, 143, 93, 117, + 94, 114, 146, 108, 95, 89, 115, 96, 97, 144, + 98, 119, 112, 145, 118, 113, 99, 109, 111, 125, + + 128, 137, 116, 126, 129, 117, 114, 133, 146, 120, + 138, 115, 139, 147, 121, 122, 140, 119, 89, 118, + 134, 89, 89, 141, 89, 125, 128, 137, 89, 126, + 129, 142, 148, 89, 120, 138, 89, 139, 147, 121, + 122, 140, 149, 89, 153, 150, 134, 89, 89, 141, + 89, 151, 89, 205, 89, 89, 142, 156, 148, 89, + 89, 154, 155, 158, 89, 89, 89, 152, 149, 153, + 150, 157, 89, 164, 160, 161, 89, 151, 205, 159, + 162, 89, 89, 156, 89, 174, 154, 89, 155, 158, + 167, 89, 152, 163, 165, 166, 157, 89, 164, 170, + + 160, 161, 89, 89, 159, 171, 162, 175, 180, 89, + 174, 168, 169, 89, 89, 176, 167, 89, 163, 165, + 166, 89, 89, 181, 170, 179, 172, 173, 182, 89, + 89, 171, 175, 180, 89, 193, 168, 169, 177, 178, + 184, 176, 198, 183, 89, 188, 89, 186, 89, 181, + 179, 172, 173, 187, 182, 185, 189, 89, 194, 195, + 207, 193, 89, 177, 178, 89, 184, 198, 183, 89, + 188, 89, 186, 190, 191, 199, 204, 201, 187, 192, + 185, 206, 189, 194, 195, 207, 196, 197, 202, 208, + 203, 209, 89, 200, 210, 213, 211, 89, 214, 190, + + 191, 199, 204, 201, 215, 192, 212, 206, 216, 217, + 89, 196, 197, 202, 208, 203, 218, 209, 200, 219, + 210, 213, 211, 214, 220, 223, 221, 224, 225, 226, + 215, 212, 227, 229, 216, 217, 222, 228, 230, 231, + 238, 218, 232, 239, 219, 236, 237, 233, 240, 220, + 241, 223, 221, 224, 225, 226, 243, 234, 227, 229, + 242, 222, 228, 244, 230, 231, 238, 232, 235, 239, + 236, 237, 245, 233, 240, 246, 241, 247, 248, 89, + 250, 243, 234, 251, 252, 253, 242, 254, 244, 255, + 89, 256, 257, 235, 249, 258, 89, 259, 245, 260, + + 246, 261, 262, 247, 248, 250, 263, 89, 251, 264, + 252, 253, 265, 254, 89, 255, 256, 257, 89, 249, + 89, 258, 259, 89, 89, 260, 89, 261, 262, 89, + 89, 89, 263, 89, 264, 89, 89, 265, 57, 57, 57, 57, 57, 61, 61, 61, 61, 61, 65, 65, 65, 65, 65, 67, 67, 67, 67, 67, 70, 70, - 70, 70, 70, 87, 87, 129, 88, 129, 129, 129, - 131, 131, 88, 131, 131, 88, 88, 88, 88, 88, - 88, 88, 88, 88, 88, 88, 88, 88, 88, 132, - 88, 84, 130, 126, 123, 122, 88, 88, 88, 86, - 85, 84, 75, 73, 72, 259, 71, 71, 66, 66, - 13, 259, 259, 259, 259, 259, 259, 259, 259, 259, - - 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 259, 259, 259, 259, 259, 259 + 70, 70, 70, 88, 88, 130, 89, 130, 130, 130, + 132, 132, 89, 132, 132, 89, 89, 89, 89, 89, + 89, 89, 89, 89, 89, 89, 133, 89, 85, 131, + 127, 124, 123, 89, 89, 89, 87, 86, 85, 75, + + 73, 72, 266, 71, 71, 66, 66, 13, 266, 266, + 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, + 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, + 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, + 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, + 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, + 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, + 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, + 266, 266, 266, 266 } ; -static const flex_int16_t yy_chk[668] = +static const flex_int16_t yy_chk[685] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -593,70 +598,72 @@ static const flex_int16_t yy_chk[668] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 4, 4, 5, 5, 6, 6, 9, 9, 10, 10, 45, 43, - 3, 42, 4, 39, 5, 48, 6, 30, 46, 30, - - 30, 42, 39, 41, 30, 265, 196, 45, 30, 43, - 30, 51, 39, 30, 76, 48, 46, 39, 30, 195, - 41, 41, 46, 30, 41, 30, 30, 42, 39, 194, - 30, 51, 45, 30, 43, 30, 51, 39, 30, 76, - 48, 46, 39, 30, 40, 41, 41, 46, 47, 41, - 49, 60, 40, 50, 40, 60, 51, 47, 40, 193, - 192, 51, 40, 40, 81, 40, 50, 191, 190, 52, - 50, 40, 47, 49, 77, 80, 52, 60, 40, 52, - 40, 60, 64, 47, 40, 53, 64, 40, 40, 81, - 40, 53, 50, 71, 52, 50, 40, 47, 49, 82, - - 77, 80, 52, 79, 93, 52, 71, 78, 64, 53, - 83, 79, 64, 94, 53, 53, 78, 53, 78, 52, - 89, 90, 78, 115, 189, 82, 93, 91, 89, 79, - 90, 115, 71, 78, 53, 83, 79, 92, 94, 53, - 53, 78, 96, 78, 91, 92, 114, 78, 95, 97, - 98, 93, 96, 188, 89, 187, 90, 115, 98, 100, - 101, 92, 95, 94, 102, 186, 97, 99, 185, 91, - 114, 92, 102, 103, 98, 99, 105, 106, 96, 104, - 100, 99, 184, 109, 98, 183, 92, 104, 95, 101, - 101, 97, 182, 102, 102, 114, 103, 105, 102, 98, - - 106, 99, 125, 108, 109, 100, 107, 99, 104, 104, - 110, 111, 107, 104, 101, 101, 110, 111, 102, 102, - 118, 103, 105, 113, 112, 106, 108, 181, 125, 109, - 112, 180, 111, 104, 104, 107, 107, 119, 107, 116, - 113, 128, 110, 111, 127, 112, 113, 116, 117, 118, - 118, 108, 120, 116, 117, 179, 112, 111, 120, 135, - 107, 107, 121, 133, 134, 113, 119, 128, 121, 127, - 112, 113, 136, 116, 118, 118, 120, 117, 117, 116, - 117, 124, 139, 124, 120, 135, 137, 138, 133, 134, - 141, 119, 142, 143, 121, 144, 137, 145, 136, 197, - - 198, 120, 117, 117, 200, 202, 124, 139, 124, 197, - 203, 204, 137, 138, 205, 206, 141, 207, 142, 143, - 144, 137, 145, 208, 214, 197, 198, 209, 178, 211, - 200, 202, 210, 215, 197, 216, 203, 204, 217, 205, - 218, 206, 210, 207, 219, 221, 225, 177, 226, 208, - 214, 227, 209, 210, 211, 228, 176, 229, 210, 215, - 230, 216, 234, 235, 217, 236, 218, 210, 237, 219, - 221, 228, 225, 226, 240, 241, 242, 227, 210, 243, - 247, 228, 229, 248, 251, 230, 252, 175, 234, 235, - 253, 236, 257, 174, 237, 173, 228, 172, 171, 240, - - 241, 170, 242, 169, 243, 168, 247, 167, 166, 248, - 251, 165, 252, 164, 163, 253, 162, 257, 260, 260, - 260, 260, 260, 261, 261, 261, 261, 261, 262, 262, - 262, 262, 262, 263, 263, 263, 263, 263, 264, 264, - 264, 264, 264, 266, 266, 267, 161, 267, 267, 267, - 268, 268, 160, 268, 268, 159, 158, 157, 156, 155, - 154, 153, 152, 151, 150, 149, 148, 147, 146, 132, - 87, 84, 69, 63, 59, 56, 55, 54, 44, 38, - 36, 32, 23, 18, 17, 13, 12, 11, 8, 7, - 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - - 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 259, 259, 259, 259, 259, 259 + 3, 42, 4, 39, 5, 272, 6, 30, 46, 30, + + 30, 42, 39, 41, 30, 201, 200, 45, 30, 43, + 30, 48, 39, 30, 76, 30, 46, 39, 30, 199, + 41, 41, 46, 30, 41, 30, 30, 42, 39, 77, + 30, 48, 45, 30, 43, 30, 198, 39, 30, 76, + 30, 46, 39, 30, 40, 41, 41, 46, 47, 41, + 49, 80, 40, 50, 40, 77, 48, 47, 40, 197, + 196, 51, 40, 40, 81, 40, 50, 82, 195, 52, + 50, 40, 47, 49, 194, 193, 52, 80, 40, 52, + 40, 51, 83, 47, 40, 53, 51, 40, 40, 81, + 40, 53, 50, 82, 52, 50, 40, 47, 49, 60, + + 64, 78, 52, 60, 64, 52, 51, 71, 83, 53, + 78, 51, 78, 84, 53, 53, 78, 53, 192, 52, + 71, 191, 94, 79, 90, 60, 64, 78, 92, 60, + 64, 79, 90, 91, 53, 78, 95, 78, 84, 53, + 53, 78, 91, 93, 94, 92, 71, 97, 96, 79, + 190, 93, 101, 128, 98, 99, 79, 97, 90, 189, + 188, 95, 96, 99, 106, 102, 100, 93, 91, 94, + 92, 98, 187, 101, 100, 100, 104, 93, 128, 99, + 100, 186, 103, 97, 107, 106, 95, 110, 96, 99, + 103, 185, 93, 100, 102, 102, 98, 105, 101, 104, + + 100, 100, 109, 184, 99, 105, 100, 107, 110, 108, + 106, 103, 103, 120, 183, 108, 103, 111, 100, 102, + 102, 115, 112, 111, 104, 109, 105, 105, 112, 118, + 114, 105, 107, 110, 113, 118, 103, 103, 108, 108, + 113, 108, 120, 112, 182, 115, 181, 114, 116, 111, + 109, 105, 105, 114, 112, 113, 116, 119, 118, 118, + 134, 118, 180, 108, 108, 117, 113, 120, 112, 121, + 115, 122, 114, 117, 117, 121, 126, 122, 114, 117, + 113, 129, 116, 118, 118, 134, 119, 119, 125, 135, + 125, 136, 179, 121, 137, 139, 138, 178, 140, 117, + + 117, 121, 126, 122, 142, 117, 138, 129, 143, 144, + 177, 119, 119, 125, 135, 125, 145, 136, 121, 146, + 137, 139, 138, 140, 147, 203, 202, 205, 207, 208, + 142, 138, 209, 211, 143, 144, 202, 210, 212, 213, + 220, 145, 214, 221, 146, 216, 219, 215, 222, 147, + 223, 203, 202, 205, 207, 208, 225, 215, 209, 211, + 224, 202, 210, 227, 212, 213, 220, 214, 215, 221, + 216, 219, 231, 215, 222, 232, 223, 233, 234, 176, + 235, 225, 215, 236, 241, 242, 224, 243, 227, 244, + 175, 247, 248, 215, 234, 249, 174, 250, 231, 254, + + 232, 255, 258, 233, 234, 235, 259, 173, 236, 260, + 241, 242, 264, 243, 172, 244, 247, 248, 171, 234, + 170, 249, 250, 169, 168, 254, 167, 255, 258, 166, + 165, 164, 259, 163, 260, 162, 161, 264, 267, 267, + 267, 267, 267, 268, 268, 268, 268, 268, 269, 269, + 269, 269, 269, 270, 270, 270, 270, 270, 271, 271, + 271, 271, 271, 273, 273, 274, 160, 274, 274, 274, + 275, 275, 159, 275, 275, 158, 157, 156, 155, 154, + 153, 152, 151, 150, 149, 148, 133, 88, 85, 69, + 63, 59, 56, 55, 54, 44, 38, 36, 32, 23, + + 18, 17, 13, 12, 11, 8, 7, 266, 266, 266, + 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, + 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, + 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, + 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, + 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, + 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, + 266, 266, 266, 266, 266, 266, 266, 266, 266, 266, + 266, 266, 266, 266 } ; static yy_state_type yy_last_accepting_state; @@ -681,9 +688,9 @@ char *yytext; * In no event will the authors be held liable for any damages arising from * the use of this software. * - * Permission is granted to anyone to use this software, alter it and re- - * distribute it freely for any non-commercial, non-profit purpose subject to - * the following restrictions: + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software in a @@ -695,20 +702,17 @@ char *yytext; * * 3. This notice may not be removed or altered from any distribution. * - * 4. The names of this software and/or it's copyright holders may not be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * */ /* scanner for a simple assembler */ #line 30 "asm.yy" #include #include #include "int.h" -#include "membuf.h" +#include "buf.h" #include "parse.h" #include "asm.tab.h" +#define YY_EXIT_FAILURE 1 #define MAX_SRC_BUFFER_DEPTH 10 static YY_BUFFER_STATE src_buffers[MAX_SRC_BUFFER_DEPTH]; static int src_buffer_depth = 0; @@ -723,9 +727,9 @@ int push_state_init = 0; int push_state_macro = 0; struct vec strdupped[1]; -#line 726 "lex.yy.c" +#line 734 "lex.yy.c" -#line 728 "lex.yy.c" +#line 736 "lex.yy.c" #define INITIAL 0 #define SKIP 1 @@ -957,10 +961,10 @@ YY_DECL } { -#line 59 "asm.yy" +#line 60 "asm.yy" -#line 62 "asm.yy" +#line 63 "asm.yy" if(push_state_init) {push_state_init = 0; yy_push_state(INITIAL); } if(push_state_skip) @@ -968,7 +972,7 @@ YY_DECL if(push_state_macro) {push_state_macro = 0; yy_push_state(MACROO); } -#line 971 "lex.yy.c" +#line 979 "lex.yy.c" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -995,13 +999,13 @@ YY_DECL 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 >= 260 ) + if ( yy_current_state >= 267 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } - while ( yy_current_state != 259 ); + while ( yy_current_state != 266 ); yy_cp = (yy_last_accepting_cpos); yy_current_state = (yy_last_accepting_state); @@ -1023,544 +1027,543 @@ YY_DECL case 1: YY_RULE_SETUP -#line 69 "asm.yy" +#line 70 "asm.yy" return IF; YY_BREAK case 2: YY_RULE_SETUP -#line 70 "asm.yy" +#line 71 "asm.yy" BEGIN(SKIP_ALL); YY_BREAK case 3: YY_RULE_SETUP -#line 71 "asm.yy" +#line 72 "asm.yy" BEGIN(SKIP); YY_BREAK case 4: YY_RULE_SETUP -#line 72 "asm.yy" +#line 73 "asm.yy" yy_pop_state(); YY_BREAK case 5: YY_RULE_SETUP -#line 74 "asm.yy" +#line 75 "asm.yy" return INCLUDE; YY_BREAK case 6: YY_RULE_SETUP -#line 75 "asm.yy" +#line 76 "asm.yy" return MACRO; YY_BREAK case 7: YY_RULE_SETUP -#line 77 "asm.yy" +#line 78 "asm.yy" return DEFINED; YY_BREAK case 8: YY_RULE_SETUP -#line 78 "asm.yy" +#line 79 "asm.yy" return ORG; YY_BREAK case 9: YY_RULE_SETUP -#line 79 "asm.yy" +#line 80 "asm.yy" return ERROR; YY_BREAK case 10: YY_RULE_SETUP -#line 80 "asm.yy" +#line 81 "asm.yy" return ECHO1; YY_BREAK case 11: YY_RULE_SETUP -#line 81 "asm.yy" +#line 82 "asm.yy" return INCBIN; YY_BREAK case 12: YY_RULE_SETUP -#line 82 "asm.yy" +#line 83 "asm.yy" return INCLEN; YY_BREAK case 13: YY_RULE_SETUP -#line 83 "asm.yy" +#line 84 "asm.yy" return INCWORD; YY_BREAK case 14: YY_RULE_SETUP -#line 84 "asm.yy" +#line 85 "asm.yy" return RES; YY_BREAK case 15: YY_RULE_SETUP -#line 85 "asm.yy" +#line 86 "asm.yy" return WORD; YY_BREAK case 16: YY_RULE_SETUP -#line 86 "asm.yy" +#line 87 "asm.yy" return BYTE; YY_BREAK case 17: YY_RULE_SETUP #line 88 "asm.yy" -BEGIN(QUOTED_STRING); +return TEXT; YY_BREAK case 18: YY_RULE_SETUP -#line 89 "asm.yy" -BEGIN(SKIP_LINE); +#line 90 "asm.yy" +BEGIN(QUOTED_STRING); YY_BREAK case 19: YY_RULE_SETUP #line 91 "asm.yy" -return LDA; +BEGIN(SKIP_LINE); YY_BREAK case 20: YY_RULE_SETUP -#line 92 "asm.yy" -return LDX; +#line 93 "asm.yy" +return LDA; YY_BREAK case 21: YY_RULE_SETUP -#line 93 "asm.yy" -return LDY; +#line 94 "asm.yy" +return LDX; YY_BREAK case 22: YY_RULE_SETUP -#line 94 "asm.yy" -return STA; +#line 95 "asm.yy" +return LDY; YY_BREAK case 23: YY_RULE_SETUP -#line 95 "asm.yy" -return STX; +#line 96 "asm.yy" +return STA; YY_BREAK case 24: YY_RULE_SETUP -#line 96 "asm.yy" -return STY; +#line 97 "asm.yy" +return STX; YY_BREAK case 25: YY_RULE_SETUP -#line 97 "asm.yy" -return AND; +#line 98 "asm.yy" +return STY; YY_BREAK case 26: YY_RULE_SETUP -#line 98 "asm.yy" -return ORA; +#line 99 "asm.yy" +return AND; YY_BREAK case 27: YY_RULE_SETUP -#line 99 "asm.yy" -return EOR; +#line 100 "asm.yy" +return ORA; YY_BREAK case 28: YY_RULE_SETUP -#line 100 "asm.yy" -return ADC; +#line 101 "asm.yy" +return EOR; YY_BREAK case 29: YY_RULE_SETUP -#line 101 "asm.yy" -return SBC; +#line 102 "asm.yy" +return ADC; YY_BREAK case 30: YY_RULE_SETUP -#line 102 "asm.yy" -return CMP; +#line 103 "asm.yy" +return SBC; YY_BREAK case 31: YY_RULE_SETUP -#line 103 "asm.yy" -return CPX; +#line 104 "asm.yy" +return CMP; YY_BREAK case 32: YY_RULE_SETUP -#line 104 "asm.yy" -return CPY; +#line 105 "asm.yy" +return CPX; YY_BREAK case 33: YY_RULE_SETUP #line 106 "asm.yy" -return TSX; +return CPY; YY_BREAK case 34: YY_RULE_SETUP -#line 107 "asm.yy" -return TXS; +#line 108 "asm.yy" +return TSX; YY_BREAK case 35: YY_RULE_SETUP -#line 108 "asm.yy" -return PHA; +#line 109 "asm.yy" +return TXS; YY_BREAK case 36: YY_RULE_SETUP -#line 109 "asm.yy" -return PLA; +#line 110 "asm.yy" +return PHA; YY_BREAK case 37: YY_RULE_SETUP -#line 110 "asm.yy" -return PHP; +#line 111 "asm.yy" +return PLA; YY_BREAK case 38: YY_RULE_SETUP -#line 111 "asm.yy" -return PLP; +#line 112 "asm.yy" +return PHP; YY_BREAK case 39: YY_RULE_SETUP -#line 112 "asm.yy" -return SEI; +#line 113 "asm.yy" +return PLP; YY_BREAK case 40: YY_RULE_SETUP -#line 113 "asm.yy" -return CLI; +#line 114 "asm.yy" +return SEI; YY_BREAK case 41: YY_RULE_SETUP -#line 114 "asm.yy" -return NOP; +#line 115 "asm.yy" +return CLI; YY_BREAK case 42: YY_RULE_SETUP -#line 115 "asm.yy" -return TYA; +#line 116 "asm.yy" +return NOP; YY_BREAK case 43: YY_RULE_SETUP -#line 116 "asm.yy" -return TAY; +#line 117 "asm.yy" +return TYA; YY_BREAK case 44: YY_RULE_SETUP -#line 117 "asm.yy" -return TXA; +#line 118 "asm.yy" +return TAY; YY_BREAK case 45: YY_RULE_SETUP -#line 118 "asm.yy" -return TAX; +#line 119 "asm.yy" +return TXA; YY_BREAK case 46: YY_RULE_SETUP -#line 119 "asm.yy" -return CLC; +#line 120 "asm.yy" +return TAX; YY_BREAK case 47: YY_RULE_SETUP -#line 120 "asm.yy" -return SEC; +#line 121 "asm.yy" +return CLC; YY_BREAK case 48: YY_RULE_SETUP -#line 121 "asm.yy" -return RTS; +#line 122 "asm.yy" +return SEC; YY_BREAK case 49: YY_RULE_SETUP #line 123 "asm.yy" -return JSR; +return RTS; YY_BREAK case 50: YY_RULE_SETUP #line 124 "asm.yy" -return JMP; +return CLV; YY_BREAK case 51: YY_RULE_SETUP #line 125 "asm.yy" -return BEQ; +return CLD; YY_BREAK case 52: YY_RULE_SETUP #line 126 "asm.yy" -return BNE; +return SED; YY_BREAK case 53: YY_RULE_SETUP -#line 127 "asm.yy" -return BCC; +#line 128 "asm.yy" +return JSR; YY_BREAK case 54: YY_RULE_SETUP -#line 128 "asm.yy" -return BCS; +#line 129 "asm.yy" +return JMP; YY_BREAK case 55: YY_RULE_SETUP -#line 129 "asm.yy" -return BPL; +#line 130 "asm.yy" +return BEQ; YY_BREAK case 56: YY_RULE_SETUP -#line 130 "asm.yy" -return BMI; +#line 131 "asm.yy" +return BNE; YY_BREAK case 57: YY_RULE_SETUP -#line 131 "asm.yy" -return BVC; +#line 132 "asm.yy" +return BCC; YY_BREAK case 58: YY_RULE_SETUP -#line 132 "asm.yy" +#line 133 "asm.yy" return BCS; YY_BREAK case 59: YY_RULE_SETUP -#line 133 "asm.yy" -return INX; +#line 134 "asm.yy" +return BPL; YY_BREAK case 60: YY_RULE_SETUP -#line 134 "asm.yy" -return DEX; +#line 135 "asm.yy" +return BMI; YY_BREAK case 61: YY_RULE_SETUP -#line 135 "asm.yy" -return INY; +#line 136 "asm.yy" +return BVC; YY_BREAK case 62: YY_RULE_SETUP -#line 136 "asm.yy" -return DEY; +#line 137 "asm.yy" +return BVS; YY_BREAK case 63: YY_RULE_SETUP -#line 137 "asm.yy" -return INC; +#line 138 "asm.yy" +return INX; YY_BREAK case 64: YY_RULE_SETUP -#line 138 "asm.yy" -return DEC; +#line 139 "asm.yy" +return DEX; YY_BREAK case 65: YY_RULE_SETUP -#line 139 "asm.yy" -return LSR; +#line 140 "asm.yy" +return INY; YY_BREAK case 66: YY_RULE_SETUP -#line 140 "asm.yy" -return ASL; +#line 141 "asm.yy" +return DEY; YY_BREAK case 67: YY_RULE_SETUP -#line 141 "asm.yy" -return ROR; +#line 142 "asm.yy" +return INC; YY_BREAK case 68: YY_RULE_SETUP -#line 142 "asm.yy" -return ROL; +#line 143 "asm.yy" +return DEC; YY_BREAK case 69: YY_RULE_SETUP -#line 143 "asm.yy" -return BIT; +#line 144 "asm.yy" +return LSR; YY_BREAK case 70: YY_RULE_SETUP #line 145 "asm.yy" -{ yylval.num = atoi(yytext); return NUMBER; } +return ASL; YY_BREAK case 71: YY_RULE_SETUP -#line 147 "asm.yy" -{ yylval.num = strtol(yytext + 1, NULL, 16); return NUMBER; } +#line 146 "asm.yy" +return ROR; YY_BREAK case 72: YY_RULE_SETUP -#line 149 "asm.yy" -return LT; +#line 147 "asm.yy" +return ROL; YY_BREAK case 73: YY_RULE_SETUP -#line 150 "asm.yy" -return GT; +#line 148 "asm.yy" +return BIT; YY_BREAK case 74: YY_RULE_SETUP -#line 151 "asm.yy" -return EQ; +#line 150 "asm.yy" +{ yylval.num = atoi(yytext); return NUMBER; } YY_BREAK case 75: YY_RULE_SETUP #line 152 "asm.yy" -return NEQ; +{ yylval.num = strtol(yytext + 1, NULL, 16); return NUMBER; } YY_BREAK case 76: YY_RULE_SETUP -#line 153 "asm.yy" -return LNOT; +#line 154 "asm.yy" +return LT; YY_BREAK case 77: YY_RULE_SETUP -#line 154 "asm.yy" -return LAND; +#line 155 "asm.yy" +return GT; YY_BREAK case 78: YY_RULE_SETUP -#line 155 "asm.yy" -return LOR; +#line 156 "asm.yy" +return EQ; YY_BREAK case 79: YY_RULE_SETUP #line 157 "asm.yy" -return LPAREN; +return NEQ; YY_BREAK case 80: YY_RULE_SETUP #line 158 "asm.yy" -return RPAREN; +return LNOT; YY_BREAK case 81: YY_RULE_SETUP #line 159 "asm.yy" -return COMMA; +return LAND; YY_BREAK case 82: YY_RULE_SETUP #line 160 "asm.yy" -return COLON; +return LOR; YY_BREAK case 83: YY_RULE_SETUP -#line 161 "asm.yy" -return HASH; +#line 162 "asm.yy" +return LPAREN; YY_BREAK case 84: YY_RULE_SETUP -#line 162 "asm.yy" -return PLUS; +#line 163 "asm.yy" +return RPAREN; YY_BREAK case 85: YY_RULE_SETUP -#line 163 "asm.yy" -return MINUS; +#line 164 "asm.yy" +return COMMA; YY_BREAK case 86: YY_RULE_SETUP -#line 164 "asm.yy" -return MULT; +#line 165 "asm.yy" +return COLON; YY_BREAK case 87: YY_RULE_SETUP -#line 165 "asm.yy" -return DIV; +#line 166 "asm.yy" +return HASH; YY_BREAK case 88: YY_RULE_SETUP -#line 166 "asm.yy" -return MOD; +#line 167 "asm.yy" +return PLUS; YY_BREAK case 89: YY_RULE_SETUP #line 168 "asm.yy" -return ASSIGN; +return MINUS; YY_BREAK case 90: YY_RULE_SETUP #line 169 "asm.yy" -return GUESS; +return MULT; YY_BREAK case 91: YY_RULE_SETUP -#line 171 "asm.yy" -return X; +#line 170 "asm.yy" +return DIV; YY_BREAK case 92: YY_RULE_SETUP -#line 172 "asm.yy" -return Y; +#line 171 "asm.yy" +return MOD; YY_BREAK case 93: -*yy_cp = (yy_hold_char); /* undo effects of setting up yytext */ -(yy_c_buf_p) = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 174 "asm.yy" -{ yylval.str = strdupped_get(yytext); return LABEL; } +#line 173 "asm.yy" +return ASSIGN; YY_BREAK case 94: YY_RULE_SETUP -#line 175 "asm.yy" -{ yylval.str = strdupped_get(yytext); return SYMBOL; } +#line 174 "asm.yy" +return GUESS; YY_BREAK case 95: -/* rule 95 can match eol */ YY_RULE_SETUP -#line 177 "asm.yy" -++num_lines; +#line 176 "asm.yy" +return X; YY_BREAK case 96: YY_RULE_SETUP -#line 179 "asm.yy" -/* eat whitespace */ +#line 177 "asm.yy" +return Y; YY_BREAK case 97: +*yy_cp = (yy_hold_char); /* undo effects of setting up yytext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 181 "asm.yy" -printf("unknown character found %s\n", yytext); +#line 179 "asm.yy" +{ yylval.str = strdupped_get(yytext); return LABEL; } YY_BREAK case 98: YY_RULE_SETUP -#line 183 "asm.yy" -yy_push_state(SKIP_ALL); +#line 180 "asm.yy" +{ yylval.str = strdupped_get(yytext); return SYMBOL; } YY_BREAK case 99: +/* rule 99 can match eol */ YY_RULE_SETUP -#line 184 "asm.yy" -{ yy_pop_state(); return IF; } +#line 182 "asm.yy" +++num_lines; YY_BREAK case 100: YY_RULE_SETUP -#line 185 "asm.yy" -BEGIN(INITIAL); +#line 184 "asm.yy" +/* eat whitespace */ YY_BREAK case 101: YY_RULE_SETUP #line 186 "asm.yy" -yy_pop_state(); +printf("unknown character found %s\n", yytext); YY_BREAK case 102: -/* rule 102 can match eol */ YY_RULE_SETUP -#line 187 "asm.yy" -++num_lines; +#line 188 "asm.yy" +yy_push_state(SKIP_ALL); YY_BREAK case 103: YY_RULE_SETUP -#line 188 "asm.yy" - +#line 189 "asm.yy" +{ yy_pop_state(); return IF; } YY_BREAK case 104: YY_RULE_SETUP #line 190 "asm.yy" -yy_pop_state(); +BEGIN(INITIAL); YY_BREAK case 105: YY_RULE_SETUP #line 191 "asm.yy" -{ yylval.str = yytext; return MACRO_STRING; } +yy_pop_state(); YY_BREAK case 106: /* rule 106 can match eol */ YY_RULE_SETUP #line 192 "asm.yy" -{ yylval.str = yytext; return MACRO_STRING; } +++num_lines; YY_BREAK case 107: YY_RULE_SETUP -#line 194 "asm.yy" -yy_push_state(SKIP_ALL); +#line 193 "asm.yy" + YY_BREAK case 108: YY_RULE_SETUP @@ -1568,20 +1571,41 @@ YY_RULE_SETUP yy_pop_state(); YY_BREAK case 109: -/* rule 109 can match eol */ YY_RULE_SETUP #line 196 "asm.yy" -++num_lines; +{ yylval.str = yytext; return MACRO_STRING; } YY_BREAK case 110: +/* rule 110 can match eol */ YY_RULE_SETUP #line 197 "asm.yy" - +{ yylval.str = yytext; return MACRO_STRING; } YY_BREAK case 111: -/* rule 111 can match eol */ YY_RULE_SETUP #line 199 "asm.yy" +yy_push_state(SKIP_ALL); + YY_BREAK +case 112: +YY_RULE_SETUP +#line 200 "asm.yy" +yy_pop_state(); + YY_BREAK +case 113: +/* rule 113 can match eol */ +YY_RULE_SETUP +#line 201 "asm.yy" +++num_lines; + YY_BREAK +case 114: +YY_RULE_SETUP +#line 202 "asm.yy" + + YY_BREAK +case 115: +/* rule 115 can match eol */ +YY_RULE_SETUP +#line 204 "asm.yy" { /* multi-line string with correct line count */ char *p = strdupped_get(yytext); @@ -1596,20 +1620,20 @@ YY_RULE_SETUP return STRING; } YY_BREAK -case 112: +case 116: YY_RULE_SETUP -#line 212 "asm.yy" +#line 217 "asm.yy" BEGIN(INITIAL); YY_BREAK -case 113: -/* rule 113 can match eol */ +case 117: +/* rule 117 can match eol */ YY_RULE_SETUP -#line 214 "asm.yy" +#line 219 "asm.yy" { ++num_lines; BEGIN(INITIAL); } YY_BREAK -case 114: +case 118: YY_RULE_SETUP -#line 215 "asm.yy" +#line 220 "asm.yy" YY_BREAK case YY_STATE_EOF(INITIAL): @@ -1618,7 +1642,7 @@ case YY_STATE_EOF(SKIP_ALL): case YY_STATE_EOF(QUOTED_STRING): case YY_STATE_EOF(SKIP_LINE): case YY_STATE_EOF(MACROO): -#line 217 "asm.yy" +#line 222 "asm.yy" { if(--src_buffer_depth == 0) { @@ -1631,12 +1655,12 @@ case YY_STATE_EOF(MACROO): } } YY_BREAK -case 115: +case 119: YY_RULE_SETUP -#line 229 "asm.yy" +#line 234 "asm.yy" ECHO; YY_BREAK -#line 1639 "lex.yy.c" +#line 1667 "lex.yy.c" case YY_END_OF_BUFFER: { @@ -1932,7 +1956,7 @@ static int yy_get_next_buffer (void) 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 >= 260 ) + if ( yy_current_state >= 267 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; @@ -1960,11 +1984,11 @@ static int yy_get_next_buffer (void) 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 >= 260 ) + if ( yy_current_state >= 267 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 259); + yy_is_jam = (yy_current_state == 266); return yy_is_jam ? 0 : yy_current_state; } @@ -2686,7 +2710,7 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 229 "asm.yy" +#line 234 "asm.yy" void scanner_init(void) @@ -2694,7 +2718,7 @@ void scanner_init(void) vec_init(strdupped, sizeof(char*)); } -void asm_src_buffer_push(struct membuf *buffer) +void asm_src_buffer_push(struct buf *buffer) { if(src_buffer_depth == MAX_SRC_BUFFER_DEPTH) { @@ -2702,7 +2726,7 @@ void asm_src_buffer_push(struct membuf *buffer) exit(1); } src_buffers[src_buffer_depth++] = YY_CURRENT_BUFFER; - yy_scan_bytes(membuf_get(buffer), membuf_memlen(buffer)); + yy_scan_bytes(buf_data(buffer), buf_size(buffer)); } static char *strdupped_get(char *text) diff --git a/src/asm/log.c b/src/asm/log.c index 5f0a1b4..99ddd53 100644 --- a/src/asm/log.c +++ b/src/asm/log.c @@ -5,9 +5,9 @@ * In no event will the authors be held liable for any damages arising from * the use of this software. * - * Permission is granted to anyone to use this software, alter it and re- - * distribute it freely for any non-commercial, non-profit purpose subject to - * the following restrictions: + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software in a @@ -19,10 +19,6 @@ * * 3. This notice may not be removed or altered from any distribution. * - * 4. The names of this software and/or it's copyright holders may not be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * * This file is a part of the Exomizer v1.1 release * */ diff --git a/src/asm/log.h b/src/asm/log.h index 78a3dda..00874bb 100644 --- a/src/asm/log.h +++ b/src/asm/log.h @@ -1,5 +1,9 @@ #ifndef ALREADY_INCLUDED_LOG #define ALREADY_INCLUDED_LOG +#ifdef __cplusplus +extern "C" { +#endif + /* * Copyright (c) 2002, 2003 Magnus Lind. * @@ -7,9 +11,9 @@ * In no event will the authors be held liable for any damages arising from * the use of this software. * - * Permission is granted to anyone to use this software, alter it and re- - * distribute it freely for any non-commercial, non-profit purpose subject to - * the following restrictions: + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software in a @@ -21,10 +25,6 @@ * * 3. This notice may not be removed or altered from any distribution. * - * 4. The names of this software and/or it's copyright holders may not be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * */ #include @@ -39,6 +39,7 @@ enum log_level { LOG_FATAL = -40, LOG_ERROR = -30, LOG_WARNING = -20, + LOG_TERSE = -15, LOG_BRIEF = -10, LOG_NORMAL = 0, LOG_VERBOSE = 10, @@ -48,11 +49,10 @@ enum log_level { LOG_MAX = 99 }; -typedef -void log_formatter_f(FILE * out, /* IN */ - enum log_level level, /* IN */ - const char *context, /* IN */ - const char *); /* IN */ +typedef void log_formatter_f(FILE * out, /* IN */ + enum log_level level, /* IN */ + const char *context, /* IN */ + const char *); /* IN */ /* * this log output function adds nothing @@ -148,4 +148,7 @@ do { \ void hex_dump(int level, unsigned char *p, int len); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/asm/map.c b/src/asm/map.c index ff0af28..bd93c9f 100644 --- a/src/asm/map.c +++ b/src/asm/map.c @@ -5,9 +5,9 @@ * In no event will the authors be held liable for any damages arising from * the use of this software. * - * Permission is granted to anyone to use this software, alter it and re- - * distribute it freely for any non-commercial, non-profit purpose subject to - * the following restrictions: + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software in a @@ -19,10 +19,6 @@ * * 3. This notice may not be removed or altered from any distribution. * - * 4. The names of this software and/or it's copyright holders may not be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * */ #include "map.h" @@ -59,13 +55,13 @@ void map_free(struct map *m) void *map_put(struct map *m, const char *key, void *value) { - struct map_entry e[1]; + struct map_entry e; int pos; void *prev_value = NULL; - e->key = key; - e->value = value; - pos = vec_find(&m->vec, map_entry_cmp, e); + e.key = key; + e.value = value; + pos = vec_find(&m->vec, map_entry_cmp, &e); if(pos == -1) { /* error, find failed */ @@ -78,24 +74,24 @@ void *map_put(struct map *m, const char *key, void *value) struct map_entry *prev_e; prev_e = vec_get(&m->vec, pos); prev_value = prev_e->value; - vec_set(&m->vec, pos, e); + vec_set(&m->vec, pos, &e); } else { /* no value exists, insert */ - vec_insert(&m->vec, -(pos + 2), e); + vec_insert(&m->vec, -(pos + 2), &e); } return prev_value; } static struct map_entry *get(const struct map *m, const char *key) { - struct map_entry e[1]; + struct map_entry e; int pos; struct map_entry *out = NULL; - e->key = key; - pos = vec_find(&m->vec, map_entry_cmp, e); + e.key = key; + pos = vec_find(&m->vec, map_entry_cmp, &e); if(pos == -1) { /* error, find failed */ @@ -127,9 +123,9 @@ void *map_get(const struct map *m, const char *key) void map_put_all(struct map *m, const struct map *source) { - struct map_iterator i[1]; + struct map_iterator i; const struct map_entry *e; - for(map_get_iterator(source, i); (e = map_iterator_next(i)) != NULL;) + for(map_get_iterator(source, &i); (e = map_iterator_next(&i)) != NULL;) { map_put(m, e->key, e->value); } @@ -137,10 +133,10 @@ void map_put_all(struct map *m, const struct map *source) int map_contains(const struct map *m1, const struct map *m2, cb_cmp *f) { - struct map_iterator i[1]; + struct map_iterator i; const struct map_entry *e; - for(map_get_iterator(m2, i); (e = map_iterator_next(i)) != NULL;) + for(map_get_iterator(m2, &i); (e = map_iterator_next(&i)) != NULL;) { int pos; pos = vec_find(&m1->vec, map_entry_cmp, e); diff --git a/src/asm/map.h b/src/asm/map.h index df41281..25d8c33 100644 --- a/src/asm/map.h +++ b/src/asm/map.h @@ -1,5 +1,8 @@ #ifndef ALREADY_INCLUDED_MAP #define ALREADY_INCLUDED_MAP +#ifdef __cplusplus +extern "C" { +#endif /* * Copyright (c) 2006 Magnus Lind. @@ -8,9 +11,9 @@ * In no event will the authors be held liable for any damages arising from * the use of this software. * - * Permission is granted to anyone to use this software, alter it and re- - * distribute it freely for any non-commercial, non-profit purpose subject to - * the following restrictions: + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software in a @@ -22,10 +25,6 @@ * * 3. This notice may not be removed or altered from any distribution. * - * 4. The names of this software and/or it's copyright holders may not be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * */ #include "vec.h" @@ -66,4 +65,7 @@ int map_equals(const struct map *m1, const struct map *m2, cb_cmp *f); void map_get_iterator(const struct map *p, struct map_iterator *i); const struct map_entry *map_iterator_next(struct map_iterator *i); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/asm/membuf.c b/src/asm/membuf.c deleted file mode 100644 index 08c8e33..0000000 --- a/src/asm/membuf.c +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright (c) 2002 2005 Magnus Lind. - * - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from - * the use of this software. - * - * Permission is granted to anyone to use this software, alter it and re- - * distribute it freely for any non-commercial, non-profit purpose subject to - * the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software in a - * product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not - * be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any distribution. - * - * 4. The names of this software and/or it's copyright holders may not be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * - */ - -#include "membuf.h" -#include -#include -#include - -#include - -#ifdef WIN32 -#define vsnprintf _vsnprintf -#endif - -void membuf_init(struct membuf *sb) -{ - sb->buf = NULL; - sb->len = 0; - sb->size = 0; -} -void membuf_clear(struct membuf *sb) -{ - sb->len = 0; -} -void membuf_free(struct membuf *sb) -{ - if (sb->buf != NULL) - { - free(sb->buf); - sb->buf = NULL; - } - sb->len = 0; - sb->size = 0; -} - -void membuf_new(struct membuf **sbp) -{ - struct membuf *sb; - - sb = malloc(sizeof(struct membuf)); - if (sb == NULL) - { - fprintf(stderr, "error, can't allocate memory\n"); - exit(1); - } - sb->buf = NULL; - sb->len = 0; - sb->size = 0; - - *sbp = sb; -} - -void membuf_delete(struct membuf **sbp) -{ - struct membuf *sb; - - sb = *sbp; - membuf_free(sb); - free(sb); - sb = NULL; - *sbp = sb; -} - -int membuf_memlen(const struct membuf *sb) -{ - return sb->len; -} - -void membuf_truncate(struct membuf *sb, int len) -{ - sb->len = len; -} - -int membuf_trim(struct membuf *sb, int pos) -{ - if(pos < 0 || pos > sb->len) - { - return -1; - } - if(pos == 0) - { - return sb->len; - } - if(pos != sb->len) - { - memmove(sb->buf, (char*)sb->buf + pos, sb->len - pos); - } - sb->len -= pos; - return sb->len; -} - -void *membuf_memcpy(struct membuf *sb, int offset, const void *mem, int len) -{ - char *buf; - membuf_atleast(sb, offset + len); - buf = (char*)sb->buf + offset; - memcpy(buf, mem, len); - return buf; -} - -void *membuf_append(struct membuf *sb, const void *mem, int len) -{ - int newlen; - void *p; - newlen = sb->len + len; - membuf_atleast(sb, newlen); - p = (char *) sb->buf + sb->len; - if(mem == NULL) - { - memset(p, 0, len); - } - else - { - memcpy(p, mem, len); - } - sb->len = newlen; - return p; -} - -void *membuf_append_char(struct membuf *sb, char c) -{ - int newlen; - char *p; - newlen = sb->len + 1; - membuf_atleast(sb, newlen); - p = (char *) sb->buf + sb->len; - *p = c; - sb->len = newlen; - return p; -} - -void *membuf_insert(struct membuf *sb, int offset, const void *mem, int len) -{ - int newlen; - void *from; - void *to; - newlen = sb->len + len; - membuf_atleast(sb, newlen); - from = (char *)sb->buf + offset; - to = (char *)from + len; - memmove(to, from, sb->len - offset); - if(mem == NULL) - { - memset(from, 0, len); - } - else - { - memcpy(from, mem, len); - } - sb->len = newlen; - return from; -} - -void membuf_remove(struct membuf *sb, int offset, int len) -{ - void *from; - void *to; - to = (char *)sb->buf + offset; - from = (char *)to + len; - sb->len -= len; - memmove(to, from, sb->len - offset); - -} - -void membuf_atleast(struct membuf *sb, int len) -{ - int size; - - size = sb->size; - if (size == 0) - size = 1; - while (size < len) - { - size <<= 1; - } - if (size > sb->size) - { - sb->buf = realloc(sb->buf, size); - if (sb->buf == NULL) - { - fprintf(stderr, "error, can't reallocate memory\n"); - exit(1); - } - sb->size = size; - } -} - -void membuf_atmost(struct membuf *sb, int len) -{ - int size; - - size = sb->size; - while (size > len) - { - size >>= 1; - } - if (size < sb->size) - { - sb->buf = realloc(sb->buf, size); - if (sb->buf == NULL) - { - fprintf(stderr, "error, can't reallocate memory\n"); - exit(1); - } - sb->size = size; - sb->len = size; - } -} - -int membuf_get_size(const struct membuf *sb) -{ - return sb->size; -} -void *membuf_get(const struct membuf *sb) -{ - return sb->buf; -} -void membuf_printf(struct membuf *sb, const char *format, ...) -{ - int pos; - int printed; - va_list args; - - pos = sb->len; - - va_start(args, format); - printed = vsnprintf((char*)membuf_get(sb) + pos, sb->size - pos, - format, args); - va_end(args); - - if (printed >= sb->size - pos) - { - va_list args2; - - membuf_atleast(sb, pos + printed + 1); - - va_start(args2, format); - printed = vsnprintf((char*)membuf_get(sb) + pos, sb->size - pos, - format, args2); - va_end(args2); - } - sb->len += printed; -} diff --git a/src/asm/membuf.h b/src/asm/membuf.h deleted file mode 100644 index 445ce97..0000000 --- a/src/asm/membuf.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef ALREADY_INCLUDED_MEMBUF -#define ALREADY_INCLUDED_MEMBUF - -/* - * Copyright (c) 2002 - 2005 Magnus Lind. - * - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from - * the use of this software. - * - * Permission is granted to anyone to use this software, alter it and re- - * distribute it freely for any non-commercial, non-profit purpose subject to - * the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software in a - * product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not - * be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any distribution. - * - * 4. The names of this software and/or it's copyright holders may not be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * - */ - -#define STATIC_MEMBUF_INIT {0, 0, 0} - -struct membuf { - void *buf; - int len; - int size; -}; - -void membuf_init(struct membuf *sb); -void membuf_clear(struct membuf *sb); -void membuf_free(struct membuf *sb); -void membuf_new(struct membuf **sbp); -void membuf_delete(struct membuf **sbp); -/* Gets the length of data put into the membuf */ -int membuf_memlen(const struct membuf *sb); -void membuf_truncate(struct membuf *sb, int len); - -/* returns the new len or < 0 if failure */ -int membuf_trim(struct membuf *sb, int pos); - -void *membuf_memcpy(struct membuf *sb, int offset, const void *mem, int len); -void *membuf_append(struct membuf *sb, const void *mem, int len); -void *membuf_append_char(struct membuf *sb, char c); -void *membuf_insert(struct membuf *sb, int offset, const void *mem, int len); -void membuf_remove(struct membuf *sb, int offset, int len); -/* Grows the capacity if it's less than the given size */ -void membuf_atleast(struct membuf *sb, int size); -/* Skrinks the capacity if it's greater than the given size */ -void membuf_atmost(struct membuf *sb, int size); -/* Gets the current capacity of the membuf */ -int membuf_get_size(const struct membuf *sb); -/* Gets a pointer to the internal buffer. Don't dereferece it beyond - * its size. */ -void *membuf_get(const struct membuf *sb); - -/* Appends a printf formatted string to */ -void membuf_printf(struct membuf *sb, const char *format, ...); -#endif diff --git a/src/asm/named_buffer.c b/src/asm/named_buffer.c index 4187b30..d63788c 100644 --- a/src/asm/named_buffer.c +++ b/src/asm/named_buffer.c @@ -5,9 +5,9 @@ * In no event will the authors be held liable for any damages arising from * the use of this software. * - * Permission is granted to anyone to use this software, alter it and re- - * distribute it freely for any non-commercial, non-profit purpose subject to - * the following restrictions: + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software in a @@ -19,30 +19,26 @@ * * 3. This notice may not be removed or altered from any distribution. * - * 4. The names of this software and/or it's copyright holders may not be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * */ #include "named_buffer.h" #include "log.h" #include "chunkpool.h" -#include "membuf_io.h" +#include "buf_io.h" #include void named_buffer_init(struct named_buffer *nb) { map_init(&nb->map); - chunkpool_init(&nb->buf, sizeof(struct membuf)); + chunkpool_init(&nb->buf, sizeof(struct buf)); } void named_buffer_free(struct named_buffer *nb) { typedef void cb_free(void *a); - chunkpool_free2(&nb->buf, (cb_free*)membuf_free); + chunkpool_free2(&nb->buf, (cb_free*)buf_free); map_free(&nb->map); } @@ -55,19 +51,20 @@ void named_buffer_clear(struct named_buffer *nb) void named_buffer_copy(struct named_buffer *nb, const struct named_buffer *source) { - struct map_iterator i[1]; + struct map_iterator i; const struct map_entry *e; - for(map_get_iterator(&source->map, i); (e = map_iterator_next(i)) != NULL;) + for(map_get_iterator(&source->map, &i); + (e = map_iterator_next(&i)) != NULL;) { /* don't allocate copies of the entries */ map_put(&nb->map, e->key, e->value); } } -struct membuf *new_named_buffer(struct named_buffer *nb, const char *name) +struct buf *new_named_buffer(struct named_buffer *nb, const char *name) { - struct membuf *mp; + struct buf *mp; mp = chunkpool_malloc(&nb->buf); /* name is already strdup:ped */ @@ -77,13 +74,13 @@ struct membuf *new_named_buffer(struct named_buffer *nb, const char *name) LOG(LOG_ERROR, ("buffer already exists.\n")); exit(1); } - membuf_init(mp); + buf_init(mp); return mp; } -struct membuf *get_named_buffer(struct named_buffer *nb, const char *name) +struct buf *get_named_buffer(struct named_buffer *nb, const char *name) { - struct membuf *mp; + struct buf *mp; mp = map_get(&nb->map, name); if(mp == NULL) diff --git a/src/asm/named_buffer.h b/src/asm/named_buffer.h index b38cff2..58645ce 100644 --- a/src/asm/named_buffer.h +++ b/src/asm/named_buffer.h @@ -1,5 +1,8 @@ #ifndef NAMED_BUFFER_INCLUDED #define NAMED_BUFFER_INCLUDED +#ifdef __cplusplus +extern "C" { +#endif /* * Copyright (c) 2005 Magnus Lind. @@ -8,9 +11,9 @@ * In no event will the authors be held liable for any damages arising from * the use of this software. * - * Permission is granted to anyone to use this software, alter it and re- - * distribute it freely for any non-commercial, non-profit purpose subject to - * the following restrictions: + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software in a @@ -22,13 +25,9 @@ * * 3. This notice may not be removed or altered from any distribution. * - * 4. The names of this software and/or it's copyright holders may not be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * */ -#include "membuf.h" +#include "buf.h" #include "chunkpool.h" #include "map.h" @@ -44,7 +43,10 @@ void named_buffer_clear(struct named_buffer *nb); void named_buffer_copy(struct named_buffer *nb, const struct named_buffer *source); -struct membuf *new_named_buffer(struct named_buffer *nb, const char *name); -struct membuf *get_named_buffer(struct named_buffer *nb, const char *name); +struct buf *new_named_buffer(struct named_buffer *nb, const char *name); +struct buf *get_named_buffer(struct named_buffer *nb, const char *name); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/asm/parse.c b/src/asm/parse.c index 841721f..1becf3e 100644 --- a/src/asm/parse.c +++ b/src/asm/parse.c @@ -5,9 +5,9 @@ * In no event will the authors be held liable for any damages arising from * the use of this software. * - * Permission is granted to anyone to use this software, alter it and re- - * distribute it freely for any non-commercial, non-profit purpose subject to - * the following restrictions: + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software in a @@ -19,10 +19,6 @@ * * 3. This notice may not be removed or altered from any distribution. * - * 4. The names of this software and/or it's copyright holders may not be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * */ #include "parse.h" @@ -37,20 +33,20 @@ struct parse { /* pools */ - struct chunkpool atom_pool[1]; - struct chunkpool vec_pool[1]; + struct chunkpool atom_pool; + struct chunkpool vec_pool; /* one pass data only */ - struct map sym_table[1]; - struct named_buffer named_buffer[1]; + struct map sym_table; + struct named_buffer named_buffer; const char *macro_name; /* history of the multi pass */ struct map *guesses; /* initial arguments */ - struct map initial_symbols[1]; - struct named_buffer initial_named_buffer[1]; + struct map initial_symbols; + struct named_buffer initial_named_buffer; }; -static struct parse s[1]; +static struct parse s; void scanner_init(void); void scanner_free(void); @@ -59,19 +55,19 @@ void parse_init(void) { expr_init(); scanner_init(); - chunkpool_init(s->atom_pool, sizeof(struct atom)); - chunkpool_init(s->vec_pool, sizeof(struct vec)); - map_init(s->sym_table); - named_buffer_init(s->named_buffer); + chunkpool_init(&s.atom_pool, sizeof(struct atom)); + chunkpool_init(&s.vec_pool, sizeof(struct vec)); + map_init(&s.sym_table); + named_buffer_init(&s.named_buffer); - map_init(s->initial_symbols); - named_buffer_init(s->initial_named_buffer); + map_init(&s.initial_symbols); + named_buffer_init(&s.initial_named_buffer); } static void parse_reset(void) { - map_clear(s->sym_table); - named_buffer_clear(s->named_buffer); + map_clear(&s.sym_table); + named_buffer_clear(&s.named_buffer); } static void free_vec_pool(struct vec *v) @@ -81,14 +77,14 @@ static void free_vec_pool(struct vec *v) void parse_free(void) { - named_buffer_free(s->initial_named_buffer); - map_free(s->initial_symbols); - - named_buffer_free(s->named_buffer); - chunkpool_free(s->atom_pool); - chunkpool_free2(s->vec_pool, (cb_free*)free_vec_pool); - named_buffer_free(s->named_buffer); - map_free(s->sym_table); + named_buffer_free(&s.initial_named_buffer); + map_free(&s.initial_symbols); + + named_buffer_free(&s.named_buffer); + chunkpool_free(&s.atom_pool); + chunkpool_free2(&s.vec_pool, (cb_free*)free_vec_pool); + named_buffer_free(&s.named_buffer); + map_free(&s.sym_table); scanner_free(); expr_free(); } @@ -120,13 +116,13 @@ int is_valid_ui16(i32 value) struct expr *new_is_defined(const char *symbol) { - int expr_val = (map_get(s->sym_table, symbol) != NULL); + int expr_val = (map_get(&s.sym_table, symbol) != NULL); return new_expr_number(expr_val); } void new_symbol_expr(const char *symbol, struct expr *arg) { - if(map_put(s->sym_table, symbol, arg) != NULL) + if(map_put(&s.sym_table, symbol, arg) != NULL) { /* error, symbol redefinition not allowed */ LOG(LOG_ERROR, ("not allowed to redefine symbol %s\n", symbol)); @@ -137,9 +133,9 @@ void new_symbol_expr(const char *symbol, struct expr *arg) void new_symbol_expr_guess(const char *symbol, struct expr *arg) { /* Set a soft symbol only if it is not set */ - if(map_get(s->guesses, symbol) == NULL) + if(map_get(s.guesses, symbol) == NULL) { - map_put(s->guesses, symbol, arg); + map_put(s.guesses, symbol, arg); } } @@ -151,13 +147,13 @@ const char *find_symref(const char *symbol, exp = NULL; p = NULL; - if(s->guesses != NULL) + if(s.guesses != NULL) { - exp = map_get(s->guesses, symbol); + exp = map_get(s.guesses, symbol); } if(exp == NULL) { - exp = map_get(s->sym_table, symbol); + exp = map_get(&s.sym_table, symbol); if(exp == NULL) { static char buf[1024]; @@ -185,10 +181,10 @@ void new_label(const char *label) static void dump_sym_table(int level, struct map *m) { - struct map_iterator i[1]; + struct map_iterator i; const struct map_entry *e; - for(map_get_iterator(m, i); (e = map_iterator_next(i)) != NULL;) + for(map_get_iterator(m, &i); (e = map_iterator_next(&i)) != NULL;) { LOG(level, ("sym_table: %s ", e->key)); expr_dump(level, e->value); @@ -198,21 +194,21 @@ static void dump_sym_table(int level, struct map *m) void set_initial_symbol(const char *symbol, i32 value) { struct expr *e = new_expr_number(value); - map_put(s->initial_symbols, symbol, e); + map_put(&s.initial_symbols, symbol, e); } void set_initial_symbol_soft(const char *symbol, i32 value) { - if (!map_contains_key(s->initial_symbols, symbol)) + if (!map_contains_key(&s.initial_symbols, symbol)) { struct expr *e = new_expr_number(value); - map_put(s->initial_symbols, symbol, e); + map_put(&s.initial_symbols, symbol, e); } } -struct membuf *new_initial_named_buffer(const char *name) +struct buf *new_initial_named_buffer(const char *name) { - return new_named_buffer(s->initial_named_buffer, name); + return new_named_buffer(&s.initial_named_buffer, name); } static const char *resolve_expr2(struct expr *e, i32 *valp) @@ -244,12 +240,8 @@ static const char *resolve_expr2(struct expr *e, i32 *valp) value = !value; break; case SYMBOL: - p = NULL; e2 = NULL; - if(s != NULL) - { - p = find_symref(e->type.symref, &e2); - } + p = find_symref(e->type.symref, &e2); if(p != NULL) break; if(e2 == NULL) { @@ -357,11 +349,11 @@ static i32 resolve_expr(struct expr *e) struct expr *new_expr_inclen(const char *name) { long length; - struct membuf *in; + struct buf *in; struct expr *expr; - in = get_named_buffer(s->named_buffer, name); - length = membuf_memlen(in); + in = get_named_buffer(&s.named_buffer, name); + length = buf_size(in); expr = new_expr_number((i32)length); return expr; @@ -373,13 +365,13 @@ struct expr *new_expr_incword(const char *name, i32 word; i32 offset; long length; - struct membuf *in; + struct buf *in; struct expr *expr; unsigned char *p; offset = resolve_expr(skip); - in = get_named_buffer(s->named_buffer, name); - length = membuf_memlen(in); + in = get_named_buffer(&s.named_buffer, name); + length = buf_size(in); if(offset < 0) { offset += length; @@ -391,7 +383,7 @@ struct expr *new_expr_incword(const char *name, offset, name)); exit(1); } - p = membuf_get(in); + p = buf_data(in); p += offset; word = *p++; word |= *p++ << 8; @@ -410,19 +402,19 @@ void set_org(struct expr *arg) void push_macro_state(const char *name) { - s->macro_name = name; + s.macro_name = name; push_state_macro = 1; - new_named_buffer(s->named_buffer, name); + new_named_buffer(&s.named_buffer, name); } void macro_append(const char *text) { - struct membuf *mb; + struct buf *mb; LOG(LOG_DEBUG, ("appending >>%s<< to macro\n", text)); - mb = get_named_buffer(s->named_buffer, s->macro_name); - membuf_append(mb, text, strlen(text)); + mb = get_named_buffer(&s.named_buffer, s.macro_name); + buf_append(mb, text, strlen(text)); } void push_if_state(struct expr *arg) @@ -446,7 +438,7 @@ struct atom *new_op(u8 op_code, u8 atom_op_type, { struct atom *atom; - atom = chunkpool_malloc(s->atom_pool); + atom = chunkpool_malloc(&s.atom_pool); atom->type = atom_op_type; atom->u.op.code = op_code; atom->u.op.arg = op_arg; @@ -489,9 +481,9 @@ struct atom *new_exprs(struct expr *arg) { struct atom *atom; - atom = chunkpool_malloc(s->atom_pool); + atom = chunkpool_malloc(&s.atom_pool); atom->type = ATOM_TYPE_EXPRS; - atom->u.exprs = chunkpool_malloc(s->vec_pool); + atom->u.exprs = chunkpool_malloc(&s.vec_pool); vec_init(atom->u.exprs, sizeof(struct expr*)); exprs_add(atom, arg); return atom; @@ -518,7 +510,7 @@ struct atom *exprs_to_byte_exprs(struct atom *atom) } atom->type = ATOM_TYPE_BYTE_EXPRS; - pc_add(vec_count(atom->u.exprs)); + pc_add(vec_size(atom->u.exprs)); return atom; } @@ -532,7 +524,27 @@ struct atom *exprs_to_word_exprs(struct atom *atom) } atom->type = ATOM_TYPE_WORD_EXPRS; - pc_add(vec_count(atom->u.exprs) * 2); + pc_add(vec_size(atom->u.exprs) * 2); + return atom; +} + +struct atom *text_to_byte_exprs(const char *text) +{ + struct atom *atom; + int c; + + atom = chunkpool_malloc(&s.atom_pool); + atom->type = ATOM_TYPE_BYTE_EXPRS; + atom->u.exprs = chunkpool_malloc(&s.vec_pool); + vec_init(atom->u.exprs, sizeof(struct expr*)); + + while ((c = *text++) != '\0') + { + struct expr *expr = new_expr_number(c & 255); + vec_push(atom->u.exprs, &expr); + } + + pc_add(vec_size(atom->u.exprs)); return atom; } @@ -540,7 +552,7 @@ struct atom *new_res(struct expr *len, struct expr *value) { struct atom *atom; - atom = chunkpool_malloc(s->atom_pool); + atom = chunkpool_malloc(&s.atom_pool); atom->type = ATOM_TYPE_RES; atom->u.res.length = len; atom->u.res.value = value; @@ -556,11 +568,11 @@ struct atom *new_incbin(const char *name, long length; i32 len32; i32 skip32; - struct membuf *in; + struct buf *in; /* find out how long the file is */ - in = get_named_buffer(s->named_buffer, name); - length = membuf_memlen(in); + in = get_named_buffer(&s.named_buffer, name); + length = buf_size(in); skip32 = 0; if(skip != NULL) @@ -596,7 +608,7 @@ struct atom *new_incbin(const char *name, exit(1); } - atom = chunkpool_malloc(s->atom_pool); + atom = chunkpool_malloc(&s.atom_pool); atom->type = ATOM_TYPE_BUFFER; atom->u.buffer.name = name; atom->u.buffer.length = len32; @@ -609,7 +621,6 @@ struct atom *new_incbin(const char *name, return atom; } - void asm_error(const char *msg) { LOG(LOG_ERROR, ("Error: %s\n", msg)); @@ -618,22 +629,22 @@ void asm_error(const char *msg) void asm_echo(const char *msg, struct atom *atom) { - struct vec_iterator i[1]; + struct vec_iterator i; struct expr **exprp; int count = 0; i32 e[10]; if(atom != NULL) { - if(atom->type != ATOM_TYPE_EXPRS || vec_count(atom->u.exprs) > 10) + if(atom->type != ATOM_TYPE_EXPRS || vec_size(atom->u.exprs) > 10) { LOG(LOG_ERROR, ("echo arguments must be a string followed by none " "or at most ten expressions.\n")); exit(1); } - vec_get_iterator(atom->u.exprs, i); - while((exprp = vec_iterator_next(i)) != NULL) + vec_get_iterator(atom->u.exprs, &i); + while((exprp = vec_iterator_next(&i)) != NULL) { e[count++] = resolve_expr(*exprp); } @@ -649,9 +660,9 @@ void asm_echo(const char *msg, struct atom *atom) void asm_include(const char *msg) { - struct membuf *src; + struct buf *src; - src = get_named_buffer(s->named_buffer, msg); + src = get_named_buffer(&s.named_buffer, msg); asm_src_buffer_push(src); } @@ -660,7 +671,7 @@ void initial_symbol_dump(int level, const char *symbol) i32 value; struct expr *expr; - expr = map_get(s->initial_symbols, symbol); + expr = map_get(&s.initial_symbols, symbol); if(expr != NULL) { value = resolve_expr(expr); @@ -669,7 +680,7 @@ void initial_symbol_dump(int level, const char *symbol) } else { - if(map_contains_key(s->initial_symbols, symbol)) + if(map_contains_key(&s.initial_symbols, symbol)) { LOG(level, ("symbol \"%s\" defined but has no value\n", symbol)); } @@ -736,23 +747,23 @@ void symbol_dump_resolved(int level, const char *symbol) } } -void output_atoms(struct membuf *out, struct vec *atoms) +void output_atoms(struct buf *out, struct vec *atoms) { - struct vec_iterator i[1]; - struct vec_iterator i2[1]; + struct vec_iterator i; + struct vec_iterator i2; struct atom **atomp; struct atom *atom; struct expr **exprp; struct expr *expr; - struct membuf *in; + struct buf *in; const char *p; i32 value; i32 value2; - dump_sym_table(LOG_DEBUG, s->sym_table); + dump_sym_table(LOG_DEBUG, &s.sym_table); - vec_get_iterator(atoms, i); - while((atomp = vec_iterator_next(i)) != NULL) + vec_get_iterator(atoms, &i); + while((atomp = vec_iterator_next(&i)) != NULL) { atom = *atomp; @@ -762,7 +773,7 @@ void output_atoms(struct membuf *out, struct vec *atoms) { case ATOM_TYPE_OP_ARG_NONE: LOG(LOG_DEBUG, ("output: $%02X\n", atom->u.op.code)); - membuf_append_char(out, atom->u.op.code); + buf_append_char(out, atom->u.op.code); break; case ATOM_TYPE_OP_ARG_U8: /* op with argument */ @@ -775,8 +786,8 @@ void output_atoms(struct membuf *out, struct vec *atoms) } LOG(LOG_DEBUG, ("output: $%02X $%02X\n", atom->u.op.code, value & 255)); - membuf_append_char(out, atom->u.op.code); - membuf_append_char(out, value); + buf_append_char(out, atom->u.op.code); + buf_append_char(out, value); break; case ATOM_TYPE_OP_ARG_I8: /* op with argument */ @@ -789,8 +800,8 @@ void output_atoms(struct membuf *out, struct vec *atoms) } LOG(LOG_DEBUG, ("output: $%02X $%02X\n", atom->u.op.code, value & 255)); - membuf_append_char(out, atom->u.op.code); - membuf_append_char(out, value); + buf_append_char(out, atom->u.op.code); + buf_append_char(out, value); break; case ATOM_TYPE_OP_ARG_UI8: /* op with argument */ @@ -803,8 +814,8 @@ void output_atoms(struct membuf *out, struct vec *atoms) } LOG(LOG_DEBUG, ("output: $%02X $%02X\n", atom->u.op.code, value & 255)); - membuf_append_char(out, atom->u.op.code); - membuf_append_char(out, value); + buf_append_char(out, atom->u.op.code); + buf_append_char(out, value); break; case ATOM_TYPE_OP_ARG_U16: /* op with argument */ @@ -820,9 +831,9 @@ void output_atoms(struct membuf *out, struct vec *atoms) LOG(LOG_DEBUG, ("output: $%02X $%02X $%02X\n", atom->u.op.code, value, value2)); - membuf_append_char(out, atom->u.op.code); - membuf_append_char(out, value); - membuf_append_char(out, value2); + buf_append_char(out, atom->u.op.code); + buf_append_char(out, value); + buf_append_char(out, value2); break; case ATOM_TYPE_RES: /* reserve memory statement */ @@ -843,7 +854,7 @@ void output_atoms(struct membuf *out, struct vec *atoms) LOG(LOG_DEBUG, ("output: .RES %d, %d\n", value, value2)); while(--value >= 0) { - membuf_append_char(out, value2); + buf_append_char(out, value2); } break; case ATOM_TYPE_BUFFER: @@ -864,17 +875,17 @@ void output_atoms(struct membuf *out, struct vec *atoms) } LOG(LOG_DEBUG, ("output: .INCBIN \"%s\", %d, %d\n", atom->u.buffer.name, value, value2)); - in = get_named_buffer(s->named_buffer, atom->u.buffer.name); - p = membuf_get(in); + in = get_named_buffer(&s.named_buffer, atom->u.buffer.name); + p = buf_data(in); p += value; while(--value2 >= 0) { - membuf_append_char(out, *p++); + buf_append_char(out, *p++); } break; case ATOM_TYPE_WORD_EXPRS: - vec_get_iterator(atom->u.exprs, i2); - while((exprp = vec_iterator_next(i2)) != NULL) + vec_get_iterator(atom->u.exprs, &i2); + while((exprp = vec_iterator_next(&i2)) != NULL) { expr = *exprp; value = resolve_expr(expr); @@ -885,14 +896,14 @@ void output_atoms(struct membuf *out, struct vec *atoms) } value2 = value / 256; value = value % 256; - membuf_append_char(out, value); - membuf_append_char(out, value2); + buf_append_char(out, value); + buf_append_char(out, value2); } - LOG(LOG_DEBUG, ("output: %d words\n", vec_count(atom->u.exprs))); + LOG(LOG_DEBUG, ("output: %d words\n", vec_size(atom->u.exprs))); break; case ATOM_TYPE_BYTE_EXPRS: - vec_get_iterator(atom->u.exprs, i2); - while((exprp = vec_iterator_next(i2)) != NULL) + vec_get_iterator(atom->u.exprs, &i2); + while((exprp = vec_iterator_next(&i2)) != NULL) { expr = *exprp; value = resolve_expr(expr); @@ -901,9 +912,9 @@ void output_atoms(struct membuf *out, struct vec *atoms) LOG(LOG_ERROR, ("value %d for .byte(value, ...) " "is out of range\n", value)); } - membuf_append_char(out, value); + buf_append_char(out, value); } - LOG(LOG_DEBUG, ("output: %d bytes\n", vec_count(atom->u.exprs))); + LOG(LOG_DEBUG, ("output: %d bytes\n", vec_size(atom->u.exprs))); break; default: LOG(LOG_ERROR, ("invalid atom_type %d @%p\n", @@ -933,12 +944,12 @@ static int expr_cmp_cb(const void *a, const void *b) static int loopDetect(struct vec *guesses_history) { int result = 0; - struct vec_iterator i[1]; + struct vec_iterator i; struct map *m; - for(vec_get_iterator(guesses_history, i); - (m = vec_iterator_next(i)) != NULL;) + for(vec_get_iterator(guesses_history, &i); + (m = vec_iterator_next(&i)) != NULL;) { - if(map_equals(m, s->guesses, expr_cmp_cb)) + if(map_equals(m, s.guesses, expr_cmp_cb)) { result = 1; break; @@ -950,17 +961,17 @@ static int loopDetect(struct vec *guesses_history) static int wasFinalPass(void) { int result = 1; - struct map_iterator i[1]; + struct map_iterator i; struct map_entry *me; - for(map_get_iterator(s->guesses, i); - (me = (struct map_entry*)map_iterator_next(i)) != NULL;) + for(map_get_iterator(s.guesses, &i); + (me = (struct map_entry*)map_iterator_next(&i)) != NULL;) { struct expr *guess_expr; struct expr *sym_expr; LOG(LOG_VERBOSE, ("Checking guessed symbol %s: ", me->key)); /* Was this guessed symbol used in this pass? */ - if((sym_expr = map_get(s->sym_table, me->key)) == NULL) + if((sym_expr = map_get(&s.sym_table, me->key)) == NULL) { /* No, skip it */ continue; @@ -981,31 +992,31 @@ static int wasFinalPass(void) return result; } -int assemble(struct membuf *source, struct membuf *dest) +int assemble(struct buf *source, struct buf *dest) { - struct vec guesses_history[1]; - struct map guesses_storage[1]; + struct vec guesses_history; + struct map guesses_storage; int dest_pos; int result; - dump_sym_table(LOG_DEBUG, s->initial_symbols); + dump_sym_table(LOG_DEBUG, &s.initial_symbols); - vec_init(guesses_history, sizeof(struct map)); - s->guesses = NULL; - dest_pos = membuf_memlen(dest); + vec_init(&guesses_history, sizeof(struct map)); + s.guesses = NULL; + dest_pos = buf_size(dest); for(;;) { - map_put_all(s->sym_table, s->initial_symbols); - named_buffer_copy(s->named_buffer, s->initial_named_buffer); - map_init(guesses_storage); + map_put_all(&s.sym_table, &s.initial_symbols); + named_buffer_copy(&s.named_buffer, &s.initial_named_buffer); + map_init(&guesses_storage); - if(s->guesses != NULL) + if(s.guesses != NULL) { /* copy updated guesses from latest pass */ - map_put_all(guesses_storage, s->guesses); + map_put_all(&guesses_storage, s.guesses); } - s->guesses = guesses_storage; + s.guesses = &guesses_storage; result = assembleSinglePass(source, dest); if(result != 0) @@ -1022,7 +1033,7 @@ int assemble(struct membuf *source, struct membuf *dest) * we're done */ break; } - if(loopDetect(guesses_history)) + if(loopDetect(&guesses_history)) { /* More passes would only get us into a loop */ LOG(LOG_VERBOSE, ("Aborting due to loop.\n")); @@ -1033,13 +1044,13 @@ int assemble(struct membuf *source, struct membuf *dest) LOG(LOG_VERBOSE, ("Trying another pass.\n")); /* allocate storage for the guesses in the history vector */ - s->guesses = vec_push(guesses_history, s->guesses); + s.guesses = vec_push(&guesses_history, s.guesses); parse_reset(); - membuf_truncate(dest, dest_pos); + buf_remove(dest, dest_pos, -1); } - map_free(guesses_storage); - vec_free(guesses_history, (cb_free*)map_free); - s->guesses = NULL; + map_free(&guesses_storage); + vec_free(&guesses_history, (cb_free*)map_free); + s.guesses = NULL; return result; } diff --git a/src/asm/parse.h b/src/asm/parse.h index 5c07938..6f9acb5 100644 --- a/src/asm/parse.h +++ b/src/asm/parse.h @@ -1,5 +1,8 @@ #ifndef INCLUDED_PARSE #define INCLUDED_PARSE +#ifdef __cplusplus +extern "C" { +#endif /* * Copyright (c) 2005 Magnus Lind. @@ -8,9 +11,9 @@ * In no event will the authors be held liable for any damages arising from * the use of this software. * - * Permission is granted to anyone to use this software, alter it and re- - * distribute it freely for any non-commercial, non-profit purpose subject to - * the following restrictions: + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software in a @@ -22,15 +25,11 @@ * * 3. This notice may not be removed or altered from any distribution. * - * 4. The names of this software and/or it's copyright holders may not be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * */ #include "int.h" #include "vec.h" -#include "membuf.h" +#include "buf.h" #include "expr.h" #include "map.h" #include "named_buffer.h" @@ -91,9 +90,9 @@ void set_initial_symbol(const char *symbol, i32 value); void set_initial_symbol_soft(const char *symbol, i32 value); void initial_symbol_dump(int level, const char *symbol); -struct membuf *new_initial_named_buffer(const char *name); +struct buf *new_initial_named_buffer(const char *name); -int assemble(struct membuf *source, struct membuf *dest); +int assemble(struct buf *source, struct buf *dest); /* start of internal functions */ @@ -104,6 +103,7 @@ struct atom *new_exprs(struct expr *arg); struct atom *exprs_add(struct atom *atom, struct expr *arg); struct atom *exprs_to_byte_exprs(struct atom *atom); struct atom *exprs_to_word_exprs(struct atom *atom); +struct atom *text_to_byte_exprs(const char *text); struct atom *new_res(struct expr *len, struct expr *value); struct atom *new_incbin(const char *name, @@ -133,9 +133,12 @@ void asm_error(const char *msg); void asm_echo(const char *msg, struct atom *atom); void asm_include(const char *msg); -void output_atoms(struct membuf *out, struct vec *mem); -void asm_src_buffer_push(struct membuf *buf); +void output_atoms(struct buf *out, struct vec *mem); +void asm_src_buffer_push(struct buf *buf); -int assembleSinglePass(struct membuf *source, struct membuf *dest); +int assembleSinglePass(struct buf *source, struct buf *dest); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/asm/pc.c b/src/asm/pc.c index 396890a..d836e54 100644 --- a/src/asm/pc.c +++ b/src/asm/pc.c @@ -5,9 +5,9 @@ * In no event will the authors be held liable for any damages arising from * the use of this software. * - * Permission is granted to anyone to use this software, alter it and re- - * distribute it freely for any non-commercial, non-profit purpose subject to - * the following restrictions: + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software in a @@ -19,10 +19,6 @@ * * 3. This notice may not be removed or altered from any distribution. * - * 4. The names of this software and/or it's copyright holders may not be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * */ #include "pc.h" @@ -34,8 +30,8 @@ struct pc { int pc2; }; -static struct expr unset_value[1]; -static struct pc p[1] = {{unset_value, 0}}; +static struct expr unset_value; +static struct pc p = {&unset_value, 0}; void pc_dump(int level) { @@ -43,44 +39,44 @@ void pc_dump(int level) void pc_set(int pc) { - p->pc1 = NULL; - p->pc2 = pc; + p.pc1 = NULL; + p.pc2 = pc; } void pc_set_expr(struct expr *pc) { - p->pc1 = pc; - p->pc2 = 0; + p.pc1 = pc; + p.pc2 = 0; } struct expr *pc_get(void) { struct expr *old_pc1; - if(p->pc1 == unset_value) + if(p.pc1 == &unset_value) { LOG(LOG_ERROR, ("PC must be set by a .org(pc) call.\n")); exit(1); } - if(p->pc1 == NULL || p->pc2 != 0) + if(p.pc1 == NULL || p.pc2 != 0) { - old_pc1 = p->pc1; - p->pc1 = new_expr_number(p->pc2); - p->pc2 = 0; + old_pc1 = p.pc1; + p.pc1 = new_expr_number(p.pc2); + p.pc2 = 0; if(old_pc1 != NULL) { - p->pc1 = new_expr_op2(PLUS, p->pc1, old_pc1); + p.pc1 = new_expr_op2(PLUS, p.pc1, old_pc1); } } - return p->pc1; + return p.pc1; } void pc_add(int offset) { - if(p->pc1 != unset_value) + if(p.pc1 != &unset_value) { - p->pc2 += offset; + p.pc2 += offset; } } @@ -88,18 +84,18 @@ void pc_add_expr(struct expr *pc) { struct expr *old_pc1; - if(p->pc1 != unset_value) + if(p.pc1 != &unset_value) { - old_pc1 = p->pc1; - p->pc1 = pc; + old_pc1 = p.pc1; + p.pc1 = pc; if(old_pc1 != NULL) { - p->pc1 = new_expr_op2(PLUS, p->pc1, old_pc1); + p.pc1 = new_expr_op2(PLUS, p.pc1, old_pc1); } } } void pc_unset(void) { - pc_set_expr(unset_value); + pc_set_expr(&unset_value); } diff --git a/src/asm/pc.h b/src/asm/pc.h index 4b37820..6f0b618 100644 --- a/src/asm/pc.h +++ b/src/asm/pc.h @@ -1,5 +1,8 @@ #ifndef ALREADY_INCLUDED_PC #define ALREADY_INCLUDED_PC +#ifdef __cplusplus +extern "C" { +#endif /* * Copyright (c) 2004 Magnus Lind. @@ -8,9 +11,9 @@ * In no event will the authors be held liable for any damages arising from * the use of this software. * - * Permission is granted to anyone to use this software, alter it and re- - * distribute it freely for any non-commercial, non-profit purpose subject to - * the following restrictions: + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software in a @@ -22,10 +25,6 @@ * * 3. This notice may not be removed or altered from any distribution. * - * 4. The names of this software and/or it's copyright holders may not be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * */ #include "expr.h" @@ -38,4 +37,7 @@ void pc_add(int offset); void pc_add_expr(struct expr *pc); void pc_unset(void); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/asm/vec.c b/src/asm/vec.c index 5ba9213..54d70ca 100644 --- a/src/asm/vec.c +++ b/src/asm/vec.c @@ -5,9 +5,9 @@ * In no event will the authors be held liable for any damages arising from * the use of this software. * - * Permission is granted to anyone to use this software, alter it and re- - * distribute it freely for any non-commercial, non-profit purpose subject to - * the following restrictions: + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software in a @@ -19,10 +19,6 @@ * * 3. This notice may not be removed or altered from any distribution. * - * 4. The names of this software and/or it's copyright holders may not be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * */ #include "vec.h" @@ -32,9 +28,8 @@ void vec_init(struct vec *p, size_t elsize) { - //printf("vec_init %ld\n", elsize); p->elsize = elsize; - membuf_init(&p->buf); + buf_init(&p->buf); p->flags = VEC_FLAG_SORTED; } @@ -52,7 +47,7 @@ void vec_clear(struct vec *p, cb_free * f) f((void*)d); } } - membuf_clear(&p->buf); + buf_clear(&p->buf); p->flags = VEC_FLAG_SORTED; } @@ -60,24 +55,23 @@ void vec_clear(struct vec *p, cb_free * f) void vec_free(struct vec *p, cb_free * f) { vec_clear(p, f); - membuf_free(&p->buf); + buf_free(&p->buf); } -int vec_count(const struct vec *p) +int vec_size(const struct vec *p) { - //printf("vec_count %ld\n", p->elsize); - int count; - count = membuf_memlen(&p->buf) / p->elsize; - return count; + int size; + size = buf_size(&p->buf) / p->elsize; + return size; } void *vec_get(const struct vec *p, int index) { char *buf = NULL; - if(index < vec_count(p)) + if(index >= 0 && index < vec_size(p)) { - buf = (char *) membuf_get(&p->buf); + buf = (char *) buf_data(&p->buf); buf += index * p->elsize; } @@ -88,9 +82,10 @@ void *vec_set(struct vec *p, int index, const void *in) { void *buf = NULL; - if(index < vec_count(p)) + if(index >= 0 && index < vec_size(p)) { - buf = membuf_memcpy(&p->buf, index * p->elsize, in, p->elsize); + buf = buf_replace(&p->buf, index * p->elsize, p->elsize, + in, p->elsize); } return buf; @@ -98,22 +93,27 @@ void *vec_set(struct vec *p, int index, const void *in) void *vec_insert(struct vec *p, int index, const void *in) { - void *buf; - - buf = membuf_insert(&p->buf, index * p->elsize, in, p->elsize); + char *buf = NULL; + if(index >= 0 && index <= vec_size(p)) + { + buf = buf_replace(&p->buf, index * p->elsize, 0, in, p->elsize); + } return buf; } void vec_remove(struct vec *p, int index) { - membuf_remove(&p->buf, index * p->elsize, p->elsize); + if(index >= 0 && index < vec_size(p)) + { + buf_replace(&p->buf, index * p->elsize, p->elsize, NULL, 0); + } } void *vec_push(struct vec *p, const void *in) { void *out; - out = membuf_append(&p->buf, in, p->elsize); + out = buf_append(&p->buf, in, p->elsize); p->flags &= ~VEC_FLAG_SORTED; return out; @@ -128,7 +128,7 @@ int vec_find(const struct vec *p, cb_cmp * f, const void *in) { int hi; lo = 0; - hi = vec_count(p) - 1; + hi = vec_size(p) - 1; while(lo <= hi) { int next; @@ -197,7 +197,7 @@ int vec_insert_uniq(struct vec *p, cb_cmp * f, const void *in, void **outp) void vec_sort(struct vec *p, cb_cmp * f) { - qsort(membuf_get(&p->buf), vec_count(p), p->elsize, f); + qsort(buf_data(&p->buf), vec_size(p), p->elsize, f); p->flags |= VEC_FLAG_SORTED; } @@ -211,9 +211,10 @@ void vec_get_iterator(const struct vec *p, struct vec_iterator *i) void *vec_iterator_next(struct vec_iterator *i) { void *out; - int count = vec_count(i->vec); - if (i->pos >= count) + int size = vec_size(i->vec); + if (i->pos >= size) { + i->pos = 0; return NULL; } out = vec_get(i->vec, i->pos); @@ -223,12 +224,12 @@ void *vec_iterator_next(struct vec_iterator *i) void vec_fprint(FILE *f, const struct vec *a, cb_fprint *fprint) { - struct vec_iterator i[1]; + struct vec_iterator i; int *e; char *glue = "["; - vec_get_iterator(a, i); - while((e = vec_iterator_next(i)) != NULL) + vec_get_iterator(a, &i); + while((e = vec_iterator_next(&i)) != NULL) { fprintf(f, "%s", glue); fprint(f, e); @@ -239,19 +240,19 @@ void vec_fprint(FILE *f, const struct vec *a, cb_fprint *fprint) int vec_equals(const struct vec *a, const struct vec *b, cb_cmp *cmp) { - struct vec_iterator ia[1]; - struct vec_iterator ib[1]; + struct vec_iterator ia; + struct vec_iterator ib; void *ea; void *eb; int equal = 1; - vec_get_iterator(a, ia); - vec_get_iterator(b, ib); + vec_get_iterator(a, &ia); + vec_get_iterator(b, &ib); while(equal) { - ea = vec_iterator_next(ia); - eb = vec_iterator_next(ib); + ea = vec_iterator_next(&ia); + eb = vec_iterator_next(&ib); if(ea == NULL && eb == NULL) { diff --git a/src/asm/vec.h b/src/asm/vec.h index 6dc12f5..bdcae9a 100644 --- a/src/asm/vec.h +++ b/src/asm/vec.h @@ -1,5 +1,8 @@ #ifndef ALREADY_INCLUDED_VEC #define ALREADY_INCLUDED_VEC +#ifdef __cplusplus +extern "C" { +#endif /* * Copyright (c) 2003 - 2005 Magnus Lind. @@ -8,9 +11,9 @@ * In no event will the authors be held liable for any damages arising from * the use of this software. * - * Permission is granted to anyone to use this software, alter it and re- - * distribute it freely for any non-commercial, non-profit purpose subject to - * the following restrictions: + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software in a @@ -22,22 +25,18 @@ * * 3. This notice may not be removed or altered from any distribution. * - * 4. The names of this software and/or it's copyright holders may not be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * */ #include "callback.h" -#include "membuf.h" +#include "buf.h" #include #include -#define STATIC_VEC_INIT(EL_SIZE) {(EL_SIZE), STATIC_MEMBUF_INIT, 1} +#define STATIC_VEC_INIT(EL_SIZE) {(EL_SIZE), STATIC_BUF_INIT, 1} struct vec { size_t elsize; - struct membuf buf; + struct buf buf; int flags; }; @@ -50,14 +49,24 @@ void vec_init(struct vec *p, size_t elsize); void vec_clear(struct vec *p, cb_free * f); void vec_free(struct vec *p, cb_free * f); -int vec_count(const struct vec *p); +int vec_size(const struct vec *p); + +/** + * Returns a pointer to the item at the given index or NULL if the + * index is out of bounds. + **/ void *vec_get(const struct vec *p, int index); /** - * Returns a pointer to the set area or null if the index is out of + * Returns a pointer to the set item or NULL if the index is out of * bounds. **/ void *vec_set(struct vec *p, int index, const void *in); + +/** + * Returns a pointer to the inserted item or NULL if the index is out of + * bounds. + **/ void *vec_insert(struct vec *p, int index, const void *in); void vec_remove(struct vec *p, int index); @@ -73,7 +82,7 @@ int vec_find(const struct vec *p, cb_cmp * f, const void *key); /** * Gets a pointer to the element that the key points to. - * Returns a pointer that may be null if not found. + * Returns a pointer that may be NULL if not found. **/ void *vec_find2(const struct vec *p, cb_cmp * f, const void *key); @@ -86,10 +95,22 @@ void *vec_find2(const struct vec *p, cb_cmp * f, const void *key); int vec_insert_uniq(struct vec *p, cb_cmp * f, const void *in, void **out); void vec_sort(struct vec *p, cb_cmp * f); +/** + * Gets a restarting iterator for the given vector. + **/ void vec_get_iterator(const struct vec *p, struct vec_iterator *i); + +/** + * Gets a pointer to the next item from a resterting iterator. Returns + * NULL when all items has been enumerated. Will restart from the + * beginning if called again after returning NULL. + **/ void *vec_iterator_next(struct vec_iterator *i); int vec_equals(const struct vec *a, const struct vec *b, cb_cmp *equals); void vec_fprint(FILE *, const struct vec *a, cb_fprint *fprint); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/reloc.cpp b/src/reloc.cpp index 193c78d..65aa07c 100644 --- a/src/reloc.cpp +++ b/src/reloc.cpp @@ -39,7 +39,7 @@ #include "bme_snd.h" extern "C" { -#include "membuf.h" +#include "buf.h" #include "parse.h" } @@ -144,8 +144,8 @@ int nozerospeed; int ciaval; -struct membuf src = STATIC_MEMBUF_INIT; -struct membuf dest = STATIC_MEMBUF_INIT; +struct buf src = STATIC_BUF_INIT; +struct buf dest = STATIC_BUF_INIT; int testoverlap(int area1start, int area1size, int area2start, int area2size); @@ -259,8 +259,8 @@ void relocator() tableerror = 0; parse_init(); - membuf_free(&src); - membuf_free(&dest); + buf_free(&src); + buf_free(&dest); int maxChns = getMaxChannels(); @@ -1240,8 +1240,8 @@ void relocator() // Modify ghostregs to not be zeropage if needed if ((playerversion & PLAYER_FULLBUFFERED) && (playerversion & PLAYER_ZPGHOSTREGS) == 0) { - int bufsize = membuf_get_size(&src); - char* bufdata = (char*)membuf_get(&src); + int bufsize = buf_size(&src); + char* bufdata = (char*)buf_data(&src); for (int c = 0; c < bufsize; c++) { if (bufdata[c] == '<') @@ -1469,17 +1469,17 @@ void relocator() insertbytes(&pattwork[pattoffset[c]], pattsize[c]); } - { + /* { FILE *handle = std::fopen("debug.s", "wb"); - std::fwrite(membuf_get(&src), membuf_memlen(&src), 1, handle); + std::fwrite(buf_data(&src), buf_size(&src), 1, handle); std::fclose(handle); - } + } */ // Assemble; on error fail in a rude way (the parser does so too) if (assemble(&src, &dest)) exit(1); - packeddata = (unsigned char*)membuf_get(&dest); - packedsize = membuf_memlen(&dest); + packeddata = (unsigned char*)buf_data(&dest); + packedsize = buf_size(&dest); playersize = packedsize - songtblsize - songdatasize - patttblsize - pattdatasize - instrsize - wavetblsize - pulsetblsize - filttblsize - speedtblsize; // Copy author info @@ -1755,8 +1755,8 @@ void relocator() std::fclose(songhandle); PRCLEANUP: - membuf_free(&src); - membuf_free(&dest); + buf_free(&src); + buf_free(&dest); parse_free(); if (pattwork) std::free(pattwork); @@ -2033,7 +2033,7 @@ int insertfile(const char *name) io_lseek(handle, 0, SEEK_SET); while (size--) { - membuf_append_char(&src, io_read8(handle)); + buf_append_char(&src, io_read8(handle)); } io_close(handle); return 1; @@ -2041,7 +2041,7 @@ int insertfile(const char *name) void inserttext(const char *text) { - membuf_append(&src, text, std::strlen(text)); + buf_append(&src, text, std::strlen(text)); } void insertdefine(const char *name, int value) @@ -2329,8 +2329,8 @@ void relocator_stereo() tableerror = 0; parse_init(); - membuf_free(&src); - membuf_free(&dest); + buf_free(&src); + buf_free(&dest); // Process song-orderlists countpatternlengths(); @@ -3509,15 +3509,15 @@ void relocator_stereo() //{ // FILE *handle = std::fopen("debug.s", "wb"); - // std::fwrite(membuf_get(&src), membuf_memlen(&src), 1, handle); + // std::fwrite(buf_get(&src), buf_memlen(&src), 1, handle); // std::fclose(handle); //} // Assemble; on error fail in a rude way (the parser does so too) if (assemble(&src, &dest)) exit(1); - packeddata = (unsigned char*)membuf_get(&dest); - packedsize = membuf_memlen(&dest); + packeddata = (unsigned char*)buf_data(&dest); + packedsize = buf_size(&dest); playersize = packedsize - songtblsize - songdatasize - patttblsize - pattdatasize - instrsize - wavetblsize - pulsetblsize - filttblsize - speedtblsize; // Copy author info @@ -3794,8 +3794,8 @@ void relocator_stereo() std::fclose(songhandle); PRCLEANUP_S: - membuf_free(&src); - membuf_free(&dest); + buf_free(&src); + buf_free(&dest); parse_free(); if (pattwork) std::free(pattwork);