Mercurial > pasana
changeset 1:1361f218a6e5
2002-12-02
| author | Radomir Dopieralski <sheep-devel@sheep.art.pl> |
|---|---|
| date | Sat, 13 Oct 2012 21:11:54 +0200 |
| parents | 05867559af8e |
| children | ff5e493bc9cb |
| files | Makefile dict.c dict.h err.txt error.pas lexer.c lexer.h main.c parse_misc.c parse_misc.h parser.c parser.h pascal.l sample.pas symbols.c symbols.h token_test.c tokenize.c tokenize.h tp4.output tp4.tab.c tp4.tab.h tp4.y |
| diffstat | 23 files changed, 9015 insertions(+), 66 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Sat Oct 13 21:11:33 2012 +0200 +++ b/Makefile Sat Oct 13 21:11:54 2012 +0200 @@ -1,12 +1,46 @@ # Makefile for PasAna -YACC=bison -d +YACC=bison -v -d +CC=gcc +RM= rm -f + +OBJS=tp4.tab.o tokenize.o dict.o parser.o +PROG=pasana + +GLIB_CFLAGS=`glib-config --cflags` +GLIB_LIBS=`glib-config --libs` + +CFLAGS= -ggdb -Wall $(GLIB_CFLAGS) -DDEBUG +LIBS=$(GLIB_LIBS) +INCS=-I./ + +prog: $(OBJS) + $(CC) $(LIBS) $(OBJS) -o $(PROG) + +test: test_token sample.pas + ./test_token clean: - rm -f tp4.tab.c tp4.tab.h + $(RM) tp4.tab.c tp4.tab.h + $(RM) $(OBJS) + $(RM) $(PROG) + $(RM) test_token token_test.o tp4.tab.c: tp4.y $(YACC) tp4.y tp4.tab.h: tp4.y $(YACC) tp4.y + +.c.o: $*.c + $(CC) $(CFLAGS) $(INCS) -c $*.c -o $@ + +test_token: token_test.o tokenize.o + $(CC) $(LIBS) $^ -o $@ + +dict.o: dict.c dict.h tp4.tab.h +dict_test.o: dict_test.c dict.h +parser.o: parser.c dict.h tokenize.h tp4.tab.h parser.h +tokenize.o: tokenize.c tokenize.h +token_test.o: token_test.c tokenize.h +tp4.tab.o: tp4.tab.c parser.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dict.c Sat Oct 13 21:11:54 2012 +0200 @@ -0,0 +1,109 @@ + +#include <stdlib.h> +#include <stdio.h> +#include <ctype.h> +#include <glib.h> +#include "dict.h" +#include "tp4.tab.h" + +/* Słowa kluczowe są globalne. */ +//static GHashTable *keywords_tab; + +Dictionary * +newDictionary() +{ + Dictionary *dict; + + dict = g_new(Dictionary, 1); + dict->table = g_hash_table_new(g_str_hash, g_str_equal); + dict->locals = g_hash_table_new(g_str_hash, g_str_equal); + return dict; +} + +void +dictAdd(Dictionary * dict, DictEntry * entry) +{ + int i; + + /* Wszystkie sybole z wielkich liter. */ + for (i=0; entry->string[i]!='\0'; ++i) + entry->string[i] = toupper(entry->string[i]); + /* Sprawdzamy, czy taki symbol juz istnieje. */ + if (g_hash_table_lookup(dict->table, entry->string) != NULL) + return; + g_hash_table_insert(dict->table, entry->string, entry); +} + +void +dictAddLocal(Dictionary * dict, DictEntry * entry) +{ + int i; + + /* Wszystkie sybole z wielkich liter. */ + for (i=0; entry->string[i]!='\0'; ++i) + entry->string[i] = toupper(entry->string[i]); + /* Sprawdzamy, czy taki symbol juz istnieje. */ + if (g_hash_table_lookup(dict->locals, entry->string) != NULL) + return; + g_hash_table_insert(dict->locals, entry->string, entry); +} + +void +keywordsInit(Dictionary *dict) +{ + int i; + const static char *keywords_str[] = + {"AND", "ABSOLUTE", "ARRAY", "BEGIN", "CASE", "CONST", "DIV", "DOWNTO", "DO", "ELSE", "END", + "EXTERNAL", "FILE", "FORWARD", "FOR", "FUNCTION", "GOTO", "IF", "IMPLEMENTATION", + "INTERFACE", "IN", "LABEL", "MOD", "NIL", "NOT", "OF", "OR", "PACKED", "PROCEDURE", + "PROGRAM", "RECORD", "REPEAT", "SET", "SHL", "SHR", "STRING", "THEN", "TO", "TYPE", "UNIT", + "UNTIL", "USES", "VAR", "WHILE", "WITH", "XOR", "THEN", "ELSE", NULL}; + const static int keywords_tok[] = + {K_AND, K_ABSOLUTE, K_ARRAY, K_BEGIN, K_CASE, K_CONST, K_DIV, K_DOWNTO, K_DO, K_ELSE, K_END, + K_EXTERNAL, K_FILE, K_FORWARD, K_FOR, K_FUNCTION, K_GOTO, K_IF, K_IMPLEMENTATION, + K_INTERFACE, K_IN, K_LABEL, K_MOD, K_NIL, K_NOT, K_OF, K_OR, K_PACKED, K_PROCEDURE, + K_PROGRAM, K_RECORD, K_REPEAT, K_SET, K_SHL, K_SHR, K_STRING, K_THEN, K_TO, K_TYPE, K_UNIT, + K_UNTIL, K_USES, K_VAR, K_WHILE, K_WITH, K_XOR, K_THEN, K_ELSE, 0}; + + dict->keywords = g_hash_table_new(g_str_hash, g_str_equal); + for (i = 0; keywords_str[i] != NULL; ++i) { + g_hash_table_insert(dict->keywords, (char *)(keywords_str[i]), GINT_TO_POINTER(keywords_tok[i])); + } +} + +DictEntry * +dictLookup(Dictionary * dict, const char *word) +{ + DictEntry *entry; + char *upper; + int i; + + upper = g_strdup(word); + for (i=0; upper[i]!='\0'; ++i) + upper[i] = toupper(upper[i]); + entry = g_hash_table_lookup(dict->locals, upper); + if (entry==NULL) + entry = g_hash_table_lookup(dict->table, upper); + else + printf("Local variable!\n"); + g_free(upper); + return entry; +} + +int +keywordLookup(Dictionary *dict, const char *word) +{ + char *upper; + int i; + gpointer p; + + upper = g_strdup(word); + for (i=0; upper[i]!='\0'; ++i) + upper[i] = toupper(upper[i]); + p = g_hash_table_lookup(dict->keywords, upper); + g_free(upper); + if (p!=NULL) + return GPOINTER_TO_INT(p); + else + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dict.h Sat Oct 13 21:11:54 2012 +0200 @@ -0,0 +1,37 @@ +/* Slownik i tablice symboli. */ + +#ifndef DICT_H +#define DICT_H + +struct Dictionary { + GHashTable *locals; + GHashTable *table; + GHashTable *keywords; + /* Tu trzeba dodac rozne zakresy i inne takie. */ +}; +typedef struct Dictionary Dictionary; + +struct DictEntry { + char *string; /* Do jakiego stringa to ma byc hashowane. */ + int token; /* Rodzaj tokena do zwrocenia. */ + /* ... XXX tu musi byc wiecej jeszcze */ +}; +typedef struct DictEntry DictEntry; + +/* Szukanie symbolu w slowniku. */ +DictEntry *dictLookup(Dictionary * dict, const char *word); + +/* Wprowadzenie slow kluczowych. */ +void keywordsInit(Dictionary * dict); + +/* Dodanie symbolu do slownika. */ +void dictAdd(Dictionary * dict, DictEntry * entry); +void dictAddLocal(Dictionary * dict, DictEntry * entry); + +/* Wyszukiwanie slow kluczowych. */ +int keywordLookup(Dictionary * dict, const char *word); + +/* Utworzenie nowego slownika. */ +Dictionary *newDictionary(); + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/err.txt Sat Oct 13 21:11:54 2012 +0200 @@ -0,0 +1,336 @@ +Starting parse +Entering state 0 +Reading a token: token 296 (unit) +Next token is 296 (K_UNIT) +Shifting token 296 (K_UNIT), Entering state 2 +Reading a token: token 316 (Error) +Next token is 316 (ID_NAME) +Shifting token 316 (ID_NAME), Entering state 8 +Reading a token: token 59 (;) +Next token is 59 (';') +Shifting token 59 (';'), Entering state 15 +Reducing via rule 13 (line 166), K_UNIT ID_NAME ';' -> unit_heading +state stack now 0 +Entering state 6 +Reading a token: token 276 (interface) +Next token is 276 (K_INTERFACE) +Shifting token 276 (K_INTERFACE), Entering state 11 +Reading a token: token 285 (procedure) +Next token is 285 (K_PROCEDURE) +Reducing via rule 7 (line 124), -> uses_clause +state stack now 0 6 11 +Entering state 20 +Reducing via rule 39 (line 255), -> int_decl_sect_list +state stack now 0 6 11 20 +Entering state 46 +Next token is 285 (K_PROCEDURE) +Shifting token 285 (K_PROCEDURE), Entering state 31 +Reading a token: token 316 (ShowError) +Next token is 316 (ID_NAME) +Shifting token 316 (ID_NAME), Entering state 89 +Reducing via rule 121 (line 544), K_PROCEDURE ID_NAME -> proc_heading_beginning +state stack now 0 6 11 20 46 +Entering state 41 +Reading a token: token 40 (() +Next token is 40 ('(') +Shifting token 40 ('('), Entering state 97 +Reading a token: token 316 (Msg) +Next token is 316 (ID_NAME) +Shifting token 316 (ID_NAME), Entering state 16 +Reducing via rule 9 (line 135), ID_NAME -> id_name_list +state stack now 0 6 11 20 46 41 97 +Entering state 155 +Reading a token: token 58 (:) +Next token is 58 (':') +Shifting token 58 (':'), Entering state 238 +Reading a token: token 292 (string) +Next token is 292 (K_STRING) +Shifting token 292 (K_STRING), Entering state 241 +Reducing via rule 138 (line 609), K_STRING -> fptype +state stack now 0 6 11 20 46 41 97 155 238 +Entering state 289 +Reducing via rule 134 (line 590), id_name_list ':' fptype -> fp_sect +state stack now 0 6 11 20 46 41 97 +Entering state 157 +Reducing via rule 132 (line 586), fp_sect -> fp_sect_list +state stack now 0 6 11 20 46 41 97 +Entering state 156 +Reading a token: token 41 ()) +Next token is 41 (')') +Shifting token 41 (')'), Entering state 240 +Reducing via rule 131 (line 582), '(' fp_sect_list ')' -> fp_list +state stack now 0 6 11 20 46 41 +Entering state 98 +Reading a token: token 59 (;) +Next token is 59 (';') +Shifting token 59 (';'), Entering state 158 +Reducing via rule 125 (line 568), proc_heading_beginning fp_list ';' -> proc_heading +state stack now 0 6 11 20 46 +Entering state 109 +Reducing via rule 44 (line 263), proc_heading -> int_decl_sect +!!! Clearing local namespace! +state stack now 0 6 11 20 46 +Entering state 108 +Reducing via rule 40 (line 256), int_decl_sect_list int_decl_sect -> int_decl_sect_list +state stack now 0 6 11 20 +Entering state 46 +Reading a token: token 275 (implementation) +Next token is 275 (K_IMPLEMENTATION) +Reducing via rule 14 (line 172), K_INTERFACE uses_clause int_decl_sect_list -> interface_part +state stack now 0 6 +Entering state 12 +Next token is 275 (K_IMPLEMENTATION) +Shifting token 275 (K_IMPLEMENTATION), Entering state 21 +Reading a token: token 298 (uses) +Next token is 298 (K_USES) +Shifting token 298 (K_USES), Entering state 9 +Reading a token: token 316 (Crt) +Next token is 316 (ID_NAME) +Shifting token 316 (ID_NAME), Entering state 16 +Reducing via rule 9 (line 135), ID_NAME -> id_name_list +state stack now 0 6 12 21 9 +Entering state 17 +Reading a token: token 44 (,) +Next token is 44 (',') +Shifting token 44 (','), Entering state 25 +Reading a token: token 316 (Display) +Next token is 316 (ID_NAME) +Shifting token 316 (ID_NAME), Entering state 52 +Reducing via rule 10 (line 142), id_name_list ',' ID_NAME -> id_name_list +state stack now 0 6 12 21 9 +Entering state 17 +Reading a token: token 59 (;) +Next token is 59 (';') +Shifting token 59 (';'), Entering state 24 +Reducing via rule 8 (line 125), K_USES id_name_list ';' -> uses_clause +state stack now 0 6 12 21 +Entering state 47 +Reducing via rule 18 (line 195), -> decl_sect_list +state stack now 0 6 12 21 47 +Entering state 111 +Reading a token: token 285 (procedure) +Next token is 285 (K_PROCEDURE) +Shifting token 285 (K_PROCEDURE), Entering state 31 +Reading a token: token 309 (ShowError) +Next token is 309 (ID_PROC) +Shifting token 309 (ID_PROC), Entering state 88 +Reducing via rule 122 (line 549), K_PROCEDURE ID_PROC -> proc_heading_beginning +state stack now 0 6 12 21 47 111 +Entering state 41 +Reading a token: token 40 (() +Next token is 40 ('(') +Shifting token 40 ('('), Entering state 97 +Reading a token: token 316 (Msg) +Next token is 316 (ID_NAME) +Shifting token 316 (ID_NAME), Entering state 16 +Reducing via rule 9 (line 135), ID_NAME -> id_name_list +state stack now 0 6 12 21 47 111 41 97 +Entering state 155 +Reading a token: token 58 (:) +Next token is 58 (':') +Shifting token 58 (':'), Entering state 238 +Reading a token: token 292 (string) +Next token is 292 (K_STRING) +Shifting token 292 (K_STRING), Entering state 241 +Reducing via rule 138 (line 609), K_STRING -> fptype +state stack now 0 6 12 21 47 111 41 97 155 238 +Entering state 289 +Reducing via rule 134 (line 590), id_name_list ':' fptype -> fp_sect +state stack now 0 6 12 21 47 111 41 97 +Entering state 157 +Reducing via rule 132 (line 586), fp_sect -> fp_sect_list +state stack now 0 6 12 21 47 111 41 97 +Entering state 156 +Reading a token: token 41 ()) +Next token is 41 (')') +Shifting token 41 (')'), Entering state 240 +Reducing via rule 131 (line 582), '(' fp_sect_list ')' -> fp_list +state stack now 0 6 12 21 47 111 41 +Entering state 98 +Reading a token: token 59 (;) +Next token is 59 (';') +Shifting token 59 (';'), Entering state 158 +Reducing via rule 125 (line 568), proc_heading_beginning fp_list ';' -> proc_heading +state stack now 0 6 12 21 47 111 +Entering state 43 +Reading a token: token 260 (begin) +Next token is 260 (K_BEGIN) +Reducing via rule 18 (line 195), -> decl_sect_list +state stack now 0 6 12 21 47 111 43 +Entering state 19 +Next token is 260 (K_BEGIN) +Shifting token 260 (K_BEGIN), Entering state 27 +Reading a token: token 309 (WriteXY) +Next token is 309 (ID_PROC) +Shifting token 309 (ID_PROC), Entering state 60 +Reading a token: token 40 (() +Next token is 40 ('(') +Shifting token 40 ('('), Entering state 138 +Reading a token: token 317 (1) +Next token is 317 (CONST_INT) +Shifting token 317 (CONST_INT), Entering state 117 +Reducing via rule 214 (line 760), CONST_INT -> factor +state stack now 0 6 12 21 47 111 43 19 27 60 138 +Entering state 130 +Reducing via rule 204 (line 749), factor -> term +state stack now 0 6 12 21 47 111 43 19 27 60 138 +Entering state 129 +Reading a token: token 44 (,) +Next token is 44 (',') +Reducing via rule 197 (line 741), term -> simple_expr +state stack now 0 6 12 21 47 111 43 19 27 60 138 +Entering state 128 +Next token is 44 (',') +Reducing via rule 188 (line 733), simple_expr -> expr +state stack now 0 6 12 21 47 111 43 19 27 60 138 +Entering state 200 +Reducing via rule 156 (line 647), expr -> expr_list +state stack now 0 6 12 21 47 111 43 19 27 60 138 +Entering state 199 +Next token is 44 (',') +Shifting token 44 (','), Entering state 264 +Reading a token: token 317 (25) +Next token is 317 (CONST_INT) +Shifting token 317 (CONST_INT), Entering state 117 +Reducing via rule 214 (line 760), CONST_INT -> factor +state stack now 0 6 12 21 47 111 43 19 27 60 138 199 264 +Entering state 130 +Reducing via rule 204 (line 749), factor -> term +state stack now 0 6 12 21 47 111 43 19 27 60 138 199 264 +Entering state 129 +Reading a token: token 44 (,) +Next token is 44 (',') +Reducing via rule 197 (line 741), term -> simple_expr +state stack now 0 6 12 21 47 111 43 19 27 60 138 199 264 +Entering state 128 +Next token is 44 (',') +Reducing via rule 188 (line 733), simple_expr -> expr +state stack now 0 6 12 21 47 111 43 19 27 60 138 199 264 +Entering state 304 +Reducing via rule 157 (line 648), expr_list ',' expr -> expr_list +state stack now 0 6 12 21 47 111 43 19 27 60 138 +Entering state 199 +Next token is 44 (',') +Shifting token 44 (','), Entering state 264 +Reading a token: token 319 (Error: ) +Next token is 319 (CONST_STRING) +Shifting token 319 (CONST_STRING), Entering state 119 +Reducing via rule 216 (line 764), CONST_STRING -> factor +state stack now 0 6 12 21 47 111 43 19 27 60 138 199 264 +Entering state 130 +Reducing via rule 204 (line 749), factor -> term +state stack now 0 6 12 21 47 111 43 19 27 60 138 199 264 +Entering state 129 +Reading a token: token 43 (+) +Next token is 43 ('+') +Reducing via rule 197 (line 741), term -> simple_expr +state stack now 0 6 12 21 47 111 43 19 27 60 138 199 264 +Entering state 128 +Next token is 43 ('+') +Shifting token 43 ('+'), Entering state 179 +Reducing via rule 200 (line 746), '+' -> addop +state stack now 0 6 12 21 47 111 43 19 27 60 138 199 264 128 +Entering state 184 +Reading a token: token 310 (Msg) +Next token is 310 (ID_VAR) +Shifting token 310 (ID_VAR), Entering state 61 +Reducing via rule 183 (line 722), ID_VAR -> variable +state stack now 0 6 12 21 47 111 43 19 27 60 138 199 264 128 184 +Entering state 126 +Reading a token: token 41 ()) +Next token is 41 (')') +Reducing via rule 213 (line 759), variable -> factor +state stack now 0 6 12 21 47 111 43 19 27 60 138 199 264 128 184 +Entering state 130 +Reducing via rule 204 (line 749), factor -> term +state stack now 0 6 12 21 47 111 43 19 27 60 138 199 264 128 184 +Entering state 255 +Next token is 41 (')') +Reducing via rule 199 (line 743), simple_expr addop term -> simple_expr +state stack now 0 6 12 21 47 111 43 19 27 60 138 199 264 +Entering state 128 +Next token is 41 (')') +Reducing via rule 188 (line 733), simple_expr -> expr +state stack now 0 6 12 21 47 111 43 19 27 60 138 199 264 +Entering state 304 +Reducing via rule 157 (line 648), expr_list ',' expr -> expr_list +state stack now 0 6 12 21 47 111 43 19 27 60 138 +Entering state 199 +Next token is 41 (')') +Shifting token 41 (')'), Entering state 263 +Reducing via rule 155 (line 643), '(' expr_list ')' -> param_list +state stack now 0 6 12 21 47 111 43 19 27 60 +Entering state 139 +Reducing via rule 153 (line 637), ID_PROC param_list -> proc_call +state stack now 0 6 12 21 47 111 43 19 27 +Entering state 69 +Reducing via rule 143 (line 621), proc_call -> unlabelled_stmt +state stack now 0 6 12 21 47 111 43 19 27 +Entering state 67 +Reducing via rule 139 (line 614), unlabelled_stmt -> stmt +state stack now 0 6 12 21 47 111 43 19 27 +Entering state 66 +Reducing via rule 160 (line 660), stmt -> stmt_list +state stack now 0 6 12 21 47 111 43 19 27 +Entering state 72 +Reading a token: token 59 (;) +Next token is 59 (';') +Shifting token 59 (';'), Entering state 143 +Reading a token: token 267 (end) +Next token is 267 (K_END) +Reducing via rule 141 (line 619), -> unlabelled_stmt +state stack now 0 6 12 21 47 111 43 19 27 72 143 +Entering state 67 +Reducing via rule 139 (line 614), unlabelled_stmt -> stmt +state stack now 0 6 12 21 47 111 43 19 27 72 143 +Entering state 203 +Reducing via rule 161 (line 661), stmt_list ';' stmt -> stmt_list +state stack now 0 6 12 21 47 111 43 19 27 +Entering state 72 +Next token is 267 (K_END) +Shifting token 267 (K_END), Entering state 142 +Reducing via rule 159 (line 656), K_BEGIN stmt_list K_END -> compound_stmt +state stack now 0 6 12 21 47 111 43 19 +Entering state 45 +Reducing via rule 11 (line 153), decl_sect_list compound_stmt -> block +state stack now 0 6 12 21 47 111 43 +Entering state 102 +Reducing via rule 127 (line 576), block -> proc_block +state stack now 0 6 12 21 47 111 43 +Entering state 103 +Reading a token: token 59 (;) +Next token is 59 (';') +Shifting token 59 (';'), Entering state 160 +Reducing via rule 119 (line 524), proc_heading proc_block ';' -> proc_decl +!!! Clearing local namespace! +state stack now 0 6 12 21 47 111 +Entering state 39 +Reducing via rule 24 (line 204), proc_decl -> decl_sect +state stack now 0 6 12 21 47 111 +Entering state 34 +Reducing via rule 19 (line 196), decl_sect_list decl_sect -> decl_sect_list +state stack now 0 6 12 21 47 +Entering state 111 +Reading a token: token 267 (end) +Next token is 267 (K_END) +Reducing via rule 15 (line 178), K_IMPLEMENTATION uses_clause decl_sect_list -> implementation_part +state stack now 0 6 12 +Entering state 22 +Next token is 267 (K_END) +Shifting token 267 (K_END), Entering state 48 +Reducing via rule 17 (line 187), K_END -> initialization_part +state stack now 0 6 12 22 +Entering state 49 +Reading a token: token 46 (.) +Next token is 46 ('.') +Shifting token 46 ('.'), Entering state 112 +Reducing via rule 12 (line 160), unit_heading interface_part implementation_part initialization_part '.' -> unit +state stack now 0 +Entering state 5 +Reducing via rule 2 (line 103), unit -> compilation_unit +state stack now 0 +Entering state 391 +Reading a token: token 0 () +Now at end of input. +Shifting token 0 ($), Entering state 392 +Now at end of input.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/error.pas Sat Oct 13 21:11:54 2012 +0200 @@ -0,0 +1,21 @@ + +{ Copyright (c) 1985, 1989 by Borland International, Inc. } + +unit Error; +{ Sample unit for CIRCULAR.PAS } + +interface + +procedure ShowError(Msg : string); + +implementation + +uses + Crt, Display; + +procedure ShowError(Msg : string); +begin + WriteXY(1, 25, 'Error: ' + Msg); +end; + +end.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lexer.c Sat Oct 13 21:11:54 2012 +0200 @@ -0,0 +1,85 @@ +/* Funkcje wymagane przez Bisona i uzywane wewnatrz parsera. */ + +#include <stdlib.h> +#include <stdio.h> +#include <glib.h> + +#include "symbol.h" +#include "tokenize.h" +#include "tp4.tab.h" +#include "parser.h" +#include "lexer.h" + +int +get_token(Parser *parser, YYSTYPE (*lvalp)) +{ + Symbol *sym; + DictEntry *entry; + int temp; + + for (;;) + switch (getNextToken(parser->tok)) { + case TOKEN_CHAR: + return parser->tok->buf->str[0]; + case TOKEN_EOF: + return 0; + case TOKEN_INT: + case TOKEN_HEX: + (*lvalp).const_int = atoi(parser->tok->buf->str); + return CONST_INT; + case TOKEN_REAL: + case TOKEN_ENG: + (*lvalp).const_real = atof(parser->tok->buf->str); + return CONST_REAL; + case TOKEN_STRING: + (*lvalp).string = parser->tok->buf->str; + return CONST_STRING; + case TOKEN_DEFEQ: + return OP_DEFEQ; + case TOKEN_DOTDOT: + return OP_DOTDOT; + case TOKEN_LEQ: + return OP_LEQ; + case TOKEN_GEQ: + return OP_GEQ; + case TOKEN_NEQ: + return OP_NEQ; + case TOKEN_NAME: + temp = findKeyword(parser, parser->tok->buf->str); + if (temp != 0) + return temp; + sym = findSymbol(parser, parser->tok->buf->str); + if (sym != NULL) { + (*lvalp).symbol = sym; + return sym->token; + } + (*lvalp).string = parser->tok->buf->str; + return ID_NAME; + case TOKEN_COMMENT: + /* Nothing */ + break; + case TOKEN_ERROR: + break; + default: + return 0; + } +} + + +int +yylex (YYSTYPE *lvalp, Parser *parser) +{ + int token; + + token = get_token(parser, lvalp); +#ifdef DEBUG + fprintf(stderr, "token %d (%s)\n", token, parser->tok->buf->str); +#endif + return token; +} + +void +yyerror(char *msg) +{ + fprintf(stderr, "%s\n", msg); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lexer.h Sat Oct 13 21:11:54 2012 +0200 @@ -0,0 +1,9 @@ +#ifndef LEXER_H +#define LEXER_H + +/* Skaner leksykalny. */ +int yylex (YYSTYPE *lvalp, Parser *parser); + +/* Obsluga bledow. */ +void yyerror(char *msg); +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.c Sat Oct 13 21:11:54 2012 +0200 @@ -0,0 +1,43 @@ +/* Funkcje wymagane przez Bisona i uzywane wewnatrz parsera. */ + +#include <stdlib.h> +#include <stdio.h> +#include <glib.h> + +#include "symbol.h" +#include "tokenize.h" +#include "tp4.tab.h" +#include "parser.h" + +/* To jest w tp4.tab.c */ +int yyparse(); +extern int yydebug; + + +int +main(int argc, char *argv[]) +{ + Parser *parser; + + if (argc<2) + parser = newParser("sample.pas"); + else + parser = newParser(argv[1]); + + /* Tymczasowo, potem to bedzie w unicie 'system'. */ + registerType(parser, "integer"); + registerType(parser, "real"); + registerType(parser, "char"); + + registerProc(parser, "write"); + registerProc(parser, "writexy"); + registerProc(parser, "writeln"); + + registerFunc(parser, "read"); + registerFunc(parser, "readln"); + +#ifdef DEBUG + yydebug = TRUE; +#endif + return yyparse(parser); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/parse_misc.c Sat Oct 13 21:11:54 2012 +0200 @@ -0,0 +1,41 @@ +/* Rozne procedury uzywane przez parsera. */ + +#include <glib.h> +#include "parser.h" +#include "parse_misc.h" + +/* Wyszukuje slowo kluczowe. */ +int +findKeyword(Parser *parser, const char *word) +{ + GString *upper; + gpointer p; + + upper = g_string_new(word); + upper = g_string_up(upper); + p = g_hash_table_lookup(parser->keywords, (gpointer)(upper->str)); + g_string_free(upper); + if (p!=NULL) + return GPOINTER_TO_INT(p); + else + return 0; +} + +Symbol * +findSymbol(Parser *parser, const char *name) +{ + Symbol *sym; + Namespace *nam; + + nam = parser->actual; + while (nam!=NULL) { + sym = getSymbol(parser->nam, name); + if (sym!=NULL) + return sym; + if (nam->owner!=NULL) + nam = nam->owner->contained; + else + nam = NULL; + } + return nam; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/parse_misc.h Sat Oct 13 21:11:54 2012 +0200 @@ -0,0 +1,8 @@ +#ifndef PARSE_MISC_H +#define PARSE_MISC_H + +/* Wyszukuje slowo kluczowe. */ +int +findKeyword(Parser *parser, const char *word) + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/parser.c Sat Oct 13 21:11:54 2012 +0200 @@ -0,0 +1,62 @@ +/* Funkcje wymagane przez Bisona i uzywane wewnatrz parsera. */ + +#include <stdlib.h> +#include <stdio.h> +#include <glib.h> + +#include "symbols.h" +#include "tokenize.h" +#include "tp4.tab.h" +#include "parser.h" + +/* Wpisuje do tablicy slowa kluczowe. */ +void +initKeywords(Parser * parser) +{ + int i; + const static char *keywords_str[] = + { "AND", "ABSOLUTE", "ARRAY", "BEGIN", "CASE", "CONST", "DIV", "DOWNTO", "DO", "ELSE", +"END", "EXTERNAL", "FILE", "FORWARD", "FOR", "FUNCTION", "GOTO", "IF", "IMPLEMENTATION", "INTERFACE", "IN", "LABEL", +"MOD", "NIL", "NOT", "OF", "OR", "PACKED", "PROCEDURE", "PROGRAM", "RECORD", "REPEAT", "SET", "SHL", "SHR", "STRING", +"THEN", "TO", "TYPE", "UNIT", "UNTIL", "USES", "VAR", "WHILE", "WITH", "XOR", "THEN", "ELSE", NULL }; + const static int keywords_tok[] = + { K_AND, K_ABSOLUTE, K_ARRAY, K_BEGIN, K_CASE, K_CONST, K_DIV, K_DOWNTO, K_DO, K_ELSE, +K_END, K_EXTERNAL, K_FILE, K_FORWARD, K_FOR, K_FUNCTION, K_GOTO, K_IF, K_IMPLEMENTATION, K_INTERFACE, K_IN, K_LABEL, +K_MOD, K_NIL, K_NOT, K_OF, K_OR, K_PACKED, K_PROCEDURE, K_PROGRAM, K_RECORD, K_REPEAT, K_SET, K_SHL, K_SHR, K_STRING, +K_THEN, K_TO, K_TYPE, K_UNIT, K_UNTIL, K_USES, K_VAR, K_WHILE, K_WITH, K_XOR, K_THEN, K_ELSE, 0 }; + + for (i = 0; keywords_str[i] != NULL; ++i) { + g_hash_table_insert(parser->keywords, (char *)(keywords_str[i]), + GINT_TO_POINTER(keywords_tok[i])); + } +} + +/* Tworzy nowy parser. */ +Parser * +newParser(const char *filename) +{ + Parser *parser; + + parser = g_new(Parser, 1); + parser->filename = g_string_new(filename); + parser->global = newNamespace(NULL); + parser->actual = parser->global; + + parser->tok = newTokenizer(filename); + parser->keywords = g_hash_table_new(g_str_hash, g_str_equal); + initKeywords(parser); + return parser; +} + +/* Niszczy parser. */ +void +destroyParser(Parser * parser) +{ + g_string_free(parser->filename, TRUE); + destroyNamespace(parser->global); + + destroyTokenizer(parser->tok); + g_hash_table_destroy(parser->keywords); + g_free(parser); + parser = NULL; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/parser.h Sat Oct 13 21:11:54 2012 +0200 @@ -0,0 +1,20 @@ +/* Struktura parsera. */ + +#ifndef PARSER_H +#define PARSER_H + +struct Parser { + GString *filename; /* Nazwa pliku zrodlowego. */ + GHashTable *keywords; /* Tablica slow kluczowych. */ + Namespace *global; /* Globalna przestrzen nazw. */ + Namespace *actual; /* Aktualna przestrzen nazw. */ + Tokenizer *tok; /* Tokenizer. */ +}; +typedef struct Parser Parser; + +/* Tworzy nowy parser. */ +Parser *newParser(const char *filename); + +/* Niszczy parser. */ +void destroyParser(Parser * parser); +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pascal.l Sat Oct 13 21:11:54 2012 +0200 @@ -0,0 +1,101 @@ +/* Tokenizer dla jezyka Turbo Pascal */ + +%{ + #include "pascal.tab.h" +%} + +%option noyywrap case-insensitive never-interactive 8bit verbose debug batch nointeractive + +SPC [ \t\v\r] +DIG [0-9] +NUM {DIG}+ +HEX [0-9a-f] +ID1ST [_a-z] +IDNTH [_a-z0-9] +SIGN [+-] +CTRL "^"[@a-z\[\]\\] +CHASH ("#"{DIG}{1,3})|("#$"{HEX}{1,2}) +QTEXT [^'\n]|"''" +COMMENT ("{"[^}]*"}")|("(*"([^*]|"*"[^)*]|"**"[^)])*"*)") + +%% + +{ID1ST}{IDNTH}* { + /* Identyfikator lub slowo kluczowe */ + return ID_NAME; + } +{NUM} { + /* Stala calkowita */ + printf("INT_CONST <%s>\n", yytext); + } +({NUM}"."{NUM})|({NUM}("."{NUM})?"e"{SIGN}?{NUM}) { + /* Stala zmiennoprzecinkowa */ + printf("REAL_CONST <%s>\n", yytext); + } +"$"{HEX}+ { + /* Stala szesnastkowa */ + printf("HEX_CONST <%s>\n", yytext); + } +("'"{QTEXT}"'")|{CTRL}|{CHASH} { + /* Stala znakowa (pojedynczy znak) */ + printf("CHAR_CONST <%s>\n", yytext); + } +(("'"{QTEXT}*"'")|{CTRL}|{CHASH})+ { + /* Stala lancuchowa */ + printf("STR_CONST <%s>\n", yytext); + } +^{SPC}*{COMMENT}(({SPC}|\n)*{COMMENT})* { + /* Komentarz blokowy XXX trzeba policzyc konce linii! */ + printf("BLOCK_COMMENT <%s>\n", yytext); + } +{COMMENT}({SPC}*{COMMENT})* { + /* Komentarz zwykly typu {...} lub (*...*) */ + printf("COMMENT <%s>\n", yytext); + } +":=" { + /* Symbole dwuznakowe */ + printf("TWOCHAR <%s>\n", yytext); + } +"<>" { + /* Symbole dwuznakowe */ + printf("TWOCHAR <%s>\n", yytext); + } +"<=" { + /* Symbole dwuznakowe */ + printf("TWOCHAR <%s>\n", yytext); + } + +">=" { + /* Symbole dwuznakowe */ + printf("TWOCHAR <%s>\n", yytext); + } + +".." { + /* Symbole dwuznakowe */ + printf("TWOCHAR <%s>\n", yytext); + } + +"(."|"[" { + printf("CHARACTER <[>\n"); + } + +".)"|"]" { + printf("CHARACTER <]>\n"); + } +[-+*/=^<>().,:;'@] { + /* Pojedyncze dozwolone symbole */ + printf("CHARACTER <%s>\n", yytext); + } +{SPC}+ { /* Pomijanie odstepow */ } +\n { /* Liczenie linii */ } +. { + /* Bledy: znaki takie, jak &%~`{}\"?! */ + printf("ILLEGAL <%s>\n", yytext); + } +%% +/* +<<EOF>> { + printf("EOF <%s>\n", yytext); + return; + } +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sample.pas Sat Oct 13 21:11:54 2012 +0200 @@ -0,0 +1,16 @@ +PROGRAM Sample; + +{ Comment 1 *) } +(* Comment 2 } *) + +PROCEDURE Smpl_1; +VAR v: integer; +BEgIN + v := (1+2)*2; +END; + +BEGIN + IF (1 >= $02) THEN BEGIN + END; + WriteLn('Hello world!'^I''''#64 + 'Hi!'); +END.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/symbols.c Sat Oct 13 21:11:54 2012 +0200 @@ -0,0 +1,113 @@ +/* Obsluga przestrzeni nazw i symboli. */ + +#include <glib.h> +#include "symbols.h" + +/* Tworzy nowa przestrzen nazw o podanym wlascicielu. */ +Namespace * +newNamespace(Symbol * owner) +{ + Namespace *nam; + + nam = g_new(Namespace, 1); + nam->owner = owner; + nam->table = g_hash_table_new(g_str_hash, g_str_equal); + return nam; +} + +/* niszczy poszczegolne elementy tablicy w przestrzeni nazw. */ +void +foreachDestroyNamespace(gpointer name, gpointer symbol, gpointer user_data) +{ + destroySymbol(symbol); + g_free(name); +} + +/* Niszczy przestrzen nazw. */ +void +destroyNamespace(Namespace * nam) +{ + if (nam == NULL) + return; + g_hash_table_foreach(nam->table, foreachDestroyNamespace, NULL); + g_hash_table_destroy(nam->table); + g_free(nam); + nam = NULL; +} + +/* Tworzy nowy symbol. */ +Symbol * +newSymbol(const char *name, int token, Type * type) +{ + Symbol *sym; + + sym = g_new(Symbol, 1); + sym->name = g_string_new(name); + sym->contained = NULL; + sym->namespace = NULL; + sym->token = token; + sym->type = type; + return sym; +} + +/* Niszczy symbol (nie usuwa go z przestrzeni nazw!) */ +void +destroySymbol(Symbol * sym) +{ + if (sym == NULL) + return; + g_string_free(sym->name, TRUE); + destroyNamespace(sym->namespace); + destroyType(sym->type); + g_free(sym); + sym = NULL; +} + +/* Tworzy nowy opis typu. */ +Type * +newType(Symbol * base) +{ + Type *type; + + type = g_new(Type, 1); + type->base = base; + type->mods = g_string_new(""); + return type; +} + +/* Niszczy opis typu. */ +void +destroyType(Type * type) +{ + if (type == NULL) + return; + g_string_free(type->mods, TRUE); + g_free(type); +} + +/* Dodaje symbol do przestrzeni nazw. */ +void +addSymbol(Namespace * nam, Symbol * sym) +{ + GString *key; + + key = g_string_new(sym->name->str); + key = g_string_up(key); + g_hash_table_insert(nam->table, (gpointer) (key->str), (gpointer) sym); + g_string_free(key, FALSE); + sym->contained = nam; +} + +/* Wyszukuje symbol w przestrzeni nazw. */ +Symbol* +getSymbol(Namespace * nam, char *name) +{ + Symbol *sym; + GString *key; + + key = g_string_new(name); + key = g_string_up(key); + sym = g_hash_table_lookup(nam->table, (gpointer) (key->str)); + g_string_free(key, TRUE); + return sym; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/symbols.h Sat Oct 13 21:11:54 2012 +0200 @@ -0,0 +1,51 @@ +#ifndef SYMBOLS_H +#define SYMBOLS_H + +/* Opis typu symbolu. */ +struct Type { + Symbol *base; /* Typ bazowy. */ + GString *mods; /* Informacje o wskaznikach, tablicach, plikach itp. */ +}; +typedef struct Type Type; + +/* Opis symbolu. */ +struct Symbol { + GString *name; /* Oryginalna nazwa symbolu (z zachowana wielkoscia liter). */ + Namespace *contained; /* Do jakiej przestrzeni nalezy ten symbol. */ + Namespace *namespace; /* Wlasna przestrzen nazw. */ + int token; /* Jakiego jest typu (jaki zwraca token). */ + Type *type; /* Jakiego jest typu. */ +}; +typedef struct Symbol Symbol; + +/* Przestrzen nazw. */ +struct Namespace { + Symbol *owner; /* Do jakiego symbolu nalezy ta przestrzen. */ + GHashTable *table; /* Tablica symboli. */ +}; +typedef struct Namespace Namespace; + +/* Tworzy nowa przestrzen nazw o podanym wlascicielu. */ +Namespace *newNamespace(Symbol * owner); + +/* Niszczy przestrzen nazw. */ +void destroyNamespace(Namespace * nam); + +/* Tworzy nowy symbol. */ +Symbol *newSymbol(const char *name, int token, Type * type); + +/* Niszczy symbol (nie usuwa go z przestrzeni nazw!) */ +void destroySymbol(Symbol * sym); + +/* Tworzy nowy opis typu. */ +Type *newType(Symbol * base); + +/* Niszczy opis typu. */ +void destroyType(Type * type); + +/* Dodaje symbol do przestrzeni nazw. */ +void addSymbol(Namespace * nam, Symbol * sym); + +/* Wyszukuje symbol w przestrzeni nazw. */ +Symbol *getSymbol(Namespace * nam, char *name); +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/token_test.c Sat Oct 13 21:11:54 2012 +0200 @@ -0,0 +1,18 @@ +#include <stdlib.h> +#include <stdio.h> +#include <glib.h> +#include "tokenize.h" + +/* Prosty programik testujacy tokenizera. */ +int +main(int argc, char *argv[]) +{ + Tokenizer *tok; + + tok = newTokenizer("sample.pas"); + while (getNextToken(tok) != TOKEN_EOF) { + printf("type: %d, string: (%s)\n", tok->type, tok->buf->str); + } + destroyTokenizer(tok); + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tokenize.c Sat Oct 13 21:11:54 2012 +0200 @@ -0,0 +1,338 @@ +#include <stdlib.h> +#include <stdio.h> +#include <glib.h> +#include <ctype.h> + +#include "tokenize.h" + +/* Tworzy nowego tokenizera. */ +Tokenizer * +newTokenizer(const char *filename) +{ + FILE *f; + Tokenizer *tok; + + f = fopen(filename, "r"); + if (f == NULL) + return NULL; + tok = g_new(Tokenizer, 1); + tok->source = f; + tok->bufpos = 0; + tok->filename = g_strdup(filename); + tok->line = 1; + tok->position = 0; + tok->c = '\0'; + tok->putback = '\0'; + tok->buf = g_string_sized_new(32); + return tok; +} + +/* Niszczy tokenizera. */ +void +destroyTokenizer(Tokenizer * tok) +{ + g_string_free(tok->buf, TRUE); + fclose(tok->source); + g_free(tok->filename); + g_free(tok); + return; +} + +/* Czyta pojedynczy znak. Ustawia position i line. */ +unsigned int +getTokenizerChar(Tokenizer * tok) +{ + if (tok->putback == '\0') { + tok->c = fgetc(tok->source); + if (tok->c == '\n') + ++(tok->line); + ++(tok->position); + } else { + tok->c = tok->putback; + tok->putback = '\0'; + } + return tok->c; +} + +/* Dodaje znaczek do bufora. */ +void +putTokenizerChar(Tokenizer * tok, char c) +{ +#if 0 + tok->buffer[tok->bufpos] = c; + if (tok->bufpos < TOKEN_SIZE - 1) + ++(tok->bufpos); +#endif + tok->buf = g_string_append_c(tok->buf, c); + return; +} + +/* Parsuje wyrazenia typu 'kflhgla''ajgkl' do stringa */ +void +TokenizeQuotes(Tokenizer * tok) +{ + for (;;) { + if (getTokenizerChar(tok) == '\'') { + if (getTokenizerChar(tok) != '\'') + return; + } + putTokenizerChar(tok, tok->c); + } +} + +/* Parsuje wyrazenia typu #123 do stringa */ +void +TokenizeHash(Tokenizer * tok) +{ + int code; + GString *buf; + + buf = g_string_sized_new(16); + if (tok->c != '#') + return; + while (isdigit(getTokenizerChar(tok))) { + buf = g_string_append_c(buf, tok->c); + } + code = atoi(buf->str); + putTokenizerChar(tok, code); + g_string_free(buf, TRUE); + return; +} + +/* Parsuje wyrazenia typu ^C do stringa */ +void +TokenizeCtrl(Tokenizer * tok) +{ + int code; + + tok->c = toupper(tok->c); + code = (tok->c - 'A') + 1; + putTokenizerChar(tok, code); + getTokenizerChar(tok); + return; +} + +/* Wczytuje do tokenizera nastepny token. */ +enum TOKEN_TYPE +getNextToken(Tokenizer * tok) +{ + + /* Nie czytamy z pustego tokenizera. */ + if (tok == NULL) + return TOKEN_EOF; + /* Oprozniamy bufor. */ + tok->buf = g_string_truncate(tok->buf, 0); + tok->bufpos = 0; + /* Wczytujemy pierwszy znak z pliku. */ + if (tok->c == '\0') + getTokenizerChar(tok); + + /* Pomijamy odstepy. */ + while (isspace(tok->c)) + getTokenizerChar(tok); + + /* Maszyna stanow (automaton) */ + if (isdigit(tok->c)) { + /* Jesli zaczyna sie od cyfry... */ + putTokenizerChar(tok, tok->c); + while (isdigit(getTokenizerChar(tok))) { + putTokenizerChar(tok, tok->c); + } + /* Koniec cyfr. */ + if (tok->c == '.') { + /* Jeszcze czesc ulamkowa. */ + /* Uwaga! Ta kropka moze byc od '..'! */ + getTokenizerChar(tok); + if (isdigit(tok->c)) { + putTokenizerChar(tok, '.'); + putTokenizerChar(tok, tok->c); + while (isdigit(getTokenizerChar(tok))) { + putTokenizerChar(tok, tok->c); + } + putTokenizerChar(tok, '\0'); + tok->type = TOKEN_REAL; + return tok->type; + } else { + /* To nie byla jednak kropka od ulamka. */ + tok->putback = tok->c; + tok->c = '.'; + putTokenizerChar(tok, '\0'); + tok->type = TOKEN_INT; + return tok->type; + } + } else if (toupper(tok->c) == 'E') { + /* Jeszcze znak i potega po 'e'. */ + putTokenizerChar(tok, 'e'); + getTokenizerChar(tok); + if ((tok->c == '+') || (tok->c == '-') || (isdigit(tok->c))) { + putTokenizerChar(tok, tok->c); + } else { + putTokenizerChar(tok, '\0'); + tok->type = TOKEN_ERROR; + return tok->type; + } + while (isdigit(getTokenizerChar(tok))) { + putTokenizerChar(tok, tok->c); + } + putTokenizerChar(tok, '\0'); + tok->type = TOKEN_ENG; + return tok->type; + } + /* Ewentualnie moze to byc tylko liczba calkowita. */ + putTokenizerChar(tok, '\0'); + tok->type = TOKEN_INT; + return tok->type; + } else if (isalpha(tok->c) || (tok->c == '_')) { + /* Mamy identyfikator. */ + putTokenizerChar(tok, tok->c); + while (isalnum(getTokenizerChar(tok)) || (tok->c == '_')) { + putTokenizerChar(tok, tok->c); + } + putTokenizerChar(tok, '\0'); + tok->type = TOKEN_NAME; + return tok->type; + } else { + switch (tok->c) { + case EOF: + tok->type = TOKEN_EOF; + return tok->type; + case ':': + getTokenizerChar(tok); + if (tok->c == '=') { + tok->type = TOKEN_DEFEQ; + putTokenizerChar(tok, ':'); + putTokenizerChar(tok, '='); + putTokenizerChar(tok, '\0'); + getTokenizerChar(tok); + return tok->type; + } else { + tok->type = TOKEN_CHAR; + putTokenizerChar(tok, ':'); + putTokenizerChar(tok, '\0'); + getTokenizerChar(tok); + return tok->type; + } + case '.': + getTokenizerChar(tok); + if (tok->c == '.') { + tok->type = TOKEN_DOTDOT; + putTokenizerChar(tok, '.'); + putTokenizerChar(tok, '.'); + putTokenizerChar(tok, '\0'); + getTokenizerChar(tok); + } else { + tok->type = TOKEN_CHAR; + putTokenizerChar(tok, '.'); + putTokenizerChar(tok, '\0'); + } + return tok->type; + case '>': + getTokenizerChar(tok); + if (tok->c == '=') { + tok->type = TOKEN_GEQ; + putTokenizerChar(tok, '>'); + putTokenizerChar(tok, '='); + putTokenizerChar(tok, '\0'); + getTokenizerChar(tok); + return tok->type; + } else { + tok->type = TOKEN_CHAR; + putTokenizerChar(tok, '>'); + putTokenizerChar(tok, '\0'); + return tok->type; + } + case '<': + getTokenizerChar(tok); + if (tok->c == '=') { + tok->type = TOKEN_LEQ; + putTokenizerChar(tok, '<'); + putTokenizerChar(tok, '='); + putTokenizerChar(tok, '\0'); + getTokenizerChar(tok); + return tok->type; + } else if (tok->c == '>') { + tok->type = TOKEN_NEQ; + putTokenizerChar(tok, '<'); + putTokenizerChar(tok, '>'); + putTokenizerChar(tok, '\0'); + getTokenizerChar(tok); + return tok->type; + } else { + tok->type = TOKEN_CHAR; + putTokenizerChar(tok, '<'); + putTokenizerChar(tok, '\0'); + return tok->type; + } + case '^': + if (!isalpha(getTokenizerChar(tok))) { + tok->type = TOKEN_CHAR; + putTokenizerChar(tok, tok->c); + putTokenizerChar(tok, '\0'); + getTokenizerChar(tok); + return tok->type; + } + TokenizeCtrl(tok); + /*@falltrough@*/ + case '\'': + case '#': + for (;;) { + if (tok->c == '\'') { + TokenizeQuotes(tok); + } else if (tok->c == '^') { + getTokenizerChar(tok); + TokenizeCtrl(tok); + } else if (tok->c == '#') { + TokenizeHash(tok); + } else { + putTokenizerChar(tok, '\0'); + tok->type = TOKEN_STRING; + return tok->type; + } + } + case '{': + while (getTokenizerChar(tok) != '}') + putTokenizerChar(tok, tok->c); + putTokenizerChar(tok, '\0'); + tok->type = TOKEN_COMMENT; + getTokenizerChar(tok); + return tok->type; + case '(': + getTokenizerChar(tok); + if (tok->c == '*') { + for (;;) { + if (getTokenizerChar(tok) == '*') { + if (getTokenizerChar(tok) == ')') { + putTokenizerChar(tok, '\0'); + tok->type = TOKEN_COMMENT; + getTokenizerChar(tok); + return tok->type; + } else { + putTokenizerChar(tok, '*'); + } + } + putTokenizerChar(tok, tok->c); + } + } else { + tok->type = TOKEN_CHAR; + putTokenizerChar(tok, '('); + putTokenizerChar(tok, '\0'); + return tok->type; + } + case '$': + putTokenizerChar(tok, '0'); + putTokenizerChar(tok, 'x'); + while (isxdigit(getTokenizerChar(tok))) { + putTokenizerChar(tok, tok->c); + } + tok->type = TOKEN_HEX; + putTokenizerChar(tok, '\0'); + return tok->type; + default: + tok->type = TOKEN_CHAR; + putTokenizerChar(tok, tok->c); + putTokenizerChar(tok, '\0'); + getTokenizerChar(tok); + return tok->type; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tokenize.h Sat Oct 13 21:11:54 2012 +0200 @@ -0,0 +1,48 @@ +#ifndef TOKENIZE_H +#define TOKENIZE_H + +#if 0 +#define TOKEN_SIZE 255 +#endif + +enum TOKEN_TYPE { + TOKEN_EOF, + TOKEN_CHAR, + TOKEN_NAME, + TOKEN_INT, + TOKEN_HEX, + TOKEN_REAL, + TOKEN_ENG, + TOKEN_STRING, + TOKEN_COMMENT, + TOKEN_DEFEQ, + TOKEN_DOTDOT, + TOKEN_LEQ, + TOKEN_GEQ, + TOKEN_NEQ, + TOKEN_ERROR, + MAX_TOKEN +}; + +struct Tokenizer { + char *filename; /* Nazwa tokenizowanego pliku. */ + FILE *source; /* Stad beda czytane tokeny. */ + unsigned int c; /* Ostatnio wczytany znak. */ + enum TOKEN_TYPE type; /* Rodzaj tokena. */ +#if 0 + char buffer[TOKEN_SIZE]; /* Bufor na tekst tokena. */ +#endif + int bufpos; /* Pozycja w buforze. */ + int line; /* Aktualny numer linii. */ + int position; /* Numer kolumny. */ + unsigned int putback; /* Znak do zwrotu. */ + GString *buf; /* String tokena. */ +}; + +typedef struct Tokenizer Tokenizer; + +Tokenizer *newTokenizer(const char *filename); +void destroyTokenizer(Tokenizer *tok); +enum TOKEN_TYPE getNextToken(Tokenizer *tok); + +#endif /*not TOKENIZE_H*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tp4.output Sat Oct 13 21:11:54 2012 +0200 @@ -0,0 +1,5365 @@ +Conflict in state 260 between rule 162 and token K_ELSE resolved as shift. + + +Terminals which are not used: + + ID_UNIT + + +Grammar + + Number, Line, Rule + 1 83 compilation_unit -> program + 2 87 compilation_unit -> unit + 3 94 program -> program_heading uses_clause block '.' + 4 98 program_heading -> /* empty */ + 5 99 program_heading -> K_PROGRAM ID_NAME ';' + 6 100 program_heading -> K_PROGRAM ID_NAME '(' id_name_list ')' ';' + 7 108 uses_clause -> /* empty */ + 8 109 uses_clause -> K_USES id_name_list ';' + 9 119 id_name_list -> ID_NAME + 10 126 id_name_list -> id_name_list ',' ID_NAME + 11 136 block -> decl_sect_list compound_stmt + 12 142 unit -> unit_heading interface_part implementation_part initialization_part '.' + 13 148 unit_heading -> K_UNIT ID_NAME ';' + 14 154 interface_part -> K_INTERFACE uses_clause int_decl_sect_list + 15 160 implementation_part -> K_IMPLEMENTATION uses_clause decl_sect_list + 16 166 initialization_part -> compound_stmt + 17 169 initialization_part -> K_END + 18 177 decl_sect_list -> /* empty */ + 19 178 decl_sect_list -> decl_sect_list decl_sect + 20 182 decl_sect -> label_decl_sect + 21 183 decl_sect -> const_decl_sect + 22 184 decl_sect -> type_decl_sect + 23 185 decl_sect -> var_decl_sect + 24 186 decl_sect -> proc_decl + 25 187 decl_sect -> func_decl + 26 191 label_decl_sect -> K_LABEL label_list ';' + 27 195 label_list -> label_decl + 28 196 label_list -> label_list ',' label_decl + 29 199 label -> CONST_INT + 30 202 label -> ID_LABEL + 31 207 label_decl -> CONST_INT + 32 215 label_decl -> ID_NAME + 33 222 const_decl_sect -> K_CONST const_decl + 34 223 const_decl_sect -> const_decl_sect const_decl + 35 227 type_decl_sect -> K_TYPE type_decl + 36 228 type_decl_sect -> type_decl_sect type_decl + 37 232 var_decl_sect -> K_VAR var_decl + 38 233 var_decl_sect -> var_decl_sect var_decl + 39 243 int_decl_sect_list -> /* empty */ + 40 244 int_decl_sect_list -> int_decl_sect_list int_decl_sect + 41 248 int_decl_sect -> const_decl_sect + 42 249 int_decl_sect -> type_decl_sect + 43 250 int_decl_sect -> var_decl_sect + 44 251 int_decl_sect -> proc_heading + 45 255 int_decl_sect -> func_heading + 46 264 const_decl -> ID_NAME '=' const ';' + 47 268 const_decl -> ID_NAME ':' type '=' typed_const ';' + 48 274 const -> unsigned_number + 49 276 const -> sign unsigned_number + 50 278 const -> ID_CONST + 51 280 const -> sign ID_CONST + 52 282 const -> CONST_STRING + 53 287 unsigned_number -> CONST_INT + 54 292 unsigned_number -> CONST_REAL + 55 295 sign -> '+' + 56 295 sign -> '-' + 57 299 typed_const -> const + 58 300 typed_const -> array_const + 59 301 typed_const -> record_const + 60 302 typed_const -> set_const + 61 306 array_const -> '(' typed_const_list ')' + 62 310 typed_const_list -> typed_const + 63 311 typed_const_list -> typed_const_list ',' typed_const + 64 315 record_const -> '(' const_field_list ')' + 65 319 const_field_list -> const_field + 66 320 const_field_list -> const_field_list ',' const_field + 67 324 const_field -> ID_FIELD ':' typed_const + 68 329 set_const -> '[' const_elem_list ']' + 69 333 const_elem_list -> /* empty */ + 70 334 const_elem_list -> const_elem_list1 + 71 338 const_elem_list1 -> const_elem + 72 339 const_elem_list1 -> const_elem_list1 ',' const_elem + 73 343 const_elem -> const + 74 344 const_elem -> const OP_DOTDOT const + 75 350 type_decl -> ID_NAME '=' type ';' + 76 356 type -> simple_type + 77 357 type -> pointer_type + 78 358 type -> structured_type + 79 359 type -> string_type + 80 363 simple_type -> ID_TYPE + 81 365 simple_type -> const OP_DOTDOT const + 82 367 simple_type -> '(' id_name_list ')' + 83 374 pointer_type -> '^' ID_TYPE + 84 378 structured_type -> unpacked_structured_type + 85 379 structured_type -> K_PACKED unpacked_structured_type + 86 383 unpacked_structured_type -> array_type + 87 384 unpacked_structured_type -> record_type + 88 385 unpacked_structured_type -> set_type + 89 386 unpacked_structured_type -> file_type + 90 390 array_type -> K_ARRAY '[' simple_type_list ']' K_OF type + 91 394 simple_type_list -> simple_type + 92 395 simple_type_list -> simple_type_list ',' simple_type + 93 399 record_type -> K_RECORD field_list K_END + 94 403 field_list -> fixed_part + 95 404 field_list -> variant_part + 96 405 field_list -> fixed_part ';' variant_part + 97 409 fixed_part -> record_section + 98 410 fixed_part -> fixed_part ';' record_section + 99 414 record_section -> /* empty */ + 100 415 record_section -> id_name_list ':' type + 101 422 variant_part -> K_CASE tag_field K_OF variant_list + 102 426 tag_field -> ID_NAME + 103 428 tag_field -> ID_NAME ':' ID_TYPE + 104 433 variant_list -> variant + 105 434 variant_list -> variant_list ';' variant + 106 437 variant -> /* empty */ + 107 438 variant -> case_tag_list ':' '(' field_list ')' + 108 442 case_tag_list -> const + 109 443 case_tag_list -> case_tag_list ',' const + 110 447 set_type -> K_SET K_OF simple_type + 111 451 file_type -> K_FILE K_OF type + 112 452 file_type -> K_FILE + 113 456 string_type -> K_STRING + 114 457 string_type -> K_STRING '[' const ']' + 115 463 var_decl -> id_name_list ':' type absolute_clause ';' + 116 473 absolute_clause -> /* empty */ + 117 474 absolute_clause -> K_ABSOLUTE CONST_INT ':' CONST_INT + 118 475 absolute_clause -> K_ABSOLUTE ID_VAR + 119 481 proc_decl -> proc_heading proc_block ';' + 120 490 func_decl -> func_heading proc_block ';' + 121 501 proc_heading_beginning -> K_PROCEDURE ID_NAME + 122 506 proc_heading_beginning -> K_PROCEDURE ID_PROC + 123 513 func_heading_beginning -> K_FUNCTION ID_NAME + 124 518 func_heading_beginning -> K_FUNCTION ID_FUNC + 125 525 proc_heading -> proc_heading_beginning fp_list ';' + 126 529 func_heading -> func_heading_beginning fp_list ':' fptype ';' + 127 533 proc_block -> block + 128 534 proc_block -> K_EXTERNAL + 129 535 proc_block -> K_FORWARD + 130 538 fp_list -> /* empty */ + 131 539 fp_list -> '(' fp_sect_list ')' + 132 543 fp_sect_list -> fp_sect + 133 544 fp_sect_list -> fp_sect_list ';' fp_sect + 134 547 fp_sect -> id_name_list ':' fptype + 135 552 fp_sect -> K_VAR id_name_list ':' fptype + 136 557 fp_sect -> K_VAR id_name_list + 137 564 fptype -> ID_TYPE + 138 566 fptype -> K_STRING + 139 571 stmt -> unlabelled_stmt + 140 572 stmt -> label ':' unlabelled_stmt + 141 576 unlabelled_stmt -> /* empty */ + 142 577 unlabelled_stmt -> assignment + 143 578 unlabelled_stmt -> proc_call + 144 579 unlabelled_stmt -> goto_stmt + 145 580 unlabelled_stmt -> compound_stmt + 146 581 unlabelled_stmt -> if_stmt + 147 582 unlabelled_stmt -> case_stmt + 148 583 unlabelled_stmt -> repeat_stmt + 149 584 unlabelled_stmt -> while_stmt + 150 585 unlabelled_stmt -> for_stmt + 151 586 unlabelled_stmt -> with_stmt + 152 590 assignment -> variable OP_DEFEQ expr + 153 594 proc_call -> ID_PROC param_list + 154 599 param_list -> /* empty */ + 155 600 param_list -> '(' expr_list ')' + 156 604 expr_list -> expr + 157 605 expr_list -> expr_list ',' expr + 158 609 goto_stmt -> K_GOTO label + 159 613 compound_stmt -> K_BEGIN stmt_list K_END + 160 617 stmt_list -> stmt + 161 618 stmt_list -> stmt_list ';' stmt + 162 621 if_stmt -> K_IF expr K_THEN stmt + 163 622 if_stmt -> K_IF expr K_THEN stmt K_ELSE stmt + 164 626 case_stmt -> K_CASE expr K_OF case_list else_case K_END + 165 630 case_list -> case + 166 631 case_list -> case_list ';' case + 167 634 case -> /* empty */ + 168 635 case -> case_label_list ':' stmt + 169 639 case_label_list -> case_label + 170 640 case_label_list -> case_label_list ',' case_label + 171 644 case_label -> const + 172 645 case_label -> const OP_DOTDOT const + 173 649 else_case -> /* empty */ + 174 650 else_case -> K_ELSE stmt + 175 651 else_case -> K_ELSE stmt ';' + 176 655 repeat_stmt -> K_REPEAT stmt_list K_UNTIL expr + 177 659 while_stmt -> K_WHILE expr K_DO stmt + 178 663 for_stmt -> K_FOR ID_VAR OP_DEFEQ expr K_TO expr K_DO stmt + 179 664 for_stmt -> K_FOR ID_VAR OP_DEFEQ expr K_DOWNTO expr K_DO stmt + 180 668 with_stmt -> K_WITH variable_list K_DO stmt + 181 672 variable_list -> variable + 182 673 variable_list -> variable_list ',' variable + 183 679 record_variable -> variable '.' + 184 683 variable -> ID_VAR + 185 685 variable -> variable '[' expr_list ']' + 186 686 variable -> record_variable ID_FIELD + 187 687 variable -> variable '^' + 188 688 variable -> ID_TYPE '(' variable ')' + 189 694 expr -> simple_expr + 190 695 expr -> simple_expr relop simple_expr + 191 698 relop -> '=' + 192 698 relop -> OP_NEQ + 193 698 relop -> '<' + 194 698 relop -> '>' + 195 698 relop -> OP_LEQ + 196 698 relop -> OP_GEQ + 197 698 relop -> K_IN + 198 702 simple_expr -> term + 199 703 simple_expr -> sign term + 200 704 simple_expr -> simple_expr addop term + 201 707 addop -> '+' + 202 707 addop -> '-' + 203 707 addop -> K_OR + 204 707 addop -> K_XOR + 205 710 term -> factor + 206 711 term -> term mulop factor + 207 714 mulop -> '*' + 208 714 mulop -> '/' + 209 714 mulop -> K_DIV + 210 714 mulop -> K_MOD + 211 714 mulop -> K_SHL + 212 714 mulop -> K_SHR + 213 714 mulop -> K_AND + 214 720 factor -> variable + 215 721 factor -> ID_CONST + 216 723 factor -> CONST_INT + 217 725 factor -> CONST_REAL + 218 727 factor -> CONST_STRING + 219 729 factor -> '[' elem_list ']' + 220 730 factor -> K_NIL + 221 731 factor -> '@' variable + 222 732 factor -> '(' expr ')' + 223 733 factor -> ID_FUNC '(' expr_list ')' + 224 735 factor -> K_NOT factor + 225 739 elem_list -> /* empty */ + 226 740 elem_list -> elem_list1 + 227 744 elem_list1 -> elem + 228 745 elem_list1 -> elem_list1 ',' elem + 229 748 elem -> expr + 230 749 elem -> expr OP_DOTDOT expr + + +Terminals, with rules where they appear + +$ (-1) +'(' (40) 6 61 64 82 107 131 155 188 222 223 +')' (41) 6 61 64 82 107 131 155 188 222 223 +'*' (42) 207 +'+' (43) 55 201 +',' (44) 10 28 63 66 72 92 109 157 170 182 228 +'-' (45) 56 202 +'.' (46) 3 12 183 +'/' (47) 208 +':' (58) 47 67 100 103 107 115 117 126 134 135 140 168 +';' (59) 5 6 8 13 26 46 47 75 96 98 105 115 119 120 125 126 133 161 + 166 175 +'<' (60) 193 +'=' (61) 46 47 75 191 +'>' (62) 194 +'@' (64) 221 +'[' (91) 68 90 114 185 219 +']' (93) 68 90 114 185 219 +'^' (94) 83 187 +error (256) +K_AND (257) 213 +K_ABSOLUTE (258) 117 118 +K_ARRAY (259) 90 +K_BEGIN (260) 159 +K_CASE (261) 101 164 +K_CONST (262) 33 +K_DIV (263) 209 +K_DOWNTO (264) 179 +K_DO (265) 177 178 179 180 +K_ELSE (266) 163 174 175 +K_END (267) 17 93 159 164 +K_EXTERNAL (268) 128 +K_FILE (269) 111 112 +K_FORWARD (270) 129 +K_FOR (271) 178 179 +K_FUNCTION (272) 123 124 +K_GOTO (273) 158 +K_IF (274) 162 163 +K_IMPLEMENTATION (275) 15 +K_INTERFACE (276) 14 +K_IN (277) 197 +K_LABEL (278) 26 +K_MOD (279) 210 +K_NIL (280) 220 +K_NOT (281) 224 +K_OF (282) 90 101 110 111 164 +K_OR (283) 203 +K_PACKED (284) 85 +K_PROCEDURE (285) 121 122 +K_PROGRAM (286) 5 6 +K_RECORD (287) 93 +K_REPEAT (288) 176 +K_SET (289) 110 +K_SHL (290) 211 +K_SHR (291) 212 +K_STRING (292) 113 114 138 +K_THEN (293) 162 163 +K_TO (294) 178 +K_TYPE (295) 35 +K_UNIT (296) 13 +K_UNTIL (297) 176 +K_USES (298) 8 +K_VAR (299) 37 135 136 +K_WHILE (300) 177 +K_WITH (301) 180 +K_XOR (302) 204 +OP_DOTDOT (303) 74 81 172 230 +OP_DEFEQ (304) 152 178 179 +OP_LEQ (305) 195 +OP_NEQ (306) 192 +OP_GEQ (307) 196 +ID_FUNC (308) 124 223 +ID_PROC (309) 122 153 +ID_VAR (310) 118 178 179 184 +ID_TYPE (311) 80 83 103 137 188 +ID_LABEL (312) 30 +ID_UNIT (313) +ID_CONST (314) 50 51 215 +ID_FIELD (315) 67 186 +ID_NAME (316) 5 6 9 10 13 32 46 47 75 102 103 121 123 +CONST_INT (317) 29 31 53 117 216 +CONST_REAL (318) 54 217 +CONST_STRING (319) 52 218 + + +Nonterminals, with rules where they appear + +compilation_unit (83) + on left: 1 2 +program (84) + on left: 3, on right: 1 +program_heading (85) + on left: 4 5 6, on right: 3 +uses_clause (86) + on left: 7 8, on right: 3 14 15 +id_name_list (87) + on left: 9 10, on right: 6 8 10 82 100 115 134 135 136 +block (88) + on left: 11, on right: 3 127 +unit (89) + on left: 12, on right: 2 +unit_heading (90) + on left: 13, on right: 12 +interface_part (91) + on left: 14, on right: 12 +implementation_part (92) + on left: 15, on right: 12 +initialization_part (93) + on left: 16 17, on right: 12 +decl_sect_list (94) + on left: 18 19, on right: 11 15 19 +decl_sect (95) + on left: 20 21 22 23 24 25, on right: 19 +label_decl_sect (96) + on left: 26, on right: 20 +label_list (97) + on left: 27 28, on right: 26 28 +label (98) + on left: 29 30, on right: 140 158 +label_decl (99) + on left: 31 32, on right: 27 28 +const_decl_sect (100) + on left: 33 34, on right: 21 34 41 +type_decl_sect (101) + on left: 35 36, on right: 22 36 42 +var_decl_sect (102) + on left: 37 38, on right: 23 38 43 +int_decl_sect_list (103) + on left: 39 40, on right: 14 40 +int_decl_sect (104) + on left: 41 42 43 44 45, on right: 40 +const_decl (105) + on left: 46 47, on right: 33 34 +const (106) + on left: 48 49 50 51 52, on right: 46 57 73 74 81 108 109 114 171 + 172 +unsigned_number (107) + on left: 53 54, on right: 48 49 +sign (108) + on left: 55 56, on right: 49 51 199 +typed_const (109) + on left: 57 58 59 60, on right: 47 62 63 67 +array_const (110) + on left: 61, on right: 58 +typed_const_list (111) + on left: 62 63, on right: 61 63 +record_const (112) + on left: 64, on right: 59 +const_field_list (113) + on left: 65 66, on right: 64 66 +const_field (114) + on left: 67, on right: 65 66 +set_const (115) + on left: 68, on right: 60 +const_elem_list (116) + on left: 69 70, on right: 68 +const_elem_list1 (117) + on left: 71 72, on right: 70 72 +const_elem (118) + on left: 73 74, on right: 71 72 +type_decl (119) + on left: 75, on right: 35 36 +type (120) + on left: 76 77 78 79, on right: 47 75 90 100 111 115 +simple_type (121) + on left: 80 81 82, on right: 76 91 92 110 +pointer_type (122) + on left: 83, on right: 77 +structured_type (123) + on left: 84 85, on right: 78 +unpacked_structured_type (124) + on left: 86 87 88 89, on right: 84 85 +array_type (125) + on left: 90, on right: 86 +simple_type_list (126) + on left: 91 92, on right: 90 92 +record_type (127) + on left: 93, on right: 87 +field_list (128) + on left: 94 95 96, on right: 93 107 +fixed_part (129) + on left: 97 98, on right: 94 96 98 +record_section (130) + on left: 99 100, on right: 97 98 +variant_part (131) + on left: 101, on right: 95 96 +tag_field (132) + on left: 102 103, on right: 101 +variant_list (133) + on left: 104 105, on right: 101 105 +variant (134) + on left: 106 107, on right: 104 105 +case_tag_list (135) + on left: 108 109, on right: 107 109 +set_type (136) + on left: 110, on right: 88 +file_type (137) + on left: 111 112, on right: 89 +string_type (138) + on left: 113 114, on right: 79 +var_decl (139) + on left: 115, on right: 37 38 +absolute_clause (140) + on left: 116 117 118, on right: 115 +proc_decl (141) + on left: 119, on right: 24 +func_decl (142) + on left: 120, on right: 25 +proc_heading_beginning (143) + on left: 121 122, on right: 125 +func_heading_beginning (144) + on left: 123 124, on right: 126 +proc_heading (145) + on left: 125, on right: 44 119 +func_heading (146) + on left: 126, on right: 45 120 +proc_block (147) + on left: 127 128 129, on right: 119 120 +fp_list (148) + on left: 130 131, on right: 125 126 +fp_sect_list (149) + on left: 132 133, on right: 131 133 +fp_sect (150) + on left: 134 135 136, on right: 132 133 +fptype (151) + on left: 137 138, on right: 126 134 135 +stmt (152) + on left: 139 140, on right: 160 161 162 163 168 174 175 177 178 + 179 180 +unlabelled_stmt (153) + on left: 141 142 143 144 145 146 147 148 149 150 151, + on right: 139 140 +assignment (154) + on left: 152, on right: 142 +proc_call (155) + on left: 153, on right: 143 +param_list (156) + on left: 154 155, on right: 153 +expr_list (157) + on left: 156 157, on right: 155 157 185 223 +goto_stmt (158) + on left: 158, on right: 144 +compound_stmt (159) + on left: 159, on right: 11 16 145 +stmt_list (160) + on left: 160 161, on right: 159 161 176 +if_stmt (161) + on left: 162 163, on right: 146 +case_stmt (162) + on left: 164, on right: 147 +case_list (163) + on left: 165 166, on right: 164 166 +case (164) + on left: 167 168, on right: 165 166 +case_label_list (165) + on left: 169 170, on right: 168 170 +case_label (166) + on left: 171 172, on right: 169 170 +else_case (167) + on left: 173 174 175, on right: 164 +repeat_stmt (168) + on left: 176, on right: 148 +while_stmt (169) + on left: 177, on right: 149 +for_stmt (170) + on left: 178 179, on right: 150 +with_stmt (171) + on left: 180, on right: 151 +variable_list (172) + on left: 181 182, on right: 180 182 +record_variable (173) + on left: 183, on right: 186 +variable (174) + on left: 184 185 186 187 188, on right: 152 181 182 183 185 187 + 188 214 221 +expr (175) + on left: 189 190, on right: 152 156 157 162 163 164 176 177 178 + 179 222 229 230 +relop (176) + on left: 191 192 193 194 195 196 197, on right: 190 +simple_expr (177) + on left: 198 199 200, on right: 189 190 200 +addop (178) + on left: 201 202 203 204, on right: 200 +term (179) + on left: 205 206, on right: 198 199 200 206 +mulop (180) + on left: 207 208 209 210 211 212 213, on right: 206 +factor (181) + on left: 214 215 216 217 218 219 220 221 222 223 224, + on right: 205 206 224 +elem_list (182) + on left: 225 226, on right: 219 +elem_list1 (183) + on left: 227 228, on right: 226 228 +elem (184) + on left: 229 230, on right: 227 228 + + +state 0 + + K_PROGRAM shift, and go to state 1 + K_UNIT shift, and go to state 2 + + $default reduce using rule 4 (program_heading) + + compilation_unit go to state 393 + program go to state 3 + program_heading go to state 4 + unit go to state 5 + unit_heading go to state 6 + + + +state 1 + + program_heading -> K_PROGRAM . ID_NAME ';' (rule 5) + program_heading -> K_PROGRAM . ID_NAME '(' id_name_list ')' ';' (rule 6) + + ID_NAME shift, and go to state 7 + + + +state 2 + + unit_heading -> K_UNIT . ID_NAME ';' (rule 13) + + ID_NAME shift, and go to state 8 + + + +state 3 + + compilation_unit -> program . (rule 1) + + $default reduce using rule 1 (compilation_unit) + + + +state 4 + + program -> program_heading . uses_clause block '.' (rule 3) + + K_USES shift, and go to state 9 + + $default reduce using rule 7 (uses_clause) + + uses_clause go to state 10 + + + +state 5 + + compilation_unit -> unit . (rule 2) + + $default reduce using rule 2 (compilation_unit) + + + +state 6 + + unit -> unit_heading . interface_part implementation_part initialization_part '.' (rule 12) + + K_INTERFACE shift, and go to state 11 + + interface_part go to state 12 + + + +state 7 + + program_heading -> K_PROGRAM ID_NAME . ';' (rule 5) + program_heading -> K_PROGRAM ID_NAME . '(' id_name_list ')' ';' (rule 6) + + ';' shift, and go to state 13 + '(' shift, and go to state 14 + + + +state 8 + + unit_heading -> K_UNIT ID_NAME . ';' (rule 13) + + ';' shift, and go to state 15 + + + +state 9 + + uses_clause -> K_USES . id_name_list ';' (rule 8) + + ID_NAME shift, and go to state 16 + + id_name_list go to state 17 + + + +state 10 + + program -> program_heading uses_clause . block '.' (rule 3) + + $default reduce using rule 18 (decl_sect_list) + + block go to state 18 + decl_sect_list go to state 19 + + + +state 11 + + interface_part -> K_INTERFACE . uses_clause int_decl_sect_list (rule 14) + + K_USES shift, and go to state 9 + + $default reduce using rule 7 (uses_clause) + + uses_clause go to state 20 + + + +state 12 + + unit -> unit_heading interface_part . implementation_part initialization_part '.' (rule 12) + + K_IMPLEMENTATION shift, and go to state 21 + + implementation_part go to state 22 + + + +state 13 + + program_heading -> K_PROGRAM ID_NAME ';' . (rule 5) + + $default reduce using rule 5 (program_heading) + + + +state 14 + + program_heading -> K_PROGRAM ID_NAME '(' . id_name_list ')' ';' (rule 6) + + ID_NAME shift, and go to state 16 + + id_name_list go to state 23 + + + +state 15 + + unit_heading -> K_UNIT ID_NAME ';' . (rule 13) + + $default reduce using rule 13 (unit_heading) + + + +state 16 + + id_name_list -> ID_NAME . (rule 9) + + $default reduce using rule 9 (id_name_list) + + + +state 17 + + uses_clause -> K_USES id_name_list . ';' (rule 8) + id_name_list -> id_name_list . ',' ID_NAME (rule 10) + + ';' shift, and go to state 24 + ',' shift, and go to state 25 + + + +state 18 + + program -> program_heading uses_clause block . '.' (rule 3) + + '.' shift, and go to state 26 + + + +state 19 + + block -> decl_sect_list . compound_stmt (rule 11) + decl_sect_list -> decl_sect_list . decl_sect (rule 19) + + K_BEGIN shift, and go to state 27 + K_CONST shift, and go to state 28 + K_FUNCTION shift, and go to state 29 + K_LABEL shift, and go to state 30 + K_PROCEDURE shift, and go to state 31 + K_TYPE shift, and go to state 32 + K_VAR shift, and go to state 33 + + decl_sect go to state 34 + label_decl_sect go to state 35 + const_decl_sect go to state 36 + type_decl_sect go to state 37 + var_decl_sect go to state 38 + proc_decl go to state 39 + func_decl go to state 40 + proc_heading_beginning go to state 41 + func_heading_beginning go to state 42 + proc_heading go to state 43 + func_heading go to state 44 + compound_stmt go to state 45 + + + +state 20 + + interface_part -> K_INTERFACE uses_clause . int_decl_sect_list (rule 14) + + $default reduce using rule 39 (int_decl_sect_list) + + int_decl_sect_list go to state 46 + + + +state 21 + + implementation_part -> K_IMPLEMENTATION . uses_clause decl_sect_list (rule 15) + + K_USES shift, and go to state 9 + + $default reduce using rule 7 (uses_clause) + + uses_clause go to state 47 + + + +state 22 + + unit -> unit_heading interface_part implementation_part . initialization_part '.' (rule 12) + + K_BEGIN shift, and go to state 27 + K_END shift, and go to state 48 + + initialization_part go to state 49 + compound_stmt go to state 50 + + + +state 23 + + program_heading -> K_PROGRAM ID_NAME '(' id_name_list . ')' ';' (rule 6) + id_name_list -> id_name_list . ',' ID_NAME (rule 10) + + ')' shift, and go to state 51 + ',' shift, and go to state 25 + + + +state 24 + + uses_clause -> K_USES id_name_list ';' . (rule 8) + + $default reduce using rule 8 (uses_clause) + + + +state 25 + + id_name_list -> id_name_list ',' . ID_NAME (rule 10) + + ID_NAME shift, and go to state 52 + + + +state 26 + + program -> program_heading uses_clause block '.' . (rule 3) + + $default reduce using rule 3 (program) + + + +state 27 + + compound_stmt -> K_BEGIN . stmt_list K_END (rule 159) + + K_BEGIN shift, and go to state 27 + K_CASE shift, and go to state 53 + K_FOR shift, and go to state 54 + K_GOTO shift, and go to state 55 + K_IF shift, and go to state 56 + K_REPEAT shift, and go to state 57 + K_WHILE shift, and go to state 58 + K_WITH shift, and go to state 59 + ID_PROC shift, and go to state 60 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_LABEL shift, and go to state 63 + CONST_INT shift, and go to state 64 + + $default reduce using rule 141 (unlabelled_stmt) + + label go to state 65 + stmt go to state 66 + unlabelled_stmt go to state 67 + assignment go to state 68 + proc_call go to state 69 + goto_stmt go to state 70 + compound_stmt go to state 71 + stmt_list go to state 72 + if_stmt go to state 73 + case_stmt go to state 74 + repeat_stmt go to state 75 + while_stmt go to state 76 + for_stmt go to state 77 + with_stmt go to state 78 + record_variable go to state 79 + variable go to state 80 + + + +state 28 + + const_decl_sect -> K_CONST . const_decl (rule 33) + + ID_NAME shift, and go to state 81 + + const_decl go to state 82 + + + +state 29 + + func_heading_beginning -> K_FUNCTION . ID_NAME (rule 123) + func_heading_beginning -> K_FUNCTION . ID_FUNC (rule 124) + + ID_FUNC shift, and go to state 83 + ID_NAME shift, and go to state 84 + + + +state 30 + + label_decl_sect -> K_LABEL . label_list ';' (rule 26) + + ID_NAME shift, and go to state 85 + CONST_INT shift, and go to state 86 + + label_list go to state 87 + label_decl go to state 88 + + + +state 31 + + proc_heading_beginning -> K_PROCEDURE . ID_NAME (rule 121) + proc_heading_beginning -> K_PROCEDURE . ID_PROC (rule 122) + + ID_PROC shift, and go to state 89 + ID_NAME shift, and go to state 90 + + + +state 32 + + type_decl_sect -> K_TYPE . type_decl (rule 35) + + ID_NAME shift, and go to state 91 + + type_decl go to state 92 + + + +state 33 + + var_decl_sect -> K_VAR . var_decl (rule 37) + + ID_NAME shift, and go to state 16 + + id_name_list go to state 93 + var_decl go to state 94 + + + +state 34 + + decl_sect_list -> decl_sect_list decl_sect . (rule 19) + + $default reduce using rule 19 (decl_sect_list) + + + +state 35 + + decl_sect -> label_decl_sect . (rule 20) + + $default reduce using rule 20 (decl_sect) + + + +state 36 + + decl_sect -> const_decl_sect . (rule 21) + const_decl_sect -> const_decl_sect . const_decl (rule 34) + + ID_NAME shift, and go to state 81 + + $default reduce using rule 21 (decl_sect) + + const_decl go to state 95 + + + +state 37 + + decl_sect -> type_decl_sect . (rule 22) + type_decl_sect -> type_decl_sect . type_decl (rule 36) + + ID_NAME shift, and go to state 91 + + $default reduce using rule 22 (decl_sect) + + type_decl go to state 96 + + + +state 38 + + decl_sect -> var_decl_sect . (rule 23) + var_decl_sect -> var_decl_sect . var_decl (rule 38) + + ID_NAME shift, and go to state 16 + + $default reduce using rule 23 (decl_sect) + + id_name_list go to state 93 + var_decl go to state 97 + + + +state 39 + + decl_sect -> proc_decl . (rule 24) + + $default reduce using rule 24 (decl_sect) + + + +state 40 + + decl_sect -> func_decl . (rule 25) + + $default reduce using rule 25 (decl_sect) + + + +state 41 + + proc_heading -> proc_heading_beginning . fp_list ';' (rule 125) + + '(' shift, and go to state 98 + + $default reduce using rule 130 (fp_list) + + fp_list go to state 99 + + + +state 42 + + func_heading -> func_heading_beginning . fp_list ':' fptype ';' (rule 126) + + '(' shift, and go to state 98 + + $default reduce using rule 130 (fp_list) + + fp_list go to state 100 + + + +state 43 + + proc_decl -> proc_heading . proc_block ';' (rule 119) + + K_EXTERNAL shift, and go to state 101 + K_FORWARD shift, and go to state 102 + + $default reduce using rule 18 (decl_sect_list) + + block go to state 103 + decl_sect_list go to state 19 + proc_block go to state 104 + + + +state 44 + + func_decl -> func_heading . proc_block ';' (rule 120) + + K_EXTERNAL shift, and go to state 101 + K_FORWARD shift, and go to state 102 + + $default reduce using rule 18 (decl_sect_list) + + block go to state 103 + decl_sect_list go to state 19 + proc_block go to state 105 + + + +state 45 + + block -> decl_sect_list compound_stmt . (rule 11) + + $default reduce using rule 11 (block) + + + +state 46 + + interface_part -> K_INTERFACE uses_clause int_decl_sect_list . (rule 14) + int_decl_sect_list -> int_decl_sect_list . int_decl_sect (rule 40) + + K_CONST shift, and go to state 28 + K_FUNCTION shift, and go to state 29 + K_PROCEDURE shift, and go to state 31 + K_TYPE shift, and go to state 32 + K_VAR shift, and go to state 33 + + $default reduce using rule 14 (interface_part) + + const_decl_sect go to state 106 + type_decl_sect go to state 107 + var_decl_sect go to state 108 + int_decl_sect go to state 109 + proc_heading_beginning go to state 41 + func_heading_beginning go to state 42 + proc_heading go to state 110 + func_heading go to state 111 + + + +state 47 + + implementation_part -> K_IMPLEMENTATION uses_clause . decl_sect_list (rule 15) + + $default reduce using rule 18 (decl_sect_list) + + decl_sect_list go to state 112 + + + +state 48 + + initialization_part -> K_END . (rule 17) + + $default reduce using rule 17 (initialization_part) + + + +state 49 + + unit -> unit_heading interface_part implementation_part initialization_part . '.' (rule 12) + + '.' shift, and go to state 113 + + + +state 50 + + initialization_part -> compound_stmt . (rule 16) + + $default reduce using rule 16 (initialization_part) + + + +state 51 + + program_heading -> K_PROGRAM ID_NAME '(' id_name_list ')' . ';' (rule 6) + + ';' shift, and go to state 114 + + + +state 52 + + id_name_list -> id_name_list ',' ID_NAME . (rule 10) + + $default reduce using rule 10 (id_name_list) + + + +state 53 + + case_stmt -> K_CASE . expr K_OF case_list else_case K_END (rule 164) + + K_NIL shift, and go to state 115 + K_NOT shift, and go to state 116 + ID_FUNC shift, and go to state 117 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_CONST shift, and go to state 118 + CONST_INT shift, and go to state 119 + CONST_REAL shift, and go to state 120 + CONST_STRING shift, and go to state 121 + '(' shift, and go to state 122 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + '[' shift, and go to state 125 + '@' shift, and go to state 126 + + sign go to state 127 + record_variable go to state 79 + variable go to state 128 + expr go to state 129 + simple_expr go to state 130 + term go to state 131 + factor go to state 132 + + + +state 54 + + for_stmt -> K_FOR . ID_VAR OP_DEFEQ expr K_TO expr K_DO stmt (rule 178) + for_stmt -> K_FOR . ID_VAR OP_DEFEQ expr K_DOWNTO expr K_DO stmt (rule 179) + + ID_VAR shift, and go to state 133 + + + +state 55 + + goto_stmt -> K_GOTO . label (rule 158) + + ID_LABEL shift, and go to state 63 + CONST_INT shift, and go to state 64 + + label go to state 134 + + + +state 56 + + if_stmt -> K_IF . expr K_THEN stmt (rule 162) + if_stmt -> K_IF . expr K_THEN stmt K_ELSE stmt (rule 163) + + K_NIL shift, and go to state 115 + K_NOT shift, and go to state 116 + ID_FUNC shift, and go to state 117 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_CONST shift, and go to state 118 + CONST_INT shift, and go to state 119 + CONST_REAL shift, and go to state 120 + CONST_STRING shift, and go to state 121 + '(' shift, and go to state 122 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + '[' shift, and go to state 125 + '@' shift, and go to state 126 + + sign go to state 127 + record_variable go to state 79 + variable go to state 128 + expr go to state 135 + simple_expr go to state 130 + term go to state 131 + factor go to state 132 + + + +state 57 + + repeat_stmt -> K_REPEAT . stmt_list K_UNTIL expr (rule 176) + + K_BEGIN shift, and go to state 27 + K_CASE shift, and go to state 53 + K_FOR shift, and go to state 54 + K_GOTO shift, and go to state 55 + K_IF shift, and go to state 56 + K_REPEAT shift, and go to state 57 + K_WHILE shift, and go to state 58 + K_WITH shift, and go to state 59 + ID_PROC shift, and go to state 60 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_LABEL shift, and go to state 63 + CONST_INT shift, and go to state 64 + + $default reduce using rule 141 (unlabelled_stmt) + + label go to state 65 + stmt go to state 66 + unlabelled_stmt go to state 67 + assignment go to state 68 + proc_call go to state 69 + goto_stmt go to state 70 + compound_stmt go to state 71 + stmt_list go to state 136 + if_stmt go to state 73 + case_stmt go to state 74 + repeat_stmt go to state 75 + while_stmt go to state 76 + for_stmt go to state 77 + with_stmt go to state 78 + record_variable go to state 79 + variable go to state 80 + + + +state 58 + + while_stmt -> K_WHILE . expr K_DO stmt (rule 177) + + K_NIL shift, and go to state 115 + K_NOT shift, and go to state 116 + ID_FUNC shift, and go to state 117 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_CONST shift, and go to state 118 + CONST_INT shift, and go to state 119 + CONST_REAL shift, and go to state 120 + CONST_STRING shift, and go to state 121 + '(' shift, and go to state 122 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + '[' shift, and go to state 125 + '@' shift, and go to state 126 + + sign go to state 127 + record_variable go to state 79 + variable go to state 128 + expr go to state 137 + simple_expr go to state 130 + term go to state 131 + factor go to state 132 + + + +state 59 + + with_stmt -> K_WITH . variable_list K_DO stmt (rule 180) + + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + + variable_list go to state 138 + record_variable go to state 79 + variable go to state 139 + + + +state 60 + + proc_call -> ID_PROC . param_list (rule 153) + + '(' shift, and go to state 140 + + $default reduce using rule 154 (param_list) + + param_list go to state 141 + + + +state 61 + + variable -> ID_VAR . (rule 184) + + $default reduce using rule 184 (variable) + + + +state 62 + + variable -> ID_TYPE . '(' variable ')' (rule 188) + + '(' shift, and go to state 142 + + + +state 63 + + label -> ID_LABEL . (rule 30) + + $default reduce using rule 30 (label) + + + +state 64 + + label -> CONST_INT . (rule 29) + + $default reduce using rule 29 (label) + + + +state 65 + + stmt -> label . ':' unlabelled_stmt (rule 140) + + ':' shift, and go to state 143 + + + +state 66 + + stmt_list -> stmt . (rule 160) + + $default reduce using rule 160 (stmt_list) + + + +state 67 + + stmt -> unlabelled_stmt . (rule 139) + + $default reduce using rule 139 (stmt) + + + +state 68 + + unlabelled_stmt -> assignment . (rule 142) + + $default reduce using rule 142 (unlabelled_stmt) + + + +state 69 + + unlabelled_stmt -> proc_call . (rule 143) + + $default reduce using rule 143 (unlabelled_stmt) + + + +state 70 + + unlabelled_stmt -> goto_stmt . (rule 144) + + $default reduce using rule 144 (unlabelled_stmt) + + + +state 71 + + unlabelled_stmt -> compound_stmt . (rule 145) + + $default reduce using rule 145 (unlabelled_stmt) + + + +state 72 + + compound_stmt -> K_BEGIN stmt_list . K_END (rule 159) + stmt_list -> stmt_list . ';' stmt (rule 161) + + K_END shift, and go to state 144 + ';' shift, and go to state 145 + + + +state 73 + + unlabelled_stmt -> if_stmt . (rule 146) + + $default reduce using rule 146 (unlabelled_stmt) + + + +state 74 + + unlabelled_stmt -> case_stmt . (rule 147) + + $default reduce using rule 147 (unlabelled_stmt) + + + +state 75 + + unlabelled_stmt -> repeat_stmt . (rule 148) + + $default reduce using rule 148 (unlabelled_stmt) + + + +state 76 + + unlabelled_stmt -> while_stmt . (rule 149) + + $default reduce using rule 149 (unlabelled_stmt) + + + +state 77 + + unlabelled_stmt -> for_stmt . (rule 150) + + $default reduce using rule 150 (unlabelled_stmt) + + + +state 78 + + unlabelled_stmt -> with_stmt . (rule 151) + + $default reduce using rule 151 (unlabelled_stmt) + + + +state 79 + + variable -> record_variable . ID_FIELD (rule 186) + + ID_FIELD shift, and go to state 146 + + + +state 80 + + assignment -> variable . OP_DEFEQ expr (rule 152) + record_variable -> variable . '.' (rule 183) + variable -> variable . '[' expr_list ']' (rule 185) + variable -> variable . '^' (rule 187) + + OP_DEFEQ shift, and go to state 147 + '.' shift, and go to state 148 + '[' shift, and go to state 149 + '^' shift, and go to state 150 + + + +state 81 + + const_decl -> ID_NAME . '=' const ';' (rule 46) + const_decl -> ID_NAME . ':' type '=' typed_const ';' (rule 47) + + '=' shift, and go to state 151 + ':' shift, and go to state 152 + + + +state 82 + + const_decl_sect -> K_CONST const_decl . (rule 33) + + $default reduce using rule 33 (const_decl_sect) + + + +state 83 + + func_heading_beginning -> K_FUNCTION ID_FUNC . (rule 124) + + $default reduce using rule 124 (func_heading_beginning) + + + +state 84 + + func_heading_beginning -> K_FUNCTION ID_NAME . (rule 123) + + $default reduce using rule 123 (func_heading_beginning) + + + +state 85 + + label_decl -> ID_NAME . (rule 32) + + $default reduce using rule 32 (label_decl) + + + +state 86 + + label_decl -> CONST_INT . (rule 31) + + $default reduce using rule 31 (label_decl) + + + +state 87 + + label_decl_sect -> K_LABEL label_list . ';' (rule 26) + label_list -> label_list . ',' label_decl (rule 28) + + ';' shift, and go to state 153 + ',' shift, and go to state 154 + + + +state 88 + + label_list -> label_decl . (rule 27) + + $default reduce using rule 27 (label_list) + + + +state 89 + + proc_heading_beginning -> K_PROCEDURE ID_PROC . (rule 122) + + $default reduce using rule 122 (proc_heading_beginning) + + + +state 90 + + proc_heading_beginning -> K_PROCEDURE ID_NAME . (rule 121) + + $default reduce using rule 121 (proc_heading_beginning) + + + +state 91 + + type_decl -> ID_NAME . '=' type ';' (rule 75) + + '=' shift, and go to state 155 + + + +state 92 + + type_decl_sect -> K_TYPE type_decl . (rule 35) + + $default reduce using rule 35 (type_decl_sect) + + + +state 93 + + id_name_list -> id_name_list . ',' ID_NAME (rule 10) + var_decl -> id_name_list . ':' type absolute_clause ';' (rule 115) + + ',' shift, and go to state 25 + ':' shift, and go to state 156 + + + +state 94 + + var_decl_sect -> K_VAR var_decl . (rule 37) + + $default reduce using rule 37 (var_decl_sect) + + + +state 95 + + const_decl_sect -> const_decl_sect const_decl . (rule 34) + + $default reduce using rule 34 (const_decl_sect) + + + +state 96 + + type_decl_sect -> type_decl_sect type_decl . (rule 36) + + $default reduce using rule 36 (type_decl_sect) + + + +state 97 + + var_decl_sect -> var_decl_sect var_decl . (rule 38) + + $default reduce using rule 38 (var_decl_sect) + + + +state 98 + + fp_list -> '(' . fp_sect_list ')' (rule 131) + + K_VAR shift, and go to state 157 + ID_NAME shift, and go to state 16 + + id_name_list go to state 158 + fp_sect_list go to state 159 + fp_sect go to state 160 + + + +state 99 + + proc_heading -> proc_heading_beginning fp_list . ';' (rule 125) + + ';' shift, and go to state 161 + + + +state 100 + + func_heading -> func_heading_beginning fp_list . ':' fptype ';' (rule 126) + + ':' shift, and go to state 162 + + + +state 101 + + proc_block -> K_EXTERNAL . (rule 128) + + $default reduce using rule 128 (proc_block) + + + +state 102 + + proc_block -> K_FORWARD . (rule 129) + + $default reduce using rule 129 (proc_block) + + + +state 103 + + proc_block -> block . (rule 127) + + $default reduce using rule 127 (proc_block) + + + +state 104 + + proc_decl -> proc_heading proc_block . ';' (rule 119) + + ';' shift, and go to state 163 + + + +state 105 + + func_decl -> func_heading proc_block . ';' (rule 120) + + ';' shift, and go to state 164 + + + +state 106 + + const_decl_sect -> const_decl_sect . const_decl (rule 34) + int_decl_sect -> const_decl_sect . (rule 41) + + ID_NAME shift, and go to state 81 + + $default reduce using rule 41 (int_decl_sect) + + const_decl go to state 95 + + + +state 107 + + type_decl_sect -> type_decl_sect . type_decl (rule 36) + int_decl_sect -> type_decl_sect . (rule 42) + + ID_NAME shift, and go to state 91 + + $default reduce using rule 42 (int_decl_sect) + + type_decl go to state 96 + + + +state 108 + + var_decl_sect -> var_decl_sect . var_decl (rule 38) + int_decl_sect -> var_decl_sect . (rule 43) + + ID_NAME shift, and go to state 16 + + $default reduce using rule 43 (int_decl_sect) + + id_name_list go to state 93 + var_decl go to state 97 + + + +state 109 + + int_decl_sect_list -> int_decl_sect_list int_decl_sect . (rule 40) + + $default reduce using rule 40 (int_decl_sect_list) + + + +state 110 + + int_decl_sect -> proc_heading . (rule 44) + + $default reduce using rule 44 (int_decl_sect) + + + +state 111 + + int_decl_sect -> func_heading . (rule 45) + + $default reduce using rule 45 (int_decl_sect) + + + +state 112 + + implementation_part -> K_IMPLEMENTATION uses_clause decl_sect_list . (rule 15) + decl_sect_list -> decl_sect_list . decl_sect (rule 19) + + K_CONST shift, and go to state 28 + K_FUNCTION shift, and go to state 29 + K_LABEL shift, and go to state 30 + K_PROCEDURE shift, and go to state 31 + K_TYPE shift, and go to state 32 + K_VAR shift, and go to state 33 + + $default reduce using rule 15 (implementation_part) + + decl_sect go to state 34 + label_decl_sect go to state 35 + const_decl_sect go to state 36 + type_decl_sect go to state 37 + var_decl_sect go to state 38 + proc_decl go to state 39 + func_decl go to state 40 + proc_heading_beginning go to state 41 + func_heading_beginning go to state 42 + proc_heading go to state 43 + func_heading go to state 44 + + + +state 113 + + unit -> unit_heading interface_part implementation_part initialization_part '.' . (rule 12) + + $default reduce using rule 12 (unit) + + + +state 114 + + program_heading -> K_PROGRAM ID_NAME '(' id_name_list ')' ';' . (rule 6) + + $default reduce using rule 6 (program_heading) + + + +state 115 + + factor -> K_NIL . (rule 220) + + $default reduce using rule 220 (factor) + + + +state 116 + + factor -> K_NOT . factor (rule 224) + + K_NIL shift, and go to state 115 + K_NOT shift, and go to state 116 + ID_FUNC shift, and go to state 117 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_CONST shift, and go to state 118 + CONST_INT shift, and go to state 119 + CONST_REAL shift, and go to state 120 + CONST_STRING shift, and go to state 121 + '(' shift, and go to state 122 + '[' shift, and go to state 125 + '@' shift, and go to state 126 + + record_variable go to state 79 + variable go to state 128 + factor go to state 165 + + + +state 117 + + factor -> ID_FUNC . '(' expr_list ')' (rule 223) + + '(' shift, and go to state 166 + + + +state 118 + + factor -> ID_CONST . (rule 215) + + $default reduce using rule 215 (factor) + + + +state 119 + + factor -> CONST_INT . (rule 216) + + $default reduce using rule 216 (factor) + + + +state 120 + + factor -> CONST_REAL . (rule 217) + + $default reduce using rule 217 (factor) + + + +state 121 + + factor -> CONST_STRING . (rule 218) + + $default reduce using rule 218 (factor) + + + +state 122 + + factor -> '(' . expr ')' (rule 222) + + K_NIL shift, and go to state 115 + K_NOT shift, and go to state 116 + ID_FUNC shift, and go to state 117 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_CONST shift, and go to state 118 + CONST_INT shift, and go to state 119 + CONST_REAL shift, and go to state 120 + CONST_STRING shift, and go to state 121 + '(' shift, and go to state 122 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + '[' shift, and go to state 125 + '@' shift, and go to state 126 + + sign go to state 127 + record_variable go to state 79 + variable go to state 128 + expr go to state 167 + simple_expr go to state 130 + term go to state 131 + factor go to state 132 + + + +state 123 + + sign -> '+' . (rule 55) + + $default reduce using rule 55 (sign) + + + +state 124 + + sign -> '-' . (rule 56) + + $default reduce using rule 56 (sign) + + + +state 125 + + factor -> '[' . elem_list ']' (rule 219) + + K_NIL shift, and go to state 115 + K_NOT shift, and go to state 116 + ID_FUNC shift, and go to state 117 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_CONST shift, and go to state 118 + CONST_INT shift, and go to state 119 + CONST_REAL shift, and go to state 120 + CONST_STRING shift, and go to state 121 + '(' shift, and go to state 122 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + '[' shift, and go to state 125 + '@' shift, and go to state 126 + + $default reduce using rule 225 (elem_list) + + sign go to state 127 + record_variable go to state 79 + variable go to state 128 + expr go to state 168 + simple_expr go to state 130 + term go to state 131 + factor go to state 132 + elem_list go to state 169 + elem_list1 go to state 170 + elem go to state 171 + + + +state 126 + + factor -> '@' . variable (rule 221) + + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + + record_variable go to state 79 + variable go to state 172 + + + +state 127 + + simple_expr -> sign . term (rule 199) + + K_NIL shift, and go to state 115 + K_NOT shift, and go to state 116 + ID_FUNC shift, and go to state 117 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_CONST shift, and go to state 118 + CONST_INT shift, and go to state 119 + CONST_REAL shift, and go to state 120 + CONST_STRING shift, and go to state 121 + '(' shift, and go to state 122 + '[' shift, and go to state 125 + '@' shift, and go to state 126 + + record_variable go to state 79 + variable go to state 128 + term go to state 173 + factor go to state 132 + + + +state 128 + + record_variable -> variable . '.' (rule 183) + variable -> variable . '[' expr_list ']' (rule 185) + variable -> variable . '^' (rule 187) + factor -> variable . (rule 214) + + '.' shift, and go to state 148 + '[' shift, and go to state 149 + '^' shift, and go to state 150 + + $default reduce using rule 214 (factor) + + + +state 129 + + case_stmt -> K_CASE expr . K_OF case_list else_case K_END (rule 164) + + K_OF shift, and go to state 174 + + + +state 130 + + expr -> simple_expr . (rule 189) + expr -> simple_expr . relop simple_expr (rule 190) + simple_expr -> simple_expr . addop term (rule 200) + + K_IN shift, and go to state 175 + K_OR shift, and go to state 176 + K_XOR shift, and go to state 177 + OP_LEQ shift, and go to state 178 + OP_NEQ shift, and go to state 179 + OP_GEQ shift, and go to state 180 + '=' shift, and go to state 181 + '+' shift, and go to state 182 + '-' shift, and go to state 183 + '<' shift, and go to state 184 + '>' shift, and go to state 185 + + $default reduce using rule 189 (expr) + + relop go to state 186 + addop go to state 187 + + + +state 131 + + simple_expr -> term . (rule 198) + term -> term . mulop factor (rule 206) + + K_AND shift, and go to state 188 + K_DIV shift, and go to state 189 + K_MOD shift, and go to state 190 + K_SHL shift, and go to state 191 + K_SHR shift, and go to state 192 + '*' shift, and go to state 193 + '/' shift, and go to state 194 + + $default reduce using rule 198 (simple_expr) + + mulop go to state 195 + + + +state 132 + + term -> factor . (rule 205) + + $default reduce using rule 205 (term) + + + +state 133 + + for_stmt -> K_FOR ID_VAR . OP_DEFEQ expr K_TO expr K_DO stmt (rule 178) + for_stmt -> K_FOR ID_VAR . OP_DEFEQ expr K_DOWNTO expr K_DO stmt (rule 179) + + OP_DEFEQ shift, and go to state 196 + + + +state 134 + + goto_stmt -> K_GOTO label . (rule 158) + + $default reduce using rule 158 (goto_stmt) + + + +state 135 + + if_stmt -> K_IF expr . K_THEN stmt (rule 162) + if_stmt -> K_IF expr . K_THEN stmt K_ELSE stmt (rule 163) + + K_THEN shift, and go to state 197 + + + +state 136 + + stmt_list -> stmt_list . ';' stmt (rule 161) + repeat_stmt -> K_REPEAT stmt_list . K_UNTIL expr (rule 176) + + K_UNTIL shift, and go to state 198 + ';' shift, and go to state 145 + + + +state 137 + + while_stmt -> K_WHILE expr . K_DO stmt (rule 177) + + K_DO shift, and go to state 199 + + + +state 138 + + with_stmt -> K_WITH variable_list . K_DO stmt (rule 180) + variable_list -> variable_list . ',' variable (rule 182) + + K_DO shift, and go to state 200 + ',' shift, and go to state 201 + + + +state 139 + + variable_list -> variable . (rule 181) + record_variable -> variable . '.' (rule 183) + variable -> variable . '[' expr_list ']' (rule 185) + variable -> variable . '^' (rule 187) + + '.' shift, and go to state 148 + '[' shift, and go to state 149 + '^' shift, and go to state 150 + + $default reduce using rule 181 (variable_list) + + + +state 140 + + param_list -> '(' . expr_list ')' (rule 155) + + K_NIL shift, and go to state 115 + K_NOT shift, and go to state 116 + ID_FUNC shift, and go to state 117 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_CONST shift, and go to state 118 + CONST_INT shift, and go to state 119 + CONST_REAL shift, and go to state 120 + CONST_STRING shift, and go to state 121 + '(' shift, and go to state 122 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + '[' shift, and go to state 125 + '@' shift, and go to state 126 + + sign go to state 127 + expr_list go to state 202 + record_variable go to state 79 + variable go to state 128 + expr go to state 203 + simple_expr go to state 130 + term go to state 131 + factor go to state 132 + + + +state 141 + + proc_call -> ID_PROC param_list . (rule 153) + + $default reduce using rule 153 (proc_call) + + + +state 142 + + variable -> ID_TYPE '(' . variable ')' (rule 188) + + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + + record_variable go to state 79 + variable go to state 204 + + + +state 143 + + stmt -> label ':' . unlabelled_stmt (rule 140) + + K_BEGIN shift, and go to state 27 + K_CASE shift, and go to state 53 + K_FOR shift, and go to state 54 + K_GOTO shift, and go to state 55 + K_IF shift, and go to state 56 + K_REPEAT shift, and go to state 57 + K_WHILE shift, and go to state 58 + K_WITH shift, and go to state 59 + ID_PROC shift, and go to state 60 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + + $default reduce using rule 141 (unlabelled_stmt) + + unlabelled_stmt go to state 205 + assignment go to state 68 + proc_call go to state 69 + goto_stmt go to state 70 + compound_stmt go to state 71 + if_stmt go to state 73 + case_stmt go to state 74 + repeat_stmt go to state 75 + while_stmt go to state 76 + for_stmt go to state 77 + with_stmt go to state 78 + record_variable go to state 79 + variable go to state 80 + + + +state 144 + + compound_stmt -> K_BEGIN stmt_list K_END . (rule 159) + + $default reduce using rule 159 (compound_stmt) + + + +state 145 + + stmt_list -> stmt_list ';' . stmt (rule 161) + + K_BEGIN shift, and go to state 27 + K_CASE shift, and go to state 53 + K_FOR shift, and go to state 54 + K_GOTO shift, and go to state 55 + K_IF shift, and go to state 56 + K_REPEAT shift, and go to state 57 + K_WHILE shift, and go to state 58 + K_WITH shift, and go to state 59 + ID_PROC shift, and go to state 60 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_LABEL shift, and go to state 63 + CONST_INT shift, and go to state 64 + + $default reduce using rule 141 (unlabelled_stmt) + + label go to state 65 + stmt go to state 206 + unlabelled_stmt go to state 67 + assignment go to state 68 + proc_call go to state 69 + goto_stmt go to state 70 + compound_stmt go to state 71 + if_stmt go to state 73 + case_stmt go to state 74 + repeat_stmt go to state 75 + while_stmt go to state 76 + for_stmt go to state 77 + with_stmt go to state 78 + record_variable go to state 79 + variable go to state 80 + + + +state 146 + + variable -> record_variable ID_FIELD . (rule 186) + + $default reduce using rule 186 (variable) + + + +state 147 + + assignment -> variable OP_DEFEQ . expr (rule 152) + + K_NIL shift, and go to state 115 + K_NOT shift, and go to state 116 + ID_FUNC shift, and go to state 117 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_CONST shift, and go to state 118 + CONST_INT shift, and go to state 119 + CONST_REAL shift, and go to state 120 + CONST_STRING shift, and go to state 121 + '(' shift, and go to state 122 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + '[' shift, and go to state 125 + '@' shift, and go to state 126 + + sign go to state 127 + record_variable go to state 79 + variable go to state 128 + expr go to state 207 + simple_expr go to state 130 + term go to state 131 + factor go to state 132 + + + +state 148 + + record_variable -> variable '.' . (rule 183) + + $default reduce using rule 183 (record_variable) + + + +state 149 + + variable -> variable '[' . expr_list ']' (rule 185) + + K_NIL shift, and go to state 115 + K_NOT shift, and go to state 116 + ID_FUNC shift, and go to state 117 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_CONST shift, and go to state 118 + CONST_INT shift, and go to state 119 + CONST_REAL shift, and go to state 120 + CONST_STRING shift, and go to state 121 + '(' shift, and go to state 122 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + '[' shift, and go to state 125 + '@' shift, and go to state 126 + + sign go to state 127 + expr_list go to state 208 + record_variable go to state 79 + variable go to state 128 + expr go to state 203 + simple_expr go to state 130 + term go to state 131 + factor go to state 132 + + + +state 150 + + variable -> variable '^' . (rule 187) + + $default reduce using rule 187 (variable) + + + +state 151 + + const_decl -> ID_NAME '=' . const ';' (rule 46) + + ID_CONST shift, and go to state 209 + CONST_INT shift, and go to state 210 + CONST_REAL shift, and go to state 211 + CONST_STRING shift, and go to state 212 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + + const go to state 213 + unsigned_number go to state 214 + sign go to state 215 + + + +state 152 + + const_decl -> ID_NAME ':' . type '=' typed_const ';' (rule 47) + + K_ARRAY shift, and go to state 216 + K_FILE shift, and go to state 217 + K_PACKED shift, and go to state 218 + K_RECORD shift, and go to state 219 + K_SET shift, and go to state 220 + K_STRING shift, and go to state 221 + ID_TYPE shift, and go to state 222 + ID_CONST shift, and go to state 209 + CONST_INT shift, and go to state 210 + CONST_REAL shift, and go to state 211 + CONST_STRING shift, and go to state 212 + '(' shift, and go to state 223 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + '^' shift, and go to state 224 + + const go to state 225 + unsigned_number go to state 214 + sign go to state 215 + type go to state 226 + simple_type go to state 227 + pointer_type go to state 228 + structured_type go to state 229 + unpacked_structured_type go to state 230 + array_type go to state 231 + record_type go to state 232 + set_type go to state 233 + file_type go to state 234 + string_type go to state 235 + + + +state 153 + + label_decl_sect -> K_LABEL label_list ';' . (rule 26) + + $default reduce using rule 26 (label_decl_sect) + + + +state 154 + + label_list -> label_list ',' . label_decl (rule 28) + + ID_NAME shift, and go to state 85 + CONST_INT shift, and go to state 86 + + label_decl go to state 236 + + + +state 155 + + type_decl -> ID_NAME '=' . type ';' (rule 75) + + K_ARRAY shift, and go to state 216 + K_FILE shift, and go to state 217 + K_PACKED shift, and go to state 218 + K_RECORD shift, and go to state 219 + K_SET shift, and go to state 220 + K_STRING shift, and go to state 221 + ID_TYPE shift, and go to state 222 + ID_CONST shift, and go to state 209 + CONST_INT shift, and go to state 210 + CONST_REAL shift, and go to state 211 + CONST_STRING shift, and go to state 212 + '(' shift, and go to state 223 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + '^' shift, and go to state 224 + + const go to state 225 + unsigned_number go to state 214 + sign go to state 215 + type go to state 237 + simple_type go to state 227 + pointer_type go to state 228 + structured_type go to state 229 + unpacked_structured_type go to state 230 + array_type go to state 231 + record_type go to state 232 + set_type go to state 233 + file_type go to state 234 + string_type go to state 235 + + + +state 156 + + var_decl -> id_name_list ':' . type absolute_clause ';' (rule 115) + + K_ARRAY shift, and go to state 216 + K_FILE shift, and go to state 217 + K_PACKED shift, and go to state 218 + K_RECORD shift, and go to state 219 + K_SET shift, and go to state 220 + K_STRING shift, and go to state 221 + ID_TYPE shift, and go to state 222 + ID_CONST shift, and go to state 209 + CONST_INT shift, and go to state 210 + CONST_REAL shift, and go to state 211 + CONST_STRING shift, and go to state 212 + '(' shift, and go to state 223 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + '^' shift, and go to state 224 + + const go to state 225 + unsigned_number go to state 214 + sign go to state 215 + type go to state 238 + simple_type go to state 227 + pointer_type go to state 228 + structured_type go to state 229 + unpacked_structured_type go to state 230 + array_type go to state 231 + record_type go to state 232 + set_type go to state 233 + file_type go to state 234 + string_type go to state 235 + + + +state 157 + + fp_sect -> K_VAR . id_name_list ':' fptype (rule 135) + fp_sect -> K_VAR . id_name_list (rule 136) + + ID_NAME shift, and go to state 16 + + id_name_list go to state 239 + + + +state 158 + + id_name_list -> id_name_list . ',' ID_NAME (rule 10) + fp_sect -> id_name_list . ':' fptype (rule 134) + + ',' shift, and go to state 25 + ':' shift, and go to state 240 + + + +state 159 + + fp_list -> '(' fp_sect_list . ')' (rule 131) + fp_sect_list -> fp_sect_list . ';' fp_sect (rule 133) + + ';' shift, and go to state 241 + ')' shift, and go to state 242 + + + +state 160 + + fp_sect_list -> fp_sect . (rule 132) + + $default reduce using rule 132 (fp_sect_list) + + + +state 161 + + proc_heading -> proc_heading_beginning fp_list ';' . (rule 125) + + $default reduce using rule 125 (proc_heading) + + + +state 162 + + func_heading -> func_heading_beginning fp_list ':' . fptype ';' (rule 126) + + K_STRING shift, and go to state 243 + ID_TYPE shift, and go to state 244 + + fptype go to state 245 + + + +state 163 + + proc_decl -> proc_heading proc_block ';' . (rule 119) + + $default reduce using rule 119 (proc_decl) + + + +state 164 + + func_decl -> func_heading proc_block ';' . (rule 120) + + $default reduce using rule 120 (func_decl) + + + +state 165 + + factor -> K_NOT factor . (rule 224) + + $default reduce using rule 224 (factor) + + + +state 166 + + factor -> ID_FUNC '(' . expr_list ')' (rule 223) + + K_NIL shift, and go to state 115 + K_NOT shift, and go to state 116 + ID_FUNC shift, and go to state 117 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_CONST shift, and go to state 118 + CONST_INT shift, and go to state 119 + CONST_REAL shift, and go to state 120 + CONST_STRING shift, and go to state 121 + '(' shift, and go to state 122 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + '[' shift, and go to state 125 + '@' shift, and go to state 126 + + sign go to state 127 + expr_list go to state 246 + record_variable go to state 79 + variable go to state 128 + expr go to state 203 + simple_expr go to state 130 + term go to state 131 + factor go to state 132 + + + +state 167 + + factor -> '(' expr . ')' (rule 222) + + ')' shift, and go to state 247 + + + +state 168 + + elem -> expr . (rule 229) + elem -> expr . OP_DOTDOT expr (rule 230) + + OP_DOTDOT shift, and go to state 248 + + $default reduce using rule 229 (elem) + + + +state 169 + + factor -> '[' elem_list . ']' (rule 219) + + ']' shift, and go to state 249 + + + +state 170 + + elem_list -> elem_list1 . (rule 226) + elem_list1 -> elem_list1 . ',' elem (rule 228) + + ',' shift, and go to state 250 + + $default reduce using rule 226 (elem_list) + + + +state 171 + + elem_list1 -> elem . (rule 227) + + $default reduce using rule 227 (elem_list1) + + + +state 172 + + record_variable -> variable . '.' (rule 183) + variable -> variable . '[' expr_list ']' (rule 185) + variable -> variable . '^' (rule 187) + factor -> '@' variable . (rule 221) + + '.' shift, and go to state 148 + '[' shift, and go to state 149 + '^' shift, and go to state 150 + + $default reduce using rule 221 (factor) + + + +state 173 + + simple_expr -> sign term . (rule 199) + term -> term . mulop factor (rule 206) + + K_AND shift, and go to state 188 + K_DIV shift, and go to state 189 + K_MOD shift, and go to state 190 + K_SHL shift, and go to state 191 + K_SHR shift, and go to state 192 + '*' shift, and go to state 193 + '/' shift, and go to state 194 + + $default reduce using rule 199 (simple_expr) + + mulop go to state 195 + + + +state 174 + + case_stmt -> K_CASE expr K_OF . case_list else_case K_END (rule 164) + + ID_CONST shift, and go to state 209 + CONST_INT shift, and go to state 210 + CONST_REAL shift, and go to state 211 + CONST_STRING shift, and go to state 212 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + + $default reduce using rule 167 (case) + + const go to state 251 + unsigned_number go to state 214 + sign go to state 215 + case_list go to state 252 + case go to state 253 + case_label_list go to state 254 + case_label go to state 255 + + + +state 175 + + relop -> K_IN . (rule 197) + + $default reduce using rule 197 (relop) + + + +state 176 + + addop -> K_OR . (rule 203) + + $default reduce using rule 203 (addop) + + + +state 177 + + addop -> K_XOR . (rule 204) + + $default reduce using rule 204 (addop) + + + +state 178 + + relop -> OP_LEQ . (rule 195) + + $default reduce using rule 195 (relop) + + + +state 179 + + relop -> OP_NEQ . (rule 192) + + $default reduce using rule 192 (relop) + + + +state 180 + + relop -> OP_GEQ . (rule 196) + + $default reduce using rule 196 (relop) + + + +state 181 + + relop -> '=' . (rule 191) + + $default reduce using rule 191 (relop) + + + +state 182 + + addop -> '+' . (rule 201) + + $default reduce using rule 201 (addop) + + + +state 183 + + addop -> '-' . (rule 202) + + $default reduce using rule 202 (addop) + + + +state 184 + + relop -> '<' . (rule 193) + + $default reduce using rule 193 (relop) + + + +state 185 + + relop -> '>' . (rule 194) + + $default reduce using rule 194 (relop) + + + +state 186 + + expr -> simple_expr relop . simple_expr (rule 190) + + K_NIL shift, and go to state 115 + K_NOT shift, and go to state 116 + ID_FUNC shift, and go to state 117 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_CONST shift, and go to state 118 + CONST_INT shift, and go to state 119 + CONST_REAL shift, and go to state 120 + CONST_STRING shift, and go to state 121 + '(' shift, and go to state 122 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + '[' shift, and go to state 125 + '@' shift, and go to state 126 + + sign go to state 127 + record_variable go to state 79 + variable go to state 128 + simple_expr go to state 256 + term go to state 131 + factor go to state 132 + + + +state 187 + + simple_expr -> simple_expr addop . term (rule 200) + + K_NIL shift, and go to state 115 + K_NOT shift, and go to state 116 + ID_FUNC shift, and go to state 117 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_CONST shift, and go to state 118 + CONST_INT shift, and go to state 119 + CONST_REAL shift, and go to state 120 + CONST_STRING shift, and go to state 121 + '(' shift, and go to state 122 + '[' shift, and go to state 125 + '@' shift, and go to state 126 + + record_variable go to state 79 + variable go to state 128 + term go to state 257 + factor go to state 132 + + + +state 188 + + mulop -> K_AND . (rule 213) + + $default reduce using rule 213 (mulop) + + + +state 189 + + mulop -> K_DIV . (rule 209) + + $default reduce using rule 209 (mulop) + + + +state 190 + + mulop -> K_MOD . (rule 210) + + $default reduce using rule 210 (mulop) + + + +state 191 + + mulop -> K_SHL . (rule 211) + + $default reduce using rule 211 (mulop) + + + +state 192 + + mulop -> K_SHR . (rule 212) + + $default reduce using rule 212 (mulop) + + + +state 193 + + mulop -> '*' . (rule 207) + + $default reduce using rule 207 (mulop) + + + +state 194 + + mulop -> '/' . (rule 208) + + $default reduce using rule 208 (mulop) + + + +state 195 + + term -> term mulop . factor (rule 206) + + K_NIL shift, and go to state 115 + K_NOT shift, and go to state 116 + ID_FUNC shift, and go to state 117 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_CONST shift, and go to state 118 + CONST_INT shift, and go to state 119 + CONST_REAL shift, and go to state 120 + CONST_STRING shift, and go to state 121 + '(' shift, and go to state 122 + '[' shift, and go to state 125 + '@' shift, and go to state 126 + + record_variable go to state 79 + variable go to state 128 + factor go to state 258 + + + +state 196 + + for_stmt -> K_FOR ID_VAR OP_DEFEQ . expr K_TO expr K_DO stmt (rule 178) + for_stmt -> K_FOR ID_VAR OP_DEFEQ . expr K_DOWNTO expr K_DO stmt (rule 179) + + K_NIL shift, and go to state 115 + K_NOT shift, and go to state 116 + ID_FUNC shift, and go to state 117 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_CONST shift, and go to state 118 + CONST_INT shift, and go to state 119 + CONST_REAL shift, and go to state 120 + CONST_STRING shift, and go to state 121 + '(' shift, and go to state 122 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + '[' shift, and go to state 125 + '@' shift, and go to state 126 + + sign go to state 127 + record_variable go to state 79 + variable go to state 128 + expr go to state 259 + simple_expr go to state 130 + term go to state 131 + factor go to state 132 + + + +state 197 + + if_stmt -> K_IF expr K_THEN . stmt (rule 162) + if_stmt -> K_IF expr K_THEN . stmt K_ELSE stmt (rule 163) + + K_BEGIN shift, and go to state 27 + K_CASE shift, and go to state 53 + K_FOR shift, and go to state 54 + K_GOTO shift, and go to state 55 + K_IF shift, and go to state 56 + K_REPEAT shift, and go to state 57 + K_WHILE shift, and go to state 58 + K_WITH shift, and go to state 59 + ID_PROC shift, and go to state 60 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_LABEL shift, and go to state 63 + CONST_INT shift, and go to state 64 + + $default reduce using rule 141 (unlabelled_stmt) + + label go to state 65 + stmt go to state 260 + unlabelled_stmt go to state 67 + assignment go to state 68 + proc_call go to state 69 + goto_stmt go to state 70 + compound_stmt go to state 71 + if_stmt go to state 73 + case_stmt go to state 74 + repeat_stmt go to state 75 + while_stmt go to state 76 + for_stmt go to state 77 + with_stmt go to state 78 + record_variable go to state 79 + variable go to state 80 + + + +state 198 + + repeat_stmt -> K_REPEAT stmt_list K_UNTIL . expr (rule 176) + + K_NIL shift, and go to state 115 + K_NOT shift, and go to state 116 + ID_FUNC shift, and go to state 117 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_CONST shift, and go to state 118 + CONST_INT shift, and go to state 119 + CONST_REAL shift, and go to state 120 + CONST_STRING shift, and go to state 121 + '(' shift, and go to state 122 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + '[' shift, and go to state 125 + '@' shift, and go to state 126 + + sign go to state 127 + record_variable go to state 79 + variable go to state 128 + expr go to state 261 + simple_expr go to state 130 + term go to state 131 + factor go to state 132 + + + +state 199 + + while_stmt -> K_WHILE expr K_DO . stmt (rule 177) + + K_BEGIN shift, and go to state 27 + K_CASE shift, and go to state 53 + K_FOR shift, and go to state 54 + K_GOTO shift, and go to state 55 + K_IF shift, and go to state 56 + K_REPEAT shift, and go to state 57 + K_WHILE shift, and go to state 58 + K_WITH shift, and go to state 59 + ID_PROC shift, and go to state 60 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_LABEL shift, and go to state 63 + CONST_INT shift, and go to state 64 + + $default reduce using rule 141 (unlabelled_stmt) + + label go to state 65 + stmt go to state 262 + unlabelled_stmt go to state 67 + assignment go to state 68 + proc_call go to state 69 + goto_stmt go to state 70 + compound_stmt go to state 71 + if_stmt go to state 73 + case_stmt go to state 74 + repeat_stmt go to state 75 + while_stmt go to state 76 + for_stmt go to state 77 + with_stmt go to state 78 + record_variable go to state 79 + variable go to state 80 + + + +state 200 + + with_stmt -> K_WITH variable_list K_DO . stmt (rule 180) + + K_BEGIN shift, and go to state 27 + K_CASE shift, and go to state 53 + K_FOR shift, and go to state 54 + K_GOTO shift, and go to state 55 + K_IF shift, and go to state 56 + K_REPEAT shift, and go to state 57 + K_WHILE shift, and go to state 58 + K_WITH shift, and go to state 59 + ID_PROC shift, and go to state 60 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_LABEL shift, and go to state 63 + CONST_INT shift, and go to state 64 + + $default reduce using rule 141 (unlabelled_stmt) + + label go to state 65 + stmt go to state 263 + unlabelled_stmt go to state 67 + assignment go to state 68 + proc_call go to state 69 + goto_stmt go to state 70 + compound_stmt go to state 71 + if_stmt go to state 73 + case_stmt go to state 74 + repeat_stmt go to state 75 + while_stmt go to state 76 + for_stmt go to state 77 + with_stmt go to state 78 + record_variable go to state 79 + variable go to state 80 + + + +state 201 + + variable_list -> variable_list ',' . variable (rule 182) + + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + + record_variable go to state 79 + variable go to state 264 + + + +state 202 + + param_list -> '(' expr_list . ')' (rule 155) + expr_list -> expr_list . ',' expr (rule 157) + + ')' shift, and go to state 265 + ',' shift, and go to state 266 + + + +state 203 + + expr_list -> expr . (rule 156) + + $default reduce using rule 156 (expr_list) + + + +state 204 + + record_variable -> variable . '.' (rule 183) + variable -> variable . '[' expr_list ']' (rule 185) + variable -> variable . '^' (rule 187) + variable -> ID_TYPE '(' variable . ')' (rule 188) + + '.' shift, and go to state 148 + ')' shift, and go to state 267 + '[' shift, and go to state 149 + '^' shift, and go to state 150 + + + +state 205 + + stmt -> label ':' unlabelled_stmt . (rule 140) + + $default reduce using rule 140 (stmt) + + + +state 206 + + stmt_list -> stmt_list ';' stmt . (rule 161) + + $default reduce using rule 161 (stmt_list) + + + +state 207 + + assignment -> variable OP_DEFEQ expr . (rule 152) + + $default reduce using rule 152 (assignment) + + + +state 208 + + expr_list -> expr_list . ',' expr (rule 157) + variable -> variable '[' expr_list . ']' (rule 185) + + ',' shift, and go to state 266 + ']' shift, and go to state 268 + + + +state 209 + + const -> ID_CONST . (rule 50) + + $default reduce using rule 50 (const) + + + +state 210 + + unsigned_number -> CONST_INT . (rule 53) + + $default reduce using rule 53 (unsigned_number) + + + +state 211 + + unsigned_number -> CONST_REAL . (rule 54) + + $default reduce using rule 54 (unsigned_number) + + + +state 212 + + const -> CONST_STRING . (rule 52) + + $default reduce using rule 52 (const) + + + +state 213 + + const_decl -> ID_NAME '=' const . ';' (rule 46) + + ';' shift, and go to state 269 + + + +state 214 + + const -> unsigned_number . (rule 48) + + $default reduce using rule 48 (const) + + + +state 215 + + const -> sign . unsigned_number (rule 49) + const -> sign . ID_CONST (rule 51) + + ID_CONST shift, and go to state 270 + CONST_INT shift, and go to state 210 + CONST_REAL shift, and go to state 211 + + unsigned_number go to state 271 + + + +state 216 + + array_type -> K_ARRAY . '[' simple_type_list ']' K_OF type (rule 90) + + '[' shift, and go to state 272 + + + +state 217 + + file_type -> K_FILE . K_OF type (rule 111) + file_type -> K_FILE . (rule 112) + + K_OF shift, and go to state 273 + + $default reduce using rule 112 (file_type) + + + +state 218 + + structured_type -> K_PACKED . unpacked_structured_type (rule 85) + + K_ARRAY shift, and go to state 216 + K_FILE shift, and go to state 217 + K_RECORD shift, and go to state 219 + K_SET shift, and go to state 220 + + unpacked_structured_type go to state 274 + array_type go to state 231 + record_type go to state 232 + set_type go to state 233 + file_type go to state 234 + + + +state 219 + + record_type -> K_RECORD . field_list K_END (rule 93) + + K_CASE shift, and go to state 275 + ID_NAME shift, and go to state 16 + + $default reduce using rule 99 (record_section) + + id_name_list go to state 276 + field_list go to state 277 + fixed_part go to state 278 + record_section go to state 279 + variant_part go to state 280 + + + +state 220 + + set_type -> K_SET . K_OF simple_type (rule 110) + + K_OF shift, and go to state 281 + + + +state 221 + + string_type -> K_STRING . (rule 113) + string_type -> K_STRING . '[' const ']' (rule 114) + + '[' shift, and go to state 282 + + $default reduce using rule 113 (string_type) + + + +state 222 + + simple_type -> ID_TYPE . (rule 80) + + $default reduce using rule 80 (simple_type) + + + +state 223 + + simple_type -> '(' . id_name_list ')' (rule 82) + + ID_NAME shift, and go to state 16 + + id_name_list go to state 283 + + + +state 224 + + pointer_type -> '^' . ID_TYPE (rule 83) + + ID_TYPE shift, and go to state 284 + + + +state 225 + + simple_type -> const . OP_DOTDOT const (rule 81) + + OP_DOTDOT shift, and go to state 285 + + + +state 226 + + const_decl -> ID_NAME ':' type . '=' typed_const ';' (rule 47) + + '=' shift, and go to state 286 + + + +state 227 + + type -> simple_type . (rule 76) + + $default reduce using rule 76 (type) + + + +state 228 + + type -> pointer_type . (rule 77) + + $default reduce using rule 77 (type) + + + +state 229 + + type -> structured_type . (rule 78) + + $default reduce using rule 78 (type) + + + +state 230 + + structured_type -> unpacked_structured_type . (rule 84) + + $default reduce using rule 84 (structured_type) + + + +state 231 + + unpacked_structured_type -> array_type . (rule 86) + + $default reduce using rule 86 (unpacked_structured_type) + + + +state 232 + + unpacked_structured_type -> record_type . (rule 87) + + $default reduce using rule 87 (unpacked_structured_type) + + + +state 233 + + unpacked_structured_type -> set_type . (rule 88) + + $default reduce using rule 88 (unpacked_structured_type) + + + +state 234 + + unpacked_structured_type -> file_type . (rule 89) + + $default reduce using rule 89 (unpacked_structured_type) + + + +state 235 + + type -> string_type . (rule 79) + + $default reduce using rule 79 (type) + + + +state 236 + + label_list -> label_list ',' label_decl . (rule 28) + + $default reduce using rule 28 (label_list) + + + +state 237 + + type_decl -> ID_NAME '=' type . ';' (rule 75) + + ';' shift, and go to state 287 + + + +state 238 + + var_decl -> id_name_list ':' type . absolute_clause ';' (rule 115) + + K_ABSOLUTE shift, and go to state 288 + + $default reduce using rule 116 (absolute_clause) + + absolute_clause go to state 289 + + + +state 239 + + id_name_list -> id_name_list . ',' ID_NAME (rule 10) + fp_sect -> K_VAR id_name_list . ':' fptype (rule 135) + fp_sect -> K_VAR id_name_list . (rule 136) + + ',' shift, and go to state 25 + ':' shift, and go to state 290 + + $default reduce using rule 136 (fp_sect) + + + +state 240 + + fp_sect -> id_name_list ':' . fptype (rule 134) + + K_STRING shift, and go to state 243 + ID_TYPE shift, and go to state 244 + + fptype go to state 291 + + + +state 241 + + fp_sect_list -> fp_sect_list ';' . fp_sect (rule 133) + + K_VAR shift, and go to state 157 + ID_NAME shift, and go to state 16 + + id_name_list go to state 158 + fp_sect go to state 292 + + + +state 242 + + fp_list -> '(' fp_sect_list ')' . (rule 131) + + $default reduce using rule 131 (fp_list) + + + +state 243 + + fptype -> K_STRING . (rule 138) + + $default reduce using rule 138 (fptype) + + + +state 244 + + fptype -> ID_TYPE . (rule 137) + + $default reduce using rule 137 (fptype) + + + +state 245 + + func_heading -> func_heading_beginning fp_list ':' fptype . ';' (rule 126) + + ';' shift, and go to state 293 + + + +state 246 + + expr_list -> expr_list . ',' expr (rule 157) + factor -> ID_FUNC '(' expr_list . ')' (rule 223) + + ')' shift, and go to state 294 + ',' shift, and go to state 266 + + + +state 247 + + factor -> '(' expr ')' . (rule 222) + + $default reduce using rule 222 (factor) + + + +state 248 + + elem -> expr OP_DOTDOT . expr (rule 230) + + K_NIL shift, and go to state 115 + K_NOT shift, and go to state 116 + ID_FUNC shift, and go to state 117 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_CONST shift, and go to state 118 + CONST_INT shift, and go to state 119 + CONST_REAL shift, and go to state 120 + CONST_STRING shift, and go to state 121 + '(' shift, and go to state 122 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + '[' shift, and go to state 125 + '@' shift, and go to state 126 + + sign go to state 127 + record_variable go to state 79 + variable go to state 128 + expr go to state 295 + simple_expr go to state 130 + term go to state 131 + factor go to state 132 + + + +state 249 + + factor -> '[' elem_list ']' . (rule 219) + + $default reduce using rule 219 (factor) + + + +state 250 + + elem_list1 -> elem_list1 ',' . elem (rule 228) + + K_NIL shift, and go to state 115 + K_NOT shift, and go to state 116 + ID_FUNC shift, and go to state 117 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_CONST shift, and go to state 118 + CONST_INT shift, and go to state 119 + CONST_REAL shift, and go to state 120 + CONST_STRING shift, and go to state 121 + '(' shift, and go to state 122 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + '[' shift, and go to state 125 + '@' shift, and go to state 126 + + sign go to state 127 + record_variable go to state 79 + variable go to state 128 + expr go to state 168 + simple_expr go to state 130 + term go to state 131 + factor go to state 132 + elem go to state 296 + + + +state 251 + + case_label -> const . (rule 171) + case_label -> const . OP_DOTDOT const (rule 172) + + OP_DOTDOT shift, and go to state 297 + + $default reduce using rule 171 (case_label) + + + +state 252 + + case_stmt -> K_CASE expr K_OF case_list . else_case K_END (rule 164) + case_list -> case_list . ';' case (rule 166) + + K_ELSE shift, and go to state 298 + ';' shift, and go to state 299 + + $default reduce using rule 173 (else_case) + + else_case go to state 300 + + + +state 253 + + case_list -> case . (rule 165) + + $default reduce using rule 165 (case_list) + + + +state 254 + + case -> case_label_list . ':' stmt (rule 168) + case_label_list -> case_label_list . ',' case_label (rule 170) + + ',' shift, and go to state 301 + ':' shift, and go to state 302 + + + +state 255 + + case_label_list -> case_label . (rule 169) + + $default reduce using rule 169 (case_label_list) + + + +state 256 + + expr -> simple_expr relop simple_expr . (rule 190) + simple_expr -> simple_expr . addop term (rule 200) + + K_OR shift, and go to state 176 + K_XOR shift, and go to state 177 + '+' shift, and go to state 182 + '-' shift, and go to state 183 + + $default reduce using rule 190 (expr) + + addop go to state 187 + + + +state 257 + + simple_expr -> simple_expr addop term . (rule 200) + term -> term . mulop factor (rule 206) + + K_AND shift, and go to state 188 + K_DIV shift, and go to state 189 + K_MOD shift, and go to state 190 + K_SHL shift, and go to state 191 + K_SHR shift, and go to state 192 + '*' shift, and go to state 193 + '/' shift, and go to state 194 + + $default reduce using rule 200 (simple_expr) + + mulop go to state 195 + + + +state 258 + + term -> term mulop factor . (rule 206) + + $default reduce using rule 206 (term) + + + +state 259 + + for_stmt -> K_FOR ID_VAR OP_DEFEQ expr . K_TO expr K_DO stmt (rule 178) + for_stmt -> K_FOR ID_VAR OP_DEFEQ expr . K_DOWNTO expr K_DO stmt (rule 179) + + K_DOWNTO shift, and go to state 303 + K_TO shift, and go to state 304 + + + +state 260 + + if_stmt -> K_IF expr K_THEN stmt . (rule 162) + if_stmt -> K_IF expr K_THEN stmt . K_ELSE stmt (rule 163) + + K_ELSE shift, and go to state 305 + + $default reduce using rule 162 (if_stmt) + + + +state 261 + + repeat_stmt -> K_REPEAT stmt_list K_UNTIL expr . (rule 176) + + $default reduce using rule 176 (repeat_stmt) + + + +state 262 + + while_stmt -> K_WHILE expr K_DO stmt . (rule 177) + + $default reduce using rule 177 (while_stmt) + + + +state 263 + + with_stmt -> K_WITH variable_list K_DO stmt . (rule 180) + + $default reduce using rule 180 (with_stmt) + + + +state 264 + + variable_list -> variable_list ',' variable . (rule 182) + record_variable -> variable . '.' (rule 183) + variable -> variable . '[' expr_list ']' (rule 185) + variable -> variable . '^' (rule 187) + + '.' shift, and go to state 148 + '[' shift, and go to state 149 + '^' shift, and go to state 150 + + $default reduce using rule 182 (variable_list) + + + +state 265 + + param_list -> '(' expr_list ')' . (rule 155) + + $default reduce using rule 155 (param_list) + + + +state 266 + + expr_list -> expr_list ',' . expr (rule 157) + + K_NIL shift, and go to state 115 + K_NOT shift, and go to state 116 + ID_FUNC shift, and go to state 117 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_CONST shift, and go to state 118 + CONST_INT shift, and go to state 119 + CONST_REAL shift, and go to state 120 + CONST_STRING shift, and go to state 121 + '(' shift, and go to state 122 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + '[' shift, and go to state 125 + '@' shift, and go to state 126 + + sign go to state 127 + record_variable go to state 79 + variable go to state 128 + expr go to state 306 + simple_expr go to state 130 + term go to state 131 + factor go to state 132 + + + +state 267 + + variable -> ID_TYPE '(' variable ')' . (rule 188) + + $default reduce using rule 188 (variable) + + + +state 268 + + variable -> variable '[' expr_list ']' . (rule 185) + + $default reduce using rule 185 (variable) + + + +state 269 + + const_decl -> ID_NAME '=' const ';' . (rule 46) + + $default reduce using rule 46 (const_decl) + + + +state 270 + + const -> sign ID_CONST . (rule 51) + + $default reduce using rule 51 (const) + + + +state 271 + + const -> sign unsigned_number . (rule 49) + + $default reduce using rule 49 (const) + + + +state 272 + + array_type -> K_ARRAY '[' . simple_type_list ']' K_OF type (rule 90) + + ID_TYPE shift, and go to state 222 + ID_CONST shift, and go to state 209 + CONST_INT shift, and go to state 210 + CONST_REAL shift, and go to state 211 + CONST_STRING shift, and go to state 212 + '(' shift, and go to state 223 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + + const go to state 225 + unsigned_number go to state 214 + sign go to state 215 + simple_type go to state 307 + simple_type_list go to state 308 + + + +state 273 + + file_type -> K_FILE K_OF . type (rule 111) + + K_ARRAY shift, and go to state 216 + K_FILE shift, and go to state 217 + K_PACKED shift, and go to state 218 + K_RECORD shift, and go to state 219 + K_SET shift, and go to state 220 + K_STRING shift, and go to state 221 + ID_TYPE shift, and go to state 222 + ID_CONST shift, and go to state 209 + CONST_INT shift, and go to state 210 + CONST_REAL shift, and go to state 211 + CONST_STRING shift, and go to state 212 + '(' shift, and go to state 223 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + '^' shift, and go to state 224 + + const go to state 225 + unsigned_number go to state 214 + sign go to state 215 + type go to state 309 + simple_type go to state 227 + pointer_type go to state 228 + structured_type go to state 229 + unpacked_structured_type go to state 230 + array_type go to state 231 + record_type go to state 232 + set_type go to state 233 + file_type go to state 234 + string_type go to state 235 + + + +state 274 + + structured_type -> K_PACKED unpacked_structured_type . (rule 85) + + $default reduce using rule 85 (structured_type) + + + +state 275 + + variant_part -> K_CASE . tag_field K_OF variant_list (rule 101) + + ID_NAME shift, and go to state 310 + + tag_field go to state 311 + + + +state 276 + + id_name_list -> id_name_list . ',' ID_NAME (rule 10) + record_section -> id_name_list . ':' type (rule 100) + + ',' shift, and go to state 25 + ':' shift, and go to state 312 + + + +state 277 + + record_type -> K_RECORD field_list . K_END (rule 93) + + K_END shift, and go to state 313 + + + +state 278 + + field_list -> fixed_part . (rule 94) + field_list -> fixed_part . ';' variant_part (rule 96) + fixed_part -> fixed_part . ';' record_section (rule 98) + + ';' shift, and go to state 314 + + $default reduce using rule 94 (field_list) + + + +state 279 + + fixed_part -> record_section . (rule 97) + + $default reduce using rule 97 (fixed_part) + + + +state 280 + + field_list -> variant_part . (rule 95) + + $default reduce using rule 95 (field_list) + + + +state 281 + + set_type -> K_SET K_OF . simple_type (rule 110) + + ID_TYPE shift, and go to state 222 + ID_CONST shift, and go to state 209 + CONST_INT shift, and go to state 210 + CONST_REAL shift, and go to state 211 + CONST_STRING shift, and go to state 212 + '(' shift, and go to state 223 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + + const go to state 225 + unsigned_number go to state 214 + sign go to state 215 + simple_type go to state 315 + + + +state 282 + + string_type -> K_STRING '[' . const ']' (rule 114) + + ID_CONST shift, and go to state 209 + CONST_INT shift, and go to state 210 + CONST_REAL shift, and go to state 211 + CONST_STRING shift, and go to state 212 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + + const go to state 316 + unsigned_number go to state 214 + sign go to state 215 + + + +state 283 + + id_name_list -> id_name_list . ',' ID_NAME (rule 10) + simple_type -> '(' id_name_list . ')' (rule 82) + + ')' shift, and go to state 317 + ',' shift, and go to state 25 + + + +state 284 + + pointer_type -> '^' ID_TYPE . (rule 83) + + $default reduce using rule 83 (pointer_type) + + + +state 285 + + simple_type -> const OP_DOTDOT . const (rule 81) + + ID_CONST shift, and go to state 209 + CONST_INT shift, and go to state 210 + CONST_REAL shift, and go to state 211 + CONST_STRING shift, and go to state 212 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + + const go to state 318 + unsigned_number go to state 214 + sign go to state 215 + + + +state 286 + + const_decl -> ID_NAME ':' type '=' . typed_const ';' (rule 47) + + ID_CONST shift, and go to state 209 + CONST_INT shift, and go to state 210 + CONST_REAL shift, and go to state 211 + CONST_STRING shift, and go to state 212 + '(' shift, and go to state 319 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + '[' shift, and go to state 320 + + const go to state 321 + unsigned_number go to state 214 + sign go to state 215 + typed_const go to state 322 + array_const go to state 323 + record_const go to state 324 + set_const go to state 325 + + + +state 287 + + type_decl -> ID_NAME '=' type ';' . (rule 75) + + $default reduce using rule 75 (type_decl) + + + +state 288 + + absolute_clause -> K_ABSOLUTE . CONST_INT ':' CONST_INT (rule 117) + absolute_clause -> K_ABSOLUTE . ID_VAR (rule 118) + + ID_VAR shift, and go to state 326 + CONST_INT shift, and go to state 327 + + + +state 289 + + var_decl -> id_name_list ':' type absolute_clause . ';' (rule 115) + + ';' shift, and go to state 328 + + + +state 290 + + fp_sect -> K_VAR id_name_list ':' . fptype (rule 135) + + K_STRING shift, and go to state 243 + ID_TYPE shift, and go to state 244 + + fptype go to state 329 + + + +state 291 + + fp_sect -> id_name_list ':' fptype . (rule 134) + + $default reduce using rule 134 (fp_sect) + + + +state 292 + + fp_sect_list -> fp_sect_list ';' fp_sect . (rule 133) + + $default reduce using rule 133 (fp_sect_list) + + + +state 293 + + func_heading -> func_heading_beginning fp_list ':' fptype ';' . (rule 126) + + $default reduce using rule 126 (func_heading) + + + +state 294 + + factor -> ID_FUNC '(' expr_list ')' . (rule 223) + + $default reduce using rule 223 (factor) + + + +state 295 + + elem -> expr OP_DOTDOT expr . (rule 230) + + $default reduce using rule 230 (elem) + + + +state 296 + + elem_list1 -> elem_list1 ',' elem . (rule 228) + + $default reduce using rule 228 (elem_list1) + + + +state 297 + + case_label -> const OP_DOTDOT . const (rule 172) + + ID_CONST shift, and go to state 209 + CONST_INT shift, and go to state 210 + CONST_REAL shift, and go to state 211 + CONST_STRING shift, and go to state 212 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + + const go to state 330 + unsigned_number go to state 214 + sign go to state 215 + + + +state 298 + + else_case -> K_ELSE . stmt (rule 174) + else_case -> K_ELSE . stmt ';' (rule 175) + + K_BEGIN shift, and go to state 27 + K_CASE shift, and go to state 53 + K_FOR shift, and go to state 54 + K_GOTO shift, and go to state 55 + K_IF shift, and go to state 56 + K_REPEAT shift, and go to state 57 + K_WHILE shift, and go to state 58 + K_WITH shift, and go to state 59 + ID_PROC shift, and go to state 60 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_LABEL shift, and go to state 63 + CONST_INT shift, and go to state 64 + + $default reduce using rule 141 (unlabelled_stmt) + + label go to state 65 + stmt go to state 331 + unlabelled_stmt go to state 67 + assignment go to state 68 + proc_call go to state 69 + goto_stmt go to state 70 + compound_stmt go to state 71 + if_stmt go to state 73 + case_stmt go to state 74 + repeat_stmt go to state 75 + while_stmt go to state 76 + for_stmt go to state 77 + with_stmt go to state 78 + record_variable go to state 79 + variable go to state 80 + + + +state 299 + + case_list -> case_list ';' . case (rule 166) + + ID_CONST shift, and go to state 209 + CONST_INT shift, and go to state 210 + CONST_REAL shift, and go to state 211 + CONST_STRING shift, and go to state 212 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + + $default reduce using rule 167 (case) + + const go to state 251 + unsigned_number go to state 214 + sign go to state 215 + case go to state 332 + case_label_list go to state 254 + case_label go to state 255 + + + +state 300 + + case_stmt -> K_CASE expr K_OF case_list else_case . K_END (rule 164) + + K_END shift, and go to state 333 + + + +state 301 + + case_label_list -> case_label_list ',' . case_label (rule 170) + + ID_CONST shift, and go to state 209 + CONST_INT shift, and go to state 210 + CONST_REAL shift, and go to state 211 + CONST_STRING shift, and go to state 212 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + + const go to state 251 + unsigned_number go to state 214 + sign go to state 215 + case_label go to state 334 + + + +state 302 + + case -> case_label_list ':' . stmt (rule 168) + + K_BEGIN shift, and go to state 27 + K_CASE shift, and go to state 53 + K_FOR shift, and go to state 54 + K_GOTO shift, and go to state 55 + K_IF shift, and go to state 56 + K_REPEAT shift, and go to state 57 + K_WHILE shift, and go to state 58 + K_WITH shift, and go to state 59 + ID_PROC shift, and go to state 60 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_LABEL shift, and go to state 63 + CONST_INT shift, and go to state 64 + + $default reduce using rule 141 (unlabelled_stmt) + + label go to state 65 + stmt go to state 335 + unlabelled_stmt go to state 67 + assignment go to state 68 + proc_call go to state 69 + goto_stmt go to state 70 + compound_stmt go to state 71 + if_stmt go to state 73 + case_stmt go to state 74 + repeat_stmt go to state 75 + while_stmt go to state 76 + for_stmt go to state 77 + with_stmt go to state 78 + record_variable go to state 79 + variable go to state 80 + + + +state 303 + + for_stmt -> K_FOR ID_VAR OP_DEFEQ expr K_DOWNTO . expr K_DO stmt (rule 179) + + K_NIL shift, and go to state 115 + K_NOT shift, and go to state 116 + ID_FUNC shift, and go to state 117 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_CONST shift, and go to state 118 + CONST_INT shift, and go to state 119 + CONST_REAL shift, and go to state 120 + CONST_STRING shift, and go to state 121 + '(' shift, and go to state 122 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + '[' shift, and go to state 125 + '@' shift, and go to state 126 + + sign go to state 127 + record_variable go to state 79 + variable go to state 128 + expr go to state 336 + simple_expr go to state 130 + term go to state 131 + factor go to state 132 + + + +state 304 + + for_stmt -> K_FOR ID_VAR OP_DEFEQ expr K_TO . expr K_DO stmt (rule 178) + + K_NIL shift, and go to state 115 + K_NOT shift, and go to state 116 + ID_FUNC shift, and go to state 117 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_CONST shift, and go to state 118 + CONST_INT shift, and go to state 119 + CONST_REAL shift, and go to state 120 + CONST_STRING shift, and go to state 121 + '(' shift, and go to state 122 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + '[' shift, and go to state 125 + '@' shift, and go to state 126 + + sign go to state 127 + record_variable go to state 79 + variable go to state 128 + expr go to state 337 + simple_expr go to state 130 + term go to state 131 + factor go to state 132 + + + +state 305 + + if_stmt -> K_IF expr K_THEN stmt K_ELSE . stmt (rule 163) + + K_BEGIN shift, and go to state 27 + K_CASE shift, and go to state 53 + K_FOR shift, and go to state 54 + K_GOTO shift, and go to state 55 + K_IF shift, and go to state 56 + K_REPEAT shift, and go to state 57 + K_WHILE shift, and go to state 58 + K_WITH shift, and go to state 59 + ID_PROC shift, and go to state 60 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_LABEL shift, and go to state 63 + CONST_INT shift, and go to state 64 + + $default reduce using rule 141 (unlabelled_stmt) + + label go to state 65 + stmt go to state 338 + unlabelled_stmt go to state 67 + assignment go to state 68 + proc_call go to state 69 + goto_stmt go to state 70 + compound_stmt go to state 71 + if_stmt go to state 73 + case_stmt go to state 74 + repeat_stmt go to state 75 + while_stmt go to state 76 + for_stmt go to state 77 + with_stmt go to state 78 + record_variable go to state 79 + variable go to state 80 + + + +state 306 + + expr_list -> expr_list ',' expr . (rule 157) + + $default reduce using rule 157 (expr_list) + + + +state 307 + + simple_type_list -> simple_type . (rule 91) + + $default reduce using rule 91 (simple_type_list) + + + +state 308 + + array_type -> K_ARRAY '[' simple_type_list . ']' K_OF type (rule 90) + simple_type_list -> simple_type_list . ',' simple_type (rule 92) + + ',' shift, and go to state 339 + ']' shift, and go to state 340 + + + +state 309 + + file_type -> K_FILE K_OF type . (rule 111) + + $default reduce using rule 111 (file_type) + + + +state 310 + + tag_field -> ID_NAME . (rule 102) + tag_field -> ID_NAME . ':' ID_TYPE (rule 103) + + ':' shift, and go to state 341 + + $default reduce using rule 102 (tag_field) + + + +state 311 + + variant_part -> K_CASE tag_field . K_OF variant_list (rule 101) + + K_OF shift, and go to state 342 + + + +state 312 + + record_section -> id_name_list ':' . type (rule 100) + + K_ARRAY shift, and go to state 216 + K_FILE shift, and go to state 217 + K_PACKED shift, and go to state 218 + K_RECORD shift, and go to state 219 + K_SET shift, and go to state 220 + K_STRING shift, and go to state 221 + ID_TYPE shift, and go to state 222 + ID_CONST shift, and go to state 209 + CONST_INT shift, and go to state 210 + CONST_REAL shift, and go to state 211 + CONST_STRING shift, and go to state 212 + '(' shift, and go to state 223 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + '^' shift, and go to state 224 + + const go to state 225 + unsigned_number go to state 214 + sign go to state 215 + type go to state 343 + simple_type go to state 227 + pointer_type go to state 228 + structured_type go to state 229 + unpacked_structured_type go to state 230 + array_type go to state 231 + record_type go to state 232 + set_type go to state 233 + file_type go to state 234 + string_type go to state 235 + + + +state 313 + + record_type -> K_RECORD field_list K_END . (rule 93) + + $default reduce using rule 93 (record_type) + + + +state 314 + + field_list -> fixed_part ';' . variant_part (rule 96) + fixed_part -> fixed_part ';' . record_section (rule 98) + + K_CASE shift, and go to state 275 + ID_NAME shift, and go to state 16 + + $default reduce using rule 99 (record_section) + + id_name_list go to state 276 + record_section go to state 344 + variant_part go to state 345 + + + +state 315 + + set_type -> K_SET K_OF simple_type . (rule 110) + + $default reduce using rule 110 (set_type) + + + +state 316 + + string_type -> K_STRING '[' const . ']' (rule 114) + + ']' shift, and go to state 346 + + + +state 317 + + simple_type -> '(' id_name_list ')' . (rule 82) + + $default reduce using rule 82 (simple_type) + + + +state 318 + + simple_type -> const OP_DOTDOT const . (rule 81) + + $default reduce using rule 81 (simple_type) + + + +state 319 + + array_const -> '(' . typed_const_list ')' (rule 61) + record_const -> '(' . const_field_list ')' (rule 64) + + ID_CONST shift, and go to state 209 + ID_FIELD shift, and go to state 347 + CONST_INT shift, and go to state 210 + CONST_REAL shift, and go to state 211 + CONST_STRING shift, and go to state 212 + '(' shift, and go to state 319 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + '[' shift, and go to state 320 + + const go to state 321 + unsigned_number go to state 214 + sign go to state 215 + typed_const go to state 348 + array_const go to state 323 + typed_const_list go to state 349 + record_const go to state 324 + const_field_list go to state 350 + const_field go to state 351 + set_const go to state 325 + + + +state 320 + + set_const -> '[' . const_elem_list ']' (rule 68) + + ID_CONST shift, and go to state 209 + CONST_INT shift, and go to state 210 + CONST_REAL shift, and go to state 211 + CONST_STRING shift, and go to state 212 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + + $default reduce using rule 69 (const_elem_list) + + const go to state 352 + unsigned_number go to state 214 + sign go to state 215 + const_elem_list go to state 353 + const_elem_list1 go to state 354 + const_elem go to state 355 + + + +state 321 + + typed_const -> const . (rule 57) + + $default reduce using rule 57 (typed_const) + + + +state 322 + + const_decl -> ID_NAME ':' type '=' typed_const . ';' (rule 47) + + ';' shift, and go to state 356 + + + +state 323 + + typed_const -> array_const . (rule 58) + + $default reduce using rule 58 (typed_const) + + + +state 324 + + typed_const -> record_const . (rule 59) + + $default reduce using rule 59 (typed_const) + + + +state 325 + + typed_const -> set_const . (rule 60) + + $default reduce using rule 60 (typed_const) + + + +state 326 + + absolute_clause -> K_ABSOLUTE ID_VAR . (rule 118) + + $default reduce using rule 118 (absolute_clause) + + + +state 327 + + absolute_clause -> K_ABSOLUTE CONST_INT . ':' CONST_INT (rule 117) + + ':' shift, and go to state 357 + + + +state 328 + + var_decl -> id_name_list ':' type absolute_clause ';' . (rule 115) + + $default reduce using rule 115 (var_decl) + + + +state 329 + + fp_sect -> K_VAR id_name_list ':' fptype . (rule 135) + + $default reduce using rule 135 (fp_sect) + + + +state 330 + + case_label -> const OP_DOTDOT const . (rule 172) + + $default reduce using rule 172 (case_label) + + + +state 331 + + else_case -> K_ELSE stmt . (rule 174) + else_case -> K_ELSE stmt . ';' (rule 175) + + ';' shift, and go to state 358 + + $default reduce using rule 174 (else_case) + + + +state 332 + + case_list -> case_list ';' case . (rule 166) + + $default reduce using rule 166 (case_list) + + + +state 333 + + case_stmt -> K_CASE expr K_OF case_list else_case K_END . (rule 164) + + $default reduce using rule 164 (case_stmt) + + + +state 334 + + case_label_list -> case_label_list ',' case_label . (rule 170) + + $default reduce using rule 170 (case_label_list) + + + +state 335 + + case -> case_label_list ':' stmt . (rule 168) + + $default reduce using rule 168 (case) + + + +state 336 + + for_stmt -> K_FOR ID_VAR OP_DEFEQ expr K_DOWNTO expr . K_DO stmt (rule 179) + + K_DO shift, and go to state 359 + + + +state 337 + + for_stmt -> K_FOR ID_VAR OP_DEFEQ expr K_TO expr . K_DO stmt (rule 178) + + K_DO shift, and go to state 360 + + + +state 338 + + if_stmt -> K_IF expr K_THEN stmt K_ELSE stmt . (rule 163) + + $default reduce using rule 163 (if_stmt) + + + +state 339 + + simple_type_list -> simple_type_list ',' . simple_type (rule 92) + + ID_TYPE shift, and go to state 222 + ID_CONST shift, and go to state 209 + CONST_INT shift, and go to state 210 + CONST_REAL shift, and go to state 211 + CONST_STRING shift, and go to state 212 + '(' shift, and go to state 223 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + + const go to state 225 + unsigned_number go to state 214 + sign go to state 215 + simple_type go to state 361 + + + +state 340 + + array_type -> K_ARRAY '[' simple_type_list ']' . K_OF type (rule 90) + + K_OF shift, and go to state 362 + + + +state 341 + + tag_field -> ID_NAME ':' . ID_TYPE (rule 103) + + ID_TYPE shift, and go to state 363 + + + +state 342 + + variant_part -> K_CASE tag_field K_OF . variant_list (rule 101) + + ID_CONST shift, and go to state 209 + CONST_INT shift, and go to state 210 + CONST_REAL shift, and go to state 211 + CONST_STRING shift, and go to state 212 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + + $default reduce using rule 106 (variant) + + const go to state 364 + unsigned_number go to state 214 + sign go to state 215 + variant_list go to state 365 + variant go to state 366 + case_tag_list go to state 367 + + + +state 343 + + record_section -> id_name_list ':' type . (rule 100) + + $default reduce using rule 100 (record_section) + + + +state 344 + + fixed_part -> fixed_part ';' record_section . (rule 98) + + $default reduce using rule 98 (fixed_part) + + + +state 345 + + field_list -> fixed_part ';' variant_part . (rule 96) + + $default reduce using rule 96 (field_list) + + + +state 346 + + string_type -> K_STRING '[' const ']' . (rule 114) + + $default reduce using rule 114 (string_type) + + + +state 347 + + const_field -> ID_FIELD . ':' typed_const (rule 67) + + ':' shift, and go to state 368 + + + +state 348 + + typed_const_list -> typed_const . (rule 62) + + $default reduce using rule 62 (typed_const_list) + + + +state 349 + + array_const -> '(' typed_const_list . ')' (rule 61) + typed_const_list -> typed_const_list . ',' typed_const (rule 63) + + ')' shift, and go to state 369 + ',' shift, and go to state 370 + + + +state 350 + + record_const -> '(' const_field_list . ')' (rule 64) + const_field_list -> const_field_list . ',' const_field (rule 66) + + ')' shift, and go to state 371 + ',' shift, and go to state 372 + + + +state 351 + + const_field_list -> const_field . (rule 65) + + $default reduce using rule 65 (const_field_list) + + + +state 352 + + const_elem -> const . (rule 73) + const_elem -> const . OP_DOTDOT const (rule 74) + + OP_DOTDOT shift, and go to state 373 + + $default reduce using rule 73 (const_elem) + + + +state 353 + + set_const -> '[' const_elem_list . ']' (rule 68) + + ']' shift, and go to state 374 + + + +state 354 + + const_elem_list -> const_elem_list1 . (rule 70) + const_elem_list1 -> const_elem_list1 . ',' const_elem (rule 72) + + ',' shift, and go to state 375 + + $default reduce using rule 70 (const_elem_list) + + + +state 355 + + const_elem_list1 -> const_elem . (rule 71) + + $default reduce using rule 71 (const_elem_list1) + + + +state 356 + + const_decl -> ID_NAME ':' type '=' typed_const ';' . (rule 47) + + $default reduce using rule 47 (const_decl) + + + +state 357 + + absolute_clause -> K_ABSOLUTE CONST_INT ':' . CONST_INT (rule 117) + + CONST_INT shift, and go to state 376 + + + +state 358 + + else_case -> K_ELSE stmt ';' . (rule 175) + + $default reduce using rule 175 (else_case) + + + +state 359 + + for_stmt -> K_FOR ID_VAR OP_DEFEQ expr K_DOWNTO expr K_DO . stmt (rule 179) + + K_BEGIN shift, and go to state 27 + K_CASE shift, and go to state 53 + K_FOR shift, and go to state 54 + K_GOTO shift, and go to state 55 + K_IF shift, and go to state 56 + K_REPEAT shift, and go to state 57 + K_WHILE shift, and go to state 58 + K_WITH shift, and go to state 59 + ID_PROC shift, and go to state 60 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_LABEL shift, and go to state 63 + CONST_INT shift, and go to state 64 + + $default reduce using rule 141 (unlabelled_stmt) + + label go to state 65 + stmt go to state 377 + unlabelled_stmt go to state 67 + assignment go to state 68 + proc_call go to state 69 + goto_stmt go to state 70 + compound_stmt go to state 71 + if_stmt go to state 73 + case_stmt go to state 74 + repeat_stmt go to state 75 + while_stmt go to state 76 + for_stmt go to state 77 + with_stmt go to state 78 + record_variable go to state 79 + variable go to state 80 + + + +state 360 + + for_stmt -> K_FOR ID_VAR OP_DEFEQ expr K_TO expr K_DO . stmt (rule 178) + + K_BEGIN shift, and go to state 27 + K_CASE shift, and go to state 53 + K_FOR shift, and go to state 54 + K_GOTO shift, and go to state 55 + K_IF shift, and go to state 56 + K_REPEAT shift, and go to state 57 + K_WHILE shift, and go to state 58 + K_WITH shift, and go to state 59 + ID_PROC shift, and go to state 60 + ID_VAR shift, and go to state 61 + ID_TYPE shift, and go to state 62 + ID_LABEL shift, and go to state 63 + CONST_INT shift, and go to state 64 + + $default reduce using rule 141 (unlabelled_stmt) + + label go to state 65 + stmt go to state 378 + unlabelled_stmt go to state 67 + assignment go to state 68 + proc_call go to state 69 + goto_stmt go to state 70 + compound_stmt go to state 71 + if_stmt go to state 73 + case_stmt go to state 74 + repeat_stmt go to state 75 + while_stmt go to state 76 + for_stmt go to state 77 + with_stmt go to state 78 + record_variable go to state 79 + variable go to state 80 + + + +state 361 + + simple_type_list -> simple_type_list ',' simple_type . (rule 92) + + $default reduce using rule 92 (simple_type_list) + + + +state 362 + + array_type -> K_ARRAY '[' simple_type_list ']' K_OF . type (rule 90) + + K_ARRAY shift, and go to state 216 + K_FILE shift, and go to state 217 + K_PACKED shift, and go to state 218 + K_RECORD shift, and go to state 219 + K_SET shift, and go to state 220 + K_STRING shift, and go to state 221 + ID_TYPE shift, and go to state 222 + ID_CONST shift, and go to state 209 + CONST_INT shift, and go to state 210 + CONST_REAL shift, and go to state 211 + CONST_STRING shift, and go to state 212 + '(' shift, and go to state 223 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + '^' shift, and go to state 224 + + const go to state 225 + unsigned_number go to state 214 + sign go to state 215 + type go to state 379 + simple_type go to state 227 + pointer_type go to state 228 + structured_type go to state 229 + unpacked_structured_type go to state 230 + array_type go to state 231 + record_type go to state 232 + set_type go to state 233 + file_type go to state 234 + string_type go to state 235 + + + +state 363 + + tag_field -> ID_NAME ':' ID_TYPE . (rule 103) + + $default reduce using rule 103 (tag_field) + + + +state 364 + + case_tag_list -> const . (rule 108) + + $default reduce using rule 108 (case_tag_list) + + + +state 365 + + variant_part -> K_CASE tag_field K_OF variant_list . (rule 101) + variant_list -> variant_list . ';' variant (rule 105) + + ';' shift, and go to state 380 + + $default reduce using rule 101 (variant_part) + + + +state 366 + + variant_list -> variant . (rule 104) + + $default reduce using rule 104 (variant_list) + + + +state 367 + + variant -> case_tag_list . ':' '(' field_list ')' (rule 107) + case_tag_list -> case_tag_list . ',' const (rule 109) + + ',' shift, and go to state 381 + ':' shift, and go to state 382 + + + +state 368 + + const_field -> ID_FIELD ':' . typed_const (rule 67) + + ID_CONST shift, and go to state 209 + CONST_INT shift, and go to state 210 + CONST_REAL shift, and go to state 211 + CONST_STRING shift, and go to state 212 + '(' shift, and go to state 319 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + '[' shift, and go to state 320 + + const go to state 321 + unsigned_number go to state 214 + sign go to state 215 + typed_const go to state 383 + array_const go to state 323 + record_const go to state 324 + set_const go to state 325 + + + +state 369 + + array_const -> '(' typed_const_list ')' . (rule 61) + + $default reduce using rule 61 (array_const) + + + +state 370 + + typed_const_list -> typed_const_list ',' . typed_const (rule 63) + + ID_CONST shift, and go to state 209 + CONST_INT shift, and go to state 210 + CONST_REAL shift, and go to state 211 + CONST_STRING shift, and go to state 212 + '(' shift, and go to state 319 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + '[' shift, and go to state 320 + + const go to state 321 + unsigned_number go to state 214 + sign go to state 215 + typed_const go to state 384 + array_const go to state 323 + record_const go to state 324 + set_const go to state 325 + + + +state 371 + + record_const -> '(' const_field_list ')' . (rule 64) + + $default reduce using rule 64 (record_const) + + + +state 372 + + const_field_list -> const_field_list ',' . const_field (rule 66) + + ID_FIELD shift, and go to state 347 + + const_field go to state 385 + + + +state 373 + + const_elem -> const OP_DOTDOT . const (rule 74) + + ID_CONST shift, and go to state 209 + CONST_INT shift, and go to state 210 + CONST_REAL shift, and go to state 211 + CONST_STRING shift, and go to state 212 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + + const go to state 386 + unsigned_number go to state 214 + sign go to state 215 + + + +state 374 + + set_const -> '[' const_elem_list ']' . (rule 68) + + $default reduce using rule 68 (set_const) + + + +state 375 + + const_elem_list1 -> const_elem_list1 ',' . const_elem (rule 72) + + ID_CONST shift, and go to state 209 + CONST_INT shift, and go to state 210 + CONST_REAL shift, and go to state 211 + CONST_STRING shift, and go to state 212 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + + const go to state 352 + unsigned_number go to state 214 + sign go to state 215 + const_elem go to state 387 + + + +state 376 + + absolute_clause -> K_ABSOLUTE CONST_INT ':' CONST_INT . (rule 117) + + $default reduce using rule 117 (absolute_clause) + + + +state 377 + + for_stmt -> K_FOR ID_VAR OP_DEFEQ expr K_DOWNTO expr K_DO stmt . (rule 179) + + $default reduce using rule 179 (for_stmt) + + + +state 378 + + for_stmt -> K_FOR ID_VAR OP_DEFEQ expr K_TO expr K_DO stmt . (rule 178) + + $default reduce using rule 178 (for_stmt) + + + +state 379 + + array_type -> K_ARRAY '[' simple_type_list ']' K_OF type . (rule 90) + + $default reduce using rule 90 (array_type) + + + +state 380 + + variant_list -> variant_list ';' . variant (rule 105) + + ID_CONST shift, and go to state 209 + CONST_INT shift, and go to state 210 + CONST_REAL shift, and go to state 211 + CONST_STRING shift, and go to state 212 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + + $default reduce using rule 106 (variant) + + const go to state 364 + unsigned_number go to state 214 + sign go to state 215 + variant go to state 388 + case_tag_list go to state 367 + + + +state 381 + + case_tag_list -> case_tag_list ',' . const (rule 109) + + ID_CONST shift, and go to state 209 + CONST_INT shift, and go to state 210 + CONST_REAL shift, and go to state 211 + CONST_STRING shift, and go to state 212 + '+' shift, and go to state 123 + '-' shift, and go to state 124 + + const go to state 389 + unsigned_number go to state 214 + sign go to state 215 + + + +state 382 + + variant -> case_tag_list ':' . '(' field_list ')' (rule 107) + + '(' shift, and go to state 390 + + + +state 383 + + const_field -> ID_FIELD ':' typed_const . (rule 67) + + $default reduce using rule 67 (const_field) + + + +state 384 + + typed_const_list -> typed_const_list ',' typed_const . (rule 63) + + $default reduce using rule 63 (typed_const_list) + + + +state 385 + + const_field_list -> const_field_list ',' const_field . (rule 66) + + $default reduce using rule 66 (const_field_list) + + + +state 386 + + const_elem -> const OP_DOTDOT const . (rule 74) + + $default reduce using rule 74 (const_elem) + + + +state 387 + + const_elem_list1 -> const_elem_list1 ',' const_elem . (rule 72) + + $default reduce using rule 72 (const_elem_list1) + + + +state 388 + + variant_list -> variant_list ';' variant . (rule 105) + + $default reduce using rule 105 (variant_list) + + + +state 389 + + case_tag_list -> case_tag_list ',' const . (rule 109) + + $default reduce using rule 109 (case_tag_list) + + + +state 390 + + variant -> case_tag_list ':' '(' . field_list ')' (rule 107) + + K_CASE shift, and go to state 275 + ID_NAME shift, and go to state 16 + + $default reduce using rule 99 (record_section) + + id_name_list go to state 276 + field_list go to state 391 + fixed_part go to state 278 + record_section go to state 279 + variant_part go to state 280 + + + +state 391 + + variant -> case_tag_list ':' '(' field_list . ')' (rule 107) + + ')' shift, and go to state 392 + + + +state 392 + + variant -> case_tag_list ':' '(' field_list ')' . (rule 107) + + $default reduce using rule 107 (variant) + + + +state 393 + + $ go to state 394 + + + +state 394 + + $ go to state 395 + + + +state 395 + + $default accept + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tp4.tab.c Sat Oct 13 21:11:54 2012 +0200 @@ -0,0 +1,1845 @@ +/* A Bison parser, made from tp4.y + by GNU bison 1.35. */ + +#define YYBISON 1 /* Identify Bison output. */ + +# define K_AND 257 +# define K_ABSOLUTE 258 +# define K_ARRAY 259 +# define K_BEGIN 260 +# define K_CASE 261 +# define K_CONST 262 +# define K_DIV 263 +# define K_DOWNTO 264 +# define K_DO 265 +# define K_ELSE 266 +# define K_END 267 +# define K_EXTERNAL 268 +# define K_FILE 269 +# define K_FORWARD 270 +# define K_FOR 271 +# define K_FUNCTION 272 +# define K_GOTO 273 +# define K_IF 274 +# define K_IMPLEMENTATION 275 +# define K_INTERFACE 276 +# define K_IN 277 +# define K_LABEL 278 +# define K_MOD 279 +# define K_NIL 280 +# define K_NOT 281 +# define K_OF 282 +# define K_OR 283 +# define K_PACKED 284 +# define K_PROCEDURE 285 +# define K_PROGRAM 286 +# define K_RECORD 287 +# define K_REPEAT 288 +# define K_SET 289 +# define K_SHL 290 +# define K_SHR 291 +# define K_STRING 292 +# define K_THEN 293 +# define K_TO 294 +# define K_TYPE 295 +# define K_UNIT 296 +# define K_UNTIL 297 +# define K_USES 298 +# define K_VAR 299 +# define K_WHILE 300 +# define K_WITH 301 +# define K_XOR 302 +# define OP_DOTDOT 303 +# define OP_DEFEQ 304 +# define OP_LEQ 305 +# define OP_NEQ 306 +# define OP_GEQ 307 +# define ID_FUNC 308 +# define ID_PROC 309 +# define ID_VAR 310 +# define ID_TYPE 311 +# define ID_LABEL 312 +# define ID_UNIT 313 +# define ID_CONST 314 +# define ID_FIELD 315 +# define ID_NAME 316 +# define CONST_INT 317 +# define CONST_REAL 318 +# define CONST_STRING 319 + +#line 1 "tp4.y" + +#include <stdio.h> +#include <glib.h> +#include "tokenize.h" +#include "dict.h" +#define YYERROR_VERBOSE +#define YYDEBUG 1 +#define YYLEX_PARAM parser +#define YYPARSE_PARAM parser + +#line 15 "tp4.y" +#ifndef YYSTYPE +typedef union { + int const_int; /* Dla stalych calkowitych. */ + float const_real; /* Dla stalych zmiennoprzecinkowych. */ + char * string; /* Dla stringow i ID_NAME */ + DictEntry * symbol; /* Dla symboli. */ + GList * list; /* Dla list. */ +} yystype; +# define YYSTYPE yystype +# define YYSTYPE_IS_TRIVIAL 1 +#endif +#line 23 "tp4.y" + +/* To musi byc wlaczone po zdefiniowaniu typu %union. */ +#include "parser.h" +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + + + +#define YYFINAL 395 +#define YYFLAG -32768 +#define YYNTBASE 83 + +/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */ +#define YYTRANSLATE(x) ((unsigned)(x) <= 319 ? yytranslate[x] : 185) + +/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */ +static const 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, + 68, 69, 80, 73, 70, 74, 66, 81, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 72, 67, + 78, 71, 79, 2, 82, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 75, 2, 76, 77, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 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, 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 +}; + +#if YYDEBUG +static const short yyprhs[] = +{ + 0, 0, 2, 4, 9, 10, 14, 21, 22, 26, + 28, 32, 35, 41, 45, 49, 53, 55, 57, 58, + 61, 63, 65, 67, 69, 71, 73, 77, 79, 83, + 85, 87, 89, 91, 94, 97, 100, 103, 106, 109, + 110, 113, 115, 117, 119, 121, 123, 128, 135, 137, + 140, 142, 145, 147, 149, 151, 153, 155, 157, 159, + 161, 163, 167, 169, 173, 177, 179, 183, 187, 191, + 192, 194, 196, 200, 202, 206, 211, 213, 215, 217, + 219, 221, 225, 229, 232, 234, 237, 239, 241, 243, + 245, 252, 254, 258, 262, 264, 266, 270, 272, 276, + 277, 281, 286, 288, 292, 294, 298, 299, 305, 307, + 311, 315, 319, 321, 323, 328, 334, 335, 340, 343, + 347, 351, 354, 357, 360, 363, 367, 373, 375, 377, + 379, 380, 384, 386, 390, 394, 399, 402, 404, 406, + 408, 412, 413, 415, 417, 419, 421, 423, 425, 427, + 429, 431, 433, 437, 440, 441, 445, 447, 451, 454, + 458, 460, 464, 469, 476, 483, 485, 489, 490, 494, + 496, 500, 502, 506, 507, 510, 514, 519, 524, 533, + 542, 547, 549, 553, 556, 558, 563, 566, 569, 574, + 576, 580, 582, 584, 586, 588, 590, 592, 594, 596, + 599, 603, 605, 607, 609, 611, 613, 617, 619, 621, + 623, 625, 627, 629, 631, 633, 635, 637, 639, 641, + 645, 647, 650, 654, 659, 662, 663, 665, 667, 671, + 673 +}; +static const short yyrhs[] = +{ + 84, 0, 89, 0, 85, 86, 88, 66, 0, 0, + 32, 62, 67, 0, 32, 62, 68, 87, 69, 67, + 0, 0, 44, 87, 67, 0, 62, 0, 87, 70, + 62, 0, 94, 159, 0, 90, 91, 92, 93, 66, + 0, 42, 62, 67, 0, 22, 86, 103, 0, 21, + 86, 94, 0, 159, 0, 13, 0, 0, 94, 95, + 0, 96, 0, 100, 0, 101, 0, 102, 0, 141, + 0, 142, 0, 24, 97, 67, 0, 99, 0, 97, + 70, 99, 0, 63, 0, 58, 0, 63, 0, 62, + 0, 8, 105, 0, 100, 105, 0, 41, 119, 0, + 101, 119, 0, 45, 139, 0, 102, 139, 0, 0, + 103, 104, 0, 100, 0, 101, 0, 102, 0, 145, + 0, 146, 0, 62, 71, 106, 67, 0, 62, 72, + 120, 71, 109, 67, 0, 107, 0, 108, 107, 0, + 60, 0, 108, 60, 0, 65, 0, 63, 0, 64, + 0, 73, 0, 74, 0, 106, 0, 110, 0, 112, + 0, 115, 0, 68, 111, 69, 0, 109, 0, 111, + 70, 109, 0, 68, 113, 69, 0, 114, 0, 113, + 70, 114, 0, 61, 72, 109, 0, 75, 116, 76, + 0, 0, 117, 0, 118, 0, 117, 70, 118, 0, + 106, 0, 106, 49, 106, 0, 62, 71, 120, 67, + 0, 121, 0, 122, 0, 123, 0, 138, 0, 57, + 0, 106, 49, 106, 0, 68, 87, 69, 0, 77, + 57, 0, 124, 0, 30, 124, 0, 125, 0, 127, + 0, 136, 0, 137, 0, 5, 75, 126, 76, 28, + 120, 0, 121, 0, 126, 70, 121, 0, 33, 128, + 13, 0, 129, 0, 131, 0, 129, 67, 131, 0, + 130, 0, 129, 67, 130, 0, 0, 87, 72, 120, + 0, 7, 132, 28, 133, 0, 62, 0, 62, 72, + 57, 0, 134, 0, 133, 67, 134, 0, 0, 135, + 72, 68, 128, 69, 0, 106, 0, 135, 70, 106, + 0, 35, 28, 121, 0, 15, 28, 120, 0, 15, + 0, 38, 0, 38, 75, 106, 76, 0, 87, 72, + 120, 140, 67, 0, 0, 4, 63, 72, 63, 0, + 4, 56, 0, 145, 147, 67, 0, 146, 147, 67, + 0, 31, 62, 0, 31, 55, 0, 18, 62, 0, + 18, 54, 0, 143, 148, 67, 0, 144, 148, 72, + 151, 67, 0, 88, 0, 14, 0, 16, 0, 0, + 68, 149, 69, 0, 150, 0, 149, 67, 150, 0, + 87, 72, 151, 0, 45, 87, 72, 151, 0, 45, + 87, 0, 57, 0, 38, 0, 153, 0, 98, 72, + 153, 0, 0, 154, 0, 155, 0, 158, 0, 159, + 0, 161, 0, 162, 0, 168, 0, 169, 0, 170, + 0, 171, 0, 174, 50, 175, 0, 55, 156, 0, + 0, 68, 157, 69, 0, 175, 0, 157, 70, 175, + 0, 19, 98, 0, 6, 160, 13, 0, 152, 0, + 160, 67, 152, 0, 20, 175, 39, 152, 0, 20, + 175, 39, 152, 12, 152, 0, 7, 175, 28, 163, + 167, 13, 0, 164, 0, 163, 67, 164, 0, 0, + 165, 72, 152, 0, 166, 0, 165, 70, 166, 0, + 106, 0, 106, 49, 106, 0, 0, 12, 152, 0, + 12, 152, 67, 0, 34, 160, 43, 175, 0, 46, + 175, 11, 152, 0, 17, 56, 50, 175, 40, 175, + 11, 152, 0, 17, 56, 50, 175, 10, 175, 11, + 152, 0, 47, 172, 11, 152, 0, 174, 0, 172, + 70, 174, 0, 174, 66, 0, 56, 0, 174, 75, + 157, 76, 0, 173, 61, 0, 174, 77, 0, 57, + 68, 174, 69, 0, 177, 0, 177, 176, 177, 0, + 71, 0, 52, 0, 78, 0, 79, 0, 51, 0, + 53, 0, 23, 0, 179, 0, 108, 179, 0, 177, + 178, 179, 0, 73, 0, 74, 0, 29, 0, 48, + 0, 181, 0, 179, 180, 181, 0, 80, 0, 81, + 0, 9, 0, 25, 0, 36, 0, 37, 0, 3, + 0, 174, 0, 60, 0, 63, 0, 64, 0, 65, + 0, 75, 182, 76, 0, 26, 0, 82, 174, 0, + 68, 175, 69, 0, 54, 68, 157, 69, 0, 27, + 181, 0, 0, 183, 0, 184, 0, 183, 70, 184, + 0, 175, 0, 175, 49, 175, 0 +}; + +#endif + +#if YYDEBUG +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const short yyrline[] = +{ + 0, 83, 87, 94, 98, 99, 100, 108, 109, 119, + 126, 136, 142, 148, 154, 160, 166, 169, 177, 178, + 182, 183, 184, 185, 186, 187, 191, 195, 196, 199, + 202, 207, 215, 222, 223, 227, 228, 232, 233, 243, + 244, 248, 249, 250, 251, 255, 264, 268, 274, 276, + 278, 280, 282, 287, 292, 295, 295, 299, 300, 301, + 302, 306, 310, 311, 315, 319, 320, 324, 329, 333, + 334, 338, 339, 343, 344, 350, 356, 357, 358, 359, + 363, 365, 367, 374, 378, 379, 383, 384, 385, 386, + 390, 394, 395, 399, 403, 404, 405, 409, 410, 414, + 415, 422, 426, 428, 433, 434, 437, 438, 442, 443, + 447, 451, 452, 456, 457, 463, 473, 474, 475, 481, + 490, 501, 506, 513, 518, 525, 529, 533, 534, 535, + 538, 539, 543, 544, 547, 552, 557, 564, 566, 571, + 572, 576, 577, 578, 579, 580, 581, 582, 583, 584, + 585, 586, 590, 594, 599, 600, 604, 605, 609, 613, + 617, 618, 621, 622, 626, 630, 631, 634, 635, 639, + 640, 644, 645, 649, 650, 651, 655, 659, 663, 664, + 668, 672, 673, 679, 683, 685, 686, 687, 688, 694, + 695, 698, 698, 698, 698, 698, 698, 698, 702, 703, + 704, 707, 707, 707, 707, 710, 711, 714, 714, 714, + 714, 714, 714, 714, 720, 721, 723, 725, 727, 729, + 730, 731, 732, 733, 735, 739, 740, 744, 745, 748, + 749 +}; +#endif + + +#if (YYDEBUG) || defined YYERROR_VERBOSE + +/* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */ +static const char *const yytname[] = +{ + "$", "error", "$undefined.", "K_AND", "K_ABSOLUTE", "K_ARRAY", "K_BEGIN", + "K_CASE", "K_CONST", "K_DIV", "K_DOWNTO", "K_DO", "K_ELSE", "K_END", + "K_EXTERNAL", "K_FILE", "K_FORWARD", "K_FOR", "K_FUNCTION", "K_GOTO", + "K_IF", "K_IMPLEMENTATION", "K_INTERFACE", "K_IN", "K_LABEL", "K_MOD", + "K_NIL", "K_NOT", "K_OF", "K_OR", "K_PACKED", "K_PROCEDURE", + "K_PROGRAM", "K_RECORD", "K_REPEAT", "K_SET", "K_SHL", "K_SHR", + "K_STRING", "K_THEN", "K_TO", "K_TYPE", "K_UNIT", "K_UNTIL", "K_USES", + "K_VAR", "K_WHILE", "K_WITH", "K_XOR", "OP_DOTDOT", "OP_DEFEQ", + "OP_LEQ", "OP_NEQ", "OP_GEQ", "ID_FUNC", "ID_PROC", "ID_VAR", "ID_TYPE", + "ID_LABEL", "ID_UNIT", "ID_CONST", "ID_FIELD", "ID_NAME", "CONST_INT", + "CONST_REAL", "CONST_STRING", "'.'", "';'", "'('", "')'", "','", "'='", + "':'", "'+'", "'-'", "'['", "']'", "'^'", "'<'", "'>'", "'*'", "'/'", + "'@'", "compilation_unit", "program", "program_heading", "uses_clause", + "id_name_list", "block", "unit", "unit_heading", "interface_part", + "implementation_part", "initialization_part", "decl_sect_list", + "decl_sect", "label_decl_sect", "label_list", "label", "label_decl", + "const_decl_sect", "type_decl_sect", "var_decl_sect", + "int_decl_sect_list", "int_decl_sect", "const_decl", "const", + "unsigned_number", "sign", "typed_const", "array_const", + "typed_const_list", "record_const", "const_field_list", "const_field", + "set_const", "const_elem_list", "const_elem_list1", "const_elem", + "type_decl", "type", "simple_type", "pointer_type", "structured_type", + "unpacked_structured_type", "array_type", "simple_type_list", + "record_type", "field_list", "fixed_part", "record_section", + "variant_part", "tag_field", "variant_list", "variant", "case_tag_list", + "set_type", "file_type", "string_type", "var_decl", "absolute_clause", + "proc_decl", "func_decl", "proc_heading_beginning", + "func_heading_beginning", "proc_heading", "func_heading", "proc_block", + "fp_list", "fp_sect_list", "fp_sect", "fptype", "stmt", + "unlabelled_stmt", "assignment", "proc_call", "param_list", "expr_list", + "goto_stmt", "compound_stmt", "stmt_list", "if_stmt", "case_stmt", + "case_list", "case", "case_label_list", "case_label", "else_case", + "repeat_stmt", "while_stmt", "for_stmt", "with_stmt", "variable_list", + "record_variable", "variable", "expr", "relop", "simple_expr", "addop", + "term", "mulop", "factor", "elem_list", "elem_list1", "elem", 0 +}; +#endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const short yyr1[] = +{ + 0, 83, 83, 84, 85, 85, 85, 86, 86, 87, + 87, 88, 89, 90, 91, 92, 93, 93, 94, 94, + 95, 95, 95, 95, 95, 95, 96, 97, 97, 98, + 98, 99, 99, 100, 100, 101, 101, 102, 102, 103, + 103, 104, 104, 104, 104, 104, 105, 105, 106, 106, + 106, 106, 106, 107, 107, 108, 108, 109, 109, 109, + 109, 110, 111, 111, 112, 113, 113, 114, 115, 116, + 116, 117, 117, 118, 118, 119, 120, 120, 120, 120, + 121, 121, 121, 122, 123, 123, 124, 124, 124, 124, + 125, 126, 126, 127, 128, 128, 128, 129, 129, 130, + 130, 131, 132, 132, 133, 133, 134, 134, 135, 135, + 136, 137, 137, 138, 138, 139, 140, 140, 140, 141, + 142, 143, 143, 144, 144, 145, 146, 147, 147, 147, + 148, 148, 149, 149, 150, 150, 150, 151, 151, 152, + 152, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 154, 155, 156, 156, 157, 157, 158, 159, + 160, 160, 161, 161, 162, 163, 163, 164, 164, 165, + 165, 166, 166, 167, 167, 167, 168, 169, 170, 170, + 171, 172, 172, 173, 174, 174, 174, 174, 174, 175, + 175, 176, 176, 176, 176, 176, 176, 176, 177, 177, + 177, 178, 178, 178, 178, 179, 179, 180, 180, 180, + 180, 180, 180, 180, 181, 181, 181, 181, 181, 181, + 181, 181, 181, 181, 181, 182, 182, 183, 183, 184, + 184 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const short yyr2[] = +{ + 0, 1, 1, 4, 0, 3, 6, 0, 3, 1, + 3, 2, 5, 3, 3, 3, 1, 1, 0, 2, + 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, + 1, 1, 1, 2, 2, 2, 2, 2, 2, 0, + 2, 1, 1, 1, 1, 1, 4, 6, 1, 2, + 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 3, 1, 3, 3, 1, 3, 3, 3, 0, + 1, 1, 3, 1, 3, 4, 1, 1, 1, 1, + 1, 3, 3, 2, 1, 2, 1, 1, 1, 1, + 6, 1, 3, 3, 1, 1, 3, 1, 3, 0, + 3, 4, 1, 3, 1, 3, 0, 5, 1, 3, + 3, 3, 1, 1, 4, 5, 0, 4, 2, 3, + 3, 2, 2, 2, 2, 3, 5, 1, 1, 1, + 0, 3, 1, 3, 3, 4, 2, 1, 1, 1, + 3, 0, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 3, 2, 0, 3, 1, 3, 2, 3, + 1, 3, 4, 6, 6, 1, 3, 0, 3, 1, + 3, 1, 3, 0, 2, 3, 4, 4, 8, 8, + 4, 1, 3, 2, 1, 4, 2, 2, 4, 1, + 3, 1, 1, 1, 1, 1, 1, 1, 1, 2, + 3, 1, 1, 1, 1, 1, 3, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, + 1, 2, 3, 4, 2, 0, 1, 1, 3, 1, + 3 +}; + +/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE + doesn't specify something else to do. Zero means the default is an + error. */ +static const short yydefact[] = +{ + 4, 0, 0, 1, 7, 2, 0, 0, 0, 0, + 18, 7, 0, 5, 0, 13, 9, 0, 0, 0, + 39, 7, 0, 0, 8, 0, 3, 141, 0, 0, + 0, 0, 0, 0, 19, 20, 21, 22, 23, 24, + 25, 130, 130, 18, 18, 11, 14, 18, 17, 0, + 16, 0, 10, 0, 0, 0, 0, 141, 0, 0, + 154, 184, 0, 30, 29, 0, 160, 139, 142, 143, + 144, 145, 0, 146, 147, 148, 149, 150, 151, 0, + 0, 0, 33, 124, 123, 32, 31, 0, 27, 122, + 121, 0, 35, 0, 37, 34, 36, 38, 0, 0, + 0, 128, 129, 127, 0, 0, 41, 42, 43, 40, + 44, 45, 15, 12, 6, 220, 0, 0, 215, 216, + 217, 218, 0, 55, 56, 225, 0, 0, 214, 0, + 189, 198, 205, 0, 158, 0, 0, 0, 0, 181, + 0, 153, 0, 141, 159, 141, 186, 0, 183, 0, + 187, 0, 0, 26, 0, 0, 0, 0, 0, 0, + 132, 125, 0, 119, 120, 224, 0, 0, 229, 0, + 226, 227, 221, 199, 167, 197, 203, 204, 195, 192, + 196, 191, 201, 202, 193, 194, 0, 0, 213, 209, + 210, 211, 212, 207, 208, 0, 0, 141, 0, 141, + 141, 0, 0, 156, 0, 140, 161, 152, 0, 50, + 53, 54, 52, 0, 48, 0, 0, 112, 0, 99, + 0, 113, 80, 0, 0, 0, 0, 76, 77, 78, + 84, 86, 87, 88, 89, 79, 28, 0, 116, 136, + 0, 0, 131, 138, 137, 0, 0, 222, 0, 219, + 0, 171, 173, 165, 0, 169, 190, 200, 206, 0, + 162, 176, 177, 180, 182, 155, 0, 188, 185, 46, + 51, 49, 0, 0, 85, 0, 0, 0, 94, 97, + 95, 0, 0, 0, 83, 0, 0, 75, 0, 0, + 0, 134, 133, 126, 223, 230, 228, 0, 141, 167, + 0, 0, 141, 0, 0, 141, 157, 91, 0, 111, + 102, 0, 0, 93, 99, 110, 0, 82, 81, 0, + 69, 57, 0, 58, 59, 60, 118, 0, 115, 135, + 172, 174, 166, 164, 170, 168, 0, 0, 163, 0, + 0, 0, 106, 100, 98, 96, 114, 0, 62, 0, + 0, 65, 73, 0, 70, 71, 47, 0, 175, 141, + 141, 92, 0, 103, 108, 101, 104, 0, 0, 61, + 0, 64, 0, 0, 68, 0, 117, 179, 178, 90, + 106, 0, 0, 67, 63, 66, 74, 72, 105, 109, + 99, 0, 107, 0, 0, 0 +}; + +static const short yydefgoto[] = +{ + 393, 3, 4, 10, 93, 103, 5, 6, 12, 22, + 49, 19, 34, 35, 87, 65, 88, 36, 37, 38, + 46, 109, 95, 225, 214, 215, 322, 323, 349, 324, + 350, 351, 325, 353, 354, 355, 96, 226, 227, 228, + 229, 230, 231, 308, 232, 277, 278, 279, 280, 311, + 365, 366, 367, 233, 234, 235, 97, 289, 39, 40, + 41, 42, 43, 44, 104, 99, 159, 160, 245, 66, + 67, 68, 69, 141, 202, 70, 71, 72, 73, 74, + 252, 253, 254, 255, 300, 75, 76, 77, 78, 138, + 79, 128, 203, 186, 130, 187, 131, 195, 132, 169, + 170, 171 +}; + +static const short yypact[] = +{ + 39, -36, -2,-32768, 34,-32768, 64, 151, 26, 83, + -32768, 34, 132,-32768, 83,-32768,-32768, -29, 92, 21, + -32768, 34, 118, 176,-32768, 101,-32768, 231, 121, 73, + 193, 89, 127, 83,-32768,-32768, 121, 127, 83,-32768, + -32768, 125, 125, 156, 156,-32768, 80,-32768,-32768, 146, + -32768, 133,-32768, 243, 180, 52, 243, 231, 243, 207, + 154,-32768, 160,-32768,-32768, 171,-32768,-32768,-32768,-32768, + -32768,-32768, -4,-32768,-32768,-32768,-32768,-32768,-32768, 192, + -16, 195,-32768,-32768,-32768,-32768,-32768, 114,-32768,-32768, + -32768, 197,-32768, 131,-32768,-32768,-32768,-32768, -22, 208, + 199,-32768,-32768,-32768, 225, 226, 121, 127, 83,-32768, + -32768,-32768, 24,-32768,-32768,-32768, 275, 227,-32768,-32768, + -32768,-32768, 243,-32768,-32768, 243, 207, 275, 31, 268, + 301, 10,-32768, 248,-32768, 265, -18, 298, -3, 31, + 243,-32768, 207, 339,-32768, 231,-32768, 243,-32768, 243, + -32768, 49, 69,-32768, 193, 69, 69, 83, 135, 142, + -32768,-32768, -14,-32768,-32768,-32768, 243, 241, 263, 237, + 244,-32768, 31, 10, 49,-32768,-32768,-32768,-32768,-32768, + -32768,-32768,-32768,-32768,-32768,-32768, 243, 275,-32768,-32768, + -32768,-32768,-32768,-32768,-32768, 275, 243, 231, 243, 231, + 231, 207, 204,-32768, 91,-32768,-32768,-32768, 60,-32768, + -32768,-32768,-32768, 252,-32768, 128, 240, 292, 134, 15, + 293, 247,-32768, 83, 266, 277, 256,-32768,-32768,-32768, + -32768,-32768,-32768,-32768,-32768,-32768,-32768, 261, 332, 143, + -14, -22,-32768,-32768,-32768, 270, 211,-32768, 243,-32768, + 243, 295, 5,-32768, 153,-32768, 22, 10,-32768, 18, + 329,-32768,-32768,-32768, 31,-32768, 243,-32768,-32768,-32768, + -32768,-32768, 122, 69,-32768, 280, 163, 334, 281,-32768, + -32768, 122, 49, 213,-32768, 49, 166,-32768, -19, 284, + -14,-32768,-32768,-32768,-32768,-32768,-32768, 49, 231, 49, + 342, 49, 231, 243, 243, 231,-32768,-32768, 71,-32768, + 288, 333, 69,-32768, 15,-32768, 286,-32768,-32768, 303, + 49,-32768, 302,-32768,-32768,-32768,-32768, 310,-32768,-32768, + -32768, 316,-32768,-32768,-32768,-32768, 354, 359,-32768, 122, + 356, 330, 49,-32768,-32768,-32768,-32768, 317,-32768, 215, + 221,-32768, 341, 312, 321,-32768,-32768, 335,-32768, 231, + 231,-32768, 69,-32768,-32768, 325,-32768, 172, 166,-32768, + 166,-32768, 336, 49,-32768, 49,-32768,-32768,-32768,-32768, + 49, 49, 331,-32768,-32768,-32768,-32768,-32768,-32768,-32768, + 15, 324,-32768, 400, 401,-32768 +}; + +static const short yypgoto[] = +{ + -32768,-32768,-32768, 107, -9, 392,-32768,-32768,-32768,-32768, + -32768, 357,-32768,-32768,-32768, 348, 251, 360, 361, 362, + -32768,-32768, 381, -121, 196, -46, -283,-32768,-32768,-32768, + -32768, 38,-32768,-32768,-32768, 37, 382, -135, -266,-32768, + -32768, 198,-32768,-32768,-32768, 23,-32768, 103, 104,-32768, + -32768, 35,-32768,-32768,-32768,-32768, 386,-32768,-32768,-32768, + -32768,-32768, 374, 375, 378, 383,-32768, 182, -222, -143, + 283,-32768,-32768,-32768, -74,-32768, 175, 367,-32768,-32768, + -32768, 129,-32768, 126,-32768,-32768,-32768,-32768,-32768,-32768, + -32768, -26, -42,-32768, 245,-32768, -123,-32768, -113,-32768, + -32768, 179 +}; + + +#define YYLAST 431 + + +static const short yytable[] = +{ + 17, 80, 206, 165, 173, 23, 307, 127, 200, 144, + 127, 129, 127, 188, 135, 315, 137, 298, 291, 189, + 237, 238, 275, 157, 243, 198, 7, 27, 303, 28, + 213, 80, 28, 139, 147, 190, 348, 326, 24, 29, + 16, 25, 29, 244, 327, 30, 191, 192, 30, 145, + 148, 176, 31, 251, 260, 31, 262, 263, 304, 149, + 8, 150, 32, 145, 257, 32, 33, 201, 329, 33, + 177, 1, 299, 361, 216, 208, 127, 16, 9, 127, + 167, 2, 258, 168, 217, 383, 11, 384, 28, 158, + 193, 194, 246, 15, 127, 182, 183, 148, 29, 218, + 172, 127, 219, 127, 220, 207, 149, 221, 150, 209, + 63, 31, 210, 211, 212, 64, 204, 80, 20, 80, + 127, 32, 123, 124, 27, 33, 222, 83, 47, 209, + 266, 48, 210, 211, 212, 84, 268, 223, 309, 216, + 127, 339, 123, 124, 89, 16, 224, 340, 239, 217, + 127, 90, 127, 21, 259, 331, 261, 148, 26, 335, + 267, 316, 338, 52, 318, 321, 149, 219, 150, 220, + 101, 80, 102, 80, 80, 264, 330, 343, 251, 222, + 251, 153, 209, 81, 154, 210, 211, 212, 270, 91, + 223, 210, 211, 98, 45, 123, 124, 50, 321, 352, + 114, 25, 127, 156, 127, 25, 295, 240, 168, 241, + 276, 242, 113, 25, 283, 290, 377, 378, 13, 14, + 127, 364, 140, 301, 306, 302, 209, 379, 142, 210, + 211, 212, 158, 25, 319, 312, 133, 27, 53, 123, + 124, 320, 381, 143, 382, 51, 25, 321, 54, 321, + 55, 56, 386, 146, 352, 85, 86, 127, 127, 364, + 389, 336, 337, 61, 62, 57, 151, 152, 155, 115, + 116, 162, 80, 265, 266, 161, 80, 58, 59, 80, + 294, 266, 317, 25, 369, 370, 60, 61, 62, 63, + 371, 372, 163, 164, 64, 166, 174, 117, 196, 61, + 62, 115, 116, 118, 197, 276, 119, 120, 121, 199, + 247, 122, 248, 249, 250, 272, 123, 124, 125, 269, + 273, 281, 282, 284, 175, 126, 285, 286, 287, 117, + 176, 61, 62, 80, 80, 118, 288, 293, 119, 120, + 121, 305, 310, 122, 297, 27, 53, 313, 314, 177, + 125, 328, 178, 179, 180, 333, 54, 126, 55, 56, + 341, 342, 346, 209, 347, 359, 210, 211, 212, 356, + 360, 319, 181, 57, 182, 183, 123, 124, 320, 184, + 185, 276, 357, 358, 362, 58, 59, 363, 374, 368, + 373, 375, 380, 392, 60, 61, 62, 347, 376, 390, + 394, 395, 18, 134, 112, 236, 106, 107, 108, 82, + 385, 271, 387, 391, 92, 388, 274, 344, 345, 94, + 110, 111, 105, 292, 136, 100, 205, 334, 332, 296, + 0, 256 +}; + +static const short yycheck[] = +{ + 9, 27, 145, 116, 127, 14, 272, 53, 11, 13, + 56, 53, 58, 3, 56, 281, 58, 12, 240, 9, + 155, 156, 7, 45, 38, 43, 62, 6, 10, 8, + 151, 57, 8, 59, 50, 25, 319, 56, 67, 18, + 62, 70, 18, 57, 63, 24, 36, 37, 24, 67, + 66, 29, 31, 174, 197, 31, 199, 200, 40, 75, + 62, 77, 41, 67, 187, 41, 45, 70, 290, 45, + 48, 32, 67, 339, 5, 149, 122, 62, 44, 125, + 122, 42, 195, 125, 15, 368, 22, 370, 8, 98, + 80, 81, 166, 67, 140, 73, 74, 66, 18, 30, + 126, 147, 33, 149, 35, 147, 75, 38, 77, 60, + 58, 31, 63, 64, 65, 63, 142, 143, 11, 145, + 166, 41, 73, 74, 6, 45, 57, 54, 21, 60, + 70, 13, 63, 64, 65, 62, 76, 68, 273, 5, + 186, 70, 73, 74, 55, 62, 77, 76, 157, 15, + 196, 62, 198, 21, 196, 298, 198, 66, 66, 302, + 69, 282, 305, 62, 285, 286, 75, 33, 77, 35, + 14, 197, 16, 199, 200, 201, 297, 312, 299, 57, + 301, 67, 60, 62, 70, 63, 64, 65, 60, 62, + 68, 63, 64, 68, 19, 73, 74, 22, 319, 320, + 67, 70, 248, 72, 250, 70, 248, 72, 250, 67, + 219, 69, 66, 70, 223, 72, 359, 360, 67, 68, + 266, 342, 68, 70, 266, 72, 60, 362, 68, 63, + 64, 65, 241, 70, 68, 72, 56, 6, 7, 73, + 74, 75, 70, 72, 72, 69, 70, 368, 17, 370, + 19, 20, 373, 61, 375, 62, 63, 303, 304, 380, + 381, 303, 304, 56, 57, 34, 71, 72, 71, 26, + 27, 72, 298, 69, 70, 67, 302, 46, 47, 305, + 69, 70, 69, 70, 69, 70, 55, 56, 57, 58, + 69, 70, 67, 67, 63, 68, 28, 54, 50, 56, + 57, 26, 27, 60, 39, 314, 63, 64, 65, 11, + 69, 68, 49, 76, 70, 75, 73, 74, 75, 67, + 28, 28, 75, 57, 23, 82, 49, 71, 67, 54, + 29, 56, 57, 359, 360, 60, 4, 67, 63, 64, + 65, 12, 62, 68, 49, 6, 7, 13, 67, 48, + 75, 67, 51, 52, 53, 13, 17, 82, 19, 20, + 72, 28, 76, 60, 61, 11, 63, 64, 65, 67, + 11, 68, 71, 34, 73, 74, 73, 74, 75, 78, + 79, 390, 72, 67, 28, 46, 47, 57, 76, 72, + 49, 70, 67, 69, 55, 56, 57, 61, 63, 68, + 0, 0, 10, 55, 47, 154, 46, 46, 46, 28, + 372, 215, 375, 390, 32, 380, 218, 314, 314, 33, + 46, 46, 44, 241, 57, 42, 143, 301, 299, 250, + -1, 186 +}; +#define YYPURE 1 + +/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ +#line 3 "/usr/share/misc/bison.simple" + +/* Skeleton output parser for bison, + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, 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. */ + +/* This is the parser code that is written into each bison parser when + the %semantic_parser declaration is not specified in the grammar. + It was written by Richard Stallman by simplifying the hairy parser + used when %semantic_parser is specified. */ + +/* 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. */ + +#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE) + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# if YYSTACK_USE_ALLOCA +# define YYSTACK_ALLOC alloca +# else +# ifndef YYSTACK_USE_ALLOCA +# if defined (alloca) || defined (_ALLOCA_H) +# define YYSTACK_ALLOC alloca +# else +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# else +# if defined (__STDC__) || defined (__cplusplus) +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +# define YYSTACK_ALLOC malloc +# define YYSTACK_FREE free +# endif +#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */ + + +#if (! defined (yyoverflow) \ + && (! defined (__cplusplus) \ + || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + short yyss; + YYSTYPE yyvs; +# if YYLSP_NEEDED + YYLTYPE yyls; +# endif +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# if YYLSP_NEEDED +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + + 2 * YYSTACK_GAP_MAX) +# else +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAX) +# endif + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + register 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_MAX; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + + +#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) +# if defined (__STDC__) || defined (__cplusplus) +# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +#endif +#if ! defined (YYSIZE_T) +# define YYSIZE_T unsigned int +#endif + +#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 yyerrlab1 +/* 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); \ + yychar1 = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror ("syntax error: cannot back up"); \ + YYERROR; \ + } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Compute the default location (before the actions + are run). + + When YYLLOC_DEFAULT is run, CURRENT is set the location of the + first token. By default, to implement support for ranges, extend + its range to the last symbol. */ + +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + Current.last_line = Rhs[N].last_line; \ + Current.last_column = Rhs[N].last_column; +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#if YYPURE +# if YYLSP_NEEDED +# ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) +# else +# define YYLEX yylex (&yylval, &yylloc) +# endif +# else /* !YYLSP_NEEDED */ +# ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +# else +# define YYLEX yylex (&yylval) +# endif +# endif /* !YYLSP_NEEDED */ +#else /* !YYPURE */ +# define YYLEX yylex () +#endif /* !YYPURE */ + + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include <stdio.h> /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +#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 + SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#if YYMAXDEPTH == 0 +# undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + +#ifdef 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 +{ + register 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 +{ + register char *yyd = yydest; + register const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif +#endif + +#line 315 "/usr/share/misc/bison.simple" + + +/* The user can define YYPARSE_PARAM as the name of an argument to be passed + into yyparse. The argument should have type void *. + It should actually point to an object. + Grammar actions can access the variable by casting it + to the proper pointer type. */ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +# define YYPARSE_PARAM_ARG void *YYPARSE_PARAM +# define YYPARSE_PARAM_DECL +# else +# define YYPARSE_PARAM_ARG YYPARSE_PARAM +# define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; +# endif +#else /* !YYPARSE_PARAM */ +# define YYPARSE_PARAM_ARG +# define YYPARSE_PARAM_DECL +#endif /* !YYPARSE_PARAM */ + +/* Prevent warning if -Wstrict-prototypes. */ +#ifdef __GNUC__ +# ifdef YYPARSE_PARAM +int yyparse (void *); +# else +int yyparse (void); +# endif +#endif + +/* YY_DECL_VARIABLES -- depending whether we use a pure parser, + variables are global, or local to YYPARSE. */ + +#define YY_DECL_NON_LSP_VARIABLES \ +/* The lookahead symbol. */ \ +int yychar; \ + \ +/* The semantic value of the lookahead symbol. */ \ +YYSTYPE yylval; \ + \ +/* Number of parse errors so far. */ \ +int yynerrs; + +#if YYLSP_NEEDED +# define YY_DECL_VARIABLES \ +YY_DECL_NON_LSP_VARIABLES \ + \ +/* Location data for the lookahead symbol. */ \ +YYLTYPE yylloc; +#else +# define YY_DECL_VARIABLES \ +YY_DECL_NON_LSP_VARIABLES +#endif + + +/* If nonreentrant, generate the variables here. */ + +#if !YYPURE +YY_DECL_VARIABLES +#endif /* !YYPURE */ + +int +yyparse (YYPARSE_PARAM_ARG) + YYPARSE_PARAM_DECL +{ + /* If reentrant, generate the variables here. */ +#if YYPURE + YY_DECL_VARIABLES +#endif /* !YYPURE */ + + register int yystate; + register int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Lookahead token as an internal (translated) token number. */ + int yychar1 = 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 yyssa[YYINITDEPTH]; + short *yyss = yyssa; + register short *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + register YYSTYPE *yyvsp; + +#if YYLSP_NEEDED + /* The location stack. */ + YYLTYPE yylsa[YYINITDEPTH]; + YYLTYPE *yyls = yylsa; + YYLTYPE *yylsp; +#endif + +#if YYLSP_NEEDED +# define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) +#else +# define YYPOPSTACK (yyvsp--, yyssp--) +#endif + + YYSIZE_T yystacksize = YYINITDEPTH; + + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; +#if YYLSP_NEEDED + YYLTYPE yyloc; +#endif + + /* 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; +#if YYLSP_NEEDED + yylsp = yyls; +#endif + 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 (yyssp >= yyss + yystacksize - 1) + { + /* 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 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. */ +# if YYLSP_NEEDED + YYLTYPE *yyls1 = yyls; + /* This used to be a conditional around just the two extra args, + but that might be undefined if yyoverflow is a macro. */ + yyoverflow ("parser stack overflow", + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yyls1, yysize * sizeof (*yylsp), + &yystacksize); + yyls = yyls1; +# else + yyoverflow ("parser stack overflow", + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); +# endif + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyoverflowlab; +# else + /* Extend the stack our own way. */ + if (yystacksize >= YYMAXDEPTH) + goto yyoverflowlab; + yystacksize *= 2; + if (yystacksize > YYMAXDEPTH) + yystacksize = YYMAXDEPTH; + + { + short *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyoverflowlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); +# if YYLSP_NEEDED + YYSTACK_RELOCATE (yyls); +# endif +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; +#if YYLSP_NEEDED + yylsp = yyls + yysize - 1; +#endif + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyssp >= yyss + yystacksize - 1) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + 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. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* yychar is either YYEMPTY or YYEOF + or a valid token in external form. */ + + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + /* Convert token to internal form (in yychar1) for indexing tables with */ + + if (yychar <= 0) /* This means end of input. */ + { + yychar1 = 0; + yychar = YYEOF; /* Don't call YYLEX any more */ + + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yychar1 = YYTRANSLATE (yychar); + +#if YYDEBUG + /* We have to keep this `#if YYDEBUG', since we use variables + which are defined only if `YYDEBUG' is set. */ + if (yydebug) + { + YYFPRINTF (stderr, "Next token is %d (%s", + yychar, yytname[yychar1]); + /* Give the individual parser a way to print the precise + meaning of a token, for further debugging info. */ +# ifdef YYPRINT + YYPRINT (stderr, yychar, yylval); +# endif + YYFPRINTF (stderr, ")\n"); + } +#endif + } + + yyn += yychar1; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) + goto yydefault; + + yyn = yytable[yyn]; + + /* yyn is what to do for this token type in this state. + Negative => reduce, -yyn is rule number. + Positive => shift, yyn is new state. + New state is final state => don't bother to shift, + just return success. + 0, or most negative number => error. */ + + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrlab; + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + YYDPRINTF ((stderr, "Shifting token %d (%s), ", + yychar, yytname[yychar1])); + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; +#if YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + /* 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 the semantic value of + the lookahead token. 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]; + +#if YYLSP_NEEDED + /* Similarly for the default location. Let the user run additional + commands if for instance locations are ranges. */ + yyloc = yylsp[1-yylen]; + YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); +#endif + +#if YYDEBUG + /* We have to keep this `#if YYDEBUG', since we use variables which + are defined only if `YYDEBUG' is set. */ + if (yydebug) + { + int yyi; + + YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", + yyn, yyrline[yyn]); + + /* Print the symbols being reduced, and their result. */ + for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++) + YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); + YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]); + } +#endif + + switch (yyn) { + +case 1: +#line 84 "tp4.y" +{ + printf("Program parsed!\n"); + ; + break;} +case 2: +#line 88 "tp4.y" +{ + printf("Unit parsed!\n"); + ; + break;} +case 6: +#line 101 "tp4.y" +{ + /* Nie wykorzystujemy listy parametrow. */ + freeNameList(yyvsp[-2].list); + ; + break;} +case 8: +#line 110 "tp4.y" +{ + /* XXX Trzeba bedzie tez te unity sparsowac. */ + registerUnitList(parser, yyvsp[-1].list); + freeNameList(yyvsp[-1].list); + ; + break;} +case 9: +#line 120 "tp4.y" +{ + /* Tworzymy pusta liste. */ + yyval.list = NULL; + /* I dodajemy do niej identyfikator. */ + yyval.list = g_list_append(yyval.list, g_strdup(yyvsp[0].string)); + ; + break;} +case 10: +#line 127 "tp4.y" +{ + /* Powtarzamy liste. */ + yyval.list = yyvsp[-2].list; + /* Dodajemy kolejny identyfikator. */ + yyval.list = g_list_append(yyval.list, g_strdup(yyvsp[0].string)); + ; + break;} +case 11: +#line 137 "tp4.y" +{ + ; + break;} +case 12: +#line 143 "tp4.y" +{ + ; + break;} +case 13: +#line 149 "tp4.y" +{ + ; + break;} +case 14: +#line 155 "tp4.y" +{ + ; + break;} +case 15: +#line 161 "tp4.y" +{ + ; + break;} +case 16: +#line 167 "tp4.y" +{ + ; + break;} +case 17: +#line 170 "tp4.y" +{ + ; + break;} +case 29: +#line 200 "tp4.y" +{; + break;} +case 30: +#line 203 "tp4.y" +{; + break;} +case 31: +#line 208 "tp4.y" +{ + /* Tymczasowa zmienna. */ + static char *temp; + temp = g_strdup_printf("%d", yyvsp[0].const_int); + registerLabel(parser, temp); + g_free(temp); + ; + break;} +case 32: +#line 216 "tp4.y" +{ + registerLabel(parser, yyvsp[0].string); + ; + break;} +case 44: +#line 252 "tp4.y" +{ + freeLocal(parser); + ; + break;} +case 45: +#line 256 "tp4.y" +{ + freeLocal(parser); + ; + break;} +case 46: +#line 265 "tp4.y" +{ + registerConst(parser, yyvsp[-3].string); + ; + break;} +case 47: +#line 269 "tp4.y" +{ + registerConst(parser, yyvsp[-5].string); + ; + break;} +case 48: +#line 275 "tp4.y" +{; + break;} +case 49: +#line 277 "tp4.y" +{; + break;} +case 50: +#line 279 "tp4.y" +{; + break;} +case 51: +#line 281 "tp4.y" +{; + break;} +case 52: +#line 283 "tp4.y" +{; + break;} +case 53: +#line 288 "tp4.y" +{ + /* Traktujemy wszystkie numery jak zmiennoprzecinkowe. */ + yyval.const_real = yyvsp[0].const_int; + ; + break;} +case 67: +#line 325 "tp4.y" +{; + break;} +case 75: +#line 351 "tp4.y" +{ + registerType(parser, yyvsp[-3].string); + ; + break;} +case 80: +#line 364 "tp4.y" +{; + break;} +case 81: +#line 366 "tp4.y" +{; + break;} +case 82: +#line 368 "tp4.y" +{ + freeNameList(yyvsp[-1].list); + ; + break;} +case 100: +#line 416 "tp4.y" +{ + freeNameList(yyvsp[-2].list); + ; + break;} +case 102: +#line 427 "tp4.y" +{; + break;} +case 103: +#line 429 "tp4.y" +{; + break;} +case 115: +#line 464 "tp4.y" +{ + /* Rejestrujemy po kolei kazda zmienna. */ + registerVarList(parser, yyvsp[-4].list); + /* Usuwamy sama liste. */ + freeNameList(yyvsp[-4].list); + ; + break;} +case 119: +#line 482 "tp4.y" +{ + fprintf(stderr, "!!! Clearing local namespace!\n"); + --(((Parser *)parser)->level); + freeLocal(parser); + ; + break;} +case 120: +#line 491 "tp4.y" +{ + fprintf(stderr, "!!! Clearing local namespace!\n"); + --(((Parser *)parser)->level); + freeLocal(parser); + ; + break;} +case 121: +#line 502 "tp4.y" +{ + registerProc(parser, yyvsp[0].string); + ++(((Parser *)parser)->level); + ; + break;} +case 122: +#line 507 "tp4.y" +{ + ++(((Parser *)parser)->level); + ; + break;} +case 123: +#line 514 "tp4.y" +{ + registerFunc(parser, yyvsp[0].string); + ++(((Parser *)parser)->level); + ; + break;} +case 124: +#line 519 "tp4.y" +{ + ++(((Parser *)parser)->level); + ; + break;} +case 134: +#line 548 "tp4.y" +{ + registerVarList(parser, yyvsp[-2].list); + freeNameList(yyvsp[-2].list); + ; + break;} +case 135: +#line 553 "tp4.y" +{ + registerVarList(parser, yyvsp[-2].list); + freeNameList(yyvsp[-2].list); + ; + break;} +case 136: +#line 558 "tp4.y" +{ + registerVarList(parser, yyvsp[0].list); + freeNameList(yyvsp[0].list); + ; + break;} +case 137: +#line 565 "tp4.y" +{; + break;} +case 153: +#line 595 "tp4.y" +{; + break;} +case 184: +#line 684 "tp4.y" +{; + break;} +case 188: +#line 689 "tp4.y" +{; + break;} +case 215: +#line 722 "tp4.y" +{; + break;} +case 216: +#line 724 "tp4.y" +{; + break;} +case 217: +#line 726 "tp4.y" +{; + break;} +case 218: +#line 728 "tp4.y" +{; + break;} +case 223: +#line 734 "tp4.y" +{; + break;} +} + +#line 705 "/usr/share/misc/bison.simple" + + + yyvsp -= yylen; + yyssp -= yylen; +#if YYLSP_NEEDED + yylsp -= yylen; +#endif + +#if YYDEBUG + if (yydebug) + { + short *yyssp1 = yyss - 1; + YYFPRINTF (stderr, "state stack now"); + while (yyssp1 != yyssp) + YYFPRINTF (stderr, " %d", *++yyssp1); + YYFPRINTF (stderr, "\n"); + } +#endif + + *++yyvsp = yyval; +#if YYLSP_NEEDED + *++yylsp = yyloc; +#endif + + /* 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 - YYNTBASE] + *yyssp; + if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTBASE]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; + +#ifdef YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (yyn > YYFLAG && yyn < YYLAST) + { + YYSIZE_T yysize = 0; + char *yymsg; + int yyx, yycount; + + yycount = 0; + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + for (yyx = yyn < 0 ? -yyn : 0; + yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) + if (yycheck[yyx + yyn] == yyx) + yysize += yystrlen (yytname[yyx]) + 15, yycount++; + yysize += yystrlen ("parse error, unexpected ") + 1; + yysize += yystrlen (yytname[YYTRANSLATE (yychar)]); + yymsg = (char *) YYSTACK_ALLOC (yysize); + if (yymsg != 0) + { + char *yyp = yystpcpy (yymsg, "parse error, unexpected "); + yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]); + + if (yycount < 5) + { + yycount = 0; + for (yyx = yyn < 0 ? -yyn : 0; + yyx < (int) (sizeof (yytname) / sizeof (char *)); + yyx++) + if (yycheck[yyx + yyn] == yyx) + { + const char *yyq = ! yycount ? ", expecting " : " or "; + yyp = yystpcpy (yyp, yyq); + yyp = yystpcpy (yyp, yytname[yyx]); + yycount++; + } + } + yyerror (yymsg); + YYSTACK_FREE (yymsg); + } + else + yyerror ("parse error; also virtual memory exhausted"); + } + else +#endif /* defined (YYERROR_VERBOSE) */ + yyerror ("parse error"); + } + goto yyerrlab1; + + +/*--------------------------------------------------. +| yyerrlab1 -- error raised explicitly by an action | +`--------------------------------------------------*/ +yyerrlab1: + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + /* return failure if at end of input */ + if (yychar == YYEOF) + YYABORT; + YYDPRINTF ((stderr, "Discarding token %d (%s).\n", + yychar, yytname[yychar1])); + yychar = YYEMPTY; + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + + yyerrstatus = 3; /* Each real token shifted decrements this */ + + goto yyerrhandle; + + +/*-------------------------------------------------------------------. +| yyerrdefault -- current state does not do anything special for the | +| error token. | +`-------------------------------------------------------------------*/ +yyerrdefault: +#if 0 + /* This is wrong; only states that explicitly want error tokens + should shift them. */ + + /* If its default is to accept any token, ok. Otherwise pop it. */ + yyn = yydefact[yystate]; + if (yyn) + goto yydefault; +#endif + + +/*---------------------------------------------------------------. +| yyerrpop -- pop the current state because it cannot handle the | +| error token | +`---------------------------------------------------------------*/ +yyerrpop: + if (yyssp == yyss) + YYABORT; + yyvsp--; + yystate = *--yyssp; +#if YYLSP_NEEDED + yylsp--; +#endif + +#if YYDEBUG + if (yydebug) + { + short *yyssp1 = yyss - 1; + YYFPRINTF (stderr, "Error: state stack now"); + while (yyssp1 != yyssp) + YYFPRINTF (stderr, " %d", *++yyssp1); + YYFPRINTF (stderr, "\n"); + } +#endif + +/*--------------. +| yyerrhandle. | +`--------------*/ +yyerrhandle: + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yyerrdefault; + + yyn += YYTERROR; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) + goto yyerrdefault; + + yyn = yytable[yyn]; + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrpop; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrpop; + + if (yyn == YYFINAL) + YYACCEPT; + + YYDPRINTF ((stderr, "Shifting error token, ")); + + *++yyvsp = yylval; +#if YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +/*---------------------------------------------. +| yyoverflowab -- parser overflow comes here. | +`---------------------------------------------*/ +yyoverflowlab: + yyerror ("parser stack overflow"); + yyresult = 2; + /* Fall through. */ + +yyreturn: +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif + return yyresult; +} +#line 752 "tp4.y"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tp4.tab.h Sat Oct 13 21:11:54 2012 +0200 @@ -0,0 +1,80 @@ +#ifndef BISON_TP4_TAB_H +# define BISON_TP4_TAB_H + +#ifndef YYSTYPE +typedef union { + int const_int; /* Dla stalych calkowitych. */ + float const_real; /* Dla stalych zmiennoprzecinkowych. */ + char * string; /* Dla stringow i ID_NAME */ + DictEntry * symbol; /* Dla symboli. */ + GList * list; /* Dla list. */ +} yystype; +# define YYSTYPE yystype +# define YYSTYPE_IS_TRIVIAL 1 +#endif +# define K_AND 257 +# define K_ABSOLUTE 258 +# define K_ARRAY 259 +# define K_BEGIN 260 +# define K_CASE 261 +# define K_CONST 262 +# define K_DIV 263 +# define K_DOWNTO 264 +# define K_DO 265 +# define K_ELSE 266 +# define K_END 267 +# define K_EXTERNAL 268 +# define K_FILE 269 +# define K_FORWARD 270 +# define K_FOR 271 +# define K_FUNCTION 272 +# define K_GOTO 273 +# define K_IF 274 +# define K_IMPLEMENTATION 275 +# define K_INTERFACE 276 +# define K_IN 277 +# define K_LABEL 278 +# define K_MOD 279 +# define K_NIL 280 +# define K_NOT 281 +# define K_OF 282 +# define K_OR 283 +# define K_PACKED 284 +# define K_PROCEDURE 285 +# define K_PROGRAM 286 +# define K_RECORD 287 +# define K_REPEAT 288 +# define K_SET 289 +# define K_SHL 290 +# define K_SHR 291 +# define K_STRING 292 +# define K_THEN 293 +# define K_TO 294 +# define K_TYPE 295 +# define K_UNIT 296 +# define K_UNTIL 297 +# define K_USES 298 +# define K_VAR 299 +# define K_WHILE 300 +# define K_WITH 301 +# define K_XOR 302 +# define OP_DOTDOT 303 +# define OP_DEFEQ 304 +# define OP_LEQ 305 +# define OP_NEQ 306 +# define OP_GEQ 307 +# define ID_FUNC 308 +# define ID_PROC 309 +# define ID_VAR 310 +# define ID_TYPE 311 +# define ID_LABEL 312 +# define ID_UNIT 313 +# define ID_CONST 314 +# define ID_FIELD 315 +# define ID_NAME 316 +# define CONST_INT 317 +# define CONST_REAL 318 +# define CONST_STRING 319 + + +#endif /* not BISON_TP4_TAB_H */
--- a/tp4.y Sat Oct 13 21:11:33 2012 +0200 +++ b/tp4.y Sat Oct 13 21:11:54 2012 +0200 @@ -1,9 +1,37 @@ -%start compilation_unit +%{ +#include <stdio.h> +#include <glib.h> +#include "tokenize.h" +#include "dict.h" +#define YYERROR_VERBOSE +#define YYDEBUG 1 +#define YYLEX_PARAM parser +#define YYPARSE_PARAM parser +%} + +%pure_parser /* Nie chcemy globalnych zmiennych! Precz z globalnymi zmiennymi! */ -%token +/* Typ danych dla tokenów. */ +%union { + int const_int; /* Dla stalych calkowitych. */ + float const_real; /* Dla stalych zmiennoprzecinkowych. */ + char * string; /* Dla stringow i ID_NAME */ + DictEntry * symbol; /* Dla symboli. */ + GList * list; /* Dla list. */ +} + +%{ +/* To musi byc wlaczone po zdefiniowaniu typu %union. */ +#include "parser.h" +%} + +/* Typy symboli nieterminalnych. */ +%type <list> id_name_list /* Lista identyfikatorow. */ +%type <const_real> unsigned_number /* Stala numeryczna. */ /* Slowa kluczowe, poprzedzone 'K_' dla odroznienia od innych identyfikatorow (na przyklad FILE). */ +%token K_AND K_ABSOLUTE K_ARRAY K_BEGIN K_CASE K_CONST K_DIV K_DOWNTO K_DO K_ELSE K_END K_EXTERNAL @@ -20,44 +48,49 @@ %right K_THEN %right K_ELSE /* resolve dangling else */ -%token /* Wieloznakowe operatory. */ - -K_DOTDOT /* .. */ -K_DEFEQ /* := */ -K_LEQ /* <= */ -K_NEQ /* <> */ -K_GEQ /* >= */ - %token +OP_DOTDOT /* .. */ +OP_DEFEQ /* := */ +OP_LEQ /* <= */ +OP_NEQ /* <> */ +OP_GEQ /* >= */ /* Identyfikatory i stale. */ -/*ID_UNKNOWN*/ /* Identyfikator (zmienna, typ, funkcja, procedura) XXX Rozbic na kilka! */ -ID_FUNC /* Identyfikator funkcji */ -ID_PROC /* Identyfikator procedury */ -ID_VAR /* Identyfikator zmiennej */ -ID_TYPE /* Identyfikator typu */ -ID_LABEL /* Identyfikator etykiety */ -ID_UNIT /* Identyfikator jednostki */ -ID_CONST /* Identyfikator stalej */ -ID_FIELD /* Identyfikator pola rekordu */ -ID_NAME /* Inny identyfikator, przed nadaniem mu znaczenia (przy deklaracji). */ +%type <symbol> ID_FUNC /* Identyfikator funkcji */ +%type <symbol> ID_PROC /* Identyfikator procedury */ +%type <symbol> ID_VAR /* Identyfikator zmiennej */ +%type <symbol> ID_TYPE /* Identyfikator typu */ +%type <symbol> ID_LABEL /* Identyfikator etykiety */ +%type <symbol> ID_UNIT /* Identyfikator jednostki */ +%type <symbol> ID_CONST /* Identyfikator stalej */ +%type <symbol> ID_FIELD /* Identyfikator pola rekordu */ +%type <string> ID_NAME /* Inny identyfikator, przed nadaniem mu znaczenia (przy deklaracji). */ +%token ID_FUNC ID_PROC ID_VAR ID_TYPE ID_LABEL ID_UNIT ID_CONST ID_FIELD ID_NAME -CONST_INT /* Stala calkowita */ -CONST_REAL /* Stala zmiennoprzecinkowa */ -CONST_STRING /* Stala lancuchowa */ +%type <const_int> CONST_INT /* Stala calkowita */ +%type <const_real> CONST_REAL /* Stala zmiennoprzecinkowa */ +%type <const_string> CONST_STRING /* Stala lancuchowa */ +%token CONST_INT CONST_REAL CONST_STRING + +%start compilation_unit %% compilation_unit - : program - | unit + : program + { + printf("Program parsed!\n"); + } + | unit + { + printf("Unit parsed!\n"); + } ; /* Programs: */ - program : program_heading uses_clause block '.' ; @@ -65,56 +98,77 @@ : /* empty */ | K_PROGRAM ID_NAME ';' | K_PROGRAM ID_NAME '(' id_name_list ')' ';' + { + /* Nie wykorzystujemy listy parametrow. */ + freeNameList($4); + } ; uses_clause : /* empty */ - | K_USES id_unit_list ';' + | K_USES id_name_list ';' + { + /* XXX Trzeba bedzie tez te unity sparsowac. */ + registerUnitList(parser, $2); + freeNameList($2); + } ; /* Listy identyfikatorow roznych rodzajow */ - -/* -id_list : ID_UNKNOWN - | id_list ',' ID_UNKNOWN - ; -*/ - -id_name_list : ID_NAME - | id_name_list ',' ID_NAME - ; - -id_unit_list : ID_UNIT - | id_unit_list ',' ID_UNIT +id_name_list : ID_NAME /* Pierwszy element. */ + { + /* Tworzymy pusta liste. */ + $$ = NULL; + /* I dodajemy do niej identyfikator. */ + $$ = g_list_append($$, g_strdup($1)); + } + | id_name_list ',' ID_NAME /* Kolejne elementy. */ + { + /* Powtarzamy liste. */ + $$ = $1; + /* Dodajemy kolejny identyfikator. */ + $$ = g_list_append($$, g_strdup($3)); + } ; /* Blok programu */ - block : decl_sect_list compound_stmt + { + } ; /* Units: */ - -unit : unit_heading interface_part implementation_part - initialization_part '.' +unit : unit_heading interface_part implementation_part initialization_part '.' + { + } ; unit_heading : K_UNIT ID_NAME ';' + { + } ; interface_part : K_INTERFACE uses_clause int_decl_sect_list + { + } ; implementation_part - : K_IMPLEMENTATION decl_sect_list + : K_IMPLEMENTATION uses_clause decl_sect_list + { + } ; initialization_part : compound_stmt + { + } | K_END + { + } ; /* Declaration sections: */ @@ -143,13 +197,25 @@ ; label : CONST_INT + {} /* must be decimal integer in the range 0..9999 */ | ID_LABEL + {} ; /* Uzywany przy deklarowaniu etykiet, kiedy jeszcze nie wiemy, ze ID to etykieta */ label_decl : CONST_INT + { + /* Tymczasowa zmienna. */ + static char *temp; + temp = g_strdup_printf("%d", $1); + registerLabel(parser, temp); + g_free(temp); + } | ID_NAME + { + registerLabel(parser, $1); + } ; const_decl_sect @@ -183,25 +249,46 @@ | type_decl_sect | var_decl_sect | proc_heading + { + freeLocal(parser); + } | func_heading + { + freeLocal(parser); + } ; /* Constant declarations: */ const_decl : ID_NAME '=' const ';' + { + registerConst(parser, $1); + } | ID_NAME ':' type '=' typed_const ';' + { + registerConst(parser, $1); + } ; const : unsigned_number - | sign unsigned_number - | ID_CONST - | sign ID_CONST - | CONST_STRING + {} + | sign unsigned_number + {} + | ID_CONST + {} + | sign ID_CONST + {} + | CONST_STRING + {} ; unsigned_number : CONST_INT + { + /* Traktujemy wszystkie numery jak zmiennoprzecinkowe. */ + $$ = $1; + } | CONST_REAL ; @@ -235,6 +322,7 @@ const_field : ID_FIELD ':' typed_const + {} ; set_const @@ -253,13 +341,16 @@ const_elem : const - | const K_DOTDOT const + | const OP_DOTDOT const ; /* Type declarations: */ type_decl : ID_NAME '=' type ';' + { + registerType(parser, $1); + } ; type : simple_type @@ -270,8 +361,13 @@ simple_type : ID_TYPE - | const K_DOTDOT const /* subrange */ + {} + | const OP_DOTDOT const /* subrange */ + {} | '(' id_name_list ')' /* enumeration */ + { + freeNameList($2); + } ; pointer_type @@ -317,6 +413,9 @@ record_section : /* empty */ | id_name_list ':' type + { + freeNameList($1); + } ; variant_part @@ -325,7 +424,9 @@ tag_field : ID_NAME + {} | ID_NAME ':' ID_TYPE + {} ; variant_list @@ -360,6 +461,12 @@ var_decl : id_name_list ':' type absolute_clause ';' + { + /* Rejestrujemy po kolei kazda zmienna. */ + registerVarList(parser, $1); + /* Usuwamy sama liste. */ + freeNameList($1); + } ; absolute_clause @@ -372,18 +479,54 @@ proc_decl : proc_heading proc_block ';' + { + fprintf(stderr, "!!! Clearing local namespace!\n"); + --(((Parser *)parser)->level); + freeLocal(parser); + } ; func_decl : func_heading proc_block ';' + { + fprintf(stderr, "!!! Clearing local namespace!\n"); + --(((Parser *)parser)->level); + freeLocal(parser); + } + ; + +/* XXX Hack -- nazwa funkcji/procedury musi istniec zanim wczytamy parametry. */ +/* XXX Funkcja/procedura mogla byc juz zadeklarowana. */ +proc_heading_beginning + : K_PROCEDURE ID_NAME + { + registerProc(parser, $2); + ++(((Parser *)parser)->level); + } + | K_PROCEDURE ID_PROC + { + ++(((Parser *)parser)->level); + } + ; + +func_heading_beginning + : K_FUNCTION ID_NAME + { + registerFunc(parser, $2); + ++(((Parser *)parser)->level); + } + | K_FUNCTION ID_FUNC + { + ++(((Parser *)parser)->level); + } ; proc_heading - : K_PROCEDURE ID_NAME fp_list ';' + : proc_heading_beginning fp_list ';' ; func_heading - : K_FUNCTION ID_NAME fp_list ':' fptype ';' + : func_heading_beginning fp_list ':' fptype ';' ; proc_block /* omitted inline and interrupt */ @@ -402,11 +545,24 @@ ; fp_sect : id_name_list ':' fptype + { + registerVarList(parser, $1); + freeNameList($1); + } | K_VAR id_name_list ':' fptype + { + registerVarList(parser, $2); + freeNameList($2); + } | K_VAR id_name_list + { + registerVarList(parser, $2); + freeNameList($2); + } ; fptype : ID_TYPE + {} | K_STRING ; @@ -431,11 +587,12 @@ ; assignment - : variable K_DEFEQ expr + : variable OP_DEFEQ expr ; proc_call : ID_PROC param_list + {} ; param_list @@ -485,7 +642,7 @@ case_label : const - | const K_DOTDOT const + | const OP_DOTDOT const ; else_case @@ -503,8 +660,8 @@ ; for_stmt - : K_FOR ID_VAR K_DEFEQ expr K_TO expr K_DO stmt - | K_FOR ID_VAR K_DEFEQ expr K_DOWNTO expr K_DO stmt + : K_FOR ID_VAR OP_DEFEQ expr K_TO expr K_DO stmt + | K_FOR ID_VAR OP_DEFEQ expr K_DOWNTO expr K_DO stmt ; with_stmt @@ -518,12 +675,18 @@ /* Variables: */ +record_variable + : variable '.' + ; + variable : ID_VAR + {} | variable '[' expr_list ']' /* array component */ - | variable '.' ID_FIELD /* record field */ + | record_variable ID_FIELD /* record field */ | variable '^' /* pointer value */ - | ID_TYPE '(' variable ')' /* type cast */ + | ID_TYPE '(' variable ')' /* type cast */ + {} ; /* Expressions: */ @@ -532,7 +695,7 @@ | simple_expr relop simple_expr ; -relop : '=' | K_NEQ | '<' | '>' | K_LEQ | K_GEQ | K_IN +relop : '=' | OP_NEQ | '<' | '>' | OP_LEQ | OP_GEQ | K_IN ; simple_expr @@ -555,14 +718,20 @@ casts are caught as variables. */ factor : variable - | CONST_INT - | CONST_REAL - | CONST_STRING + | ID_CONST + {} + | CONST_INT + {} + | CONST_REAL + {} + | CONST_STRING + {} | '[' elem_list ']' | K_NIL | '@' variable | '(' expr ')' | ID_FUNC '(' expr_list ')' + {} | K_NOT factor ; @@ -577,6 +746,6 @@ ; elem : expr - | expr K_DOTDOT expr + | expr OP_DOTDOT expr ;
