diff options
Diffstat (limited to 'omega/omega_calc')
-rw-r--r-- | omega/omega_calc/doc/calculator.pdf | bin | 0 -> 108062 bytes | |||
-rw-r--r-- | omega/omega_calc/include/omega_calc/AST.h | 310 | ||||
-rw-r--r-- | omega/omega_calc/include/omega_calc/PT-omega.c | 81 | ||||
-rwxr-xr-x | omega/omega_calc/include/omega_calc/myflex.h | 27 | ||||
-rwxr-xr-x | omega/omega_calc/obj/FlexLexer.h | 206 | ||||
-rw-r--r-- | omega/omega_calc/obj/Makefile | 57 | ||||
-rwxr-xr-x | omega/omega_calc/obj/lex.yy.cc | 3966 | ||||
-rw-r--r-- | omega/omega_calc/obj/tile.script | 5 | ||||
-rw-r--r-- | omega/omega_calc/src/AST.cc | 467 | ||||
-rwxr-xr-x | omega/omega_calc/src/myflex.cc | 421 | ||||
-rw-r--r-- | omega/omega_calc/src/parser.l | 350 | ||||
-rwxr-xr-x | omega/omega_calc/src/parser.ll | 350 | ||||
-rw-r--r-- | omega/omega_calc/src/parser.y | 1925 | ||||
-rwxr-xr-x | omega/omega_calc/src/parser.yy | 1928 |
14 files changed, 10093 insertions, 0 deletions
diff --git a/omega/omega_calc/doc/calculator.pdf b/omega/omega_calc/doc/calculator.pdf Binary files differnew file mode 100644 index 0000000..5c307ab --- /dev/null +++ b/omega/omega_calc/doc/calculator.pdf diff --git a/omega/omega_calc/include/omega_calc/AST.h b/omega/omega_calc/include/omega_calc/AST.h new file mode 100644 index 0000000..58d74fb --- /dev/null +++ b/omega/omega_calc/include/omega_calc/AST.h @@ -0,0 +1,310 @@ +#ifndef _AST_H +#define _AST_H + +#include <assert.h> +#include <omega.h> +#include <map> +#include <set> + +typedef enum {eq, lt, gt, geq, leq, neq} Rel_Op; + +class tupleDescriptor; + +class Variable_Ref { +public: + int anonymous; + omega::Const_String name; + omega::Const_String stripped_name; + omega::Variable_ID vid; + omega::Variable_ID id(omega::Rel_Body *R) { + if (vid) return vid; + if (arity == 0) + vid = R->get_local(g); + else + vid = R->get_local(g,of); + return vid; + } + omega::Variable_ID id(omega::Relation &R) { + if (vid) return vid; + if (arity == 0) + vid = R.get_local(g); + else + vid = R.get_local(g,of); + return vid; + } + omega::Free_Var_Decl *g; + int arity; + int pos; + omega::Argument_Tuple of; + Variable_Ref(char *s, int _arity, omega::Argument_Tuple _of); + Variable_Ref(char *s); + Variable_Ref(); + ~Variable_Ref(); +}; + +extern std::map<omega::Const_String, Variable_Ref *> functionOfInput; +extern std::map<omega::Const_String, Variable_Ref *> functionOfOutput; + +class Declaration_Site { +public: + Declaration_Site(); + Declaration_Site(std::set<char *> *v); + virtual Variable_Ref *extend(char *s); + virtual Variable_Ref *extend(char *s, omega::Argument_Tuple, int); + virtual ~Declaration_Site(); + + Variable_Ref *extend(); + void print() { + for (std::set<Variable_Ref *>::iterator i = declarations.begin(); ;) { + printf("%s", static_cast<const char *>((*i)->name)); + i++; + if (i != declarations.end()) + printf(","); + else + break; + } + } + + Declaration_Site *previous; + std::set<Variable_Ref *> declarations; +}; + +class Global_Declaration_Site: public Declaration_Site { +public: + virtual Variable_Ref *extend(char *s); + virtual Variable_Ref *extend() { + return Declaration_Site::extend(); + } + virtual Variable_Ref *extend(char *s, omega::Argument_Tuple in_of, int in_arity) { + return Declaration_Site::extend(s,in_of,in_arity); + } + void extend_both_tuples(char *s, int arity); + virtual ~Global_Declaration_Site(); +}; + +extern Declaration_Site *current_Declaration_Site; + +inline void popScope() { + assert(current_Declaration_Site); + current_Declaration_Site = current_Declaration_Site->previous; +} + +Variable_Ref *lookupScalar(char *s); +Declaration_Site * defined (char *); + +class Exp { +public: + Exp(omega::coef_t c); + Exp(Variable_Ref *v); + friend Exp *multiply (omega::coef_t c, Exp *x); + friend Exp *multiply (Exp *x, Exp *y); + friend Exp *negate (Exp *x); + friend Exp *add (Exp *x, Exp *y); + friend Exp *subtract (Exp *x, Exp *y); + std::map<Variable_Ref *, omega::coef_t> coefs; + omega::coef_t constantTerm; +protected: + void addTerm(omega::coef_t coef, omega::Variable_ID v); +}; + + +typedef struct { + Exp *e; + int step; +} strideConstraint; + + +class AST; +class AST_constraints; + + +class Tuple_Part { +public: + Variable_Ref *from,*to; + Tuple_Part(Variable_Ref *f, Variable_Ref *t) + { from = f; to = t; } + Tuple_Part(Variable_Ref *f) + { from = f; to = 0; } + Tuple_Part() + { from = 0; to = 0; } +}; + + +class AST { +public: + virtual void install(omega::Formula *F) = 0; + virtual void print() = 0; + virtual ~AST() {} +}; + + +class AST_And: public AST { +public: + AST_And(AST *l, AST *r) { left = l; right = r; } + ~AST_And() { delete left; delete right; } + + virtual void install(omega::Formula *F); + + virtual void print() { + printf("("); + left->print(); + printf(" && "); + right->print(); + printf(")"); + } + + AST *left,*right; +}; + + +class AST_Or: public AST { +public: + AST_Or(AST *l, AST *r) { left = l; right = r; } + ~AST_Or() { delete left; delete right; } + + virtual void install(omega::Formula *F); + + virtual void print() { + printf("("); + left->print(); + printf(" || "); + right->print(); + printf(")"); + } + + + AST *left, *right; +}; + + +class AST_Not: public AST { +public: + AST_Not(AST *c) { child = c; } + ~AST_Not() { delete child; } + + virtual void install(omega::Formula *F); + + virtual void print() { + printf("(!"); + child->print(); + printf(")"); + } + + AST *child; +}; + + +class AST_declare: public AST { +public: + virtual void install(omega::Formula *F) = 0; + + virtual void print() { + printf("("); + declaredVariables->print(); + printf(" : "); + child->print(); + printf(")"); + } + + Declaration_Site *declaredVariables; + AST *child; +}; + + +class AST_exists: public AST_declare { +public: + AST_exists(Declaration_Site *dV, AST *c) {declaredVariables = dV, child = c;} + ~AST_exists() { delete child; delete declaredVariables; } + + virtual void install(omega::Formula *F); + + virtual void print() { + printf("exists "); + AST_declare::print(); + } +}; + + +class AST_forall: public AST_declare { +public: + AST_forall(Declaration_Site *dV, AST *c) {declaredVariables = dV, child = c; } + ~AST_forall() { delete child; delete declaredVariables; } + + virtual void install(omega::Formula *F); + + virtual void print() { + printf("forall "); + AST_declare::print(); + } +}; + + + +class AST_constraints: public AST { +public: + AST_constraints(std::set<Exp *> *f, Rel_Op r, AST_constraints *o); + AST_constraints(std::set<Exp *> *f, Rel_Op r, std::set<Exp *> *s); + AST_constraints(std::set<Exp *> *f); + ~AST_constraints(); + + virtual void install(omega::Formula *F); + + virtual void print(); + + AST_constraints *others; + std::set<Exp *> *first; + Rel_Op rel_op; +}; + +void install_stride(omega::F_And *F, strideConstraint *c); +void install_eq(omega::F_And *F, Exp *e1, Exp *e2); +void install_geq(omega::F_And *F, Exp *e1, Exp *e2); +void install_gt(omega::F_And *F, Exp *e1, Exp *e2); +void install_neq(omega::F_And *F, Exp *e1, Exp *e2); + + + +class tupleDescriptor { +public: + tupleDescriptor() { size = 0; } + void extend(); + void extend(Exp * e); + void extend(Exp * lb, Exp *ub); + void extend(Exp * lb, Exp *ub, omega::coef_t stride); + void extend(char * s, Exp *e); + void extend(char * s); + void extend(char * s, omega::Argument_Tuple, int); + + int size; + std::vector<Variable_Ref *> vars; + std::set<Exp *> eq_constraints; + std::set<Exp *> geq_constraints; + std::set<strideConstraint *> stride_constraints; + ~tupleDescriptor() { + for (std::set<Exp *>::iterator i = eq_constraints.begin(); i != eq_constraints.end(); i++) + delete *i; + for (std::set<Exp *>::iterator i = geq_constraints.begin(); i != geq_constraints.end(); i++) + delete *i; + for (std::set<strideConstraint *>::iterator i = stride_constraints.begin(); i != stride_constraints.end(); i++) { + delete (*i)->e; + delete *i; + } + } +}; + +extern Global_Declaration_Site *globalDecls; +extern Declaration_Site *relationDecl; +extern tupleDescriptor *currentTupleDescriptor; + +void resetGlobals(); + + +// Used to parse a list of paired relations for code generation commands +// class RelTuplePair { +// public: +// RelTuplePair() : ispaces(0), mappings(0) {} +// omega::Tuple<omega::Relation> ispaces; +// omega::Tuple<omega::Relation> mappings; +// }; + +#endif diff --git a/omega/omega_calc/include/omega_calc/PT-omega.c b/omega/omega_calc/include/omega_calc/PT-omega.c new file mode 100644 index 0000000..ad6b979 --- /dev/null +++ b/omega/omega_calc/include/omega_calc/PT-omega.c @@ -0,0 +1,81 @@ +#undef DONT_INCLUDE_TEMPLATE_CODE + +#include <basic/bool.h> +#include <basic/util.h> +#include <basic/List.h> +#include <basic/SimpleList.h> +#include <basic/Bag.h> +#include <basic/Map.h> +#include <basic/Tuple.h> +#include <basic/Section.h> +#include <basic/Exit.h> +#include <basic/Dynamic_Array.h> +#include <omega.h> +#include <omega/AST.h> + +template int max(int, int); +template int min(int, int); +template unsigned int min(unsigned int, unsigned int); +template void set_max(int&,int); +template void set_min(int&,int); +template void swap(int&,int&); +template void swap(short&,short&); +template void swap(signed char&,signed char&); +template Relation copy(const Relation &); + +instantiate_Set(int); +instantiate_Set(Global_Var_ID); +instantiate_Set(Variable_ID); + +instantiate_List(int); +instantiate_List(exit_func); +instantiate_List(Formula *); +instantiate_List(Conjunct *); +instantiate_List(DNF *); +instantiate_List(Relation *); +instantiate_Simple_List(Relation); + +typedef Tuple<Relation> RelationTuple; +instantiate_Tuple(bool); +instantiate_Tuple(int); +instantiate_Tuple(coef_t); +instantiate_Tuple(char *); +instantiate_Tuple(Const_String); +instantiate_Tuple(Conjunct *); +instantiate_Tuple(Relation); +instantiate_Tuple(RelationTuple); +instantiate_Tuple(Variable_ID); +instantiate_Tuple(Free_Var_Decl *); +instantiate_Tuple(std::string); +instantiate_Tuple(GEQ_Handle); + +instantiate_Section(Variable_ID); + +instantiate_Generator(Variable_Info); +instantiate_Generator(GEQ_Handle); +instantiate_Generator(EQ_Handle); +instantiate_Generator(Constraint_Handle); +instantiate_Generator(Sub_Handle); + +instantiate_Map(Variable_ID,int); +instantiate_Map(Global_Var_ID, Variable_ID); +instantiate_Map(GEQ_Handle,Variable_ID); +instantiate_Map(EQ_Handle,Variable_ID); +instantiate_Map(Variable_ID,Set<Variable_ID>); +instantiate_Map(Const_String, Relation *); + +instantiate_Dynamic_Array1(Coef_Var_Decl *); +instantiate_Dynamic_Array1(Relation); +instantiate_Dynamic_Array2(Relation); + + +/* Stuff required by calculator: */ +instantiate_Bag(Exp *); +instantiate_Bag(strideConstraint *); +instantiate_Bag(Variable_Ref *); +instantiate_Bag(char *); +instantiate_Map(Variable_Ref *, int); +instantiate_Map(Variable_Ref *, Variable_Ref *); +instantiate_Map(Const_String, Variable_Ref *); +instantiate_Set(Free_Var_Decl *); +instantiate_Tuple(Variable_Ref *); diff --git a/omega/omega_calc/include/omega_calc/myflex.h b/omega/omega_calc/include/omega_calc/myflex.h new file mode 100755 index 0000000..d472e51 --- /dev/null +++ b/omega/omega_calc/include/omega_calc/myflex.h @@ -0,0 +1,27 @@ +#ifndef _MYFLEX_H +#define _MYFLEX_H + +#ifndef yyFlexLexerOnce +#include <FlexLexer.h> +#endif +#include <iostream> +#include <string> +#include <vector> + +class myFlexLexer: public yyFlexLexer { +protected: + std::string cur_line; + int cur_pos; + std::vector<std::string> history; + int first_history_pos; + int last_history_pos; + std::vector<std::string> key_seqs; + +public: + myFlexLexer(std::istream *arg_yyin = NULL, std::ostream *arg_yyout = NULL); + ~myFlexLexer() {} +protected: + int LexerInput(char *buf, int max_size); +}; + +#endif diff --git a/omega/omega_calc/obj/FlexLexer.h b/omega/omega_calc/obj/FlexLexer.h new file mode 100755 index 0000000..bad4ce0 --- /dev/null +++ b/omega/omega_calc/obj/FlexLexer.h @@ -0,0 +1,206 @@ +// -*-C++-*- +// FlexLexer.h -- define interfaces for lexical analyzer classes generated +// by flex + +// Copyright (c) 1993 The Regents of the University of California. +// All rights reserved. +// +// This code is derived from software contributed to Berkeley by +// Kent Williams and Tom Epperly. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: + +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. + +// Neither the name of the University nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. + +// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR +// IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE. + +// This file defines FlexLexer, an abstract class which specifies the +// external interface provided to flex C++ lexer objects, and yyFlexLexer, +// which defines a particular lexer class. +// +// If you want to create multiple lexer classes, you use the -P flag +// to rename each yyFlexLexer to some other xxFlexLexer. You then +// include <FlexLexer.h> in your other sources once per lexer class: +// +// #undef yyFlexLexer +// #define yyFlexLexer xxFlexLexer +// #include <FlexLexer.h> +// +// #undef yyFlexLexer +// #define yyFlexLexer zzFlexLexer +// #include <FlexLexer.h> +// ... + +#ifndef __FLEX_LEXER_H +// Never included before - need to define base class. +#define __FLEX_LEXER_H + +#include <iostream> +# ifndef FLEX_STD +# define FLEX_STD std:: +# endif + +extern "C++" { + +struct yy_buffer_state; +typedef int yy_state_type; + +class FlexLexer { +public: + virtual ~FlexLexer() { } + + const char* YYText() const { return yytext; } + int YYLeng() const { return yyleng; } + + virtual void + yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0; + virtual struct yy_buffer_state* + yy_create_buffer( FLEX_STD istream* s, int size ) = 0; + virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0; + virtual void yyrestart( FLEX_STD istream* s ) = 0; + + virtual int yylex() = 0; + + // Call yylex with new input/output sources. + int yylex( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 ) + { + switch_streams( new_in, new_out ); + return yylex(); + } + + // Switch to new input/output streams. A nil stream pointer + // indicates "keep the current one". + virtual void switch_streams( FLEX_STD istream* new_in = 0, + FLEX_STD ostream* new_out = 0 ) = 0; + + int lineno() const { return yylineno; } + + int debug() const { return yy_flex_debug; } + void set_debug( int flag ) { yy_flex_debug = flag; } + +protected: + char* yytext; + int yyleng; + int yylineno; // only maintained if you use %option yylineno + int yy_flex_debug; // only has effect with -d or "%option debug" +}; + +} +#endif // FLEXLEXER_H + +#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce) +// Either this is the first time through (yyFlexLexerOnce not defined), +// or this is a repeated include to define a different flavor of +// yyFlexLexer, as discussed in the flex manual. +#define yyFlexLexerOnce + +extern "C++" { + +class yyFlexLexer : public FlexLexer { +public: + // arg_yyin and arg_yyout default to the cin and cout, but we + // only make that assignment when initializing in yylex(). + yyFlexLexer( FLEX_STD istream* arg_yyin = 0, FLEX_STD ostream* arg_yyout = 0 ); + + virtual ~yyFlexLexer(); + + void yy_switch_to_buffer( struct yy_buffer_state* new_buffer ); + struct yy_buffer_state* yy_create_buffer( FLEX_STD istream* s, int size ); + void yy_delete_buffer( struct yy_buffer_state* b ); + void yyrestart( FLEX_STD istream* s ); + + void yypush_buffer_state( struct yy_buffer_state* new_buffer ); + void yypop_buffer_state(); + + virtual int yylex(); + virtual void switch_streams( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 ); + virtual int yywrap(); + +protected: + virtual int LexerInput( char* buf, int max_size ); + virtual void LexerOutput( const char* buf, int size ); + virtual void LexerError( const char* msg ); + + void yyunput( int c, char* buf_ptr ); + int yyinput(); + + void yy_load_buffer_state(); + void yy_init_buffer( struct yy_buffer_state* b, FLEX_STD istream* s ); + void yy_flush_buffer( struct yy_buffer_state* b ); + + int yy_start_stack_ptr; + int yy_start_stack_depth; + int* yy_start_stack; + + void yy_push_state( int new_state ); + void yy_pop_state(); + int yy_top_state(); + + yy_state_type yy_get_previous_state(); + yy_state_type yy_try_NUL_trans( yy_state_type current_state ); + int yy_get_next_buffer(); + + FLEX_STD istream* yyin; // input source for default LexerInput + FLEX_STD ostream* yyout; // output sink for default LexerOutput + + // yy_hold_char holds the character lost when yytext is formed. + char yy_hold_char; + + // Number of characters read into yy_ch_buf. + int yy_n_chars; + + // Points to current character in buffer. + char* yy_c_buf_p; + + int yy_init; // whether we need to initialize + int yy_start; // start state number + + // Flag which is used to allow yywrap()'s to do buffer switches + // instead of setting up a fresh yyin. A bit of a hack ... + int yy_did_buffer_switch_on_eof; + + + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + struct yy_buffer_state ** yy_buffer_stack; /**< Stack as an array. */ + void yyensure_buffer_stack(void); + + // The following are not always needed, but may be depending + // on use of certain flex features (like REJECT or yymore()). + + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + yy_state_type* yy_state_buf; + yy_state_type* yy_state_ptr; + + char* yy_full_match; + int* yy_full_state; + int yy_full_lp; + + int yy_lp; + int yy_looking_for_trail_begin; + + int yy_more_flag; + int yy_more_len; + int yy_more_offset; + int yy_prev_more_offset; +}; + +} + +#endif // yyFlexLexer || ! yyFlexLexerOnce + diff --git a/omega/omega_calc/obj/Makefile b/omega/omega_calc/obj/Makefile new file mode 100644 index 0000000..4001c83 --- /dev/null +++ b/omega/omega_calc/obj/Makefile @@ -0,0 +1,57 @@ +# Makefile for release 1.0 of the omega system +# DON'T EDIT -- put any locally required changes in Makefile.config. +# See INSTALL for more details. + +EXEC_TARGET=oc + + +all: $(EXEC_TARGET) + +clean: clean_self + +veryclean: veryclean_self + + +SRCS := ../src/AST.cc ../src/myflex.cc +OBJS := $(SRCS:../src/%.cc=%.o) + +YACC_SRCS := lex.yy.cc parser.tab.cc +YACC_OBJS := $(YACC_SRCS:.cc=.o) + +depend: $(YACC_SRCS) depend_self + +SRCS := $(SRCS) $(YACC_SRCS) +OBJS := $(OBJS) $(YACC_OBJS) + +BASEDIR=../.. +include $(BASEDIR)/Makefile.config + +LIB_PATH := $(LIB_PATH) -L../../omega_lib/obj +LIBS := $(LIBS) -lomega + +ifeq ($(BUILD_CODEGEN), true) +LIB_PATH := $(LIB_PATH) -L../../code_gen/obj +LIBS := $(LIBS) -lcodegen +CFLAGS := $(CFLAGS) -DBUILD_CODEGEN +endif + +CFLAGS := $(CFLAGS) +INCL_PATH := -I. $(INCL_PATH) -I../../omega_lib/include -I../../code_gen/include + +include $(BASEDIR)/Makefile.rules + +# lex/yacc related +.PHONY: parser.tab.o + +lex.yy.cc: ../src/parser.ll + flex++ $< + +parser.tab.hh parser.tab.cc: ../src/parser.yy + bison -t -d $< + +parser.tab.o: parser.tab.cc + $(CC) $(CFLAGS) -DOMEGA_BUILD_DATE="\"$(OMEGA_BUILD_DATE)\"" $(INCL_PATH) -c $< + +ifeq ($(shell test -f Makefile.deps && echo "true"), true) +include Makefile.deps +endif diff --git a/omega/omega_calc/obj/lex.yy.cc b/omega/omega_calc/obj/lex.yy.cc new file mode 100755 index 0000000..49a85e1 --- /dev/null +++ b/omega/omega_calc/obj/lex.yy.cc @@ -0,0 +1,3966 @@ + +#line 3 "lex.yy.cc" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + + /* The c++ scanner is a mess. The FlexLexer.h header file relies on the + * following macro. This is required in order to pass the c++-multiple-scanners + * test in the regression suite. We get reports that it breaks inheritance. + * We will address this in a future release of flex, or omit the C++ scanner + * altogether. + */ + #define yyFlexLexer yyFlexLexer + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include <inttypes.h> +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ +#include <iostream> +#include <errno.h> +#include <cstdlib> +#include <cstdio> +#include <cstring> +/* end standard C++ headers. */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +extern int yyleng; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires + * access to the local variable yy_act. Since yyless() is a macro, it would break + * existing scanners that call yyless() from OUTSIDE yylex. + * One obvious solution it to make yy_act a global. I tried that, and saw + * a 5% performance hit in a non-yylineno scanner, because yy_act is + * normally declared as a register variable-- so it is not worth it. + */ + #define YY_LESS_LINENO(n) \ + do { \ + int yyl;\ + for ( yyl = n; yyl < yyleng; ++yyl )\ + if ( yytext[yyl] == '\n' )\ + --yylineno;\ + }while(0) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + + std::istream* yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +void *yyalloc (yy_size_t ); +void *yyrealloc (void *,yy_size_t ); +void yyfree (void * ); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +#define yytext_ptr yytext +#define YY_INTERACTIVE + +#include <FlexLexer.h> + +int yyFlexLexer::yywrap() { return 1; } + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 147 +#define YY_END_OF_BUFFER 148 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[2067] = + { 0, + 0, 0, 0, 0, 0, 0, 7, 7, 148, 146, + 5, 16, 117, 146, 6, 146, 109, 146, 46, 108, + 144, 146, 132, 134, 133, 136, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 103, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 17, 110, 19, 15, + 146, 103, 30, 146, 5, 3, 3, 117, 146, 6, + 146, 109, 146, 46, 108, 144, 146, 132, 134, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 103, 136, 136, 136, 136, 136, 136, 136, 136, 136, + + 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 17, 110, 19, 7, 5, 7, 7, 6, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 5, 130, 0, 145, 10, 111, 121, 144, + 120, 1, 124, 135, 127, 136, 0, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + + 136, 136, 122, 136, 136, 136, 136, 136, 114, 136, + 136, 136, 0, 136, 136, 136, 136, 136, 136, 112, + 9, 4, 13, 140, 14, 140, 140, 140, 140, 140, + 140, 140, 11, 140, 140, 12, 18, 20, 0, 0, + 5, 130, 0, 145, 0, 10, 111, 121, 144, 120, + 1, 124, 135, 136, 0, 136, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 122, 136, 136, 136, 136, 136, 114, 136, 136, 136, + 0, 136, 136, 136, 136, 136, 136, 112, 7, 5, + + 7, 7, 7, 7, 7, 7, 7, 7, 1, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 136, 113, 136, 136, 136, 136, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 136, 136, 118, 136, 136, 136, 136, 0, 136, 136, + + 28, 136, 136, 136, 136, 8, 0, 140, 140, 140, + 140, 140, 140, 129, 140, 140, 126, 140, 140, 140, + 140, 31, 2, 2, 0, 0, 0, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 113, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 118, + 136, 136, 136, 136, 0, 136, 136, 28, 136, 136, + 136, 136, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 0, 0, 0, 136, 136, 136, 136, 72, 136, 136, + 136, 136, 136, 136, 56, 136, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 87, 136, 136, + 136, 47, 136, 136, 136, 136, 136, 136, 136, 32, + 136, 136, 136, 136, 49, 136, 136, 136, 0, 0, + 0, 25, 140, 23, 140, 140, 128, 140, 140, 125, + 116, 29, 119, 131, 140, 0, 0, 0, 136, 136, + 136, 136, 72, 136, 136, 136, 136, 136, 136, 56, + + 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 136, 136, 87, 136, 136, 136, 47, 136, 136, 136, + 136, 136, 136, 136, 32, 136, 136, 136, 136, 49, + 136, 136, 136, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 137, 0, 0, 136, 136, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + + 136, 136, 136, 136, 136, 136, 136, 136, 88, 136, + 136, 136, 136, 136, 136, 51, 136, 136, 136, 136, + 136, 136, 136, 22, 136, 136, 136, 0, 0, 0, + 35, 140, 140, 45, 115, 140, 137, 0, 0, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 136, 136, 136, 88, 136, 136, 136, 136, 136, 136, + 51, 136, 136, 136, 136, 136, 136, 136, 22, 136, + 136, 136, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 139, 138, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 48, + 136, 55, 73, 53, 136, 136, 136, 136, 136, 136, + 136, 136, 90, 136, 136, 136, 136, 136, 89, 136, + 141, 0, 0, 140, 140, 140, 139, 138, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 48, 136, 55, + + 73, 53, 136, 136, 136, 136, 136, 136, 136, 136, + 90, 136, 136, 136, 136, 136, 89, 136, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 91, 136, + 36, 136, 136, 136, 97, 136, 33, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + + 143, 142, 54, 52, 140, 136, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 136, 136, 136, 91, 136, 36, 136, 136, 136, 97, + 136, 33, 136, 136, 136, 136, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 136, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 62, 136, + + 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 78, 77, 0, 136, 136, 136, 136, 136, 95, 136, + 136, 27, 136, 136, 136, 140, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 62, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 136, 78, 77, 136, 136, 136, 136, 136, 95, 136, + 136, 27, 136, 136, 136, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + + 7, 7, 7, 7, 7, 136, 136, 67, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 71, 136, 136, + 136, 136, 136, 136, 136, 38, 136, 136, 136, 0, + 136, 136, 0, 136, 136, 0, 0, 136, 136, 136, + 136, 99, 136, 136, 136, 136, 136, 136, 136, 136, + 140, 136, 136, 67, 136, 136, 136, 136, 136, 136, + 136, 136, 136, 71, 136, 136, 136, 136, 136, 136, + 136, 38, 136, 136, 136, 0, 136, 136, 0, 136, + 136, 136, 136, 136, 136, 99, 136, 136, 136, 136, + 136, 136, 136, 136, 7, 7, 7, 7, 7, 7, + + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 136, + 66, 136, 136, 64, 136, 136, 136, 68, 136, 136, + 63, 136, 136, 136, 98, 34, 0, 136, 136, 37, + 136, 136, 0, 0, 136, 136, 0, 0, 136, 136, + 0, 0, 136, 136, 136, 136, 0, 136, 136, 136, + 136, 94, 136, 136, 136, 136, 140, 136, 66, 136, + 136, 64, 136, 136, 136, 68, 136, 136, 63, 136, + + 136, 136, 98, 34, 0, 136, 136, 37, 136, 136, + 0, 0, 136, 136, 0, 0, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 94, 136, 136, 136, + 136, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 136, 70, + 136, 136, 136, 136, 136, 136, 21, 136, 136, 0, + 136, 136, 136, 93, 0, 0, 136, 136, 0, 0, + + 136, 136, 0, 0, 136, 136, 136, 136, 0, 136, + 136, 136, 136, 96, 50, 92, 136, 123, 136, 70, + 136, 136, 136, 136, 136, 136, 21, 136, 136, 0, + 136, 136, 136, 93, 0, 0, 136, 136, 0, 0, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 96, 50, 92, 136, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 136, 136, 136, 136, 136, 136, 136, + + 136, 136, 0, 136, 136, 24, 0, 0, 136, 136, + 0, 0, 136, 136, 0, 0, 136, 136, 136, 136, + 100, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 0, 136, 136, 24, 0, + 0, 136, 136, 0, 0, 136, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 136, + 136, 136, 136, 136, 69, 136, 136, 136, 0, 136, + + 136, 0, 0, 136, 82, 0, 0, 136, 81, 0, + 0, 136, 136, 136, 136, 136, 105, 136, 136, 136, + 136, 136, 136, 136, 136, 69, 136, 136, 136, 0, + 136, 136, 0, 0, 136, 82, 0, 0, 136, 81, + 136, 136, 136, 136, 136, 105, 136, 136, 136, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 136, 136, 136, 136, 136, 136, 136, 136, 0, 136, + 136, 0, 80, 86, 0, 79, 85, 0, 0, 136, + + 136, 136, 136, 102, 136, 104, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 0, 136, 136, 0, 80, + 86, 0, 79, 85, 136, 136, 136, 136, 102, 136, + 104, 136, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 136, + 136, 136, 136, 136, 136, 136, 136, 0, 136, 74, + 84, 83, 0, 0, 136, 136, 136, 136, 101, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 0, 136, + 74, 84, 83, 136, 136, 136, 136, 101, 136, 7, + + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 136, 136, 136, 136, 136, 136, 136, 136, 75, 76, + 0, 0, 136, 44, 136, 136, 26, 136, 136, 136, + 136, 136, 136, 136, 136, 75, 76, 136, 44, 136, + 136, 26, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 61, + 58, 136, 136, 60, 136, 136, 136, 0, 0, 136, + 136, 136, 61, 58, 136, 136, 60, 136, 136, 136, + 136, 136, 136, 7, 7, 7, 7, 7, 7, 7, + + 7, 7, 7, 7, 7, 7, 136, 136, 136, 136, + 136, 0, 42, 41, 136, 43, 136, 136, 136, 136, + 136, 41, 136, 43, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 136, 65, 59, 106, 136, 0, + 136, 136, 65, 59, 106, 136, 136, 7, 7, 7, + 7, 7, 7, 7, 57, 107, 39, 40, 57, 107, + 40, 7, 7, 7, 7, 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 4, 5, 6, 7, 8, 1, 9, 10, 11, + 12, 1, 1, 1, 13, 14, 15, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 17, 1, 18, + 19, 20, 1, 1, 21, 22, 23, 24, 22, 22, + 22, 25, 26, 22, 22, 27, 22, 22, 28, 29, + 30, 31, 32, 33, 34, 35, 22, 22, 22, 22, + 1, 36, 1, 1, 37, 1, 38, 39, 40, 41, + + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[67] = + { 0, + 1, 1, 2, 3, 4, 1, 1, 1, 1, 5, + 6, 1, 1, 1, 1, 7, 1, 1, 1, 1, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 4, 7, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 4, 1, 4 + } ; + +static yyconst flex_int16_t yy_base[2080] = + { 0, + 0, 0, 64, 65, 130, 0, 196, 0, 3618, 3619, + 67, 3619, 3598, 3610, 3619, 3607, 3605, 3593, 3619, 3619, + 3596, 3592, 56, 3591, 3590, 66, 68, 70, 72, 253, + 74, 255, 257, 76, 78, 81, 3619, 3598, 261, 264, + 267, 259, 270, 272, 274, 276, 278, 285, 280, 287, + 289, 83, 323, 293, 295, 316, 3619, 3542, 3619, 3619, + 3598, 382, 3540, 3584, 93, 3619, 94, 83, 332, 3583, + 91, 95, 3582, 3581, 3580, 90, 88, 108, 97, 448, + 514, 3547, 3556, 3539, 3550, 67, 3537, 3552, 3547, 3550, + 3571, 580, 294, 272, 307, 3529, 291, 3543, 3537, 3535, + + 3534, 317, 3533, 3529, 3528, 316, 307, 3536, 241, 3535, + 3560, 331, 3559, 0, 362, 3559, 270, 0, 3569, 3567, + 3555, 0, 0, 3558, 3554, 322, 3553, 3552, 646, 712, + 3518, 3527, 3510, 3521, 318, 3508, 3523, 3518, 3521, 0, + 778, 320, 322, 315, 3501, 330, 3515, 3509, 3507, 3506, + 334, 3505, 3501, 3500, 337, 378, 3508, 337, 3507, 0, + 3487, 0, 387, 3619, 3545, 3619, 3619, 3619, 3619, 3534, + 3619, 3619, 3619, 3619, 3619, 3539, 367, 367, 373, 390, + 387, 393, 396, 398, 424, 441, 403, 459, 466, 3538, + 461, 482, 484, 409, 489, 463, 468, 486, 472, 494, + + 496, 545, 548, 527, 536, 542, 532, 551, 400, 554, + 558, 564, 3490, 623, 534, 560, 566, 614, 556, 3619, + 3543, 3619, 3619, 3534, 3619, 632, 487, 434, 530, 616, + 631, 603, 629, 626, 497, 3533, 3619, 3619, 3523, 3522, + 615, 3521, 671, 3520, 469, 3519, 3518, 3517, 401, 3516, + 3515, 3514, 3513, 392, 660, 0, 3489, 3480, 3490, 3480, + 3477, 3481, 3470, 3479, 3484, 3473, 3471, 844, 3480, 3467, + 3463, 3463, 440, 3477, 3473, 3465, 377, 3459, 3458, 429, + 371, 3466, 3451, 3449, 3458, 3451, 0, 3455, 3455, 573, + 676, 579, 3455, 3454, 3457, 3449, 3444, 3480, 0, 619, + + 0, 554, 0, 0, 0, 0, 3483, 0, 0, 0, + 0, 0, 3488, 653, 0, 3454, 3445, 3455, 3445, 3442, + 3446, 3435, 3444, 3449, 3438, 3436, 910, 3445, 3432, 3428, + 3428, 581, 3442, 3438, 3430, 590, 3424, 3423, 582, 636, + 3431, 3416, 3414, 3423, 3416, 0, 3420, 3420, 646, 3413, + 648, 3419, 3418, 3421, 3413, 3408, 0, 3413, 3405, 3420, + 688, 693, 695, 697, 725, 739, 727, 730, 743, 746, + 750, 732, 748, 764, 752, 794, 755, 758, 805, 734, + 810, 812, 817, 801, 814, 824, 827, 830, 819, 863, + 821, 867, 807, 879, 887, 892, 876, 3447, 881, 865, + + 924, 928, 884, 930, 932, 3619, 853, 3449, 59, 889, + 698, 836, 890, 717, 936, 704, 895, 893, 939, 940, + 941, 3448, 3619, 3452, 782, 761, 259, 3411, 580, 3404, + 3406, 3412, 3398, 3406, 3411, 3393, 3396, 3397, 0, 3392, + 3404, 3390, 3402, 3390, 3390, 3398, 3402, 3389, 3382, 3389, + 3398, 3378, 3392, 3391, 3390, 3380, 3388, 3383, 3382, 0, + 3380, 3382, 3385, 3367, 680, 3367, 3380, 916, 3379, 3368, + 3377, 3373, 3366, 3358, 3373, 3368, 767, 3361, 3363, 3369, + 3355, 3363, 3368, 3350, 3353, 3354, 0, 3349, 3361, 3347, + 3359, 3347, 3347, 3355, 3359, 3346, 3339, 3346, 3355, 3335, + + 3349, 3348, 3347, 3337, 3345, 3340, 3339, 0, 3337, 3339, + 3342, 3324, 3366, 3323, 3336, 917, 3335, 3324, 3333, 3329, + 3361, 3315, 3314, 947, 949, 954, 956, 873, 968, 958, + 976, 980, 982, 989, 991, 993, 998, 1000, 1005, 1002, + 1009, 1014, 1011, 1016, 1019, 1021, 1024, 1026, 1029, 1031, + 1033, 1050, 1052, 1054, 1060, 1064, 1067, 1071, 1073, 3619, + 1079, 1081, 1083, 1085, 1087, 1089, 1091, 1101, 3319, 3311, + 3326, 3356, 977, 3355, 753, 1012, 3354, 1057, 1044, 3353, + 3352, 3351, 3350, 3349, 960, 876, 1046, 1067, 3308, 3318, + 3315, 3298, 0, 3317, 3294, 3296, 3304, 3326, 3301, 0, + + 3297, 3293, 3301, 3302, 1065, 3287, 1080, 3298, 3290, 3285, + 3303, 3291, 0, 3288, 3283, 3282, 0, 3281, 3285, 3284, + 3291, 3290, 3286, 3275, 3309, 3286, 3272, 3284, 3273, 3284, + 3272, 3267, 847, 3309, 3263, 3262, 3267, 3277, 3274, 3257, + 0, 3276, 3253, 3255, 3263, 3285, 3260, 0, 3256, 3252, + 3260, 3261, 1066, 3246, 1087, 3257, 3249, 3244, 3262, 3250, + 0, 3247, 3242, 3241, 0, 3240, 3244, 3243, 3250, 3249, + 3245, 3234, 0, 3246, 3232, 3244, 3233, 3244, 3232, 3227, + 1006, 3619, 3269, 3268, 1120, 1123, 1128, 1131, 1133, 1139, + 1141, 1144, 1146, 1148, 1150, 1153, 1155, 1157, 1160, 1162, + + 1164, 1167, 1169, 1171, 1181, 1183, 1185, 1195, 1190, 1197, + 1202, 1205, 1210, 1215, 1217, 1221, 1224, 1226, 1235, 1237, + 1239, 1241, 1249, 1244, 1254, 1256, 1258, 3267, 3221, 3220, + 3265, 1172, 1165, 3264, 3263, 1222, 3253, 961, 1251, 3230, + 3246, 3209, 3216, 3213, 3221, 3220, 3240, 3206, 3221, 3201, + 3204, 3218, 3217, 3216, 3201, 3203, 3203, 3199, 3202, 3203, + 3195, 3194, 3200, 0, 3192, 3191, 3209, 3199, 3198, 3203, + 0, 3204, 3195, 3183, 3183, 3177, 3188, 3187, 0, 3198, + 3183, 3175, 0, 3220, 3219, 3188, 3204, 3167, 3174, 3171, + 3179, 3178, 3198, 3164, 3179, 3159, 3162, 3176, 3175, 3174, + + 3159, 3161, 3161, 3157, 3160, 3161, 3153, 3152, 3158, 0, + 3150, 3149, 3167, 3157, 3156, 3161, 0, 3162, 3153, 3141, + 3141, 3135, 3146, 3145, 0, 3156, 3141, 3133, 3619, 3619, + 1263, 1265, 1271, 1273, 1294, 1298, 1267, 1300, 1302, 1304, + 1310, 1323, 1314, 1317, 1320, 1325, 1327, 1330, 1332, 1334, + 1336, 1338, 1342, 1352, 1354, 1361, 1369, 1371, 1373, 1375, + 1377, 1379, 1381, 1383, 1388, 1391, 1394, 1396, 1399, 1401, + 3619, 3178, 3177, 1187, 1269, 1094, 3168, 3167, 972, 3128, + 1264, 3136, 1215, 3128, 3124, 3124, 3132, 3155, 3133, 1089, + 3137, 3126, 3126, 3133, 3125, 3142, 3130, 0, 3129, 0, + + 0, 0, 3128, 3127, 3129, 3104, 3103, 3108, 3125, 3123, + 3110, 3119, 3122, 3104, 3090, 3087, 0, 3062, 0, 0, + 1274, 3060, 1390, 3062, 1278, 3054, 3036, 3036, 3042, 3065, + 3043, 1332, 3043, 3018, 3018, 3025, 3017, 3034, 3022, 0, + 3021, 0, 0, 0, 3020, 3019, 3021, 2996, 2995, 3000, + 3017, 3015, 3002, 3010, 3013, 3003, 2996, 3008, 0, 2989, + 1407, 1412, 1417, 1419, 1428, 1430, 1432, 1437, 1434, 1439, + 1441, 1444, 1446, 1450, 1452, 1458, 1465, 1467, 1469, 1474, + 1477, 1480, 1486, 1488, 1490, 1495, 1500, 1502, 1504, 1507, + 1515, 1510, 1519, 1521, 1523, 1527, 1530, 1534, 1537, 1545, + + 3619, 3619, 3034, 3033, 1295, 2991, 2984, 2992, 1027, 32, + 352, 363, 449, 505, 573, 588, 648, 913, 925, 998, + 1068, 1077, 1108, 0, 1144, 0, 1161, 1167, 1172, 0, + 1230, 0, 1233, 1290, 1297, 1546, 1310, 1316, 1332, 1320, + 1345, 1357, 1344, 1362, 1383, 1372, 1373, 1404, 1506, 1407, + 1425, 1431, 1430, 1436, 1461, 1465, 1475, 1478, 1484, 1503, + 1506, 1502, 1524, 0, 1520, 0, 1521, 1523, 1515, 0, + 1528, 0, 1517, 1529, 1530, 1571, 1524, 1521, 1536, 1524, + 1534, 1545, 1530, 1535, 1551, 1583, 1585, 1587, 1590, 1592, + 1594, 1596, 1599, 1601, 1603, 1605, 1607, 1609, 1611, 1613, + + 1615, 1627, 1634, 1636, 1644, 1646, 1649, 1653, 1655, 1657, + 1659, 1663, 1589, 1667, 1669, 1671, 1679, 1695, 1681, 1686, + 1691, 1697, 1700, 1706, 1714, 1580, 1579, 1582, 1590, 1606, + 1600, 1612, 1618, 1643, 1636, 1639, 1671, 1676, 1654, 0, + 1664, 1684, 1672, 1678, 1691, 1680, 1692, 1685, 1695, 1679, + 1679, 1726, 1727, 1681, 1691, 1705, 1703, 1722, 0, 1695, + 1695, 0, 1691, 1692, 1695, 1702, 1705, 1706, 1714, 1710, + 1712, 1709, 1722, 1715, 1717, 1746, 1748, 1723, 0, 1724, + 1736, 1719, 1725, 1738, 1727, 1738, 1731, 1743, 1727, 1727, + 1773, 1774, 1750, 1729, 1739, 1753, 1750, 1769, 0, 1742, + + 1742, 0, 1738, 1739, 1742, 1793, 1797, 1799, 1801, 1806, + 1808, 1810, 1812, 1814, 1820, 1816, 1823, 1826, 1828, 1832, + 1838, 1840, 1844, 1848, 1857, 1852, 1861, 1863, 1868, 1758, + 1870, 1872, 1811, 1874, 1876, 1741, 1789, 1880, 1888, 1882, + 1897, 1891, 1901, 1905, 1913, 1917, 1920, 1922, 1924, 1926, + 1836, 1805, 1807, 0, 1820, 1825, 1848, 1849, 1890, 1878, + 1872, 1880, 1877, 0, 1889, 1882, 1902, 1885, 1882, 1888, + 1933, 0, 1905, 1903, 1899, 1932, 1899, 1917, 1937, 1904, + 1920, 1921, 1929, 1902, 1912, 1960, 1913, 1928, 1926, 1928, + 1925, 1924, 1929, 1936, 1944, 1935, 0, 1945, 1947, 1939, + + 1934, 1967, 1952, 1944, 1949, 1943, 0, 1947, 1940, 1960, + 1943, 1938, 1944, 1989, 0, 1961, 1958, 1954, 1965, 1955, + 1970, 1968, 1958, 1973, 1952, 1962, 1976, 1983, 1956, 1966, + 2014, 1967, 1983, 1981, 1981, 1976, 1972, 1977, 1983, 2020, + 2023, 2027, 2030, 2032, 2035, 2037, 2039, 2041, 2044, 2046, + 2048, 2050, 2052, 2057, 2054, 2059, 1992, 2061, 2063, 2068, + 2070, 2072, 1987, 2006, 2077, 2080, 2001, 2046, 2083, 2087, + 2061, 2096, 2092, 2095, 2097, 2100, 2060, 2105, 2107, 2109, + 2113, 2115, 2118, 2129, 2131, 2133, 2103, 2075, 0, 2082, + 2086, 0, 2092, 2084, 2099, 0, 2104, 2097, 0, 2106, + + 2092, 2112, 0, 0, 2132, 2110, 2118, 0, 2107, 2121, + 2144, 2146, 2115, 2116, 2148, 2149, 2120, 2122, 2112, 2114, + 2139, 2141, 2129, 2129, 2129, 2144, 0, 2143, 2144, 2147, + 2139, 2144, 0, 2143, 2146, 0, 2151, 2142, 2149, 0, + 2155, 2148, 0, 2157, 2144, 2164, 0, 0, 2160, 2161, + 2167, 0, 2154, 2166, 2156, 2171, 2160, 2160, 2160, 2175, + 2164, 2164, 2178, 2213, 2156, 2157, 2182, 2184, 2170, 2173, + 2173, 2173, 2188, 0, 2185, 2186, 2188, 2180, 2221, 2223, + 2225, 2227, 2229, 2231, 2233, 2235, 2237, 2239, 2241, 2215, + 2246, 2244, 2249, 2251, 2208, 2212, 2254, 2257, 2216, 2218, + + 2267, 2260, 2213, 2223, 2276, 2278, 2280, 2283, 2238, 2285, + 2292, 2296, 2299, 2301, 2303, 2305, 2307, 2286, 2268, 0, + 2269, 2265, 2271, 2273, 2285, 2287, 0, 2281, 2272, 2310, + 2293, 2277, 2282, 0, 2314, 2315, 2299, 2294, 2320, 2321, + 2305, 2300, 2313, 2297, 2287, 2295, 2314, 2309, 2304, 2304, + 0, 0, 0, 2303, 2306, 0, 2307, 2303, 2310, 2311, + 2323, 2326, 0, 2321, 2311, 2331, 2333, 2318, 2323, 0, + 2325, 2325, 2339, 2334, 2329, 2329, 2343, 2338, 2321, 2328, + 2353, 2336, 2325, 2332, 2346, 2352, 2347, 2342, 2342, 0, + 0, 0, 2341, 2385, 2387, 2389, 2391, 2394, 2396, 2399, + + 2401, 2403, 2348, 2405, 2407, 2409, 2370, 2377, 2416, 2419, + 2384, 2380, 2423, 2425, 2424, 2375, 2428, 2431, 2436, 2441, + 3619, 2443, 2453, 2448, 2455, 2461, 2402, 2405, 2406, 2397, + 2430, 2426, 2429, 2420, 2431, 2458, 2424, 2432, 0, 2462, + 2461, 2437, 2442, 2468, 2465, 2441, 2449, 2430, 2454, 2457, + 2434, 2451, 2456, 2463, 2458, 2455, 2469, 2470, 2469, 2453, + 2476, 2467, 2470, 2461, 2472, 2464, 2465, 2473, 0, 2484, + 2479, 2478, 2483, 2488, 2483, 2482, 2487, 2526, 2469, 2470, + 2494, 2497, 2473, 0, 2490, 2495, 2500, 2495, 2491, 2531, + 2533, 2535, 2537, 2539, 2541, 2543, 2546, 2548, 2507, 2550, + + 2553, 2516, 2523, 2556, 2558, 2524, 2529, 2562, 2564, 2520, + 2527, 2570, 2572, 2574, 2582, 2589, 2591, 2595, 2600, 2598, + 2521, 2530, 2544, 2555, 2546, 0, 2561, 2571, 2559, 2597, + 2568, 2580, 2601, 2606, 2568, 0, 2603, 2608, 2571, 0, + 2575, 2575, 2573, 2581, 2582, 0, 2588, 2593, 2590, 2580, + 2581, 2588, 2601, 2589, 0, 2600, 2609, 2597, 2606, 2607, + 2618, 2611, 2616, 2608, 0, 2614, 2619, 2611, 0, 2607, + 2614, 2615, 2614, 2611, 2618, 2618, 0, 2624, 2629, 2626, + 2663, 2665, 2667, 2669, 2671, 2674, 2676, 2678, 2645, 2680, + 2682, 2643, 3619, 2685, 2646, 3619, 2688, 2638, 2662, 2692, + + 2694, 2696, 2703, 2705, 2709, 2715, 2718, 2662, 2664, 2666, + 2666, 2686, 2695, 2688, 2692, 2716, 2699, 2683, 2720, 2721, + 0, 2724, 2725, 0, 2707, 2698, 2686, 2710, 0, 2699, + 0, 2708, 2706, 2707, 2698, 2695, 2711, 2721, 2716, 2720, + 2726, 2727, 2710, 2716, 0, 0, 2717, 0, 0, 2707, + 2731, 2733, 2724, 2712, 2737, 0, 2726, 0, 2735, 2769, + 2771, 2773, 2775, 2777, 2779, 2781, 2784, 2737, 2786, 2788, + 3619, 3619, 2751, 2750, 2793, 2795, 2797, 2802, 2799, 2804, + 2764, 2765, 2780, 2795, 2770, 2767, 2787, 2780, 2807, 2772, + 0, 2811, 2812, 2781, 2778, 2785, 2785, 0, 2776, 2787, + + 2788, 2803, 2818, 2792, 2789, 2810, 2803, 2794, 2796, 0, + 0, 0, 2803, 2803, 2804, 2801, 2808, 2807, 0, 2798, + 2851, 2854, 2857, 2859, 2861, 2863, 2865, 2868, 3619, 2870, + 2838, 2833, 2873, 2875, 2877, 2879, 2881, 2842, 2843, 2838, + 2838, 2846, 2852, 2860, 2862, 2881, 0, 2854, 0, 2868, + 2859, 0, 2859, 2860, 2856, 2857, 2867, 2873, 2881, 2883, + 0, 0, 2884, 2875, 2876, 0, 2887, 2878, 0, 2919, + 2921, 2923, 2925, 2927, 2929, 2931, 2933, 2893, 2890, 2937, + 2939, 2941, 0, 0, 2907, 2905, 0, 2903, 2907, 2918, + 2902, 2907, 2904, 0, 0, 2915, 2913, 0, 2911, 2915, + + 2926, 2914, 2911, 2912, 2918, 2915, 2965, 2967, 2972, 2976, + 2978, 2924, 3619, 2974, 2984, 2988, 2927, 2941, 2941, 2954, + 2951, 0, 2952, 0, 2950, 2954, 2953, 2963, 2957, 2958, + 0, 0, 2959, 0, 2999, 3001, 3003, 3009, 3011, 2959, + 3014, 2975, 0, 0, 0, 2986, 2973, 2979, 0, 0, + 0, 2989, 2976, 2978, 3025, 3027, 3619, 3029, 0, 0, + 0, 0, 0, 0, 0, 3619, 3070, 3074, 3078, 3084, + 3092, 3100, 3108, 3116, 3124, 3132, 3140, 3148, 3151 + } ; + +static yyconst flex_int16_t yy_def[2080] = + { 0, + 2066, 1, 1, 1, 2066, 5, 2066, 7, 2066, 2066, + 2066, 2066, 2066, 2067, 2066, 2066, 2066, 2066, 2066, 2066, + 2066, 2066, 2066, 2066, 2066, 2068, 2068, 2068, 2068, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2066, 2069, 2068, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2066, 2066, 2066, 2066, + 2066, 2070, 2066, 2071, 2071, 2066, 2066, 2071, 2072, 2071, + 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2073, + 2073, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 2071, 2074, 81, 81, 81, 81, 81, 81, 81, 81, + + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 2071, 2071, 2071, 2075, 2075, 2075, 2076, 2075, 2075, 2075, + 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2077, 2077, + 130, 130, 130, 130, 130, 130, 130, 130, 130, 2075, + 2078, 130, 130, 130, 130, 130, 130, 130, 130, 130, + 130, 130, 130, 130, 130, 130, 130, 130, 130, 2075, + 2075, 2075, 2066, 2066, 2067, 2066, 2066, 2066, 2066, 2066, + 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2068, 2068, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2069, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + 2068, 2068, 2066, 2068, 2068, 2068, 2068, 2068, 2068, 2066, + 2066, 2066, 2066, 2079, 2066, 2079, 2079, 2079, 2079, 2079, + 2079, 2079, 2079, 2079, 2079, 2079, 2066, 2066, 2071, 2066, + 2071, 2071, 2072, 2071, 2067, 2071, 2071, 2066, 2071, 2071, + 2071, 2071, 2071, 2071, 2071, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 2074, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 2071, 81, 81, 81, 81, 81, 81, 2071, 2075, 2075, + + 2075, 2076, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, + 2075, 2075, 2075, 2075, 130, 130, 130, 130, 130, 130, + 130, 130, 130, 130, 130, 130, 2078, 130, 130, 130, + 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, + 130, 130, 130, 130, 130, 130, 130, 130, 130, 2075, + 130, 130, 130, 130, 130, 130, 2075, 2066, 2066, 2066, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2066, 2068, 2068, + + 2068, 2068, 2068, 2068, 2068, 2066, 2066, 2079, 2079, 2079, + 2079, 2079, 2079, 2079, 2079, 2079, 2079, 2079, 2079, 2079, + 2079, 2079, 2066, 2067, 2071, 2071, 2071, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 2071, 81, 81, 81, 81, 81, + 81, 81, 2075, 2075, 2075, 130, 130, 130, 130, 130, + 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, + 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, + + 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, + 130, 130, 2075, 130, 130, 130, 130, 130, 130, 130, + 2066, 2066, 2066, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2066, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2066, 2066, + 2066, 2079, 2079, 2079, 2079, 2079, 2079, 2079, 2079, 2079, + 2079, 2079, 2079, 2079, 2079, 2071, 2071, 2071, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 2071, 81, 81, 81, 81, 81, + 81, 81, 81, 2075, 2075, 2075, 130, 130, 130, 130, + 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, + 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, + 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, + 130, 130, 2075, 130, 130, 130, 130, 130, 130, 130, + 130, 2066, 2066, 2066, 2068, 2068, 2068, 2068, 2068, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2066, 2066, 2066, + 2079, 2079, 2079, 2079, 2079, 2079, 2071, 2071, 2071, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 2075, 2075, 2075, 130, 130, 130, 130, 130, + 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, + + 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, + 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, + 130, 130, 130, 130, 130, 130, 130, 130, 2066, 2066, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + 2066, 2066, 2066, 2079, 2079, 2079, 2071, 2071, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 2075, 2075, + 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, + 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, + 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, + 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + + 2066, 2066, 2079, 2079, 2079, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 130, 130, 130, 130, 130, + 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, + 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, + 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, + 130, 130, 130, 130, 130, 2068, 2068, 2068, 2068, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + 2068, 2068, 2066, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + 2068, 2068, 2068, 2068, 2068, 2079, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 130, 130, 130, 130, 130, + 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, + 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, + 130, 130, 2075, 130, 130, 130, 130, 130, 130, 130, + + 130, 130, 130, 130, 130, 2068, 2068, 2068, 2068, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2066, + 2068, 2068, 2066, 2068, 2068, 2066, 2066, 2068, 2068, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + 2079, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 2071, 81, 81, 2071, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 130, 130, 130, 130, 130, 130, + + 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, + 130, 130, 130, 130, 130, 130, 130, 130, 2075, 130, + 130, 2075, 130, 130, 2075, 2075, 130, 130, 130, 130, + 130, 130, 130, 130, 130, 130, 130, 130, 130, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2066, 2068, 2068, 2068, + 2068, 2068, 2066, 2066, 2068, 2068, 2066, 2066, 2068, 2068, + 2066, 2066, 2068, 2068, 2068, 2068, 2066, 2068, 2068, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2079, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + + 81, 81, 81, 81, 2071, 81, 81, 81, 81, 81, + 2071, 2071, 81, 81, 2071, 2071, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 130, 130, 130, 130, 130, 130, 130, 130, 130, + 130, 130, 130, 130, 130, 130, 130, 130, 2075, 130, + 130, 130, 130, 130, 2075, 2075, 130, 130, 2075, 2075, + 130, 130, 2075, 2075, 130, 130, 130, 130, 2075, 130, + 130, 130, 130, 130, 130, 130, 130, 130, 2068, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2066, + 2068, 2068, 2068, 2068, 2066, 2066, 2068, 2068, 2066, 2066, + + 2068, 2068, 2066, 2066, 2068, 2068, 2068, 2068, 2066, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2079, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 2071, + 81, 81, 81, 81, 2071, 2071, 81, 81, 2071, 2071, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 130, 130, 130, 130, 130, 130, + 130, 130, 130, 130, 130, 2075, 130, 130, 130, 130, + 2075, 2075, 130, 130, 2075, 2075, 130, 130, 2075, 2075, + 130, 130, 130, 130, 2075, 130, 130, 130, 130, 130, + 130, 130, 130, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + + 2068, 2068, 2066, 2068, 2068, 2068, 2066, 2066, 2068, 2068, + 2066, 2066, 2068, 2068, 2066, 2066, 2068, 2068, 2068, 2068, + 2066, 2068, 2068, 2068, 2068, 2068, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 2071, 81, 81, 81, 2071, + 2071, 81, 81, 2071, 2071, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 130, 130, 130, 130, + 130, 130, 130, 130, 130, 2075, 130, 130, 130, 2075, + 2075, 130, 130, 2075, 2075, 130, 130, 2075, 2075, 130, + 130, 130, 130, 2075, 130, 130, 130, 130, 130, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2066, 2068, + + 2068, 2066, 2066, 2068, 2068, 2066, 2066, 2068, 2068, 2066, + 2066, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 2071, + 81, 81, 2071, 2071, 81, 81, 2071, 2071, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 130, + 130, 130, 130, 130, 130, 130, 130, 130, 2075, 130, + 130, 2075, 2075, 130, 130, 2075, 2075, 130, 130, 2075, + 2075, 130, 130, 130, 130, 130, 130, 130, 130, 130, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2066, 2068, + 2068, 2066, 2066, 2068, 2066, 2066, 2068, 2066, 2066, 2068, + + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 81, 81, 81, + 81, 81, 81, 81, 81, 2071, 81, 81, 2071, 2071, + 81, 2071, 2071, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 130, 130, 130, 130, 130, 130, 130, 130, + 2075, 130, 130, 2075, 2075, 130, 2075, 2075, 130, 2075, + 2075, 130, 130, 130, 130, 130, 130, 130, 130, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2066, 2068, 2068, + 2066, 2066, 2066, 2066, 2068, 2068, 2068, 2068, 2068, 2068, + 81, 81, 81, 81, 81, 81, 81, 81, 2071, 81, + 81, 2071, 2071, 81, 81, 81, 81, 81, 81, 130, + + 130, 130, 130, 130, 130, 130, 130, 2075, 130, 130, + 2075, 2075, 2075, 2075, 130, 130, 130, 130, 130, 130, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2066, 2068, + 2066, 2066, 2068, 2068, 2068, 2068, 2068, 81, 81, 81, + 81, 81, 81, 81, 81, 2071, 81, 81, 81, 81, + 81, 81, 130, 130, 130, 130, 130, 130, 130, 130, + 2075, 130, 2075, 2075, 130, 130, 130, 130, 130, 2068, + 2068, 2068, 2068, 2068, 2068, 2068, 2068, 2066, 2066, 2068, + 2068, 2068, 81, 81, 81, 81, 81, 81, 81, 81, + 81, 81, 81, 130, 130, 130, 130, 130, 130, 130, + + 130, 2075, 2075, 130, 130, 130, 2068, 2068, 2068, 2068, + 2068, 2066, 2066, 2068, 2068, 2068, 81, 81, 81, 81, + 81, 81, 81, 81, 130, 130, 130, 130, 130, 2075, + 2075, 130, 130, 130, 2068, 2068, 2068, 2068, 2068, 2066, + 2068, 81, 81, 81, 81, 81, 81, 130, 130, 130, + 130, 130, 2075, 130, 2068, 2068, 2066, 2068, 81, 81, + 81, 130, 130, 2075, 130, 0, 2066, 2066, 2066, 2066, + 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066 + } ; + +static yyconst flex_int16_t yy_nxt[3686] = + { 0, + 10, 11, 12, 11, 13, 14, 15, 16, 17, 10, + 10, 10, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 27, 31, 27, 32, 33, + 34, 35, 27, 27, 36, 37, 38, 39, 27, 40, + 41, 42, 43, 44, 27, 45, 46, 27, 47, 48, + 49, 50, 51, 27, 52, 53, 54, 55, 27, 56, + 27, 27, 27, 57, 58, 59, 60, 60, 163, 407, + 163, 61, 61, 172, 173, 176, 177, 176, 177, 176, + 177, 176, 177, 176, 177, 176, 177, 176, 177, 1132, + 176, 177, 176, 177, 241, 163, 163, 163, 246, 62, + + 62, 242, 240, 247, 262, 249, 250, 240, 179, 240, + 240, 572, 240, 181, 240, 253, 240, 187, 263, 183, + 211, 180, 189, 188, 212, 251, 252, 240, 63, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 64, + 64, 64, 73, 74, 75, 76, 77, 78, 79, 25, + 80, 81, 82, 83, 84, 81, 85, 81, 86, 87, + 88, 89, 81, 81, 90, 91, 92, 93, 81, 94, + 95, 96, 97, 98, 81, 99, 100, 81, 101, 102, + 103, 104, 105, 81, 106, 107, 108, 109, 81, 110, + 81, 81, 81, 111, 112, 113, 114, 115, 12, 115, + + 116, 117, 118, 119, 120, 114, 114, 114, 121, 122, + 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, + 133, 130, 134, 130, 135, 136, 137, 138, 130, 130, + 139, 140, 141, 142, 130, 143, 144, 145, 146, 147, + 130, 148, 149, 130, 150, 151, 152, 153, 154, 130, + 155, 156, 157, 158, 130, 159, 130, 130, 130, 160, + 161, 162, 176, 177, 176, 177, 176, 177, 176, 177, + 176, 177, 165, 176, 177, 303, 176, 177, 240, 176, + 177, 176, 177, 176, 177, 176, 177, 176, 177, 176, + 177, 295, 184, 296, 176, 177, 176, 177, 176, 177, + + 588, 194, 176, 177, 176, 177, 185, 200, 196, 272, + 182, 191, 197, 192, 186, 195, 193, 202, 198, 199, + 291, 201, 206, 273, 203, 176, 177, 204, 278, 205, + 207, 208, 176, 177, 165, 165, 213, 244, 216, 309, + 310, 209, 279, 210, 269, 217, 270, 218, 274, 271, + 240, 245, 275, 289, 284, 321, 333, 290, 276, 331, + 334, 219, 285, 300, 292, 300, 335, 337, 293, 322, + 328, 343, 329, 332, 348, 330, 176, 177, 349, 344, + 214, 338, 176, 177, 215, 222, 223, 354, 163, 355, + 163, 350, 358, 1133, 359, 298, 176, 177, 360, 176, + + 177, 254, 176, 177, 1134, 176, 177, 176, 177, 176, + 177, 240, 176, 177, 448, 361, 249, 225, 176, 177, + 240, 226, 449, 227, 228, 229, 363, 454, 230, 455, + 231, 232, 233, 176, 177, 351, 234, 235, 236, 352, + 362, 364, 369, 366, 407, 237, 365, 238, 239, 239, + 176, 177, 239, 239, 239, 239, 239, 254, 255, 239, + 239, 239, 239, 375, 239, 239, 239, 240, 176, 177, + 176, 177, 176, 177, 166, 176, 177, 176, 177, 367, + 443, 176, 177, 239, 452, 413, 368, 453, 424, 444, + 257, 176, 177, 176, 177, 176, 177, 407, 176, 177, + + 1135, 372, 378, 176, 177, 176, 177, 407, 370, 381, + 379, 239, 239, 239, 239, 239, 371, 382, 239, 239, + 239, 239, 239, 254, 255, 239, 239, 239, 239, 376, + 239, 239, 239, 240, 373, 380, 176, 177, 377, 374, + 407, 176, 177, 176, 177, 176, 177, 412, 383, 239, + 384, 176, 177, 422, 176, 177, 165, 176, 177, 303, + 176, 177, 1136, 176, 177, 176, 177, 176, 177, 176, + 177, 414, 389, 176, 177, 176, 177, 239, 239, 239, + 239, 239, 392, 401, 239, 239, 239, 239, 239, 254, + 239, 239, 239, 239, 239, 390, 239, 239, 239, 240, + + 385, 396, 391, 386, 387, 394, 388, 393, 395, 402, + 463, 403, 405, 407, 1137, 239, 241, 466, 163, 397, + 300, 491, 300, 176, 177, 590, 407, 496, 464, 1138, + 492, 467, 176, 177, 240, 497, 407, 500, 591, 407, + 501, 407, 407, 239, 239, 239, 299, 299, 419, 299, + 299, 299, 299, 299, 299, 313, 314, 299, 299, 299, + 299, 399, 299, 299, 299, 299, 404, 415, 416, 409, + 420, 421, 417, 165, 165, 400, 244, 410, 473, 240, + 474, 299, 418, 511, 475, 425, 514, 426, 316, 411, + 245, 427, 502, 625, 503, 240, 1139, 176, 177, 240, + + 515, 512, 176, 177, 176, 177, 176, 177, 407, 299, + 299, 299, 299, 299, 407, 299, 299, 299, 299, 299, + 299, 313, 314, 299, 299, 299, 299, 407, 299, 299, + 299, 299, 465, 524, 176, 177, 176, 177, 525, 176, + 177, 176, 177, 176, 177, 528, 527, 299, 176, 177, + 574, 526, 176, 177, 579, 176, 177, 176, 177, 176, + 177, 176, 177, 407, 176, 177, 529, 176, 177, 532, + 577, 543, 531, 176, 177, 299, 299, 299, 299, 299, + 240, 299, 299, 299, 299, 299, 299, 313, 299, 299, + 299, 299, 299, 530, 299, 299, 299, 299, 534, 533, + + 535, 240, 536, 176, 177, 537, 538, 540, 732, 541, + 176, 177, 638, 299, 176, 177, 176, 177, 587, 176, + 177, 176, 177, 176, 177, 639, 176, 177, 176, 177, + 176, 177, 586, 176, 177, 539, 176, 177, 547, 176, + 177, 299, 299, 299, 239, 239, 407, 542, 239, 239, + 239, 239, 239, 254, 239, 239, 239, 239, 239, 544, + 239, 239, 239, 240, 546, 549, 554, 545, 550, 552, + 548, 551, 176, 177, 176, 177, 176, 177, 569, 239, + 570, 575, 176, 177, 571, 176, 177, 737, 176, 177, + 176, 177, 781, 176, 177, 240, 176, 177, 782, 407, + + 407, 176, 177, 407, 553, 407, 562, 239, 239, 239, + 299, 299, 555, 299, 299, 299, 299, 299, 299, 313, + 299, 299, 299, 299, 299, 556, 299, 299, 299, 299, + 557, 558, 559, 176, 177, 566, 561, 176, 177, 176, + 177, 176, 177, 573, 576, 299, 407, 581, 580, 407, + 407, 407, 628, 676, 629, 677, 176, 177, 176, 177, + 563, 1140, 564, 176, 177, 176, 177, 176, 177, 565, + 407, 567, 877, 299, 299, 299, 568, 176, 177, 582, + 240, 578, 1141, 583, 585, 176, 177, 407, 686, 176, + 177, 176, 177, 584, 1006, 687, 1007, 685, 176, 177, + + 176, 177, 176, 177, 736, 689, 693, 176, 177, 176, + 177, 176, 177, 688, 176, 177, 731, 690, 176, 177, + 176, 177, 407, 176, 177, 176, 177, 692, 176, 177, + 176, 177, 691, 176, 177, 176, 177, 694, 176, 177, + 176, 177, 176, 177, 695, 697, 702, 1142, 698, 733, + 699, 827, 696, 700, 407, 703, 704, 828, 707, 176, + 177, 176, 177, 176, 177, 240, 701, 407, 705, 176, + 177, 1130, 708, 176, 177, 706, 176, 177, 1131, 709, + 176, 177, 176, 177, 735, 710, 240, 711, 176, 177, + 176, 177, 176, 177, 176, 177, 176, 177, 176, 177, + + 176, 177, 738, 713, 407, 715, 712, 734, 716, 714, + 176, 177, 757, 754, 800, 717, 755, 801, 1143, 803, + 719, 758, 1021, 739, 721, 1022, 723, 718, 804, 176, + 177, 1005, 176, 177, 1144, 720, 722, 176, 177, 724, + 176, 177, 176, 177, 1145, 725, 726, 832, 176, 177, + 176, 177, 727, 176, 177, 176, 177, 176, 177, 176, + 177, 831, 176, 177, 176, 177, 176, 177, 838, 176, + 177, 176, 177, 176, 177, 407, 176, 177, 176, 177, + 176, 177, 407, 834, 836, 1146, 837, 835, 833, 840, + 176, 177, 176, 177, 176, 177, 843, 407, 844, 176, + + 177, 845, 1147, 839, 176, 177, 176, 177, 1148, 842, + 841, 176, 177, 875, 176, 177, 847, 846, 848, 176, + 177, 850, 1149, 849, 176, 177, 176, 177, 874, 851, + 176, 177, 407, 176, 177, 176, 177, 1013, 852, 1014, + 853, 857, 1003, 854, 176, 177, 176, 177, 176, 177, + 176, 177, 855, 176, 177, 858, 860, 856, 176, 177, + 859, 861, 878, 176, 177, 176, 177, 176, 177, 1150, + 240, 862, 176, 177, 176, 177, 176, 177, 876, 407, + 176, 177, 176, 177, 1151, 961, 1009, 962, 1010, 866, + 868, 863, 864, 964, 1011, 965, 1046, 867, 1047, 865, + + 1053, 966, 1054, 176, 177, 407, 869, 176, 177, 176, + 177, 176, 177, 176, 177, 870, 968, 1004, 969, 176, + 177, 967, 963, 176, 177, 971, 176, 177, 974, 176, + 177, 1152, 176, 177, 176, 177, 176, 177, 1153, 176, + 177, 176, 177, 176, 177, 176, 177, 176, 177, 1126, + 973, 176, 177, 970, 978, 975, 976, 972, 1157, 977, + 983, 176, 177, 176, 177, 1061, 981, 979, 1062, 980, + 176, 177, 1158, 984, 1159, 982, 1160, 985, 176, 177, + 176, 177, 176, 177, 176, 177, 176, 177, 176, 177, + 176, 177, 176, 177, 1161, 986, 1162, 176, 177, 1163, + + 176, 177, 987, 176, 177, 176, 177, 988, 176, 177, + 176, 177, 1049, 1164, 1050, 992, 176, 177, 993, 1165, + 1051, 176, 177, 1166, 995, 996, 176, 177, 176, 177, + 1167, 991, 994, 989, 999, 990, 997, 176, 177, 176, + 177, 176, 177, 176, 177, 998, 176, 177, 176, 177, + 176, 177, 1168, 176, 177, 176, 177, 1000, 1086, 176, + 177, 176, 177, 1089, 1171, 1088, 1172, 176, 177, 1087, + 1090, 1092, 1173, 1093, 176, 177, 176, 177, 176, 177, + 1096, 1174, 1097, 176, 177, 1091, 176, 177, 1094, 176, + 177, 1095, 1098, 1175, 1099, 176, 177, 176, 177, 176, + + 177, 1101, 1176, 1104, 176, 177, 1177, 1100, 1102, 176, + 177, 176, 177, 176, 177, 1105, 176, 177, 1113, 176, + 177, 1106, 1103, 1178, 176, 177, 1179, 1107, 176, 177, + 176, 177, 176, 177, 1109, 1114, 176, 177, 1108, 176, + 177, 1180, 1115, 176, 177, 1111, 176, 177, 1112, 1113, + 1169, 1116, 1181, 1110, 176, 177, 1182, 1170, 1117, 1183, + 1184, 1185, 1186, 1119, 1187, 1188, 1154, 1189, 1190, 1122, + 1191, 1192, 1197, 1155, 1193, 1118, 1121, 1198, 1199, 1120, + 1200, 1125, 1156, 1201, 1202, 1203, 1204, 1205, 1124, 1123, + 407, 1194, 176, 177, 176, 177, 176, 177, 1195, 176, + + 177, 176, 177, 176, 177, 176, 177, 1196, 176, 177, + 176, 177, 176, 177, 176, 177, 176, 177, 176, 177, + 176, 177, 176, 177, 176, 177, 1236, 1216, 1252, 1217, + 1253, 1209, 1206, 1207, 1251, 1208, 176, 177, 1254, 1213, + 1237, 1210, 1211, 176, 177, 176, 177, 1255, 1212, 1256, + 1214, 1215, 1220, 176, 177, 176, 177, 1218, 176, 177, + 1257, 1219, 176, 177, 176, 177, 176, 177, 176, 177, + 1258, 1230, 176, 177, 1223, 1233, 176, 177, 176, 177, + 176, 177, 1221, 1259, 1222, 1260, 1225, 1261, 176, 177, + 176, 177, 1227, 1262, 1224, 176, 177, 1226, 1263, 1231, + + 176, 177, 1264, 1234, 176, 177, 176, 177, 1240, 176, + 177, 1228, 1265, 1232, 1229, 176, 177, 1235, 1243, 1239, + 1242, 1266, 1241, 176, 177, 1244, 1238, 1267, 1268, 1269, + 1270, 1245, 1271, 1272, 1273, 1274, 1275, 1246, 1276, 1279, + 1282, 1283, 1284, 1247, 1286, 1287, 1290, 1291, 1292, 1293, + 1294, 1295, 1288, 1296, 1297, 1298, 1285, 1248, 1289, 1299, + 1300, 1301, 1302, 1249, 1303, 1304, 1277, 1280, 1305, 1250, + 1306, 1307, 1308, 1309, 1310, 1311, 1312, 1313, 1314, 1315, + 1278, 1281, 1316, 1317, 1318, 1319, 1322, 1325, 1327, 1328, + 1329, 1331, 1332, 1335, 1336, 1337, 1338, 1339, 1363, 1333, + + 1371, 1326, 176, 177, 1330, 1334, 176, 177, 176, 177, + 176, 177, 1364, 1320, 1323, 176, 177, 176, 177, 176, + 177, 176, 177, 176, 177, 176, 177, 1321, 1324, 176, + 177, 1340, 176, 177, 1346, 176, 177, 176, 177, 1372, + 1342, 176, 177, 1388, 1343, 1341, 407, 176, 177, 176, + 177, 1367, 1347, 176, 177, 1389, 1344, 176, 177, 1390, + 1349, 176, 177, 1391, 1345, 1368, 176, 177, 1348, 1357, + 176, 177, 176, 177, 1350, 1353, 1351, 176, 177, 176, + 177, 176, 177, 176, 177, 176, 177, 1387, 1352, 176, + 177, 176, 177, 1358, 1377, 1354, 1392, 176, 177, 1359, + + 176, 177, 1360, 1393, 1356, 1355, 176, 177, 1361, 1366, + 176, 177, 1394, 1370, 176, 177, 1395, 1373, 1362, 1374, + 1396, 1365, 176, 177, 1397, 1369, 176, 177, 1398, 176, + 177, 176, 177, 176, 177, 176, 177, 1399, 1400, 1401, + 1402, 1375, 1379, 1403, 1404, 1405, 1408, 1376, 1409, 1410, + 1413, 240, 1378, 1380, 1414, 1417, 240, 1418, 1419, 1382, + 1420, 1421, 1422, 1377, 1423, 1424, 1425, 1381, 1383, 1406, + 1427, 1386, 1411, 1428, 1385, 1407, 1384, 1415, 1429, 1430, + 1426, 1431, 1432, 1433, 1434, 1435, 1412, 1436, 1437, 1438, + 1439, 1416, 1440, 1441, 1442, 1443, 1444, 1445, 1446, 1447, + + 1448, 1449, 1452, 1453, 1454, 1455, 1457, 1458, 1459, 1461, + 1462, 1463, 1464, 1465, 1466, 1467, 1468, 1469, 1470, 1456, + 1471, 1472, 1460, 1474, 1475, 1450, 1476, 1477, 1478, 176, + 177, 1451, 176, 177, 1490, 1473, 176, 177, 1495, 176, + 177, 176, 177, 1496, 176, 177, 176, 177, 176, 177, + 176, 177, 1499, 176, 177, 176, 177, 176, 177, 176, + 177, 176, 177, 176, 177, 1479, 176, 177, 176, 177, + 176, 177, 176, 177, 1480, 1481, 1482, 176, 177, 176, + 177, 176, 177, 1500, 1484, 1485, 176, 177, 1483, 176, + 177, 1487, 176, 177, 1489, 1486, 176, 177, 1503, 1504, + + 1492, 176, 177, 1491, 176, 177, 176, 177, 1488, 176, + 177, 1509, 1494, 407, 176, 177, 176, 177, 176, 177, + 1519, 1493, 176, 177, 176, 177, 1497, 176, 177, 1520, + 1498, 1521, 1501, 1522, 1507, 1523, 1508, 1502, 176, 177, + 176, 177, 176, 177, 1524, 1525, 1526, 1527, 1528, 1529, + 1513, 240, 1531, 1505, 1510, 1532, 1506, 1511, 1533, 1514, + 1512, 1534, 1518, 240, 1537, 240, 1538, 240, 240, 1541, + 1515, 1516, 1542, 1543, 1530, 1544, 1545, 1546, 1547, 1548, + 1549, 1550, 1517, 1536, 1551, 1552, 1540, 1553, 1554, 1555, + 1556, 1557, 1558, 1559, 1560, 1535, 1561, 1562, 1563, 1539, + + 1564, 1565, 1566, 1567, 1568, 1569, 1570, 1571, 1572, 1573, + 1574, 1575, 1576, 1577, 1578, 1579, 1580, 1581, 1582, 1583, + 1584, 1585, 1586, 1587, 1588, 1589, 1590, 1591, 1592, 1593, + 176, 177, 176, 177, 176, 177, 176, 177, 176, 177, + 176, 177, 176, 177, 176, 177, 176, 177, 176, 177, + 176, 177, 1603, 176, 177, 176, 177, 1607, 176, 177, + 176, 177, 1608, 176, 177, 1611, 176, 177, 1612, 176, + 177, 1594, 1599, 1600, 1615, 1595, 176, 177, 1616, 1597, + 1621, 1598, 1596, 1604, 1601, 176, 177, 176, 177, 176, + 177, 1609, 176, 177, 176, 177, 407, 1602, 1605, 1606, + + 1610, 176, 177, 1614, 1613, 176, 177, 1617, 176, 177, + 176, 177, 176, 177, 176, 177, 176, 177, 1627, 1628, + 1629, 1630, 1622, 1631, 1632, 1633, 1634, 1618, 1635, 240, + 1637, 1638, 1639, 240, 240, 1623, 1642, 1643, 1620, 240, + 240, 1619, 1646, 1647, 1648, 1624, 1649, 1636, 1650, 1625, + 1651, 1652, 1653, 1654, 1655, 1656, 1657, 1658, 1659, 1626, + 1660, 1661, 1662, 1640, 1663, 1641, 1664, 1665, 1666, 1644, + 1667, 1645, 1668, 1669, 1670, 1671, 1672, 1673, 1674, 1675, + 1676, 1677, 1678, 1679, 1680, 1681, 1682, 1683, 1684, 1685, + 1686, 1687, 1688, 1689, 176, 177, 176, 177, 176, 177, + + 176, 177, 1699, 176, 177, 176, 177, 1702, 176, 177, + 176, 177, 176, 177, 176, 177, 176, 177, 176, 177, + 1703, 1706, 1690, 1707, 1691, 176, 177, 1710, 176, 177, + 1692, 1694, 176, 177, 176, 177, 1711, 176, 177, 1721, + 176, 177, 1722, 1695, 1696, 176, 177, 1723, 1698, 1693, + 176, 177, 176, 177, 1701, 1724, 1697, 176, 177, 1700, + 1705, 1704, 176, 177, 176, 177, 1709, 1725, 1708, 1713, + 176, 177, 1714, 1726, 1727, 1728, 1729, 240, 1731, 1732, + 240, 240, 1735, 1736, 240, 1718, 1739, 240, 1716, 1712, + 1740, 1741, 1742, 1743, 1717, 1744, 1745, 1746, 1719, 1733, + + 1747, 1748, 1715, 1749, 1734, 1737, 1750, 1751, 1738, 1720, + 1752, 1753, 1730, 1754, 1755, 1756, 1757, 1758, 1759, 1760, + 1761, 1762, 1763, 1764, 1765, 1766, 1767, 1768, 1769, 1770, + 1771, 1772, 1773, 1774, 1775, 1776, 1777, 1778, 1779, 1780, + 176, 177, 176, 177, 176, 177, 176, 177, 176, 177, + 176, 177, 176, 177, 1789, 176, 177, 176, 177, 176, + 177, 1792, 176, 177, 1793, 176, 177, 176, 177, 1795, + 1796, 176, 177, 176, 177, 1798, 1799, 1808, 1784, 176, + 177, 176, 177, 176, 177, 1783, 1809, 1781, 1787, 1782, + 1791, 176, 177, 1786, 1810, 1785, 1811, 1790, 176, 177, + + 176, 177, 1812, 1788, 176, 177, 1794, 176, 177, 176, + 177, 1813, 1797, 1814, 1815, 1817, 240, 1818, 1821, 1800, + 240, 1824, 240, 1801, 1825, 240, 1826, 240, 1827, 1802, + 1828, 1803, 1829, 1830, 1831, 1832, 1833, 1834, 1835, 1804, + 1805, 1806, 1836, 1807, 1816, 1837, 1819, 1820, 1822, 1823, + 1838, 1839, 1840, 1841, 1842, 1843, 1844, 1845, 1846, 1847, + 1848, 1849, 1850, 1851, 1852, 1853, 1854, 1855, 1856, 1857, + 1858, 1859, 176, 177, 176, 177, 176, 177, 176, 177, + 176, 177, 1868, 176, 177, 176, 177, 176, 177, 176, + 177, 176, 177, 1871, 176, 177, 1872, 176, 177, 1873, + + 1874, 176, 177, 176, 177, 176, 177, 1881, 1860, 1882, + 1861, 1865, 176, 177, 176, 177, 1864, 1869, 176, 177, + 1867, 1866, 1883, 1862, 176, 177, 1884, 176, 177, 1863, + 1875, 1885, 1886, 1887, 1888, 240, 1890, 1870, 1891, 240, + 240, 1878, 1876, 240, 240, 1894, 1895, 1896, 1897, 1898, + 1899, 1900, 1901, 1889, 1902, 1903, 1904, 1877, 1905, 1879, + 1880, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1914, + 1892, 1915, 1916, 1917, 1893, 1918, 1919, 1920, 176, 177, + 176, 177, 176, 177, 176, 177, 176, 177, 176, 177, + 176, 177, 1929, 176, 177, 176, 177, 176, 177, 1924, + + 1931, 1932, 176, 177, 176, 177, 176, 177, 176, 177, + 1923, 176, 177, 176, 177, 1938, 1939, 1940, 1927, 1941, + 1921, 1942, 1922, 1943, 1944, 1945, 240, 1947, 1925, 1928, + 240, 240, 1948, 1949, 1950, 1926, 1951, 1952, 1953, 1954, + 1955, 1930, 1956, 1957, 1933, 1958, 1935, 1959, 1960, 1961, + 1934, 1962, 1963, 1936, 1964, 1965, 1966, 1967, 1968, 1969, + 176, 177, 1946, 176, 177, 1937, 176, 177, 176, 177, + 176, 177, 176, 177, 176, 177, 1978, 176, 177, 176, + 177, 1979, 176, 177, 176, 177, 176, 177, 176, 177, + 176, 177, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, + + 240, 1970, 1991, 1976, 1971, 1977, 1992, 1993, 1975, 1994, + 1995, 1974, 1996, 1972, 1997, 1981, 1973, 1998, 1999, 2000, + 2001, 1980, 2002, 2003, 2004, 2005, 2006, 1982, 176, 177, + 176, 177, 176, 177, 176, 177, 176, 177, 176, 177, + 176, 177, 176, 177, 2012, 2013, 176, 177, 176, 177, + 176, 177, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, + 2025, 2026, 2027, 2028, 2029, 2030, 2031, 2032, 2007, 2033, + 2034, 2011, 2040, 2008, 176, 177, 176, 177, 2042, 2010, + 2009, 176, 177, 176, 177, 176, 177, 176, 177, 2043, + 2015, 2044, 2014, 176, 177, 2045, 2016, 176, 177, 2046, + + 2047, 2048, 2049, 2050, 2051, 2052, 2053, 2054, 176, 177, + 176, 177, 176, 177, 2057, 2036, 2035, 2038, 176, 177, + 176, 177, 2037, 176, 177, 2059, 2039, 2060, 2061, 2062, + 2063, 2064, 2041, 2065, 176, 177, 176, 177, 176, 177, + 1129, 1128, 1127, 407, 407, 1085, 1084, 1083, 1082, 2055, + 1081, 1080, 2056, 1079, 1078, 1077, 1076, 1075, 1074, 1073, + 1072, 1071, 1070, 1069, 1068, 1067, 1066, 1065, 1064, 2058, + 165, 165, 165, 165, 165, 165, 165, 165, 178, 178, + 178, 178, 190, 1063, 190, 190, 224, 224, 1060, 1059, + 1058, 224, 239, 1057, 1056, 239, 239, 239, 239, 239, + + 243, 243, 243, 243, 243, 243, 243, 243, 256, 1055, + 1052, 256, 256, 256, 256, 256, 268, 1048, 1045, 268, + 268, 268, 268, 268, 299, 1044, 299, 299, 299, 299, + 299, 299, 302, 302, 302, 302, 302, 302, 302, 302, + 315, 1043, 315, 315, 315, 315, 315, 315, 327, 1042, + 327, 327, 327, 327, 327, 327, 408, 408, 408, 1041, + 1040, 1039, 1038, 1037, 1036, 1035, 1034, 1033, 1032, 1031, + 1030, 1029, 1028, 1027, 1026, 1025, 1024, 1023, 1020, 1019, + 1018, 1017, 1016, 1015, 1012, 1008, 240, 240, 1002, 1001, + 960, 959, 958, 957, 956, 955, 954, 953, 952, 951, + + 950, 949, 948, 947, 946, 945, 944, 943, 942, 941, + 940, 939, 938, 937, 936, 935, 934, 933, 932, 931, + 930, 929, 928, 927, 926, 925, 924, 923, 922, 921, + 920, 919, 918, 917, 916, 915, 914, 913, 912, 911, + 910, 909, 908, 907, 906, 905, 904, 903, 902, 901, + 900, 899, 898, 897, 896, 895, 894, 893, 892, 891, + 890, 889, 888, 887, 886, 885, 884, 883, 882, 881, + 880, 879, 240, 407, 407, 407, 873, 872, 871, 830, + 829, 826, 825, 824, 823, 822, 821, 820, 819, 818, + 817, 816, 815, 814, 813, 812, 811, 810, 809, 808, + + 807, 806, 805, 802, 799, 798, 797, 796, 795, 794, + 793, 792, 791, 790, 789, 788, 787, 786, 785, 784, + 783, 780, 779, 778, 777, 776, 775, 774, 240, 773, + 772, 771, 770, 769, 768, 767, 766, 765, 764, 763, + 762, 761, 760, 759, 756, 753, 752, 751, 750, 749, + 748, 747, 746, 745, 744, 743, 742, 741, 740, 407, + 407, 407, 407, 407, 407, 407, 407, 730, 729, 728, + 684, 683, 682, 681, 680, 679, 678, 675, 674, 673, + 672, 671, 670, 669, 668, 667, 666, 665, 664, 663, + 662, 661, 660, 659, 658, 657, 656, 655, 654, 653, + + 652, 651, 650, 649, 648, 647, 646, 645, 644, 643, + 642, 641, 640, 637, 636, 635, 634, 633, 632, 631, + 630, 627, 626, 624, 623, 622, 621, 620, 619, 618, + 617, 616, 615, 614, 613, 612, 611, 610, 609, 608, + 607, 606, 605, 604, 603, 602, 601, 600, 599, 598, + 597, 596, 595, 594, 593, 592, 589, 166, 407, 407, + 560, 523, 522, 521, 520, 519, 518, 517, 516, 513, + 510, 509, 508, 507, 506, 505, 504, 499, 498, 495, + 494, 493, 490, 489, 488, 487, 486, 485, 484, 483, + 482, 481, 480, 479, 478, 477, 476, 313, 307, 240, + + 472, 471, 470, 469, 468, 462, 461, 460, 459, 458, + 457, 456, 451, 450, 447, 446, 445, 442, 441, 440, + 439, 438, 437, 436, 435, 434, 433, 432, 431, 430, + 429, 428, 240, 240, 240, 240, 423, 240, 240, 240, + 240, 423, 240, 407, 407, 406, 398, 176, 176, 170, + 166, 357, 356, 353, 347, 346, 345, 342, 341, 340, + 339, 336, 326, 325, 324, 323, 320, 319, 318, 317, + 312, 311, 308, 307, 306, 305, 304, 301, 240, 240, + 297, 294, 288, 287, 286, 283, 282, 281, 280, 277, + 240, 267, 266, 265, 264, 261, 260, 259, 258, 240, + + 240, 248, 240, 240, 220, 221, 220, 176, 175, 174, + 171, 170, 169, 168, 167, 166, 164, 2066, 9, 2066, + 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, + 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, + 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, + 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, + 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, + 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, + 2066, 2066, 2066, 2066, 2066 + } ; + +static yyconst flex_int16_t yy_chk[3686] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 3, 4, 11, 409, + 11, 3, 4, 23, 23, 26, 26, 27, 27, 28, + 28, 29, 29, 31, 31, 34, 34, 35, 35, 1010, + 36, 36, 52, 52, 65, 67, 65, 67, 71, 3, + + 4, 68, 68, 72, 86, 76, 77, 77, 26, 76, + 71, 409, 65, 29, 72, 79, 79, 34, 86, 31, + 52, 28, 36, 35, 52, 78, 78, 78, 3, 4, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 7, 7, 7, 7, + + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 30, 30, 32, 32, 33, 33, 42, 42, + 39, 39, 117, 40, 40, 117, 41, 41, 427, 43, + 43, 44, 44, 45, 45, 46, 46, 47, 47, 49, + 49, 109, 32, 109, 48, 48, 50, 50, 51, 51, + + 427, 40, 54, 54, 55, 55, 32, 43, 41, 94, + 30, 39, 41, 39, 33, 40, 39, 44, 41, 42, + 107, 43, 48, 94, 45, 56, 56, 46, 97, 47, + 48, 49, 53, 53, 69, 69, 53, 69, 54, 126, + 126, 50, 97, 51, 93, 55, 93, 55, 95, 93, + 112, 69, 95, 106, 102, 135, 144, 106, 95, 143, + 144, 56, 102, 115, 107, 115, 144, 146, 107, 135, + 142, 151, 142, 143, 155, 142, 178, 178, 155, 151, + 53, 146, 179, 179, 53, 62, 62, 158, 163, 158, + 163, 156, 177, 1011, 177, 112, 181, 181, 177, 180, + + 180, 254, 182, 182, 1012, 183, 183, 184, 184, 209, + 209, 254, 187, 187, 277, 179, 249, 62, 194, 194, + 249, 62, 277, 62, 62, 62, 181, 281, 62, 281, + 62, 62, 62, 185, 185, 156, 62, 62, 62, 156, + 180, 182, 187, 184, 228, 62, 183, 62, 80, 80, + 186, 186, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 194, 80, 80, 80, 80, 188, 188, + 191, 191, 196, 196, 245, 189, 189, 197, 197, 185, + 273, 199, 199, 80, 280, 228, 186, 280, 245, 273, + 80, 192, 192, 193, 193, 198, 198, 227, 195, 195, + + 1013, 191, 196, 200, 200, 201, 201, 235, 188, 199, + 197, 80, 80, 80, 81, 81, 189, 199, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 81, 81, 195, + 81, 81, 81, 81, 192, 198, 204, 204, 195, 193, + 229, 207, 207, 215, 215, 205, 205, 227, 200, 81, + 201, 206, 206, 235, 202, 202, 302, 203, 203, 302, + 208, 208, 1014, 210, 210, 219, 219, 211, 211, 216, + 216, 229, 204, 212, 212, 217, 217, 81, 81, 81, + 92, 92, 207, 215, 92, 92, 92, 92, 92, 92, + 92, 92, 92, 92, 92, 205, 92, 92, 92, 92, + + 202, 212, 206, 202, 203, 210, 203, 208, 211, 216, + 290, 217, 219, 232, 1015, 92, 241, 292, 241, 212, + 300, 332, 300, 218, 218, 429, 230, 336, 290, 1016, + 332, 292, 214, 214, 241, 336, 234, 339, 429, 233, + 339, 231, 226, 92, 92, 92, 129, 129, 232, 129, + 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, + 129, 214, 129, 129, 129, 129, 218, 230, 231, 226, + 233, 234, 231, 243, 243, 214, 243, 226, 314, 255, + 314, 129, 231, 349, 314, 255, 351, 255, 129, 226, + 243, 255, 340, 465, 340, 291, 1017, 361, 361, 465, + + 351, 349, 362, 362, 363, 363, 364, 364, 411, 129, + 129, 129, 130, 130, 416, 130, 130, 130, 130, 130, + 130, 130, 130, 130, 130, 130, 130, 414, 130, 130, + 130, 130, 291, 361, 365, 365, 367, 367, 362, 368, + 368, 372, 372, 380, 380, 364, 363, 130, 366, 366, + 411, 362, 369, 369, 416, 370, 370, 373, 373, 371, + 371, 375, 375, 575, 377, 377, 365, 378, 378, 368, + 414, 380, 367, 374, 374, 130, 130, 130, 141, 141, + 426, 141, 141, 141, 141, 141, 141, 141, 141, 141, + 141, 141, 141, 366, 141, 141, 141, 141, 370, 369, + + 371, 425, 373, 376, 376, 374, 375, 377, 575, 378, + 384, 384, 477, 141, 379, 379, 393, 393, 426, 381, + 381, 382, 382, 385, 385, 477, 383, 383, 389, 389, + 391, 391, 425, 386, 386, 376, 387, 387, 384, 388, + 388, 141, 141, 141, 268, 268, 412, 379, 268, 268, + 268, 268, 268, 268, 268, 268, 268, 268, 268, 381, + 268, 268, 268, 268, 383, 386, 391, 382, 387, 389, + 385, 388, 390, 390, 400, 400, 392, 392, 407, 268, + 407, 412, 528, 528, 407, 397, 397, 586, 394, 394, + 399, 399, 633, 403, 403, 586, 395, 395, 633, 410, + + 413, 396, 396, 418, 390, 417, 400, 268, 268, 268, + 327, 327, 392, 327, 327, 327, 327, 327, 327, 327, + 327, 327, 327, 327, 327, 394, 327, 327, 327, 327, + 395, 396, 397, 401, 401, 403, 399, 402, 402, 404, + 404, 405, 405, 410, 413, 327, 415, 418, 417, 419, + 420, 421, 468, 516, 468, 516, 524, 524, 525, 525, + 401, 1018, 401, 526, 526, 527, 527, 530, 530, 402, + 585, 404, 738, 327, 327, 327, 405, 529, 529, 419, + 738, 415, 1019, 420, 421, 531, 531, 573, 525, 532, + 532, 533, 533, 420, 879, 526, 879, 524, 534, 534, + + 535, 535, 536, 536, 585, 529, 533, 537, 537, 538, + 538, 540, 540, 527, 539, 539, 573, 530, 541, 541, + 543, 543, 576, 542, 542, 544, 544, 532, 545, 545, + 546, 546, 531, 547, 547, 548, 548, 534, 549, 549, + 550, 550, 551, 551, 536, 538, 542, 1020, 539, 576, + 540, 681, 537, 540, 579, 542, 543, 681, 546, 552, + 552, 553, 553, 554, 554, 587, 541, 578, 544, 555, + 555, 1009, 547, 556, 556, 545, 557, 557, 1009, 549, + 558, 558, 559, 559, 579, 550, 588, 551, 561, 561, + 562, 562, 563, 563, 564, 564, 565, 565, 566, 566, + + 567, 567, 587, 554, 876, 556, 553, 578, 557, 555, + 568, 568, 607, 605, 653, 558, 605, 653, 1021, 655, + 561, 607, 890, 588, 563, 890, 565, 559, 655, 685, + 685, 876, 686, 686, 1022, 562, 564, 687, 687, 566, + 688, 688, 689, 689, 1023, 567, 568, 686, 690, 690, + 691, 691, 568, 692, 692, 693, 693, 694, 694, 695, + 695, 685, 696, 696, 697, 697, 698, 698, 692, 699, + 699, 700, 700, 701, 701, 733, 702, 702, 703, 703, + 704, 704, 732, 688, 690, 1025, 691, 689, 687, 694, + 705, 705, 706, 706, 707, 707, 697, 874, 698, 709, + + 709, 699, 1027, 693, 708, 708, 710, 710, 1028, 696, + 695, 711, 711, 733, 712, 712, 701, 700, 702, 713, + 713, 704, 1029, 703, 714, 714, 715, 715, 732, 705, + 716, 716, 736, 717, 717, 718, 718, 883, 706, 883, + 707, 712, 874, 708, 719, 719, 720, 720, 721, 721, + 722, 722, 710, 724, 724, 713, 715, 711, 723, 723, + 714, 717, 739, 725, 725, 726, 726, 727, 727, 1031, + 739, 718, 831, 831, 832, 832, 837, 837, 736, 875, + 833, 833, 834, 834, 1033, 831, 881, 831, 881, 722, + 725, 719, 720, 833, 881, 833, 921, 723, 921, 721, + + 925, 833, 925, 835, 835, 1005, 726, 836, 836, 838, + 838, 839, 839, 840, 840, 727, 835, 875, 835, 841, + 841, 834, 832, 843, 843, 837, 844, 844, 840, 845, + 845, 1034, 842, 842, 846, 846, 847, 847, 1035, 848, + 848, 849, 849, 850, 850, 851, 851, 852, 852, 1005, + 839, 853, 853, 836, 843, 841, 842, 838, 1037, 842, + 848, 854, 854, 855, 855, 932, 846, 844, 932, 845, + 856, 856, 1038, 849, 1039, 847, 1040, 851, 857, 857, + 858, 858, 859, 859, 860, 860, 861, 861, 862, 862, + 863, 863, 864, 864, 1041, 855, 1042, 865, 865, 1043, + + 866, 866, 856, 867, 867, 868, 868, 857, 869, 869, + 870, 870, 923, 1044, 923, 861, 961, 961, 862, 1045, + 923, 962, 962, 1046, 864, 865, 963, 963, 964, 964, + 1047, 860, 863, 858, 868, 859, 866, 965, 965, 966, + 966, 967, 967, 969, 969, 867, 968, 968, 970, 970, + 971, 971, 1048, 972, 972, 973, 973, 870, 961, 974, + 974, 975, 975, 964, 1050, 963, 1051, 976, 976, 962, + 964, 966, 1052, 967, 977, 977, 978, 978, 979, 979, + 970, 1053, 971, 980, 980, 965, 981, 981, 968, 982, + 982, 969, 972, 1054, 973, 983, 983, 984, 984, 985, + + 985, 975, 1055, 978, 986, 986, 1056, 974, 976, 987, + 987, 988, 988, 989, 989, 980, 990, 990, 991, 992, + 992, 982, 977, 1057, 991, 991, 1058, 983, 993, 993, + 994, 994, 995, 995, 986, 991, 996, 996, 984, 997, + 997, 1059, 991, 998, 998, 989, 999, 999, 990, 1036, + 1049, 991, 1060, 988, 1000, 1000, 1061, 1049, 992, 1062, + 1063, 1065, 1067, 994, 1068, 1069, 1036, 1071, 1073, 997, + 1074, 1075, 1077, 1036, 1076, 993, 996, 1078, 1079, 995, + 1080, 1000, 1036, 1081, 1082, 1083, 1084, 1085, 999, 998, + 1126, 1076, 1086, 1086, 1087, 1087, 1088, 1088, 1076, 1089, + + 1089, 1090, 1090, 1091, 1091, 1092, 1092, 1076, 1093, 1093, + 1094, 1094, 1095, 1095, 1096, 1096, 1097, 1097, 1098, 1098, + 1099, 1099, 1100, 1100, 1101, 1101, 1113, 1096, 1127, 1097, + 1128, 1089, 1086, 1087, 1126, 1088, 1102, 1102, 1129, 1093, + 1113, 1090, 1091, 1103, 1103, 1104, 1104, 1130, 1092, 1131, + 1094, 1095, 1101, 1105, 1105, 1106, 1106, 1098, 1107, 1107, + 1132, 1100, 1108, 1108, 1109, 1109, 1110, 1110, 1111, 1111, + 1133, 1111, 1112, 1112, 1104, 1112, 1114, 1114, 1115, 1115, + 1116, 1116, 1102, 1134, 1103, 1135, 1106, 1136, 1117, 1117, + 1119, 1119, 1108, 1137, 1105, 1120, 1120, 1107, 1138, 1111, + + 1121, 1121, 1139, 1112, 1118, 1118, 1122, 1122, 1116, 1123, + 1123, 1109, 1141, 1111, 1110, 1124, 1124, 1112, 1118, 1115, + 1117, 1142, 1116, 1125, 1125, 1118, 1114, 1143, 1144, 1145, + 1146, 1118, 1147, 1148, 1149, 1150, 1151, 1120, 1152, 1153, + 1154, 1155, 1156, 1121, 1157, 1158, 1160, 1161, 1163, 1164, + 1165, 1166, 1158, 1167, 1168, 1169, 1156, 1123, 1158, 1170, + 1171, 1172, 1173, 1124, 1174, 1175, 1152, 1153, 1176, 1125, + 1177, 1178, 1180, 1181, 1182, 1183, 1184, 1185, 1186, 1187, + 1152, 1153, 1188, 1189, 1190, 1191, 1192, 1193, 1194, 1195, + 1196, 1197, 1198, 1200, 1201, 1203, 1204, 1205, 1230, 1198, + + 1236, 1193, 1206, 1206, 1196, 1198, 1207, 1207, 1208, 1208, + 1209, 1209, 1230, 1191, 1192, 1210, 1210, 1211, 1211, 1212, + 1212, 1213, 1213, 1214, 1214, 1216, 1216, 1191, 1192, 1215, + 1215, 1206, 1217, 1217, 1213, 1218, 1218, 1219, 1219, 1237, + 1209, 1220, 1220, 1252, 1210, 1207, 1251, 1221, 1221, 1222, + 1222, 1233, 1214, 1223, 1223, 1253, 1211, 1224, 1224, 1255, + 1216, 1226, 1226, 1256, 1212, 1233, 1225, 1225, 1215, 1225, + 1227, 1227, 1228, 1228, 1217, 1221, 1219, 1229, 1229, 1231, + 1231, 1232, 1232, 1234, 1234, 1235, 1235, 1251, 1220, 1238, + 1238, 1240, 1240, 1225, 1242, 1222, 1257, 1239, 1239, 1225, + + 1242, 1242, 1227, 1258, 1224, 1223, 1241, 1241, 1228, 1232, + 1243, 1243, 1259, 1235, 1244, 1244, 1260, 1238, 1229, 1239, + 1261, 1231, 1245, 1245, 1262, 1234, 1246, 1246, 1263, 1247, + 1247, 1248, 1248, 1249, 1249, 1250, 1250, 1265, 1266, 1267, + 1268, 1240, 1244, 1269, 1270, 1271, 1273, 1241, 1274, 1275, + 1277, 1276, 1243, 1245, 1278, 1280, 1279, 1281, 1282, 1246, + 1283, 1284, 1285, 1286, 1287, 1288, 1289, 1245, 1247, 1271, + 1290, 1250, 1276, 1291, 1249, 1271, 1248, 1279, 1292, 1293, + 1289, 1294, 1295, 1296, 1298, 1299, 1276, 1300, 1301, 1302, + 1303, 1279, 1304, 1305, 1306, 1308, 1309, 1310, 1311, 1312, + + 1313, 1314, 1316, 1317, 1318, 1319, 1320, 1321, 1322, 1323, + 1324, 1325, 1326, 1327, 1328, 1329, 1330, 1331, 1332, 1319, + 1333, 1334, 1322, 1335, 1336, 1314, 1337, 1338, 1339, 1340, + 1340, 1314, 1341, 1341, 1357, 1334, 1342, 1342, 1363, 1343, + 1343, 1344, 1344, 1364, 1345, 1345, 1346, 1346, 1347, 1347, + 1348, 1348, 1367, 1349, 1349, 1350, 1350, 1351, 1351, 1352, + 1352, 1353, 1353, 1355, 1355, 1340, 1354, 1354, 1356, 1356, + 1358, 1358, 1359, 1359, 1342, 1343, 1345, 1360, 1360, 1361, + 1361, 1362, 1362, 1368, 1347, 1349, 1365, 1365, 1346, 1366, + 1366, 1352, 1369, 1369, 1354, 1350, 1370, 1370, 1371, 1372, + + 1359, 1373, 1373, 1358, 1374, 1374, 1375, 1375, 1353, 1376, + 1376, 1377, 1362, 1387, 1378, 1378, 1379, 1379, 1380, 1380, + 1388, 1361, 1381, 1381, 1382, 1382, 1365, 1383, 1383, 1390, + 1366, 1391, 1369, 1393, 1375, 1394, 1376, 1370, 1384, 1384, + 1385, 1385, 1386, 1386, 1395, 1397, 1398, 1400, 1401, 1402, + 1381, 1405, 1406, 1373, 1378, 1407, 1374, 1379, 1409, 1383, + 1380, 1410, 1387, 1411, 1413, 1412, 1414, 1415, 1416, 1417, + 1384, 1385, 1418, 1419, 1405, 1420, 1421, 1422, 1423, 1424, + 1425, 1426, 1386, 1412, 1428, 1429, 1416, 1430, 1431, 1432, + 1434, 1435, 1437, 1438, 1439, 1411, 1441, 1442, 1444, 1415, + + 1445, 1446, 1449, 1450, 1451, 1453, 1454, 1455, 1456, 1457, + 1458, 1459, 1460, 1461, 1462, 1463, 1464, 1465, 1466, 1467, + 1468, 1469, 1470, 1471, 1472, 1473, 1475, 1476, 1477, 1478, + 1479, 1479, 1480, 1480, 1481, 1481, 1482, 1482, 1483, 1483, + 1484, 1484, 1485, 1485, 1486, 1486, 1487, 1487, 1488, 1488, + 1489, 1489, 1490, 1492, 1492, 1491, 1491, 1495, 1493, 1493, + 1494, 1494, 1496, 1497, 1497, 1499, 1498, 1498, 1500, 1502, + 1502, 1479, 1485, 1486, 1503, 1481, 1501, 1501, 1504, 1483, + 1509, 1484, 1482, 1491, 1488, 1505, 1505, 1506, 1506, 1507, + 1507, 1497, 1508, 1508, 1510, 1510, 1518, 1489, 1492, 1493, + + 1498, 1511, 1511, 1502, 1501, 1512, 1512, 1505, 1513, 1513, + 1514, 1514, 1515, 1515, 1516, 1516, 1517, 1517, 1519, 1521, + 1522, 1523, 1510, 1524, 1525, 1526, 1528, 1506, 1529, 1530, + 1531, 1532, 1533, 1535, 1536, 1511, 1537, 1538, 1508, 1539, + 1540, 1507, 1541, 1542, 1543, 1512, 1544, 1530, 1545, 1513, + 1546, 1547, 1548, 1549, 1550, 1554, 1555, 1557, 1558, 1517, + 1559, 1560, 1561, 1535, 1562, 1536, 1564, 1565, 1566, 1539, + 1567, 1540, 1568, 1569, 1571, 1572, 1573, 1574, 1575, 1576, + 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1585, 1586, + 1587, 1588, 1589, 1593, 1594, 1594, 1595, 1595, 1596, 1596, + + 1597, 1597, 1603, 1598, 1598, 1599, 1599, 1607, 1600, 1600, + 1601, 1601, 1602, 1602, 1604, 1604, 1605, 1605, 1606, 1606, + 1608, 1611, 1594, 1612, 1595, 1609, 1609, 1615, 1610, 1610, + 1596, 1598, 1613, 1613, 1614, 1614, 1616, 1617, 1617, 1627, + 1618, 1618, 1628, 1599, 1600, 1619, 1619, 1629, 1602, 1597, + 1620, 1620, 1622, 1622, 1605, 1630, 1601, 1624, 1624, 1604, + 1610, 1609, 1623, 1623, 1625, 1625, 1614, 1631, 1613, 1618, + 1626, 1626, 1619, 1632, 1633, 1634, 1635, 1636, 1637, 1638, + 1641, 1640, 1642, 1643, 1645, 1624, 1646, 1644, 1622, 1617, + 1647, 1648, 1649, 1650, 1623, 1651, 1652, 1653, 1625, 1640, + + 1654, 1655, 1620, 1656, 1641, 1644, 1657, 1658, 1645, 1626, + 1659, 1660, 1636, 1661, 1662, 1663, 1664, 1665, 1666, 1667, + 1668, 1670, 1671, 1672, 1673, 1674, 1675, 1676, 1677, 1678, + 1679, 1680, 1681, 1682, 1683, 1685, 1686, 1687, 1688, 1689, + 1690, 1690, 1691, 1691, 1692, 1692, 1693, 1693, 1694, 1694, + 1695, 1695, 1696, 1696, 1699, 1697, 1697, 1698, 1698, 1700, + 1700, 1702, 1701, 1701, 1703, 1704, 1704, 1705, 1705, 1706, + 1707, 1708, 1708, 1709, 1709, 1710, 1711, 1721, 1693, 1712, + 1712, 1713, 1713, 1714, 1714, 1692, 1722, 1690, 1697, 1691, + 1701, 1715, 1715, 1696, 1723, 1694, 1724, 1700, 1716, 1716, + + 1717, 1717, 1725, 1698, 1718, 1718, 1704, 1720, 1720, 1719, + 1719, 1727, 1708, 1728, 1729, 1731, 1730, 1732, 1735, 1712, + 1733, 1739, 1737, 1713, 1741, 1734, 1742, 1738, 1743, 1714, + 1744, 1715, 1745, 1747, 1748, 1749, 1750, 1751, 1752, 1716, + 1718, 1719, 1753, 1720, 1730, 1754, 1733, 1734, 1737, 1738, + 1756, 1757, 1758, 1759, 1760, 1761, 1762, 1763, 1764, 1766, + 1767, 1768, 1770, 1771, 1772, 1773, 1774, 1775, 1776, 1778, + 1779, 1780, 1781, 1781, 1782, 1782, 1783, 1783, 1784, 1784, + 1785, 1785, 1789, 1786, 1786, 1787, 1787, 1788, 1788, 1790, + 1790, 1791, 1791, 1792, 1794, 1794, 1795, 1797, 1797, 1798, + + 1799, 1800, 1800, 1801, 1801, 1802, 1802, 1808, 1781, 1809, + 1782, 1786, 1803, 1803, 1804, 1804, 1785, 1790, 1805, 1805, + 1788, 1787, 1810, 1783, 1806, 1806, 1811, 1807, 1807, 1784, + 1800, 1812, 1813, 1814, 1815, 1816, 1817, 1791, 1818, 1819, + 1820, 1803, 1801, 1822, 1823, 1825, 1826, 1827, 1828, 1830, + 1832, 1833, 1834, 1816, 1835, 1836, 1837, 1802, 1838, 1805, + 1807, 1839, 1840, 1841, 1842, 1843, 1844, 1847, 1850, 1851, + 1819, 1852, 1853, 1854, 1822, 1855, 1857, 1859, 1860, 1860, + 1861, 1861, 1862, 1862, 1863, 1863, 1864, 1864, 1865, 1865, + 1866, 1866, 1868, 1867, 1867, 1869, 1869, 1870, 1870, 1863, + + 1873, 1874, 1875, 1875, 1876, 1876, 1877, 1877, 1879, 1879, + 1862, 1878, 1878, 1880, 1880, 1881, 1882, 1883, 1866, 1884, + 1860, 1885, 1861, 1886, 1887, 1888, 1889, 1890, 1864, 1867, + 1892, 1893, 1894, 1895, 1896, 1865, 1897, 1899, 1900, 1901, + 1902, 1869, 1903, 1904, 1875, 1905, 1877, 1906, 1907, 1908, + 1876, 1909, 1913, 1878, 1914, 1915, 1916, 1917, 1918, 1920, + 1921, 1921, 1889, 1922, 1922, 1880, 1923, 1923, 1924, 1924, + 1925, 1925, 1926, 1926, 1927, 1927, 1931, 1928, 1928, 1930, + 1930, 1932, 1933, 1933, 1934, 1934, 1935, 1935, 1936, 1936, + 1937, 1937, 1938, 1939, 1940, 1941, 1942, 1943, 1944, 1945, + + 1946, 1921, 1948, 1927, 1922, 1928, 1950, 1951, 1926, 1953, + 1954, 1925, 1955, 1923, 1956, 1935, 1924, 1957, 1958, 1959, + 1960, 1933, 1963, 1964, 1965, 1967, 1968, 1936, 1970, 1970, + 1971, 1971, 1972, 1972, 1973, 1973, 1974, 1974, 1975, 1975, + 1976, 1976, 1977, 1977, 1978, 1979, 1980, 1980, 1981, 1981, + 1982, 1982, 1985, 1986, 1988, 1989, 1990, 1991, 1992, 1993, + 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004, 1972, 2005, + 2006, 1977, 2012, 1973, 2007, 2007, 2008, 2008, 2017, 1976, + 1975, 2009, 2009, 2014, 2014, 2010, 2010, 2011, 2011, 2018, + 1981, 2019, 1980, 2015, 2015, 2020, 1982, 2016, 2016, 2021, + + 2023, 2025, 2026, 2027, 2028, 2029, 2030, 2033, 2035, 2035, + 2036, 2036, 2037, 2037, 2040, 2008, 2007, 2010, 2038, 2038, + 2039, 2039, 2009, 2041, 2041, 2042, 2011, 2046, 2047, 2048, + 2052, 2053, 2015, 2054, 2055, 2055, 2056, 2056, 2058, 2058, + 1008, 1007, 1006, 1004, 1003, 960, 958, 957, 956, 2035, + 955, 954, 2039, 953, 952, 951, 950, 949, 948, 947, + 946, 945, 941, 939, 938, 937, 936, 935, 934, 2041, + 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2068, 2068, + 2068, 2068, 2069, 933, 2069, 2069, 2070, 2070, 931, 930, + 929, 2070, 2071, 928, 927, 2071, 2071, 2071, 2071, 2071, + + 2072, 2072, 2072, 2072, 2072, 2072, 2072, 2072, 2073, 926, + 924, 2073, 2073, 2073, 2073, 2073, 2074, 922, 918, 2074, + 2074, 2074, 2074, 2074, 2075, 916, 2075, 2075, 2075, 2075, + 2075, 2075, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, + 2077, 915, 2077, 2077, 2077, 2077, 2077, 2077, 2078, 914, + 2078, 2078, 2078, 2078, 2078, 2078, 2079, 2079, 2079, 913, + 912, 911, 910, 909, 908, 907, 906, 905, 904, 903, + 899, 897, 896, 895, 894, 893, 892, 891, 889, 888, + 887, 886, 885, 884, 882, 880, 878, 877, 873, 872, + 828, 827, 826, 824, 823, 822, 821, 820, 819, 818, + + 816, 815, 814, 813, 812, 811, 809, 808, 807, 806, + 805, 804, 803, 802, 801, 800, 799, 798, 797, 796, + 795, 794, 793, 792, 791, 790, 789, 788, 787, 786, + 785, 784, 782, 781, 780, 778, 777, 776, 775, 774, + 773, 772, 770, 769, 768, 767, 766, 765, 763, 762, + 761, 760, 759, 758, 757, 756, 755, 754, 753, 752, + 751, 750, 749, 748, 747, 746, 745, 744, 743, 742, + 741, 740, 737, 735, 734, 731, 730, 729, 728, 684, + 683, 680, 679, 678, 677, 676, 675, 674, 672, 671, + 670, 669, 668, 667, 666, 664, 663, 662, 660, 659, + + 658, 657, 656, 654, 652, 651, 650, 649, 647, 646, + 645, 644, 643, 642, 640, 639, 638, 637, 636, 635, + 634, 632, 631, 630, 629, 628, 627, 626, 625, 624, + 623, 622, 621, 620, 619, 618, 616, 615, 614, 612, + 611, 610, 609, 608, 606, 604, 603, 602, 601, 599, + 598, 597, 596, 595, 594, 592, 591, 590, 589, 584, + 583, 582, 581, 580, 577, 574, 572, 571, 570, 569, + 523, 522, 521, 520, 519, 518, 517, 515, 514, 513, + 512, 511, 510, 509, 507, 506, 505, 504, 503, 502, + 501, 500, 499, 498, 497, 496, 495, 494, 493, 492, + + 491, 490, 489, 488, 486, 485, 484, 483, 482, 481, + 480, 479, 478, 476, 475, 474, 473, 472, 471, 470, + 469, 467, 466, 464, 463, 462, 461, 459, 458, 457, + 456, 455, 454, 453, 452, 451, 450, 449, 448, 447, + 446, 445, 444, 443, 442, 441, 440, 438, 437, 436, + 435, 434, 433, 432, 431, 430, 428, 424, 422, 408, + 398, 360, 359, 358, 356, 355, 354, 353, 352, 350, + 348, 347, 345, 344, 343, 342, 341, 338, 337, 335, + 334, 333, 331, 330, 329, 328, 326, 325, 324, 323, + 322, 321, 320, 319, 318, 317, 316, 313, 307, 298, + + 297, 296, 295, 294, 293, 289, 288, 286, 285, 284, + 283, 282, 279, 278, 276, 275, 274, 272, 271, 270, + 269, 267, 266, 265, 264, 263, 262, 261, 260, 259, + 258, 257, 253, 252, 251, 250, 248, 247, 246, 244, + 242, 240, 239, 236, 224, 221, 213, 190, 176, 170, + 165, 161, 159, 157, 154, 153, 152, 150, 149, 148, + 147, 145, 139, 138, 137, 136, 134, 133, 132, 131, + 128, 127, 125, 124, 121, 120, 119, 116, 113, 111, + 110, 108, 105, 104, 103, 101, 100, 99, 98, 96, + 91, 90, 89, 88, 87, 85, 84, 83, 82, 75, + + 74, 73, 70, 64, 63, 61, 58, 38, 25, 24, + 22, 21, 18, 17, 16, 14, 13, 9, 2066, 2066, + 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, + 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, + 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, + 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, + 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, + 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, 2066, + 2066, 2066, 2066, 2066, 2066 + } ; + +/* Table of booleans, true if rule could match eol. */ +static yyconst flex_int32_t yy_rule_can_match_eol[148] = + { 0, +0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 0, 0, }; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "../src/parser.ll" +/***************************************************************************** + Copyright (C) 1994-2000 the Omega Project Team + Copyright (C) 2005-2011 Chun Chen + All Rights Reserved. + + Purpose: + lex parser for calculator. + + Notes: + + History: + 02/04/11 migrate to flex c++ mode, Chun Chen +*****************************************************************************/ +#line 16 "../src/parser.ll" +#include <stdio.h> +#include <string.h> +#include <string> +#include <sstream> +#include <iostream> +#include <fstream> +#include <omega_calc/AST.h> +#include <basic/Dynamic_Array.h> +#include "parser.tab.hh" +#include <omega_calc/myflex.h> + +myFlexLexer mylexer; +bool is_interactive; +const char *PROMPT_STRING = ">>>"; + +#define BUFFER scanBuf += yytext +std::string scanBuf; +std::string err_msg; + +extern bool need_coef; + +void yyerror(const std::string &s); +void flushScanBuffer(); + + +#line 1974 "lex.yy.cc" + +#define INITIAL 0 +#define LATEX 1 +#define INCLUDE 2 +#define COMMENT 3 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include <unistd.h> +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +#define ECHO LexerOutput( yytext, yyleng ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ +\ + if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) LexerError( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 +#define YY_DECL int yyFlexLexer::yylex() +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 46 "../src/parser.ll" + + +#line 2085 "lex.yy.cc" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = & std::cin; + + if ( ! yyout ) + yyout = & std::cout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 2067 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 3619 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + + if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) + { + int yyl; + for ( yyl = 0; yyl < yyleng; ++yyl ) + if ( yytext[yyl] == '\n' ) + + yylineno++; +; + } + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 48 "../src/parser.ll" +{ BUFFER; BEGIN(INCLUDE); } + YY_BREAK +case 2: +YY_RULE_SETUP +#line 49 "../src/parser.ll" +{ + BUFFER; + scanBuf += "\n"; + flushScanBuffer(); + + if (is_interactive) { + std::cout << "file include disabled in interactive mode\n"; + } + else { + char *s = yytext; + while (*s != '>') s++; + *s = '\0'; + std::ifstream *ifs = new std::ifstream(yytext, std::ifstream::in); + if (!ifs->is_open()) { + fprintf(stderr, "Can't open file %s\n", yytext); + } + else { + yy_buffer_state *bs = mylexer.yy_create_buffer(ifs, 8092); + mylexer.yypush_buffer_state(bs); + } + } + BEGIN(INITIAL); +} + YY_BREAK +case 3: +/* rule 3 can match eol */ +YY_RULE_SETUP +#line 72 "../src/parser.ll" +{ + std::cout << "Error in include syntax\n"; + std::cout << "Use <<fname>> to include the file named fname\n"; + BEGIN(INITIAL); + if(is_interactive) { + std::cout << PROMPT_STRING << ' '; + std::cout.flush(); + } +} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 86 "../src/parser.ll" +{ BUFFER; } + YY_BREAK +case 5: +YY_RULE_SETUP +#line 87 "../src/parser.ll" +{ BUFFER; } + YY_BREAK +case 6: +YY_RULE_SETUP +#line 88 "../src/parser.ll" +{ BUFFER; BEGIN(COMMENT); } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 89 "../src/parser.ll" +{ BUFFER; } + YY_BREAK +case 8: +/* rule 8 can match eol */ +YY_RULE_SETUP +#line 90 "../src/parser.ll" +{ BUFFER; BEGIN(INITIAL); } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 91 "../src/parser.ll" +{ BUFFER; BEGIN(INITIAL); } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 92 "../src/parser.ll" +{ BUFFER; BEGIN(LATEX); } + YY_BREAK +case 11: +YY_RULE_SETUP +#line 93 "../src/parser.ll" +{ BUFFER; } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 94 "../src/parser.ll" +{ BUFFER; } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 95 "../src/parser.ll" +{ BUFFER; } + YY_BREAK +case 14: +YY_RULE_SETUP +#line 96 "../src/parser.ll" +{ BUFFER; } + YY_BREAK +case 15: +/* rule 15 can match eol */ +YY_RULE_SETUP +#line 97 "../src/parser.ll" +{ BUFFER; } + YY_BREAK +case 16: +/* rule 16 can match eol */ +YY_RULE_SETUP +#line 100 "../src/parser.ll" +{ + BUFFER; + BEGIN(INITIAL); + if(is_interactive) { + std::cout << PROMPT_STRING << ' '; + std::cout.flush(); + } +} + YY_BREAK +case 17: +YY_RULE_SETUP +#line 113 "../src/parser.ll" +{ BUFFER; return OPEN_BRACE; } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 114 "../src/parser.ll" +{ BUFFER; return OPEN_BRACE; } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 115 "../src/parser.ll" +{ BUFFER; return CLOSE_BRACE; } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 116 "../src/parser.ll" +{ BUFFER; return CLOSE_BRACE; } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 117 "../src/parser.ll" +{ BUFFER; return APPROX; } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 118 "../src/parser.ll" +{ BUFFER; return UNION; } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 119 "../src/parser.ll" +{ BUFFER; return UNION; } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 120 "../src/parser.ll" +{ BUFFER; return INTERSECTION; } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 121 "../src/parser.ll" +{ BUFFER; return INTERSECTION; } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 122 "../src/parser.ll" +{ BUFFER; return NO_SIMPLIFY; } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 123 "../src/parser.ll" +{ BUFFER; return SYMBOLIC; } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 124 "../src/parser.ll" +{ BUFFER; return SYMBOLIC; } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 125 "../src/parser.ll" +{ BUFFER; return VERTICAL_BAR; } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 126 "../src/parser.ll" +{ BUFFER; return VERTICAL_BAR; } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 127 "../src/parser.ll" +{ BUFFER; return SUCH_THAT; } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 128 "../src/parser.ll" +{ BUFFER; return SUCH_THAT; } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 129 "../src/parser.ll" +{ BUFFER; return INVERSE; } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 130 "../src/parser.ll" +{ BUFFER; return COMPLEMENT; } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 131 "../src/parser.ll" +{ BUFFER; return COMPOSE; } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 132 "../src/parser.ll" +{ BUFFER; return COMPOSE; } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 133 "../src/parser.ll" +{ BUFFER; return DIFFERENCE; } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 134 "../src/parser.ll" +{ BUFFER; return DIFFERENCE_TO_RELATION; } + YY_BREAK +case 39: +YY_RULE_SETUP +#line 135 "../src/parser.ll" +{ BUFFER; return PROJECT_AWAY_SYMBOLS; } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 136 "../src/parser.ll" +{ BUFFER; return PROJECT_AWAY_SYMBOLS; } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 137 "../src/parser.ll" +{ BUFFER; return PROJECT_AWAY_SYMBOLS; } + YY_BREAK +case 42: +YY_RULE_SETUP +#line 138 "../src/parser.ll" +{ BUFFER; return PROJECT_ON_SYMBOLS; } + YY_BREAK +case 43: +YY_RULE_SETUP +#line 139 "../src/parser.ll" +{ BUFFER; return PROJECT_ON_SYMBOLS; } + YY_BREAK +case 44: +YY_RULE_SETUP +#line 140 "../src/parser.ll" +{ BUFFER; return PROJECT_ON_SYMBOLS; } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 141 "../src/parser.ll" +{ BUFFER; return JOIN; } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 142 "../src/parser.ll" +{ BUFFER; return JOIN; } + YY_BREAK +case 47: +YY_RULE_SETUP +#line 143 "../src/parser.ll" +{ BUFFER; return JOIN; } + YY_BREAK +case 48: +YY_RULE_SETUP +#line 144 "../src/parser.ll" +{ BUFFER; return DOMAIN; } + YY_BREAK +case 49: +YY_RULE_SETUP +#line 145 "../src/parser.ll" +{ BUFFER; return TIME; } + YY_BREAK +case 50: +YY_RULE_SETUP +#line 146 "../src/parser.ll" +{ BUFFER; return TIMECLOSURE; } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 147 "../src/parser.ll" +{ BUFFER; return RANGE; } + YY_BREAK +case 52: +YY_RULE_SETUP +#line 148 "../src/parser.ll" +{ BUFFER; return FORALL; } + YY_BREAK +case 53: +YY_RULE_SETUP +#line 149 "../src/parser.ll" +{ BUFFER; return FORALL; } + YY_BREAK +case 54: +YY_RULE_SETUP +#line 150 "../src/parser.ll" +{ BUFFER; return EXISTS; } + YY_BREAK +case 55: +YY_RULE_SETUP +#line 151 "../src/parser.ll" +{ BUFFER; return EXISTS; } + YY_BREAK +case 56: +YY_RULE_SETUP +#line 153 "../src/parser.ll" +{ BUFFER; return VENN; } + YY_BREAK +case 57: +YY_RULE_SETUP +#line 154 "../src/parser.ll" +{ BUFFER; return CONVEX_REPRESENTATION; } + YY_BREAK +case 58: +YY_RULE_SETUP +#line 155 "../src/parser.ll" +{ BUFFER; return CONVEX_COMBINATION; } + YY_BREAK +case 59: +YY_RULE_SETUP +#line 156 "../src/parser.ll" +{ BUFFER; return POSITIVE_COMBINATION; } + YY_BREAK +case 60: +YY_RULE_SETUP +#line 157 "../src/parser.ll" +{ BUFFER; return LINEAR_COMBINATION; } + YY_BREAK +case 61: +YY_RULE_SETUP +#line 158 "../src/parser.ll" +{ BUFFER; return AFFINE_COMBINATION; } + YY_BREAK +case 62: +YY_RULE_SETUP +#line 159 "../src/parser.ll" +{ /*deprecated*/ BUFFER; return RECT_HULL; } + YY_BREAK +case 63: +YY_RULE_SETUP +#line 160 "../src/parser.ll" +{ BUFFER; return SIMPLE_HULL; } + YY_BREAK +case 64: +YY_RULE_SETUP +#line 161 "../src/parser.ll" +{ BUFFER; return CONVEX_HULL; } + YY_BREAK +case 65: +YY_RULE_SETUP +#line 162 "../src/parser.ll" +{ BUFFER; return DECOUPLED_CONVEX_HULL; } + YY_BREAK +case 66: +YY_RULE_SETUP +#line 163 "../src/parser.ll" +{ BUFFER; return AFFINE_HULL; } + YY_BREAK +case 67: +YY_RULE_SETUP +#line 164 "../src/parser.ll" +{ BUFFER; return CONIC_HULL; } + YY_BREAK +case 68: +YY_RULE_SETUP +#line 165 "../src/parser.ll" +{ BUFFER; return LINEAR_HULL; } + YY_BREAK +case 69: +YY_RULE_SETUP +#line 166 "../src/parser.ll" +{ /*deprecated*/ BUFFER; return PAIRWISE_CHECK; } + YY_BREAK +case 70: +YY_RULE_SETUP +#line 167 "../src/parser.ll" +{ /*deprecated*/ BUFFER; return CONVEX_CHECK; } + YY_BREAK +case 71: +YY_RULE_SETUP +#line 168 "../src/parser.ll" +{ /*deprecated*/ BUFFER; return QUICK_HULL; } + YY_BREAK +case 72: +YY_RULE_SETUP +#line 169 "../src/parser.ll" +{ BUFFER; return HULL; } + YY_BREAK +case 73: +YY_RULE_SETUP +#line 170 "../src/parser.ll" +{ BUFFER; return FARKAS; } + YY_BREAK +case 74: +YY_RULE_SETUP +#line 171 "../src/parser.ll" +{ BUFFER; return DECOUPLED_FARKAS; } + YY_BREAK +case 75: +YY_RULE_SETUP +#line 172 "../src/parser.ll" +{ BUFFER; return DECOUPLED_FARKAS; } + YY_BREAK +case 76: +YY_RULE_SETUP +#line 173 "../src/parser.ll" +{ BUFFER; return DECOUPLED_FARKAS; } + YY_BREAK +case 77: +YY_RULE_SETUP +#line 175 "../src/parser.ll" +{ BUFFER; return MINIMIZE; } + YY_BREAK +case 78: +YY_RULE_SETUP +#line 176 "../src/parser.ll" +{ BUFFER; return MAXIMIZE; } + YY_BREAK +case 79: +YY_RULE_SETUP +#line 177 "../src/parser.ll" +{ BUFFER; return MINIMIZE_RANGE; } + YY_BREAK +case 80: +YY_RULE_SETUP +#line 178 "../src/parser.ll" +{ BUFFER; return MAXIMIZE_RANGE; } + YY_BREAK +case 81: +YY_RULE_SETUP +#line 179 "../src/parser.ll" +{ BUFFER; return MINIMIZE_RANGE; } + YY_BREAK +case 82: +YY_RULE_SETUP +#line 180 "../src/parser.ll" +{ BUFFER; return MAXIMIZE_RANGE; } + YY_BREAK +case 83: +YY_RULE_SETUP +#line 181 "../src/parser.ll" +{ BUFFER; return MINIMIZE_DOMAIN; } + YY_BREAK +case 84: +YY_RULE_SETUP +#line 182 "../src/parser.ll" +{ BUFFER; return MAXIMIZE_DOMAIN; } + YY_BREAK +case 85: +YY_RULE_SETUP +#line 183 "../src/parser.ll" +{ BUFFER; return MINIMIZE_DOMAIN; } + YY_BREAK +case 86: +YY_RULE_SETUP +#line 184 "../src/parser.ll" +{ BUFFER; return MAXIMIZE_DOMAIN; } + YY_BREAK +case 87: +YY_RULE_SETUP +#line 185 "../src/parser.ll" +{ BUFFER; return GIST; } + YY_BREAK +case 88: +YY_RULE_SETUP +#line 186 "../src/parser.ll" +{ BUFFER; return GIVEN; } + YY_BREAK +case 89: +YY_RULE_SETUP +#line 187 "../src/parser.ll" +{ BUFFER; return WITHIN; } + YY_BREAK +case 90: +YY_RULE_SETUP +#line 188 "../src/parser.ll" +{ BUFFER; return SUBSET; } + YY_BREAK +case 91: +YY_RULE_SETUP +#line 189 "../src/parser.ll" +{ BUFFER; return CODEGEN; } + YY_BREAK +case 92: +YY_RULE_SETUP +#line 190 "../src/parser.ll" +{ BUFFER; return MAKE_UPPER_BOUND; } + YY_BREAK +case 93: +YY_RULE_SETUP +#line 191 "../src/parser.ll" +{ BUFFER; return MAKE_LOWER_BOUND; } + YY_BREAK +case 94: +YY_RULE_SETUP +#line 192 "../src/parser.ll" +{ BUFFER; return SUPERSETOF;} + YY_BREAK +case 95: +YY_RULE_SETUP +#line 193 "../src/parser.ll" +{ BUFFER; return SUBSETOF;} + YY_BREAK +case 96: +YY_RULE_SETUP +#line 194 "../src/parser.ll" +{ BUFFER; return SYM_SAMPLE;} + YY_BREAK +case 97: +YY_RULE_SETUP +#line 195 "../src/parser.ll" +{ BUFFER; return SAMPLE;} + YY_BREAK +case 98: +YY_RULE_SETUP +#line 196 "../src/parser.ll" +{ BUFFER; return CARRIED_BY;} + YY_BREAK +case 99: +YY_RULE_SETUP +#line 197 "../src/parser.ll" +{ BUFFER; return REACHABLE_FROM; } + YY_BREAK +case 100: +YY_RULE_SETUP +#line 198 "../src/parser.ll" +{ BUFFER; return REACHABLE_OF; } + YY_BREAK +case 101: +YY_RULE_SETUP +#line 199 "../src/parser.ll" +{ BUFFER; return RESTRICT_DOMAIN; } + YY_BREAK +case 102: +YY_RULE_SETUP +#line 200 "../src/parser.ll" +{ BUFFER; return RESTRICT_DOMAIN; } + YY_BREAK +case 103: +YY_RULE_SETUP +#line 201 "../src/parser.ll" +{ BUFFER; return RESTRICT_DOMAIN; } + YY_BREAK +case 104: +YY_RULE_SETUP +#line 202 "../src/parser.ll" +{ BUFFER; return RESTRICT_RANGE; } + YY_BREAK +case 105: +YY_RULE_SETUP +#line 203 "../src/parser.ll" +{ BUFFER; return RESTRICT_RANGE; } + YY_BREAK +case 106: +YY_RULE_SETUP +#line 204 "../src/parser.ll" +{ BUFFER; return ASSERT_UNSAT; } + YY_BREAK +case 107: +YY_RULE_SETUP +#line 205 "../src/parser.ll" +{ BUFFER; return ASSERT_UNSAT; } + YY_BREAK +case 108: +YY_RULE_SETUP +#line 207 "../src/parser.ll" +{ BUFFER; return RESTRICT_RANGE; } + YY_BREAK +case 109: +YY_RULE_SETUP +#line 208 "../src/parser.ll" +{ BUFFER; return AND; } + YY_BREAK +case 110: +YY_RULE_SETUP +#line 209 "../src/parser.ll" +{ BUFFER; return OR; } + YY_BREAK +case 111: +YY_RULE_SETUP +#line 210 "../src/parser.ll" +{ BUFFER; return AND; } + YY_BREAK +case 112: +YY_RULE_SETUP +#line 211 "../src/parser.ll" +{ BUFFER; return OR; } + YY_BREAK +case 113: +YY_RULE_SETUP +#line 212 "../src/parser.ll" +{ BUFFER; return AND; } + YY_BREAK +case 114: +YY_RULE_SETUP +#line 213 "../src/parser.ll" +{ BUFFER; return OR; } + YY_BREAK +case 115: +YY_RULE_SETUP +#line 214 "../src/parser.ll" +{ BUFFER; return AND; } + YY_BREAK +case 116: +YY_RULE_SETUP +#line 215 "../src/parser.ll" +{ BUFFER; return OR; } + YY_BREAK +case 117: +YY_RULE_SETUP +#line 216 "../src/parser.ll" +{ BUFFER; return NOT; } + YY_BREAK +case 118: +YY_RULE_SETUP +#line 217 "../src/parser.ll" +{ BUFFER; return NOT; } + YY_BREAK +case 119: +YY_RULE_SETUP +#line 218 "../src/parser.ll" +{ BUFFER; return NOT; } + YY_BREAK +case 120: +YY_RULE_SETUP +#line 219 "../src/parser.ll" +{ BUFFER; return IS_ASSIGNED; } + YY_BREAK +case 121: +YY_RULE_SETUP +#line 220 "../src/parser.ll" +{ BUFFER; return GOES_TO; } + YY_BREAK +case 122: +YY_RULE_SETUP +#line 221 "../src/parser.ll" +{ BUFFER; return IN; } + YY_BREAK +case 123: +YY_RULE_SETUP +#line 222 "../src/parser.ll" +{ BUFFER; return GOES_TO; } + YY_BREAK +case 124: +YY_RULE_SETUP +#line 223 "../src/parser.ll" +{ BUFFER; yylval.REL_OPERATOR = leq; return REL_OP; } + YY_BREAK +case 125: +YY_RULE_SETUP +#line 224 "../src/parser.ll" +{ BUFFER; yylval.REL_OPERATOR = leq; return REL_OP; } + YY_BREAK +case 126: +YY_RULE_SETUP +#line 225 "../src/parser.ll" +{ BUFFER; yylval.REL_OPERATOR = leq; return REL_OP; } + YY_BREAK +case 127: +YY_RULE_SETUP +#line 226 "../src/parser.ll" +{ BUFFER; yylval.REL_OPERATOR = geq; return REL_OP; } + YY_BREAK +case 128: +YY_RULE_SETUP +#line 227 "../src/parser.ll" +{ BUFFER; yylval.REL_OPERATOR = geq; return REL_OP; } + YY_BREAK +case 129: +YY_RULE_SETUP +#line 228 "../src/parser.ll" +{ BUFFER; yylval.REL_OPERATOR = geq; return REL_OP; } + YY_BREAK +case 130: +YY_RULE_SETUP +#line 229 "../src/parser.ll" +{ BUFFER; yylval.REL_OPERATOR = neq; return REL_OP; } + YY_BREAK +case 131: +YY_RULE_SETUP +#line 230 "../src/parser.ll" +{ BUFFER; yylval.REL_OPERATOR = neq; return REL_OP; } + YY_BREAK +case 132: +YY_RULE_SETUP +#line 231 "../src/parser.ll" +{ BUFFER; yylval.REL_OPERATOR = lt; return REL_OP; } + YY_BREAK +case 133: +YY_RULE_SETUP +#line 232 "../src/parser.ll" +{ BUFFER; yylval.REL_OPERATOR = gt; return REL_OP; } + YY_BREAK +case 134: +YY_RULE_SETUP +#line 233 "../src/parser.ll" +{ BUFFER; yylval.REL_OPERATOR = eq; return REL_OP; } + YY_BREAK +case 135: +YY_RULE_SETUP +#line 234 "../src/parser.ll" +{ BUFFER; yylval.REL_OPERATOR = eq; return REL_OP; } + YY_BREAK +case 136: +YY_RULE_SETUP +#line 236 "../src/parser.ll" +{ + BUFFER; + yylval.VAR_NAME = new char[yyleng+1]; + strcpy(yylval.VAR_NAME,yytext); + return VAR; +} + YY_BREAK +case 137: +YY_RULE_SETUP +#line 242 "../src/parser.ll" +{ + BUFFER; + yylval.VAR_NAME = new char[yyleng+1]; + strcpy(yylval.VAR_NAME,yytext); + yylval.VAR_NAME[yyleng-3] = 'i'; // lowercase + yylval.VAR_NAME[yyleng-2] = 'n'; + return VAR; +} + YY_BREAK +case 138: +YY_RULE_SETUP +#line 250 "../src/parser.ll" +{ + BUFFER; + yylval.VAR_NAME = new char[yyleng+1]; + strcpy(yylval.VAR_NAME,yytext); + yylval.VAR_NAME[yyleng-4] = 'i'; // Change to "in" + yylval.VAR_NAME[yyleng-3] = 'n'; // Be afraid + yylval.VAR_NAME[yyleng-2] = ')'; + yylval.VAR_NAME[yyleng-1] = '\0'; + return VAR; +} + YY_BREAK +case 139: +YY_RULE_SETUP +#line 260 "../src/parser.ll" +{ + BUFFER; + yylval.VAR_NAME = new char[yyleng+1]; + strcpy(yylval.VAR_NAME,yytext); + yylval.VAR_NAME[yyleng-4] = 'o'; // lowercase + yylval.VAR_NAME[yyleng-3] = 'u'; + yylval.VAR_NAME[yyleng-2] = 't'; + return VAR; +} + YY_BREAK +case 140: +YY_RULE_SETUP +#line 269 "../src/parser.ll" +{ + BUFFER; + yylval.VAR_NAME = new char[yyleng+1]; + strcpy(yylval.VAR_NAME,yytext); + return VAR; + } + YY_BREAK +case 141: +YY_RULE_SETUP +#line 275 "../src/parser.ll" +{ + BUFFER; + yylval.VAR_NAME = new char[yyleng+1]; + strcpy(yylval.VAR_NAME,yytext); + yylval.VAR_NAME[yyleng-3] = 'i'; // lowercase + yylval.VAR_NAME[yyleng-2] = 'n'; + return VAR; + } + YY_BREAK +case 142: +YY_RULE_SETUP +#line 283 "../src/parser.ll" +{ + BUFFER; + yylval.VAR_NAME = new char[yyleng+1]; + strcpy(yylval.VAR_NAME,yytext); + yylval.VAR_NAME[yyleng-4] = 'i'; // Change to "in" + yylval.VAR_NAME[yyleng-3] = 'n'; // Be afraid + yylval.VAR_NAME[yyleng-2] = ')'; + yylval.VAR_NAME[yyleng-1] = '\0'; + return VAR; + } + YY_BREAK +case 143: +YY_RULE_SETUP +#line 293 "../src/parser.ll" +{ + BUFFER; + yylval.VAR_NAME = new char[yyleng+1]; + strcpy(yylval.VAR_NAME,yytext); + yylval.VAR_NAME[yyleng-4] = 'o'; // lowercase + yylval.VAR_NAME[yyleng-3] = 'u'; + yylval.VAR_NAME[yyleng-2] = 't'; + return VAR; + } + YY_BREAK +case 144: +YY_RULE_SETUP +#line 303 "../src/parser.ll" +{ BUFFER; + if (need_coef) { + sscanf(yytext, coef_fmt, &yylval.COEF_VALUE); + return COEF; + } + else { + yylval.INT_VALUE = atoi(yytext); + return INT; + } +} + YY_BREAK +case 145: +/* rule 145 can match eol */ +YY_RULE_SETUP +#line 314 "../src/parser.ll" +{ BUFFER; + yytext[yyleng-1]='\0'; + yylval.STRING_VALUE = new std::string(yytext+1); + return STRING; +} + YY_BREAK +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(LATEX): +case YY_STATE_EOF(INCLUDE): +case YY_STATE_EOF(COMMENT): +#line 321 "../src/parser.ll" +{ + mylexer.yypop_buffer_state(); + if (!YY_CURRENT_BUFFER) { + flushScanBuffer(); + return YY_NULL; + } +} + YY_BREAK +case 146: +YY_RULE_SETUP +#line 329 "../src/parser.ll" +{ BUFFER; return yytext[0]; } + YY_BREAK +case 147: +YY_RULE_SETUP +#line 332 "../src/parser.ll" +ECHO; + YY_BREAK +#line 3039 "lex.yy.cc" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_c_buf_p); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of yylex */ + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ) +{ + yyin = arg_yyin; + yyout = arg_yyout; + yy_c_buf_p = 0; + yy_init = 0; + yy_start = 0; + yy_flex_debug = 0; + yylineno = 1; // this will only get updated if %option yylineno + + yy_did_buffer_switch_on_eof = 0; + + yy_looking_for_trail_begin = 0; + yy_more_flag = 0; + yy_more_len = 0; + yy_more_offset = yy_prev_more_offset = 0; + + yy_start_stack_ptr = yy_start_stack_depth = 0; + yy_start_stack = NULL; + + yy_buffer_stack = 0; + yy_buffer_stack_top = 0; + yy_buffer_stack_max = 0; + + yy_state_buf = 0; + +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::~yyFlexLexer() +{ + delete [] yy_state_buf; + yyfree(yy_start_stack ); + yy_delete_buffer( YY_CURRENT_BUFFER ); + yyfree(yy_buffer_stack ); +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) +{ + if ( new_in ) + { + yy_delete_buffer( YY_CURRENT_BUFFER ); + yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); + } + + if ( new_out ) + yyout = new_out; +} + +#ifdef YY_INTERACTIVE +int yyFlexLexer::LexerInput( char* buf, int /* max_size */ ) +#else +int yyFlexLexer::LexerInput( char* buf, int max_size ) +#endif +{ + if ( yyin->eof() || yyin->fail() ) + return 0; + +#ifdef YY_INTERACTIVE + yyin->get( buf[0] ); + + if ( yyin->eof() ) + return 0; + + if ( yyin->bad() ) + return -1; + + return 1; + +#else + (void) yyin->read( buf, max_size ); + + if ( yyin->bad() ) + return -1; + else + return yyin->gcount(); +#endif +} + +void yyFlexLexer::LexerOutput( const char* buf, int size ) +{ + (void) yyout->write( buf, size ); +} + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +int yyFlexLexer::yy_get_next_buffer() +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), (size_t) num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + yy_state_type yyFlexLexer::yy_get_previous_state() +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 2067 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) +{ + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 2067 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 2066); + + return yy_is_jam ? 0 : yy_current_state; +} + + void yyFlexLexer::yyunput( int c, register char* yy_bp) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + if ( c == '\n' ){ + --yylineno; + } + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + + int yyFlexLexer::yyinput() +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + int offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return EOF; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + if ( c == '\n' ) + + yylineno++; +; + + return c; +} + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyFlexLexer::yyrestart( std::istream* input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + + void yyFlexLexer::yy_load_buffer_state() +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree((void *) b->yy_ch_buf ); + + yyfree((void *) b ); +} + +extern "C" int isatty (int ); + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ) + +{ + int oerrno = errno; + + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yyFlexLexer::yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +void yyFlexLexer::yyensure_buffer_stack(void) +{ + int num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + + void yyFlexLexer::yy_push_state( int new_state ) +{ + if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) ) + { + yy_size_t new_size; + + (yy_start_stack_depth) += YY_START_STACK_INCR; + new_size = (yy_start_stack_depth) * sizeof( int ); + + if ( ! (yy_start_stack) ) + (yy_start_stack) = (int *) yyalloc(new_size ); + + else + (yy_start_stack) = (int *) yyrealloc((void *) (yy_start_stack),new_size ); + + if ( ! (yy_start_stack) ) + YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); + } + + (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START; + + BEGIN(new_state); +} + + void yyFlexLexer::yy_pop_state() +{ + if ( --(yy_start_stack_ptr) < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); +} + + int yyFlexLexer::yy_top_state() +{ + return (yy_start_stack)[(yy_start_stack_ptr) - 1]; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +void yyFlexLexer::LexerError( yyconst char msg[] ) +{ + std::cerr << msg << std::endl; + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *yyrealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void yyfree (void * ptr ) +{ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 332 "../src/parser.ll" + + + +void flushScanBuffer() { + if (scanBuf.size() == 0) + return; + if (!is_interactive) { + size_t prev_pos = 0; + if (scanBuf[0] == '\n') + prev_pos = 1; + for (size_t pos = prev_pos; pos <= scanBuf.size(); pos++) { + if (pos == scanBuf.size() || scanBuf[pos] == '\n') { + std::cout << PROMPT_STRING << " " << scanBuf.substr(prev_pos, pos-prev_pos) << std::endl; + prev_pos = pos+1; + } + } + } + + scanBuf.clear(); +} + diff --git a/omega/omega_calc/obj/tile.script b/omega/omega_calc/obj/tile.script new file mode 100644 index 0000000..54980bb --- /dev/null +++ b/omega/omega_calc/obj/tile.script @@ -0,0 +1,5 @@ +sym = n; +s1:={[In_1,In_2,In_3,In_4] : exists ( t2,t4,t6,t8,t2',t4',t6',t8' : ( exists ( alpha,beta : t2 = 16beta && t2' = 16alpha && t4' = t4 && t6' = 1+t6 && t8' = 1+t8 && t2' = t2+In_1 && t4' = t4+In_2 && t6' = t6+In_3 && t8' = t8+In_4 && 0, t8-15 <= t2 <= t8 <= t2'+14 && 0 <= t2' <= t8+1, n-1 && 0 <= t6 <= n-2 && 0 <= t4 < n && t2 < n) )) }; +s2:={[t8]: 0 < t8 < 8}; + +gist(s1,s2); diff --git a/omega/omega_calc/src/AST.cc b/omega/omega_calc/src/AST.cc new file mode 100644 index 0000000..1f885a6 --- /dev/null +++ b/omega/omega_calc/src/AST.cc @@ -0,0 +1,467 @@ +/***************************************************************************** + Copyright (C) 1994-2000 the Omega Project Team + Copyright (C) 2009-2011 Chun Chen + All Rights Reserved. + + Purpose: + build relation from parsed input. + + Notes: + + History: +*****************************************************************************/ + +#include <omega_calc/AST.h> +#include <string.h> + +using namespace omega; + +Global_Declaration_Site *globalDecls; +Declaration_Site *relationDecl = NULL; +tupleDescriptor *currentTupleDescriptor; +std::map<omega::Const_String, Variable_Ref *> functionOfInput; +std::map<omega::Const_String, Variable_Ref *> functionOfOutput; + +AST_constraints::AST_constraints(std::set<Exp *> *f, Rel_Op r, AST_constraints *o) { + others = o; + rel_op = r; + first = f; +} + +AST_constraints::AST_constraints(std::set<Exp *> *f, Rel_Op r, std::set<Exp *> *s) { + others = new AST_constraints(s); + rel_op = r; + first = f; +} + +AST_constraints::AST_constraints(std::set<Exp *> *f){ + others = 0; + first = f; +} + +AST_constraints::~AST_constraints() { + for (std::set<Exp *>::iterator i = first->begin(); i != first->end(); i++) + delete *i; + delete first; + delete others; +} + +void AST_constraints::print() { + for (std::set<Exp *>::iterator i = first->begin(); ;) { + printf(coef_fmt, (*i)->constantTerm); + for (std::map<Variable_Ref *, omega::coef_t>::iterator j = (*i)->coefs.begin(); j != (*i)->coefs.end(); j++) + printf("+"coef_fmt"%s", (*j).second, static_cast<const char *>((*j).first->name)); + i++; + if (i != first->end()) + printf(", "); + else + break; + } +} + + +Exp::Exp(coef_t c) : coefs() { + constantTerm = c; +} + +Exp::Exp(Variable_Ref *v) : coefs() { + assert(v != 0); + constantTerm = 0; + coefs[v] = 1; +} + +Exp *negate (Exp *x) { + x->constantTerm = -x->constantTerm; + for (std::map<Variable_Ref *, omega::coef_t>::iterator i = x->coefs.begin(); i != x->coefs.end(); i++) + (*i).second = -(*i).second; + return x; +} + +Exp *add (Exp *x, Exp *y) { + x->constantTerm += y->constantTerm; + for (std::map<Variable_Ref *, omega::coef_t>::iterator i = y->coefs.begin(); i != y->coefs.end(); i++) + x->coefs[(*i).first] += (*i).second; + delete y; + return x; +} + +Exp *subtract (Exp *x, Exp *y) { + x->constantTerm -= y->constantTerm; + for (std::map<Variable_Ref *, omega::coef_t>::iterator i = y->coefs.begin(); i != y->coefs.end(); i++) + x->coefs[(*i).first] -= (*i).second; + delete y; + return x; +} + +Exp *multiply (coef_t c, Exp *x) { + x->constantTerm *= c; + for (std::map<Variable_Ref *, omega::coef_t>::iterator i = x->coefs.begin(); i != x->coefs.end(); i++) + (*i).second *= c; + return x; +} + +Exp *multiply (Exp *x, Exp *y) { + bool found_nonzero = false; + for (std::map<Variable_Ref *, omega::coef_t>::iterator i = x->coefs.begin(); i != x->coefs.end(); i++) + if ((*i).second != 0) + found_nonzero = true; + if (!found_nonzero) { + coef_t c = x->constantTerm; + delete x; + return multiply(c,y); + } + + found_nonzero = false; + for (std::map<Variable_Ref *, omega::coef_t>::iterator i = y->coefs.begin(); i != y->coefs.end(); i++) + if ((*i).second != 0) + found_nonzero = true; + if (!found_nonzero) { + coef_t c = y->constantTerm; + delete y; + return multiply(c,x); + } + + delete x; + delete y; + throw std::runtime_error("invalid exp multiply"); +} + + + +Declaration_Site *current_Declaration_Site = 0; + +Declaration_Site::Declaration_Site() { + previous = current_Declaration_Site; + current_Declaration_Site = this; +} + +Declaration_Site::Declaration_Site(std::set<char *> *v) { + previous = current_Declaration_Site; + current_Declaration_Site = this; + for (std::set<char *>::iterator i = v->begin(); i != v->end(); i++) + declarations.insert(new Variable_Ref(*i)); +} + +Declaration_Site::~Declaration_Site() { + for (std::set<Variable_Ref *>::iterator i = declarations.begin(); i != declarations.end(); i++) + delete *i; +} + +Variable_Ref::Variable_Ref(char *s, int _arity, Argument_Tuple _of) { + name = s; + arity = _arity; + of = _of; + anonymous = !strncmp("In_",s,3) || !strncmp("Out_",s,4); + char *t = s; + while (*t != '\0') t++; + t--; + while (*t == '\'') t--; + t++; + *t = '\0'; + stripped_name = s; + g = 0; +} + +Variable_Ref::Variable_Ref(char *s) { + name = s; + arity = 0; + anonymous = !strncmp("In_",s,3) || !strncmp("Out_",s,4); + char *t = s; + while (*t != '\0') t++; + t--; + while (*t == '\'') t--; + t++; + *t = '\0'; + stripped_name = s; + g = 0; +} + +Variable_Ref::Variable_Ref() { + name = "#anonymous"; + arity = 0; + anonymous = 1; + stripped_name = name; + g = 0; +} + +Variable_Ref::~Variable_Ref() { + assert(g == 0); +} + +Variable_Ref *lookupScalar(char *s) { + Declaration_Site *ds; + for(ds = current_Declaration_Site; ds; ds = ds->previous) + for (std::set<Variable_Ref *>::iterator i = ds->declarations.begin(); i != ds->declarations.end(); i++) + if ((*i)->name == static_cast<Const_String>(s)) + return (*i); + return NULL; +} + +Declaration_Site *defined(char *s) { + Declaration_Site *ds; + for(ds = current_Declaration_Site; ds; ds = ds->previous) + for (std::set<Variable_Ref *>::iterator i = ds->declarations.begin(); i != ds->declarations.end(); i++) + if ((*i)->name == static_cast<Const_String>(s)) + return ds; + return NULL; +} + + +void AST_Or::install(Formula *F) { + if (F->node_type() != Op_Or) + F = F->add_or(); + left->install(F); + right->install(F); +} + +void AST_And::install(Formula *F) { + if (F->node_type() != Op_And) F = F->add_and(); + left->install(F); + right->install(F); +} + +void AST_Not::install(Formula *F) { + child->install(F->add_not()); +} + +void AST_exists::install(Formula *F) { + F_Exists *G = F->add_exists(); + for (std::set<Variable_Ref *>::iterator i = declaredVariables->declarations.begin(); i != declaredVariables->declarations.end(); i++) + (*i)->vid = G->declare((*i)->stripped_name); + child->install(G); +} + +void AST_forall::install(Formula *F) { + F_Forall *G = F->add_forall(); + for (std::set<Variable_Ref *>::iterator i = declaredVariables->declarations.begin(); i != declaredVariables->declarations.end(); i++) + (*i)->vid = G->declare((*i)->stripped_name); + child->install(G); +} + +void AST_constraints::install(Formula *F) { + if (!others) return; + F_And *f = F->and_with(); + + for (std::set<Exp *>::iterator i = first->begin(); i != first->end(); i++) + for (std::set<Exp *>::iterator j = others->first->begin(); j != others->first->end(); j++) + switch (rel_op) { + case(lt) : install_gt(f, *j, *i); break; + case(gt) : install_gt(f, *i, *j); break; + case(leq) : install_geq(f, *j, *i); break; + case(geq) : install_geq(f, *i, *j); break; + case(eq) : install_eq(f, *i, *j); break; + case(neq) : install_neq(f, *i, *j); break; + default : assert(0); + } + others->install(f); +} + + +void install_neq(F_And *F, Exp *e1, Exp *e2) { + F_Or *or_ = F->add_or(); + F_And *and1 = or_->add_and(); + F_And *and2 = or_->add_and(); + install_gt(and1,e1,e2); + install_gt(and2,e2,e1); +}; + +void install_stride(F_And *F, strideConstraint *s) { + Stride_Handle c = F->add_stride(s->step); + c.update_const(s->e->constantTerm); + for (std::map<Variable_Ref *, omega::coef_t>::iterator i = s->e->coefs.begin(); i != s->e->coefs.end(); i++) + c.update_coef((*i).first->id(F->relation()), (*i).second); + c.finalize(); +} + +void install_eq(F_And *F, Exp *e1, Exp *e2) { + EQ_Handle c = F->add_EQ(); + c.update_const(e1->constantTerm); + if (e2) c.update_const(-e2->constantTerm); + for (std::map<Variable_Ref *, omega::coef_t>::iterator i = e1->coefs.begin(); i != e1->coefs.end(); i++) + c.update_coef((*i).first->id(F->relation()), (*i).second); + if (e2) + for (std::map<Variable_Ref *, omega::coef_t>::iterator i = e2->coefs.begin(); i != e2->coefs.end(); i++) + c.update_coef((*i).first->id(F->relation()), -(*i).second); + c.finalize(); +} + +void install_geq(F_And *F, Exp *e1, Exp *e2) { + GEQ_Handle c = F->add_GEQ(); + c.update_const(e1->constantTerm); + if (e2) c.update_const(-e2->constantTerm); + for (std::map<Variable_Ref *, omega::coef_t>::iterator i = e1->coefs.begin(); i != e1->coefs.end(); i++) + c.update_coef((*i).first->id(F->relation()), (*i).second); + if (e2) + for (std::map<Variable_Ref *, omega::coef_t>::iterator i = e2->coefs.begin(); i != e2->coefs.end(); i++) + c.update_coef((*i).first->id(F->relation()), -(*i).second); + c.finalize(); +} + +void install_gt(F_And *F, Exp *e1, Exp *e2) { + GEQ_Handle c = F->add_GEQ(); + c.update_const(-1); + c.update_const(e1->constantTerm); + if (e2) c.update_const(-e2->constantTerm); + for (std::map<Variable_Ref *, omega::coef_t>::iterator i = e1->coefs.begin(); i != e1->coefs.end(); i++) + c.update_coef((*i).first->id(F->relation()), (*i).second); + if (e2) + for (std::map<Variable_Ref *, omega::coef_t>::iterator i = e2->coefs.begin(); i != e2->coefs.end(); i++) + c.update_coef((*i).first->id(F->relation()), -(*i).second); + c.finalize(); +} + + +Global_Declaration_Site::~Global_Declaration_Site() { +/* // Take care of global variables - since we do that kludge */ +/* // of declaring globals twice if arity > 0, we must take care */ +/* // not to just delete each global once per declaration. */ + +/* // Actually, we can't free these, since Relations containing references to */ +/* // this may get freed later */ +/* foreach(v,Variable_Ref*,this->declarations,v->g=0); */ +/* //Set<Free_Var_Decl *> globals; */ +/* //foreach(v,Variable_Ref*,this->declarations,(globals.insert(v->g),v->g=0)); */ +/* //foreach(g,Free_Var_Decl*,globals,delete g); */ + + // Only delete global variables here. --chun 5/28/2008 + for (std::set<Variable_Ref *>::iterator i= declarations.begin(); i != declarations.end(); i++) { + if ((*i)->g != 0) { + if ((*i)->arity != 0) { // functional symbols + // only delete once from a pair of "(in)" and "(out)" variables + const char *name = static_cast<const char *>((*i)->name); + const char *s = "(in)"; + bool match = true; + for (size_t p = strlen(name)-4, q = 0; p < strlen(name); p++, q++) + if (s[q] != name[p]) { + match = false; + break; + } + if (match) + delete (*i)->g; + } + else // not functions + delete (*i)->g; + + (*i)->g = 0; + } + } +} + +Variable_Ref * Global_Declaration_Site::extend(char *s) { + Variable_Ref *r = new Variable_Ref(s); + r->g = new Free_Var_Decl(r->stripped_name); + declarations.insert(r); + return r; +} + +void Global_Declaration_Site::extend_both_tuples(char *s, int arity) { + if (arity == 0) + extend(s); + else { + assert(arity > 0); + + char s1[strlen(s)+5], s2[strlen(s)+6]; + strcpy(s1,s); strcat(s1,"(in)"); + strcpy(s2,s); strcat(s2,"(out)"); + Const_String name = s; + + Variable_Ref *r1 = new Variable_Ref(s1, arity, Input_Tuple); + Variable_Ref *r2 = new Variable_Ref(s2, arity, Output_Tuple); + r1->g = r2->g = new Free_Var_Decl(s,arity); + + functionOfInput[name] = r1; + functionOfOutput[name] = r2; + + declarations.insert(r1); + declarations.insert(r2); + } +} + + +void resetGlobals() { + for (std::set<Variable_Ref *>::iterator i = globalDecls->declarations.begin(); i != globalDecls->declarations.end(); i++) + (*i)->vid = 0; +} + + +Variable_Ref *Declaration_Site::extend(char *s) { + Variable_Ref *r = new Variable_Ref(s); + declarations.insert(r); + return r; +} + +Variable_Ref *Declaration_Site::extend(char *s, Argument_Tuple of, int pos) { + Variable_Ref *r = new Variable_Ref(s); + declarations.insert(r); + r->of = of; + r->pos = pos; + return r; +} + +Variable_Ref * Declaration_Site::extend() { + Variable_Ref *r = new Variable_Ref(); + declarations.insert(r); + return r; +} + +void tupleDescriptor::extend(char *s) { + Variable_Ref *r = relationDecl->extend(s); + size++; + vars.push_back(r); + assert(size == vars.size()); +} + +void tupleDescriptor::extend(char *s, Argument_Tuple of, int pos) { + Variable_Ref *r = relationDecl->extend(s, of, pos); + size++; + vars.push_back(r); + assert(size == vars.size()); +} + +void tupleDescriptor::extend(Exp *e) { + Variable_Ref *r = relationDecl->extend(); + size++; + vars.push_back(r); + assert(size == vars.size()); + Exp *eq = subtract(e, new Exp(r)); + eq_constraints.insert(eq); +} + +void tupleDescriptor::extend(char *s, Exp *e) { + Variable_Ref *r = relationDecl->extend(s); + size++; + vars.push_back(r); + assert(size == vars.size()); + Exp *eq = subtract(e, new Exp(r)); + eq_constraints.insert(eq); +} + +void tupleDescriptor::extend() { + Variable_Ref *r = relationDecl->extend(); + size++; + vars.push_back(r); + assert(size == vars.size()); +} +void tupleDescriptor::extend(Exp *lb,Exp *ub) { + Variable_Ref *r = relationDecl->extend(); + size++; + vars.push_back(r); + assert(size == vars.size()); + Exp *lb_exp = subtract(new Exp(r), lb); + geq_constraints.insert(lb_exp); + Exp *ub_exp = subtract(ub, new Exp(r)); + geq_constraints.insert(ub_exp); +} +void tupleDescriptor::extend(Exp *lb,Exp *ub, coef_t stride) { + Variable_Ref *r = relationDecl->extend(); + size++; + vars.push_back(r); + Exp *lb_exp = subtract(new Exp(r), new Exp(*lb)); + geq_constraints.insert(lb_exp); + Exp *ub_exp = subtract(ub, new Exp(r)); + geq_constraints.insert(ub_exp); + strideConstraint *s = new strideConstraint; + s->e = subtract(lb, new Exp(r)); + s->step = stride; + stride_constraints.insert(s); +} diff --git a/omega/omega_calc/src/myflex.cc b/omega/omega_calc/src/myflex.cc new file mode 100755 index 0000000..89a2544 --- /dev/null +++ b/omega/omega_calc/src/myflex.cc @@ -0,0 +1,421 @@ +/***************************************************************************** + Copyright (C) 2011 Chun Chen + All Rights Reserved. + + Purpose: + support command line editing for calculator. + + Notes: + Since terminfo database is not queried for those nagging escape sequences, + current supported terminials are limited to xterm, linux, cygwin. + + History: + 02/06/11 created by Chun Chen +*****************************************************************************/ + +#include <omega_calc/myflex.h> +#include <basic/util.h> +#include <string.h> +#include <stdlib.h> + +#if defined __USE_POSIX +#include <unistd.h> +#include <termios.h> +#include <sys/ioctl.h> +#elif defined __WIN32 +#else +#endif + +#define HISTORY_SIZE 100 + +namespace { +enum {MY_KEY_EOF=0, MY_KEY_LEFT, MY_KEY_RIGHT, MY_KEY_UP, MY_KEY_DOWN, + MY_KEY_DEL, MY_KEY_HOME, MY_KEY_END, MY_KEY_PGUP, MY_KEY_PGDOWN, + MY_KEY_NUMPAD_HOME, MY_KEY_NUMPAD_END}; +} + +extern bool is_interactive; +extern const char * PROMPT_STRING; + +void move_cursor(int col, int n, int num_cols, const std::vector<std::string> &key_seqs) { + if (n == 0) + return; + + int new_col = omega::int_mod(col + n, num_cols); + if (new_col == 0) + new_col = num_cols; + + for (int i = 0; i < new_col-col; i++) + std::cout.write(key_seqs[MY_KEY_RIGHT].c_str(), key_seqs[MY_KEY_RIGHT].length()); + for (int i = 0; i < col-new_col; i++) + std::cout.write(key_seqs[MY_KEY_LEFT].c_str(), key_seqs[MY_KEY_LEFT].length()); + + if (n < 0) + for (int i = 0; i < omega::abs(n) / num_cols + (new_col>col)?1:0; i++) + std::cout.write(key_seqs[MY_KEY_UP].c_str(), key_seqs[MY_KEY_UP].length()); + else + for (int i = 0; i < omega::abs(n) / num_cols + (new_col<col)?1:0; i++) + std::cout.write(key_seqs[MY_KEY_DOWN].c_str(), key_seqs[MY_KEY_DOWN].length()); +} + + + +myFlexLexer::myFlexLexer(std::istream *arg_yyin, std::ostream *arg_yyout): + yyFlexLexer(arg_yyin, arg_yyout), history(HISTORY_SIZE), key_seqs(12) { + cur_pos = 0; + first_history_pos = 0; + last_history_pos = -1; + + if (strcmp(getenv("TERM"), "xterm") == 0 || + strcmp(getenv("TERM"), "xterm-color") == 0) { + key_seqs[MY_KEY_EOF] = "\x04"; + key_seqs[MY_KEY_LEFT] = "\x1B\x5B\x44"; + key_seqs[MY_KEY_RIGHT] = "\x1B\x5B\x43"; + key_seqs[MY_KEY_UP] = "\x1B\x5B\x41"; + key_seqs[MY_KEY_DOWN] = "\x1B\x5B\x42"; + key_seqs[MY_KEY_DEL] = "\x1B\x5B\x33\x7E"; + key_seqs[MY_KEY_HOME] = "\x1B\x4F\x48"; + key_seqs[MY_KEY_END] = "\x1B\x4F\x46"; + key_seqs[MY_KEY_PGUP] = "\x1B\x5B\x35\x7E"; + key_seqs[MY_KEY_PGDOWN] = "\x1B\x5B\x36\x7E"; + key_seqs[MY_KEY_NUMPAD_HOME] = "\x1B\x5B\x31\x7E"; + key_seqs[MY_KEY_NUMPAD_END] = "\x1B\x5B\x34\x7E"; + } + else if (strcmp(getenv("TERM"), "linux") == 0 || + strcmp(getenv("TERM"), "cygwin") == 0) { + key_seqs[MY_KEY_EOF] = "\x04"; + key_seqs[MY_KEY_LEFT] = "\x1B\x5B\x44"; + key_seqs[MY_KEY_RIGHT] = "\x1B\x5B\x43"; + key_seqs[MY_KEY_UP] = "\x1B\x5B\x41"; + key_seqs[MY_KEY_DOWN] = "\x1B\x5B\x42"; + key_seqs[MY_KEY_DEL] = "\x1B\x5B\x33\x7E"; + key_seqs[MY_KEY_HOME] = "\x1B\x5B\x31\x7E"; + key_seqs[MY_KEY_END] = "\x1B\x5B\x34\x7E"; + key_seqs[MY_KEY_PGUP] = "\x1B\x5B\x35\x7E"; + key_seqs[MY_KEY_PGDOWN] = "\x1B\x5B\x36\x7E"; + key_seqs[MY_KEY_NUMPAD_HOME] = "\x1B\x5B\x31\x7E"; + key_seqs[MY_KEY_NUMPAD_END] = "\x1B\x5B\x34\x7E"; + } + else { + key_seqs[MY_KEY_EOF] = "\x04"; + } +} + +int myFlexLexer::LexerInput(char *buf, int max_size) { + if (!is_interactive) + return yyFlexLexer::LexerInput(buf, max_size); + +#if defined __USE_POSIX + winsize wsz; + ioctl(0, TIOCGWINSZ, &wsz); + int num_cols = wsz.ws_col; + + // unknown screen size, bail out + if (num_cols == 0) + return yyFlexLexer::LexerInput(buf, max_size); + + termios old_settings; + termios new_settings; + char keycodes[255]; + + // set console to no echo, raw input mode + tcgetattr(STDIN_FILENO, &old_settings); + new_settings = old_settings; + new_settings.c_cc[VTIME] = 1; + new_settings.c_cc[VMIN] = 1; + new_settings.c_iflag &= ~(IXOFF); + new_settings.c_lflag &= ~(ECHO|ICANON); + tcsetattr(STDIN_FILENO, TCSANOW, &new_settings); + + int cur_history_pos = (last_history_pos+1)%HISTORY_SIZE; + while (true) { + // feed current line to lex + int len = cur_line.length(); + if (len > 0 && cur_line[len-1] == '\n') { + int n = omega::min(len-cur_pos, max_size); + for (int i = 0; i < n; i++) + buf[i] = cur_line[cur_pos+i]; + cur_pos = cur_pos + n; + if (cur_pos == len) { + // save history + if (len > 1) { + if (last_history_pos == -1) + last_history_pos = 0; + else { + last_history_pos = (last_history_pos+1)%HISTORY_SIZE; + if ((last_history_pos + 1)%HISTORY_SIZE == first_history_pos) + first_history_pos = (first_history_pos+1)%HISTORY_SIZE; + } + history[last_history_pos] = cur_line.substr(0, len-1); + cur_history_pos = (last_history_pos+1)%HISTORY_SIZE; + } + + // clear the working line + cur_pos = 0; + cur_line.clear(); + } + tcsetattr(STDIN_FILENO, TCSANOW, &old_settings); + return n; + } + + int count = read(STDIN_FILENO, keycodes, 255); + + // handle special key my way + int eaten = 0; + while (eaten < count) { + if (key_seqs[MY_KEY_EOF].length() > 0 && + static_cast<size_t>(count - eaten) >= key_seqs[MY_KEY_EOF].length() && + strncmp(&keycodes[eaten], key_seqs[MY_KEY_EOF].c_str(), key_seqs[MY_KEY_EOF].length()) == 0) { + if (cur_line.length() == 0) { + tcsetattr(STDIN_FILENO, TCSANOW, &old_settings); + return 0; + } + + eaten += key_seqs[MY_KEY_EOF].length(); + } + else if (key_seqs[MY_KEY_LEFT].length() > 0 && + static_cast<size_t>(count - eaten) >= key_seqs[MY_KEY_LEFT].length() && + strncmp(&keycodes[eaten], key_seqs[MY_KEY_LEFT].c_str(), key_seqs[MY_KEY_LEFT].length()) == 0) { + if (cur_pos > 0) { + int cur_col = (cur_pos + 1 + strlen(PROMPT_STRING) + 1) % num_cols; + if (cur_col == 0) + cur_col = num_cols; + + cur_pos--; + + move_cursor(cur_col, -1, num_cols, key_seqs); + } + eaten += key_seqs[MY_KEY_LEFT].length(); + } + else if (key_seqs[MY_KEY_RIGHT].length() > 0 && + static_cast<size_t>(count - eaten) >= key_seqs[MY_KEY_RIGHT].length() && + strncmp(&keycodes[eaten], key_seqs[MY_KEY_RIGHT].c_str(), key_seqs[MY_KEY_RIGHT].length()) == 0) { + if (static_cast<size_t>(cur_pos) < cur_line.length()) { + int cur_col = (cur_pos + 1 + strlen(PROMPT_STRING) + 1) % num_cols; + if (cur_col == 0) + cur_col = num_cols; + + cur_pos++; + + move_cursor(cur_col, 1, num_cols, key_seqs); + } + eaten += key_seqs[MY_KEY_RIGHT].length(); + } + else if (key_seqs[MY_KEY_UP].length() > 0 && + static_cast<size_t>(count - eaten) >= key_seqs[MY_KEY_UP].length() && + strncmp(&keycodes[eaten], key_seqs[MY_KEY_UP].c_str(), key_seqs[MY_KEY_UP].length()) == 0) { + if (cur_history_pos >= 0 && cur_history_pos != first_history_pos) { + history[cur_history_pos] = cur_line; + cur_history_pos = omega::int_mod(cur_history_pos-1, HISTORY_SIZE); + + int cur_col = (cur_pos + 1 + strlen(PROMPT_STRING) + 1) % num_cols; + if (cur_col == 0) + cur_col = num_cols; + + move_cursor(cur_col, -cur_pos, num_cols, key_seqs); + + std::cout.write(history[cur_history_pos].c_str(), history[cur_history_pos].length()); + + cur_col = (history[cur_history_pos].length() + strlen(PROMPT_STRING) + 1) % num_cols; + if (cur_col == 0) { + std::cout.put(' '); + std::cout.put('\b'); + } + + if (cur_line.length() > history[cur_history_pos].length()) { + for (size_t i = 0; i < cur_line.length() - history[cur_history_pos].length(); i++) + std::cout.put(' '); + + cur_col = (cur_line.length() + strlen(PROMPT_STRING) + 1) % num_cols; + if (cur_col == 0) + cur_col = num_cols + 1; + else + cur_col++; + + move_cursor(cur_col, -(cur_line.length() - history[cur_history_pos].length()), num_cols, key_seqs); + } + cur_line = history[cur_history_pos]; + cur_pos = cur_line.length(); + } + + eaten += key_seqs[MY_KEY_UP].length(); + } + else if (key_seqs[MY_KEY_DOWN].length() > 0 && + static_cast<size_t>(count - eaten) >= key_seqs[MY_KEY_DOWN].length() && + strncmp(&keycodes[eaten], key_seqs[MY_KEY_DOWN].c_str(), key_seqs[MY_KEY_DOWN].length()) == 0) { + if (cur_history_pos >= 0 && cur_history_pos != (last_history_pos+1)%HISTORY_SIZE) { + history[cur_history_pos] = cur_line; + cur_history_pos = (cur_history_pos+1)%HISTORY_SIZE; + + int cur_col = (cur_pos + 1 + strlen(PROMPT_STRING) + 1) % num_cols; + if (cur_col == 0) + cur_col = num_cols; + + move_cursor(cur_col, -cur_pos, num_cols, key_seqs); + + std::cout.write(history[cur_history_pos].c_str(), history[cur_history_pos].length()); + + cur_col = (history[cur_history_pos].length() + strlen(PROMPT_STRING) + 1) % num_cols; + if (cur_col == 0) { + std::cout.put(' '); + std::cout.put('\b'); + } + + if (cur_line.length() > history[cur_history_pos].length()) { + for (size_t i = 0; i < cur_line.length() - history[cur_history_pos].length(); i++) + std::cout.put(' '); + + cur_col = (cur_line.length() + strlen(PROMPT_STRING) + 1) % num_cols; + if (cur_col == 0) + cur_col = num_cols + 1; + else + cur_col++; + + move_cursor(cur_col, -(cur_line.length() - history[cur_history_pos].length()), num_cols, key_seqs); + } + cur_line = history[cur_history_pos]; + cur_pos = cur_line.length(); + } + + eaten += key_seqs[MY_KEY_DOWN].length(); + } + else if (key_seqs[MY_KEY_DEL].length() > 0 && + static_cast<size_t>(count - eaten) >= key_seqs[MY_KEY_DEL].length() && + strncmp(&keycodes[eaten], key_seqs[MY_KEY_DEL].c_str(), key_seqs[MY_KEY_DEL].length()) == 0) { + if (static_cast<size_t>(cur_pos) < cur_line.length()) { + cur_line.erase(cur_pos, 1); + std::cout.write(&(cur_line.c_str()[cur_pos]), cur_line.length()-cur_pos); + std::cout.put(' '); + + int cur_col = (cur_line.length() + 1 + strlen(PROMPT_STRING) + 1) % num_cols; + if (cur_col == 0) + cur_col = num_cols + 1; + else + cur_col++; + + move_cursor(cur_col, -(cur_line.length()-cur_pos+1), num_cols, key_seqs); + } + + eaten += key_seqs[MY_KEY_DEL].length(); + } + else if (key_seqs[MY_KEY_HOME].length() > 0 && + static_cast<size_t>(count - eaten) >= key_seqs[MY_KEY_HOME].length() && + strncmp(&keycodes[eaten], key_seqs[MY_KEY_HOME].c_str(), key_seqs[MY_KEY_HOME].length()) == 0) { + int cur_col = (cur_pos + 1 + strlen(PROMPT_STRING) + 1) % num_cols; + if (cur_col == 0) + cur_col = num_cols; + + move_cursor(cur_col, -cur_pos, num_cols, key_seqs); + + cur_pos = 0; + eaten += key_seqs[MY_KEY_HOME].length(); + } + else if (key_seqs[MY_KEY_END].length() > 0 && + static_cast<size_t>(count - eaten) >= key_seqs[MY_KEY_END].length() && + strncmp(&keycodes[eaten], key_seqs[MY_KEY_END].c_str(), key_seqs[MY_KEY_END].length()) == 0) { + int cur_col = (cur_pos + 1 + strlen(PROMPT_STRING) + 1) % num_cols; + if (cur_col == 0) + cur_col = num_cols; + + move_cursor(cur_col, cur_line.length()-cur_pos, num_cols, key_seqs); + + cur_pos = cur_line.length(); + eaten += key_seqs[MY_KEY_END].length(); + } + else if (key_seqs[MY_KEY_PGUP].length() > 0 && + static_cast<size_t>(count - eaten) >= key_seqs[MY_KEY_PGUP].length() && + strncmp(&keycodes[eaten], key_seqs[MY_KEY_PGUP].c_str(), key_seqs[MY_KEY_PGUP].length()) == 0) { + eaten += key_seqs[MY_KEY_PGUP].length(); + } + else if (key_seqs[MY_KEY_PGDOWN].length() > 0 && + static_cast<size_t>(count - eaten) >= key_seqs[MY_KEY_PGDOWN].length() && + strncmp(&keycodes[eaten], key_seqs[MY_KEY_PGDOWN].c_str(), key_seqs[MY_KEY_PGDOWN].length()) == 0) { + eaten += key_seqs[MY_KEY_PGDOWN].length(); + } + else if (key_seqs[MY_KEY_NUMPAD_HOME].length() > 0 && + static_cast<size_t>(count - eaten) >= key_seqs[MY_KEY_NUMPAD_HOME].length() && + strncmp(&keycodes[eaten], key_seqs[MY_KEY_NUMPAD_HOME].c_str(), key_seqs[MY_KEY_NUMPAD_HOME].length()) == 0) { + eaten += key_seqs[MY_KEY_NUMPAD_HOME].length(); + } + else if (key_seqs[MY_KEY_NUMPAD_END].length() > 0 && + static_cast<size_t>(count - eaten) >= key_seqs[MY_KEY_NUMPAD_END].length() && + strncmp(&keycodes[eaten], key_seqs[MY_KEY_NUMPAD_END].c_str(), key_seqs[MY_KEY_NUMPAD_END].length()) == 0) { + eaten += key_seqs[MY_KEY_NUMPAD_END].length(); + } + else if (keycodes[eaten] == '\x1B' && (count - eaten == 1 || keycodes[eaten+1] == '\x1B')) { // single ESC key + eaten++; + } + else if (keycodes[eaten] == '\x1B') { // unknown escape sequences + while (eaten+1 < count && keycodes[eaten+1] != '\x1B') + eaten++; + + keycodes[eaten] = '~'; + } + else if (keycodes[eaten] == '\x7F') { // backspace key + if (cur_pos > 0) { + int cur_col = (cur_pos + 1 + strlen(PROMPT_STRING) + 1) % num_cols; + if (cur_col == 0) + cur_col = num_cols; + + cur_pos--; + cur_line.erase(cur_pos, 1); + + move_cursor(cur_col, -1, num_cols, key_seqs); + + std::cout.write(&(cur_line.c_str()[cur_pos]), cur_line.length()-cur_pos); + std::cout.put(' '); + + cur_col = (cur_line.length() + 1 + strlen(PROMPT_STRING) + 1) % num_cols; + if (cur_col == 0) + cur_col = num_cols + 1; + else + cur_col++; + + move_cursor(cur_col, -(cur_line.length()-cur_pos+1), num_cols, key_seqs); + } + + eaten++; + } + else if (keycodes[eaten] == '\n'){ // return key + int cur_col = (cur_pos + 1 + strlen(PROMPT_STRING) + 1) % num_cols; + if (cur_col == 0) + cur_col = num_cols; + + move_cursor(cur_col, cur_line.length()-cur_pos, num_cols, key_seqs); + + std::cout.put(keycodes[eaten]); + cur_line.append(1, '\n'); + cur_pos = 0; + break; + } + else { // all other key + std::cout.put(keycodes[eaten]); + std::cout.write(&(cur_line.c_str()[cur_pos]), cur_line.length()-cur_pos); + + cur_line.insert(cur_pos, &keycodes[eaten], 1); + cur_pos++; + + int cur_col = (cur_line.length() + strlen(PROMPT_STRING) + 1) % num_cols; + if (cur_col == 0) { + // force cursor to move to the next line when the last printed char is at + // the right boundary of the terminal + std::cout.put(' '); + std::cout.put('\b'); + + cur_col = 1; + } + else + cur_col++; + + move_cursor(cur_col, -(cur_line.length()-cur_pos), num_cols, key_seqs); + + eaten++; + } + + std::cout.flush(); + } + } +#else + return yyFlexLexer::LexerInput(buf, max_size); +#endif +} diff --git a/omega/omega_calc/src/parser.l b/omega/omega_calc/src/parser.l new file mode 100644 index 0000000..ac2b448 --- /dev/null +++ b/omega/omega_calc/src/parser.l @@ -0,0 +1,350 @@ +%{ +#include <stdio.h> +#include <string> +#include <sstream> +#include <iostream> +#include <omega_calc/AST.h> +#include <basic/Dynamic_Array.h> + +using namespace omega; +#include "y.tab.h" + +#define BUFFER scanBuf += yytext +std::string scanBuf; +std::string err_msg; + +extern "C" int yywrap() {return 1;}; + + +#define MAX_INCLUDE_DEPTH 10 +YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; +int include_stack_ptr = 0; +int comment_caller; + +extern bool is_interactive; +extern const char *PROMPT_STRING; +extern bool need_coef; + +// void yyerror(const char *s); +void yyerror(const std::string &s); +void flushScanBuffer(); + +%} + +%s LATEX INCLUDE COMMENT +%option yylineno + +%% + +"<<" { BUFFER; BEGIN(INCLUDE); } +<INCLUDE>[^>\n ]+">>" { + BUFFER; + scanBuf += "\n"; + flushScanBuffer(); + + if (include_stack_ptr >= MAX_INCLUDE_DEPTH) { + fprintf(stderr, "File including nested too deeply, abort"); + exit(1); + } + + char *s = yytext; + while (*s != '>') s++; + *s = '\0'; + FILE *f = fopen(yytext, "r"); + if (!f) { + fprintf(stderr, "Can't open file %s\n", yytext); + } + else { + include_stack[include_stack_ptr++] = YY_CURRENT_BUFFER; + yyin = f; + yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); + } + BEGIN(INITIAL); +} +<INCLUDE>[ \n] { + fprintf(stderr,"Error in include syntax\n"); + fprintf(stderr,"Use <<fname>> to include the file named fname\n"); + BEGIN(INITIAL); + if(is_interactive && include_stack_ptr == 0) + printf("%s ", PROMPT_STRING); +} + +<COMMENT>\n { + BUFFER; + BEGIN(comment_caller); + if(is_interactive && include_stack_ptr == 0) + printf("%s ", PROMPT_STRING); +} + +\n { + BUFFER; + if(is_interactive && include_stack_ptr == 0) + printf("%s ", PROMPT_STRING); +} + +<LATEX>"\\ " { BUFFER; } +[ \t]+ { BUFFER; } +# { BUFFER; comment_caller = YY_START; BEGIN(COMMENT); } +<COMMENT>.* { BUFFER; flushScanBuffer(); } +<LATEX>"\$\$" { BUFFER; BEGIN(INITIAL); } +"\$\$" { BUFFER; BEGIN(LATEX); } +<LATEX>"\\t" { BUFFER; } +<LATEX>"\\!" { BUFFER; } +<LATEX>"\\\\" { BUFFER; } + +"{" { BUFFER; return OPEN_BRACE; } +<LATEX>"\\{" { BUFFER; return OPEN_BRACE; } +"}" { BUFFER; return CLOSE_BRACE; } +<LATEX>"\\}" { BUFFER; return CLOSE_BRACE; } +"approximate" { BUFFER; return APPROX; } +"union" { BUFFER; return UNION; } +<LATEX>"\\cup" { BUFFER; return UNION; } +"intersection" { BUFFER; return INTERSECTION; } +<LATEX>"\\cap" { BUFFER; return INTERSECTION; } +"symbolic" { BUFFER; return SYMBOLIC; } +"sym" { BUFFER; return SYMBOLIC; } +<LATEX>"\\mid" { BUFFER; return VERTICAL_BAR; } +<LATEX>"|" { BUFFER; return VERTICAL_BAR; } +<LATEX>"\\st" { BUFFER; return SUCH_THAT; } +"s.t." { BUFFER; return SUCH_THAT; } +"inverse" { BUFFER; return INVERSE; } +"complement" { BUFFER; return COMPLEMENT; } +<LATEX>"\\circ" { BUFFER; return COMPOSE; } +"compose" { BUFFER; return COMPOSE; } +"difference" { BUFFER; return DIFFERENCE; } +"diffToRel" { BUFFER; return DIFFERENCE_TO_RELATION; } +"project away symbols" { BUFFER; return PROJECT_AWAY_SYMBOLS; } +"project_away_symbols" { BUFFER; return PROJECT_AWAY_SYMBOLS; } +"projectAwaySymbols" { BUFFER; return PROJECT_AWAY_SYMBOLS; } +"project on symbols" { BUFFER; return PROJECT_ON_SYMBOLS; } +"project_on_symbols" { BUFFER; return PROJECT_ON_SYMBOLS; } +"projectOnSymbols" { BUFFER; return PROJECT_ON_SYMBOLS; } +<LATEX>"\\join" { BUFFER; return JOIN; } +"\." { BUFFER; return JOIN; } +"join" { BUFFER; return JOIN; } +"domain" { BUFFER; return DOMAIN; } +"time" { BUFFER; return TIME; } +"timeclosure" { BUFFER; return TIMECLOSURE; } +"range" { BUFFER; return RANGE; } +<LATEX>"\\forall" { BUFFER; return FORALL; } +"forall" { BUFFER; return FORALL; } +<LATEX>"\\exists" { BUFFER; return EXISTS; } +"exists" { BUFFER; return EXISTS; } + +"Venn" { BUFFER; return VENN; } +"ConvexRepresentation" { BUFFER; return CONVEX_REPRESENTATION; } +"ConvexCombination" { BUFFER; return CONVEX_COMBINATION; } +"PositiveCombination" { BUFFER; return POSITIVE_COMBINATION; } +"LinearCombination" { BUFFER; return LINEAR_COMBINATION; } +"AffineCombination" { BUFFER; return AFFINE_COMBINATION; } +"RectHull" { BUFFER; return RECT_HULL; } +"ConvexHull" { BUFFER; return CONVEX_HULL; } +"DecoupledConvexHull" { BUFFER; return DECOUPLED_CONVEX_HULL; } +"AffineHull" { BUFFER; return AFFINE_HULL; } +"ConicHull" { BUFFER; return CONIC_HULL; } +"LinearHull" { BUFFER; return LINEAR_HULL; } +"PairwiseCheck" { /*deprecated*/ BUFFER; return PAIRWISE_CHECK; } +"ConvexCheck" { /*deprecated*/ BUFFER; return CONVEX_CHECK; } +"QuickHull" { /*deprecated*/ BUFFER; return QUICK_HULL; } +"hull" { BUFFER; return HULL; } + +"minimize" { BUFFER; return MINIMIZE; } +"maximize" { BUFFER; return MAXIMIZE; } +"minimize-range" { BUFFER; return MINIMIZE_RANGE; } +"maximize-range" { BUFFER; return MAXIMIZE_RANGE; } +"minimizerange" { BUFFER; return MINIMIZE_RANGE; } +"maximizerange" { BUFFER; return MAXIMIZE_RANGE; } +"minimize-domain" { BUFFER; return MINIMIZE_DOMAIN; } +"maximize-domain" { BUFFER; return MAXIMIZE_DOMAIN; } +"minimizedomain" { BUFFER; return MINIMIZE_DOMAIN; } +"maximizedomain" { BUFFER; return MAXIMIZE_DOMAIN; } +"gist" { BUFFER; return GIST; } +"given" { BUFFER; return GIVEN; } +"within" { BUFFER; return WITHIN; } +"subset" { BUFFER; return SUBSET; } +"codegen" { BUFFER; return CODEGEN; } +"farkas" { BUFFER; return FARKAS; } +"decoupledfarkas" { BUFFER; return DECOUPLED_FARKAS; } +"decoupled-farkas" { BUFFER; return DECOUPLED_FARKAS; } +"decoupled_farkas" { BUFFER; return DECOUPLED_FARKAS; } +"upper_bound" { BUFFER; return MAKE_UPPER_BOUND; } +"lower_bound" { BUFFER; return MAKE_LOWER_BOUND; } +"supersetof" { BUFFER; return SUPERSETOF;} +"subsetof" { BUFFER; return SUBSETOF;} +"sym_example" { BUFFER; return SYM_SAMPLE;} +"example" { BUFFER; return SAMPLE;} +"carried_by" { BUFFER; return CARRIED_BY;} +"reachable" { BUFFER; return REACHABLE_FROM; } +"reachable of" { BUFFER; return REACHABLE_OF; } +"restrict_domain" { BUFFER; return RESTRICT_DOMAIN; } +"restrictDomain" { BUFFER; return RESTRICT_DOMAIN; } +<LATEX>"\\" { yyerror("Can't use \\ for restrict_domain in Tex mode"); } +"\\" { BUFFER; return RESTRICT_DOMAIN; } +"restrict_range" { BUFFER; return RESTRICT_RANGE; } +"restrictRange" { BUFFER; return RESTRICT_RANGE; } +"assertUnsatisfiable" { BUFFER; return ASSERT_UNSAT; } +"assert_unsatisfiable" { BUFFER; return ASSERT_UNSAT; } + +"/" { BUFFER; return RESTRICT_RANGE; } +"&" { BUFFER; return AND; } +"|" { BUFFER; return OR; } +"&&" { BUFFER; return AND; } +"||" { BUFFER; return OR; } +"and" { BUFFER; return AND; } +"or" { BUFFER; return OR; } +<LATEX>"\\land" { BUFFER; return AND; } +<LATEX>"\\lor" { BUFFER; return OR; } +"!" { BUFFER; return NOT; } +"not" { BUFFER; return NOT; } +<LATEX>"\\neg" { BUFFER; return NOT; } +":=" { BUFFER; return IS_ASSIGNED; } +"->" { BUFFER; return GOES_TO; } +"in" { BUFFER; return IN; } +<LATEX>"\\rightarrow" { BUFFER; return GOES_TO; } +"<=" { BUFFER; yylval.REL_OPERATOR = leq; return REL_OP; } +<LATEX>"\\leq" { BUFFER; yylval.REL_OPERATOR = leq; return REL_OP; } +<LATEX>"\\le" { BUFFER; yylval.REL_OPERATOR = leq; return REL_OP; } +">=" { BUFFER; yylval.REL_OPERATOR = geq; return REL_OP; } +<LATEX>"\\geq" { BUFFER; yylval.REL_OPERATOR = geq; return REL_OP; } +<LATEX>"\\ge" { BUFFER; yylval.REL_OPERATOR = geq; return REL_OP; } +"!=" { BUFFER; yylval.REL_OPERATOR = neq; return REL_OP; } +<LATEX>"\\neq" { BUFFER; yylval.REL_OPERATOR = neq; return REL_OP; } +"<" { BUFFER; yylval.REL_OPERATOR = lt; return REL_OP; } +">" { BUFFER; yylval.REL_OPERATOR = gt; return REL_OP; } +"=" { BUFFER; yylval.REL_OPERATOR = eq; return REL_OP; } +"==" { BUFFER; yylval.REL_OPERATOR = eq; return REL_OP; } + +[A-Za-z][A-Za-z0-9_]*[\']* { + BUFFER; + if (yyleng > 19) yyerror("Identifier too long"); + yylval.VAR_NAME = new char[yyleng+1]; + strcpy(yylval.VAR_NAME,yytext); + return VAR; +} +[A-Za-z][A-Za-z0-9_]*"(in)" { + BUFFER; + if (yyleng > 19) yyerror("Identifier too long"); + yylval.VAR_NAME = new char[yyleng+1]; + strcpy(yylval.VAR_NAME,yytext); + yylval.VAR_NAME[yyleng-3] = 'i'; // lowercase + yylval.VAR_NAME[yyleng-2] = 'n'; + return VAR; +} +[A-Za-z][A-Za-z0-9_]*"(set)" { + BUFFER; + if (yyleng > 19) yyerror("Identifier too long"); + yylval.VAR_NAME = new char[yyleng+1]; + strcpy(yylval.VAR_NAME,yytext); + yylval.VAR_NAME[yyleng-4] = 'i'; // Change to "in" + yylval.VAR_NAME[yyleng-3] = 'n'; // Be afraid + yylval.VAR_NAME[yyleng-2] = ')'; + yylval.VAR_NAME[yyleng-1] = '\0'; + return VAR; +} +[A-Za-z][A-Za-z0-9_]*"(out)" { + BUFFER; + if (yyleng > 19) yyerror("Identifier too long"); + yylval.VAR_NAME = new char[yyleng+1]; + strcpy(yylval.VAR_NAME,yytext); + yylval.VAR_NAME[yyleng-4] = 'o'; // lowercase + yylval.VAR_NAME[yyleng-3] = 'u'; + yylval.VAR_NAME[yyleng-2] = 't'; + return VAR; +} +<LATEX>"\\"[A-Za-z][A-Za-z0-9_]* { + BUFFER; + if (yyleng > 19) yyerror("Identifier too long"); + yylval.VAR_NAME = new char[yyleng+1]; + strcpy(yylval.VAR_NAME,yytext); + return VAR; + } +<LATEX>"\\"[A-Za-z][A-Za-z0-9_]*"(in)" { + BUFFER; + if (yyleng > 19) yyerror("Identifier too long"); + yylval.VAR_NAME = new char[yyleng+1]; + strcpy(yylval.VAR_NAME,yytext); + yylval.VAR_NAME[yyleng-3] = 'i'; // lowercase + yylval.VAR_NAME[yyleng-2] = 'n'; + return VAR; + } +<LATEX>"\\"[A-Za-z][A-Za-z0-9_]*"(set)" { + BUFFER; + if (yyleng > 19) yyerror("Identifier too long"); + yylval.VAR_NAME = new char[yyleng+1]; + strcpy(yylval.VAR_NAME,yytext); + yylval.VAR_NAME[yyleng-4] = 'i'; // Change to "in" + yylval.VAR_NAME[yyleng-3] = 'n'; // Be afraid + yylval.VAR_NAME[yyleng-2] = ')'; + yylval.VAR_NAME[yyleng-1] = '\0'; + return VAR; + } +<LATEX>"\\"[A-Za-z][A-Za-z0-9_]*"(out)" { + BUFFER; + if (yyleng > 19) yyerror("Identifier too long"); + yylval.VAR_NAME = new char[yyleng+1]; + strcpy(yylval.VAR_NAME,yytext); + yylval.VAR_NAME[yyleng-4] = 'o'; // lowercase + yylval.VAR_NAME[yyleng-3] = 'u'; + yylval.VAR_NAME[yyleng-2] = 't'; + return VAR; + } + +[0-9]+ { BUFFER; + if (need_coef) { + sscanf(yytext, coef_fmt, &yylval.COEF_VALUE); + return COEF; + } + else { + yylval.INT_VALUE = atoi(yytext); + return INT; + } +} + +\"[^\"]*\" { BUFFER; + yytext[strlen(yytext)-1]='\0'; + yylval.STRING_VALUE = new std::string(yytext+1); + return STRING; +} + + +<<EOF>> { + if (--include_stack_ptr < 0) { + flushScanBuffer(); + return yytext[0]; + } + yy_delete_buffer(YY_CURRENT_BUFFER); + yy_switch_to_buffer(include_stack[include_stack_ptr]); +} + +. { BUFFER; return yytext[0]; } + + +%% + +void yyerror(const std::string &s) { + std::stringstream ss; + if (is_interactive && include_stack_ptr == 0) + ss << s << "\n"; + else + ss << s << " at line " << yylineno << "\n"; + err_msg = ss.str(); +} + + +void flushScanBuffer() { + if (scanBuf.size() == 0) + return; + if (!is_interactive || include_stack_ptr > 0) { + size_t prev_pos = 0; + if (scanBuf[0] == '\n') + prev_pos = 1; + for (size_t pos = prev_pos; pos <= scanBuf.size(); pos++) { + if (pos == scanBuf.size() || scanBuf[pos] == '\n') { + std::cout << PROMPT_STRING << " " << scanBuf.substr(prev_pos, pos-prev_pos) << std::endl; + prev_pos = pos+1; + } + } + } + + scanBuf.clear(); +} diff --git a/omega/omega_calc/src/parser.ll b/omega/omega_calc/src/parser.ll new file mode 100755 index 0000000..86de3a4 --- /dev/null +++ b/omega/omega_calc/src/parser.ll @@ -0,0 +1,350 @@ +/***************************************************************************** + Copyright (C) 1994-2000 the Omega Project Team + Copyright (C) 2005-2011 Chun Chen + All Rights Reserved. + + Purpose: + lex parser for calculator. + + Notes: + + History: + 02/04/11 migrate to flex c++ mode, Chun Chen +*****************************************************************************/ + +%{ +#include <stdio.h> +#include <string.h> +#include <string> +#include <sstream> +#include <iostream> +#include <fstream> +#include <omega_calc/AST.h> +#include <basic/Dynamic_Array.h> +#include "parser.tab.hh" +#include <omega_calc/myflex.h> + +myFlexLexer mylexer; +bool is_interactive; +const char *PROMPT_STRING = ">>>"; + +#define BUFFER scanBuf += yytext +std::string scanBuf; +std::string err_msg; + +extern bool need_coef; + +void yyerror(const std::string &s); +void flushScanBuffer(); + +%} + +%s LATEX INCLUDE COMMENT +%option yylineno +%option noyywrap + +%% + +"<<" { BUFFER; BEGIN(INCLUDE); } +<INCLUDE>[^>\n ]+">>" { + BUFFER; + scanBuf += "\n"; + flushScanBuffer(); + + if (is_interactive) { + std::cout << "file include disabled in interactive mode\n"; + } + else { + char *s = yytext; + while (*s != '>') s++; + *s = '\0'; + std::ifstream *ifs = new std::ifstream(yytext, std::ifstream::in); + if (!ifs->is_open()) { + fprintf(stderr, "Can't open file %s\n", yytext); + } + else { + yy_buffer_state *bs = mylexer.yy_create_buffer(ifs, 8092); + mylexer.yypush_buffer_state(bs); + } + } + BEGIN(INITIAL); +} +<INCLUDE>[ \n] { + std::cout << "Error in include syntax\n"; + std::cout << "Use <<fname>> to include the file named fname\n"; + BEGIN(INITIAL); + if(is_interactive) { + std::cout << PROMPT_STRING << ' '; + std::cout.flush(); + } +} + + + + + +<LATEX>"\\ " { BUFFER; } +[ \t]+ { BUFFER; } +# { BUFFER; BEGIN(COMMENT); } +<COMMENT>.* { BUFFER; } +<LATEX>"\$\$\n" { BUFFER; BEGIN(INITIAL); } +<LATEX>"\$\$" { BUFFER; BEGIN(INITIAL); } +"\$\$" { BUFFER; BEGIN(LATEX); } +<LATEX>"\\n" { BUFFER; } +<LATEX>"\\t" { BUFFER; } +<LATEX>"\\!" { BUFFER; } +<LATEX>"\\\\" { BUFFER; } +<LATEX>"\n" { BUFFER; } + + +\n { + BUFFER; + BEGIN(INITIAL); + if(is_interactive) { + std::cout << PROMPT_STRING << ' '; + std::cout.flush(); + } +} + + + + + +"{" { BUFFER; return OPEN_BRACE; } +<LATEX>"\\{" { BUFFER; return OPEN_BRACE; } +"}" { BUFFER; return CLOSE_BRACE; } +<LATEX>"\\}" { BUFFER; return CLOSE_BRACE; } +"approximate" { BUFFER; return APPROX; } +"union" { BUFFER; return UNION; } +<LATEX>"\\cup" { BUFFER; return UNION; } +"intersection" { BUFFER; return INTERSECTION; } +<LATEX>"\\cap" { BUFFER; return INTERSECTION; } +"without_simplify" { BUFFER; return NO_SIMPLIFY; } +"symbolic" { BUFFER; return SYMBOLIC; } +"sym" { BUFFER; return SYMBOLIC; } +<LATEX>"\\mid" { BUFFER; return VERTICAL_BAR; } +<LATEX>"|" { BUFFER; return VERTICAL_BAR; } +<LATEX>"\\st" { BUFFER; return SUCH_THAT; } +"s.t." { BUFFER; return SUCH_THAT; } +"inverse" { BUFFER; return INVERSE; } +"complement" { BUFFER; return COMPLEMENT; } +<LATEX>"\\circ" { BUFFER; return COMPOSE; } +"compose" { BUFFER; return COMPOSE; } +"difference" { BUFFER; return DIFFERENCE; } +"diffToRel" { BUFFER; return DIFFERENCE_TO_RELATION; } +"project away symbols" { BUFFER; return PROJECT_AWAY_SYMBOLS; } +"project_away_symbols" { BUFFER; return PROJECT_AWAY_SYMBOLS; } +"projectAwaySymbols" { BUFFER; return PROJECT_AWAY_SYMBOLS; } +"project on symbols" { BUFFER; return PROJECT_ON_SYMBOLS; } +"project_on_symbols" { BUFFER; return PROJECT_ON_SYMBOLS; } +"projectOnSymbols" { BUFFER; return PROJECT_ON_SYMBOLS; } +<LATEX>"\\join" { BUFFER; return JOIN; } +"\." { BUFFER; return JOIN; } +"join" { BUFFER; return JOIN; } +"domain" { BUFFER; return DOMAIN; } +"time" { BUFFER; return TIME; } +"timeclosure" { BUFFER; return TIMECLOSURE; } +"range" { BUFFER; return RANGE; } +<LATEX>"\\forall" { BUFFER; return FORALL; } +"forall" { BUFFER; return FORALL; } +<LATEX>"\\exists" { BUFFER; return EXISTS; } +"exists" { BUFFER; return EXISTS; } + +"Venn" { BUFFER; return VENN; } +"ConvexRepresentation" { BUFFER; return CONVEX_REPRESENTATION; } +"ConvexCombination" { BUFFER; return CONVEX_COMBINATION; } +"PositiveCombination" { BUFFER; return POSITIVE_COMBINATION; } +"LinearCombination" { BUFFER; return LINEAR_COMBINATION; } +"AffineCombination" { BUFFER; return AFFINE_COMBINATION; } +"RectHull" { /*deprecated*/ BUFFER; return RECT_HULL; } +"SimpleHull" { BUFFER; return SIMPLE_HULL; } +"ConvexHull" { BUFFER; return CONVEX_HULL; } +"DecoupledConvexHull" { BUFFER; return DECOUPLED_CONVEX_HULL; } +"AffineHull" { BUFFER; return AFFINE_HULL; } +"ConicHull" { BUFFER; return CONIC_HULL; } +"LinearHull" { BUFFER; return LINEAR_HULL; } +"PairwiseCheck" { /*deprecated*/ BUFFER; return PAIRWISE_CHECK; } +"ConvexCheck" { /*deprecated*/ BUFFER; return CONVEX_CHECK; } +"QuickHull" { /*deprecated*/ BUFFER; return QUICK_HULL; } +"Hull" { BUFFER; return HULL; } +"farkas" { BUFFER; return FARKAS; } +"decoupledfarkas" { BUFFER; return DECOUPLED_FARKAS; } +"decoupled-farkas" { BUFFER; return DECOUPLED_FARKAS; } +"decoupled_farkas" { BUFFER; return DECOUPLED_FARKAS; } + +"minimize" { BUFFER; return MINIMIZE; } +"maximize" { BUFFER; return MAXIMIZE; } +"minimize-range" { BUFFER; return MINIMIZE_RANGE; } +"maximize-range" { BUFFER; return MAXIMIZE_RANGE; } +"minimizerange" { BUFFER; return MINIMIZE_RANGE; } +"maximizerange" { BUFFER; return MAXIMIZE_RANGE; } +"minimize-domain" { BUFFER; return MINIMIZE_DOMAIN; } +"maximize-domain" { BUFFER; return MAXIMIZE_DOMAIN; } +"minimizedomain" { BUFFER; return MINIMIZE_DOMAIN; } +"maximizedomain" { BUFFER; return MAXIMIZE_DOMAIN; } +"gist" { BUFFER; return GIST; } +"given" { BUFFER; return GIVEN; } +"within" { BUFFER; return WITHIN; } +"subset" { BUFFER; return SUBSET; } +"codegen" { BUFFER; return CODEGEN; } +"upper_bound" { BUFFER; return MAKE_UPPER_BOUND; } +"lower_bound" { BUFFER; return MAKE_LOWER_BOUND; } +"supersetof" { BUFFER; return SUPERSETOF;} +"subsetof" { BUFFER; return SUBSETOF;} +"sym_example" { BUFFER; return SYM_SAMPLE;} +"example" { BUFFER; return SAMPLE;} +"carried_by" { BUFFER; return CARRIED_BY;} +"reachable" { BUFFER; return REACHABLE_FROM; } +"reachable of" { BUFFER; return REACHABLE_OF; } +"restrict_domain" { BUFFER; return RESTRICT_DOMAIN; } +"restrictDomain" { BUFFER; return RESTRICT_DOMAIN; } +"\\" { BUFFER; return RESTRICT_DOMAIN; } +"restrict_range" { BUFFER; return RESTRICT_RANGE; } +"restrictRange" { BUFFER; return RESTRICT_RANGE; } +"assertUnsatisfiable" { BUFFER; return ASSERT_UNSAT; } +"assert_unsatisfiable" { BUFFER; return ASSERT_UNSAT; } + +"/" { BUFFER; return RESTRICT_RANGE; } +"&" { BUFFER; return AND; } +"|" { BUFFER; return OR; } +"&&" { BUFFER; return AND; } +"||" { BUFFER; return OR; } +"and" { BUFFER; return AND; } +"or" { BUFFER; return OR; } +<LATEX>"\\land" { BUFFER; return AND; } +<LATEX>"\\lor" { BUFFER; return OR; } +"!" { BUFFER; return NOT; } +"not" { BUFFER; return NOT; } +<LATEX>"\\neg" { BUFFER; return NOT; } +":=" { BUFFER; return IS_ASSIGNED; } +"->" { BUFFER; return GOES_TO; } +"in" { BUFFER; return IN; } +<LATEX>"\\rightarrow" { BUFFER; return GOES_TO; } +"<=" { BUFFER; yylval.REL_OPERATOR = leq; return REL_OP; } +<LATEX>"\\leq" { BUFFER; yylval.REL_OPERATOR = leq; return REL_OP; } +<LATEX>"\\le" { BUFFER; yylval.REL_OPERATOR = leq; return REL_OP; } +">=" { BUFFER; yylval.REL_OPERATOR = geq; return REL_OP; } +<LATEX>"\\geq" { BUFFER; yylval.REL_OPERATOR = geq; return REL_OP; } +<LATEX>"\\ge" { BUFFER; yylval.REL_OPERATOR = geq; return REL_OP; } +"!=" { BUFFER; yylval.REL_OPERATOR = neq; return REL_OP; } +<LATEX>"\\neq" { BUFFER; yylval.REL_OPERATOR = neq; return REL_OP; } +"<" { BUFFER; yylval.REL_OPERATOR = lt; return REL_OP; } +">" { BUFFER; yylval.REL_OPERATOR = gt; return REL_OP; } +"=" { BUFFER; yylval.REL_OPERATOR = eq; return REL_OP; } +"==" { BUFFER; yylval.REL_OPERATOR = eq; return REL_OP; } + +[A-Za-z_][A-Za-z0-9_]*[\']* { + BUFFER; + yylval.VAR_NAME = new char[yyleng+1]; + strcpy(yylval.VAR_NAME,yytext); + return VAR; +} +[A-Za-z][A-Za-z0-9_]*"(In)" { + BUFFER; + yylval.VAR_NAME = new char[yyleng+1]; + strcpy(yylval.VAR_NAME,yytext); + yylval.VAR_NAME[yyleng-3] = 'i'; // lowercase + yylval.VAR_NAME[yyleng-2] = 'n'; + return VAR; +} +[A-Za-z][A-Za-z0-9_]*"(Set)" { + BUFFER; + yylval.VAR_NAME = new char[yyleng+1]; + strcpy(yylval.VAR_NAME,yytext); + yylval.VAR_NAME[yyleng-4] = 'i'; // Change to "in" + yylval.VAR_NAME[yyleng-3] = 'n'; // Be afraid + yylval.VAR_NAME[yyleng-2] = ')'; + yylval.VAR_NAME[yyleng-1] = '\0'; + return VAR; +} +[A-Za-z][A-Za-z0-9_]*"(Out)" { + BUFFER; + yylval.VAR_NAME = new char[yyleng+1]; + strcpy(yylval.VAR_NAME,yytext); + yylval.VAR_NAME[yyleng-4] = 'o'; // lowercase + yylval.VAR_NAME[yyleng-3] = 'u'; + yylval.VAR_NAME[yyleng-2] = 't'; + return VAR; +} +<LATEX>"\\"[A-Za-z][A-Za-z0-9_]* { + BUFFER; + yylval.VAR_NAME = new char[yyleng+1]; + strcpy(yylval.VAR_NAME,yytext); + return VAR; + } +<LATEX>"\\"[A-Za-z][A-Za-z0-9_]*"(In)" { + BUFFER; + yylval.VAR_NAME = new char[yyleng+1]; + strcpy(yylval.VAR_NAME,yytext); + yylval.VAR_NAME[yyleng-3] = 'i'; // lowercase + yylval.VAR_NAME[yyleng-2] = 'n'; + return VAR; + } +<LATEX>"\\"[A-Za-z][A-Za-z0-9_]*"(Set)" { + BUFFER; + yylval.VAR_NAME = new char[yyleng+1]; + strcpy(yylval.VAR_NAME,yytext); + yylval.VAR_NAME[yyleng-4] = 'i'; // Change to "in" + yylval.VAR_NAME[yyleng-3] = 'n'; // Be afraid + yylval.VAR_NAME[yyleng-2] = ')'; + yylval.VAR_NAME[yyleng-1] = '\0'; + return VAR; + } +<LATEX>"\\"[A-Za-z][A-Za-z0-9_]*"(Out)" { + BUFFER; + yylval.VAR_NAME = new char[yyleng+1]; + strcpy(yylval.VAR_NAME,yytext); + yylval.VAR_NAME[yyleng-4] = 'o'; // lowercase + yylval.VAR_NAME[yyleng-3] = 'u'; + yylval.VAR_NAME[yyleng-2] = 't'; + return VAR; + } + +[0-9]+ { BUFFER; + if (need_coef) { + sscanf(yytext, coef_fmt, &yylval.COEF_VALUE); + return COEF; + } + else { + yylval.INT_VALUE = atoi(yytext); + return INT; + } +} + +\"[^\"]*\" { BUFFER; + yytext[yyleng-1]='\0'; + yylval.STRING_VALUE = new std::string(yytext+1); + return STRING; +} + + +<<EOF>> { + mylexer.yypop_buffer_state(); + if (!YY_CURRENT_BUFFER) { + flushScanBuffer(); + return YY_NULL; + } +} + +. { BUFFER; return yytext[0]; } + + +%% + +void flushScanBuffer() { + if (scanBuf.size() == 0) + return; + if (!is_interactive) { + size_t prev_pos = 0; + if (scanBuf[0] == '\n') + prev_pos = 1; + for (size_t pos = prev_pos; pos <= scanBuf.size(); pos++) { + if (pos == scanBuf.size() || scanBuf[pos] == '\n') { + std::cout << PROMPT_STRING << " " << scanBuf.substr(prev_pos, pos-prev_pos) << std::endl; + prev_pos = pos+1; + } + } + } + + scanBuf.clear(); +} diff --git a/omega/omega_calc/src/parser.y b/omega/omega_calc/src/parser.y new file mode 100644 index 0000000..7369b94 --- /dev/null +++ b/omega/omega_calc/src/parser.y @@ -0,0 +1,1925 @@ +/***************************************************************************** + Copyright (C) 1994-2000 University of Maryland. + Copyright (C) 2008 University of Southern California. + Copyright (C) 2009-2010 University of Utah. + All Rights Reserved. + + Purpose: + omega calculator yacc parser. + + Notes: + + History: +*****************************************************************************/ + +%{ + +#include <basic/Dynamic_Array.h> +#include <basic/Iterator.h> +#include <code_gen/code_gen.h> +#include <omega_calc/AST.h> +#include <omega/hull.h> +#include <omega/closure.h> +#include <omega/reach.h> +#include <string> +#include <iostream> + +#ifdef WIN32 +#include <io.h> +#define isatty _isatty +#define alloca _alloca +#endif +#ifndef WIN32 +#include <sys/time.h> +#include <sys/resource.h> +#endif +#if !defined(OMIT_GETRUSAGE) +#include <sys/types.h> +#include <sys/time.h> +#include <sys/resource.h> +#endif + +#if !defined(OMIT_GETRUSAGE) +#ifdef __sparc__ +extern "C" int getrusage (int, struct rusage*); +#endif + +using namespace omega; + +struct rusage start_time; +bool anyTimingDone = false; + +void start_clock( void ) { + getrusage(RUSAGE_SELF, &start_time); +} + +int clock_diff( void ) { + struct rusage current_time; + getrusage(RUSAGE_SELF, ¤t_time); + return (current_time.ru_utime.tv_sec -start_time.ru_utime.tv_sec)*1000000 + (current_time.ru_utime.tv_usec-start_time.ru_utime.tv_usec); +} +#endif + +int omega_calc_debug = 0; + +bool is_interactive; +const char *PROMPT_STRING = ">>>"; +extern std::string err_msg; +extern FILE *yyin; +bool need_coef; + +Map<Const_String,Relation*> relationMap ((Relation *)0); +namespace { + int redundant_conj_level = 2; // default maximum 2 + int redundant_constr_level = 4; // default maximum 4 +} + +int argCount = 0; +int tuplePos = 0; +Argument_Tuple currentTuple = Input_Tuple; + +Relation LexForward(int n); +reachable_information *reachable_info; + +int yylex(); +void yyerror(const std::string &s); +void flushScanBuffer(); + +%} + +%union { + int INT_VALUE; + coef_t COEF_VALUE; + Rel_Op REL_OPERATOR; + char *VAR_NAME; + VarList *VAR_LIST; + Exp *EXP; + ExpList *EXP_LIST; + AST *ASTP; + Argument_Tuple ARGUMENT_TUPLE; + AST_constraints *ASTCP; + Declaration_Site * DECLARATION_SITE; + Relation * RELATION; + tupleDescriptor * TUPLE_DESCRIPTOR; + RelTuplePair * REL_TUPLE_PAIR; + Dynamic_Array2<Relation> * RELATION_ARRAY_2D; + Dynamic_Array1<Relation> * RELATION_ARRAY_1D; + Tuple<std::string> *STRING_TUPLE; + std::string *STRING_VALUE; +} + +%token <VAR_NAME> VAR +%token <INT_VALUE> INT +%token <COEF_VALUE> COEF +%token <STRING_VALUE> STRING +%token OPEN_BRACE CLOSE_BRACE +%token SYMBOLIC +%token OR AND NOT +%token ST APPROX +%token IS_ASSIGNED +%token FORALL EXISTS +%token DOMAIN RANGE +%token DIFFERENCE DIFFERENCE_TO_RELATION +%token GIST GIVEN HULL WITHIN MAXIMIZE MINIMIZE +%token AFFINE_HULL VENN CONVEX_COMBINATION POSITIVE_COMBINATION LINEAR_COMBINATION AFFINE_COMBINATION CONVEX_HULL CONIC_HULL LINEAR_HULL QUICK_HULL PAIRWISE_CHECK CONVEX_CHECK CONVEX_REPRESENTATION RECT_HULL DECOUPLED_CONVEX_HULL +%token MAXIMIZE_RANGE MINIMIZE_RANGE +%token MAXIMIZE_DOMAIN MINIMIZE_DOMAIN +%token LEQ GEQ NEQ +%token GOES_TO +%token COMPOSE JOIN INVERSE COMPLEMENT IN CARRIED_BY TIME TIMECLOSURE +%token UNION INTERSECTION +%token VERTICAL_BAR SUCH_THAT +%token SUBSET CODEGEN DECOUPLED_FARKAS FARKAS +%token MAKE_UPPER_BOUND MAKE_LOWER_BOUND +%token <REL_OPERATOR> REL_OP +%token RESTRICT_DOMAIN RESTRICT_RANGE +%token SUPERSETOF SUBSETOF SAMPLE SYM_SAMPLE +%token PROJECT_AWAY_SYMBOLS PROJECT_ON_SYMBOLS REACHABLE_FROM REACHABLE_OF +%token ASSERT_UNSAT +%token PARSE_EXPRESSION PARSE_FORMULA PARSE_RELATION + +%type <INT_VALUE> effort +%type <EXP> exp simpleExp +%type <EXP_LIST> expList +%type <VAR_LIST> varList +%type <ARGUMENT_TUPLE> argumentList +%type <ASTP> formula optionalFormula +%type <ASTCP> constraintChain +%type <TUPLE_DESCRIPTOR> tupleDeclaration +%type <DECLARATION_SITE> varDecl varDeclOptBrackets +%type <RELATION> relation builtRelation context +%type <RELATION> reachable_of +%type <REL_TUPLE_PAIR> relPairList +%type <RELATION_ARRAY_1D> reachable + +%destructor {delete []$$;} VAR +%destructor {delete $$;} STRING +%destructor {delete $$;} relation builtRelation tupleDeclaration formula optionalFormula context reachable_of constraintChain varDecl varDeclOptBrackets relPairList reachable +%destructor {delete $$;} varList exp simpleExp +%destructor { + foreach(e, Exp *, *$$, delete e); + delete $$; + } expList; + +%nonassoc ASSERT_UNSAT +%left UNION p1 '+' '-' +%nonassoc SUPERSETOF SUBSETOF +%left p2 RESTRICT_DOMAIN RESTRICT_RANGE +%left INTERSECTION p3 '*' '@' +%left p4 +%left OR p5 +%left AND p6 +%left COMPOSE JOIN CARRIED_BY +%right NOT APPROX DOMAIN RANGE HULL PROJECT_AWAY_SYMBOLS PROJECT_ON_SYMBOLS DIFFERENCE DIFFERENCE_TO_RELATION INVERSE COMPLEMENT FARKAS SAMPLE SYM_SAMPLE MAKE_UPPER_BOUND MAKE_LOWER_BOUND p7 +%left p8 +%nonassoc GIVEN +%left p9 +%left '(' p10 + +%% + +inputSequence : /*empty*/ + | inputSequence { assert( current_Declaration_Site == globalDecls);} + inputItem +; + +inputItem : ';' /*empty*/ + | error ';' { + flushScanBuffer(); + std::cout << err_msg; + err_msg.clear(); + current_Declaration_Site = globalDecls; + need_coef = false; + std::cout << "...skipping to statement end..." << std::endl; + delete relationDecl; + relationDecl = NULL; + } + | SYMBOLIC globVarList ';' {flushScanBuffer();} + | VAR IS_ASSIGNED relation ';' { + flushScanBuffer(); + try { + $3->simplify(redundant_conj_level, redundant_constr_level); + Relation *r = relationMap((Const_String)$1); + if (r) delete r; + relationMap[(Const_String)$1] = $3; + } + catch (const std::exception &e) { + std::cout << e.what() << std::endl; + } + delete []$1; + } + | relation ';' { + flushScanBuffer(); + $1->simplify(redundant_conj_level, redundant_constr_level); + $1->print_with_subs(stdout); + delete $1; + } + | TIME relation ';' { +#if defined(OMIT_GETRUSAGE) + printf("'time' requires getrusage, but the omega calclator was compiled with OMIT_GETRUSAGE set!\n"); +#else + flushScanBuffer(); + printf("\n"); + int t; + Relation R; + bool SKIP_FULL_CHECK = getenv("OC_TIMING_SKIP_FULL_CHECK"); + ($2)->and_with_GEQ(); + start_clock(); + for (t=1;t<=100;t++) { + R = *$2; + R.finalize(); + } + int copyTime = clock_diff(); + start_clock(); + for (t=1;t<=100;t++) { + R = *$2; + R.finalize(); + R.simplify(); /* default simplification effort */ + } + int simplifyTime = clock_diff() -copyTime; + Relation R2; + if (!SKIP_FULL_CHECK) { + start_clock(); + for (t=1;t<=100;t++) { + R2 = *$2; + R2.finalize(); + R2.simplify(2,4); /* maximal simplification effort */ + } + } + int excessiveTime = clock_diff() - copyTime; + printf("Times (in microseconds): \n"); + printf("%5d us to copy original set of constraints\n",copyTime/100); + printf("%5d us to do the default amount of simplification, obtaining: \n\t", simplifyTime/100); + R.print_with_subs(stdout); + printf("\n"); + if (!SKIP_FULL_CHECK) { + printf("%5d us to do the maximum (i.e., excessive) amount of simplification, obtaining: \n\t", excessiveTime/100); + R2.print_with_subs(stdout); + printf("\n"); + } + if (!anyTimingDone) { + bool warn = false; +#ifndef SPEED + warn =true; +#endif +#ifndef NDEBUG + warn = true; +#endif + if (warn) { + printf("WARNING: The Omega calculator was compiled with options that force\n"); + printf("it to perform additional consistency and error checks\n"); + printf("that may slow it down substantially\n"); + printf("\n"); + } + printf("NOTE: These times relect the time of the current _implementation_\n"); + printf("of our algorithms. Performance bugs do exist. If you intend to publish or \n"); + printf("report on the performance on the Omega test, we respectfully but strongly \n"); + printf("request that send your test cases to us to allow us to determine if the \n"); + printf("times are appropriate, and if the way you are using the Omega library to \n"); + printf("solve your problem is the most effective way.\n"); + printf("\n"); + + printf("Also, please be aware that over the past two years, we have focused our \n"); + printf("efforts on the expressive power of the Omega library, sometimes at the\n"); + printf("expensive of raw speed. Our original implementation of the Omega test\n"); + printf("was substantially faster on the limited domain it handled.\n"); + printf("\n"); + printf(" Thanks, \n"); + printf(" the Omega Team \n"); + } + anyTimingDone = true; + delete $2; +#endif + } + | TIMECLOSURE relation ';' { +#if defined(OMIT_GETRUSAGE) + printf("'timeclosure' requires getrusage, but the omega calclator was compiled with OMIT_GETRUSAGE set!\n"); +#else + flushScanBuffer(); + try { + int t; + Relation R; + ($2)->and_with_GEQ(); + start_clock(); + for (t=1;t<=100;t++) { + R = *$2; + R.finalize(); + } + int copyTime = clock_diff(); + start_clock(); + for (t=1;t<=100;t++) { + R = *$2; + R.finalize(); + R.simplify(); + } + int simplifyTime = clock_diff() -copyTime; + Relation Rclosed; + start_clock(); + for (t=1;t<=100;t++) { + Rclosed = *$2; + Rclosed.finalize(); + Rclosed = TransitiveClosure(Rclosed, 1,Relation::Null()); + } + int closureTime = clock_diff() - copyTime; + Relation R2; + start_clock(); + for (t=1;t<=100;t++) { + R2 = *$2; + R2.finalize(); + R2.simplify(2,4); + } + int excessiveTime = clock_diff() - copyTime; + printf("Times (in microseconds): \n"); + printf("%5d us to copy original set of constraints\n",copyTime/100); + printf("%5d us to do the default amount of simplification, obtaining: \n\t", simplifyTime/100); + R.print_with_subs(stdout); + printf("\n"); + printf("%5d us to do the maximum (i.e., excessive) amount of simplification, obtaining: \n\t", excessiveTime/100); + R2.print_with_subs(stdout); + printf("%5d us to do the transitive closure, obtaining: \n\t", closureTime/100); + Rclosed.print_with_subs(stdout); + printf("\n"); + if (!anyTimingDone) { + bool warn = false; +#ifndef SPEED + warn =true; +#endif +#ifndef NDEBUG + warn = true; +#endif + if (warn) { + printf("WARNING: The Omega calculator was compiled with options that force\n"); + printf("it to perform additional consistency and error checks\n"); + printf("that may slow it down substantially\n"); + printf("\n"); + } + printf("NOTE: These times relect the time of the current _implementation_\n"); + printf("of our algorithms. Performance bugs do exist. If you intend to publish or \n"); + printf("report on the performance on the Omega test, we respectfully but strongly \n"); + printf("request that send your test cases to us to allow us to determine if the \n"); + printf("times are appropriate, and if the way you are using the Omega library to \n"); + printf("solve your problem is the most effective way.\n"); + printf("\n"); + + printf("Also, please be aware that over the past two years, we have focused our \n"); + printf("efforts on the expressive power of the Omega library, sometimes at the\n"); + printf("expensive of raw speed. Our original implementation of the Omega test\n"); + printf("was substantially faster on the limited domain it handled.\n"); + printf("\n"); + printf(" Thanks, \n"); + printf(" the Omega Team \n"); + } + anyTimingDone = true; + } + catch (const std::exception &e) { + std::cout << e.what() << std::endl; + } + delete $2; +#endif + } + | relation SUBSET relation ';' { + flushScanBuffer(); + try { + if (Must_Be_Subset(copy(*$1), copy(*$3))) + std::cout << "True" << std::endl; + else if (Might_Be_Subset(copy(*$1), copy(*$3))) + std::cout << "Possible" << std::endl; + else + std::cout << "False" << std::endl; + } + catch (const std::exception &e) { + std::cout << e.what() << std::endl; + } + delete $1; + delete $3; + } + | CODEGEN effort relPairList context';' { + flushScanBuffer(); + try { + std::string s = MMGenerateCode($3->mappings, $3->ispaces,*$4,$2); + std::cout << s << std::endl; + } + catch (const std::exception &e) { + std::cout << e.what() << std::endl; + } + delete $4; + delete $3; + } + | reachable ';' { + flushScanBuffer(); + Dynamic_Array1<Relation> &final = *$1; + bool any_sat = false; + int i,n_nodes = reachable_info->node_names.size(); + for(i = 1; i <= n_nodes; i++) + if(final[i].is_upper_bound_satisfiable()) { + any_sat = true; + std::cout << "Node %s: " << reachable_info->node_names[i]; + final[i].print_with_subs(stdout); + } + if(!any_sat) + std::cout << "No nodes reachable.\n"; + delete $1; + delete reachable_info; + } +; + + +effort : {$$ = 1;} + | INT {$$ = $1;} + | '-' INT {$$ = -$2;} +; + +context : {$$ = new Relation(); *$$ = Relation::Null();} + | GIVEN relation {$$ = $2; } +; + +relPairList : relPairList ',' relation ':' relation { + try { + $1->mappings.append(*$3); + $1->mappings[$1->mappings.size()].compress(); + $1->ispaces.append(*$5); + $1->ispaces[$1->ispaces.size()].compress(); + } + catch (const std::exception &e) { + delete $1; + delete $3; + delete $5; + yyerror(e.what()); + YYERROR; + } + delete $3; + delete $5; + $$ = $1; + } + | relPairList ',' relation { + try { + $1->mappings.append(Identity($3->n_set())); + $1->mappings[$1->mappings.size()].compress(); + $1->ispaces.append(*$3); + $1->ispaces[$1->ispaces.size()].compress(); + } + catch (const std::exception &e) { + delete $1; + delete $3; + yyerror(e.what()); + YYERROR; + } + delete $3; + $$ = $1; + } + | relation ':' relation { + RelTuplePair *rtp = new RelTuplePair; + try { + rtp->mappings.append(*$1); + rtp->mappings[rtp->mappings.size()].compress(); + rtp->ispaces.append(*$3); + rtp->ispaces[rtp->ispaces.size()].compress(); + } + catch (const std::exception &e) { + delete rtp; + delete $1; + delete $3; + yyerror(e.what()); + YYERROR; + } + delete $1; + delete $3; + $$ = rtp; + } + | relation { + RelTuplePair *rtp = new RelTuplePair; + try { + rtp->mappings.append(Identity($1->n_set())); + rtp->mappings[rtp->mappings.size()].compress(); + rtp->ispaces.append(*$1); + rtp->ispaces[rtp->ispaces.size()].compress(); + } + catch (const std::exception &e) { + delete rtp; + delete $1; + yyerror(e.what()); + YYERROR; + } + delete $1; + $$ = rtp; + } +; + +relation : OPEN_BRACE {need_coef = true; relationDecl = new Declaration_Site();} + builtRelation CLOSE_BRACE { + need_coef = false; + $$ = $3; + if (omega_calc_debug) { + fprintf(DebugFile,"Built relation:\n"); + $$->prefix_print(DebugFile); + } + current_Declaration_Site = globalDecls; + delete relationDecl; + relationDecl = NULL; + } + | VAR { + Const_String s = $1; + Relation *r = relationMap(s); + if (r == NULL) { + yyerror(std::string("relation ") + to_string($1) + std::string(" not declared")); + delete []$1; + YYERROR; + } + $$ = new Relation(*r); + delete []$1; + } + | '(' relation ')' {$$ = $2;} + | relation '+' %prec p9 { + $$ = new Relation(); + try { + *$$ = TransitiveClosure(*$1, 1, Relation::Null()); + } + catch (const std::exception &e) { + delete $$; + delete $1; + yyerror(e.what()); + YYERROR; + } + delete $1; + } + | relation '*' %prec p9 { + $$ = new Relation(); + try { + int vars = $1->n_inp(); + *$$ = Union(Identity(vars), TransitiveClosure(*$1, 1, Relation::Null())); + } + catch (const std::exception &e) { + delete $$; + delete $1; + yyerror(e.what()); + YYERROR; + } + delete $1; + } + | relation '+' WITHIN relation %prec p9 { + $$ = new Relation(); + try { + *$$= TransitiveClosure(*$1, 1, *$4); + } + catch (const std::exception &e) { + delete $$; + delete $1; + delete $4; + yyerror(e.what()); + YYERROR; + } + delete $1; + delete $4; + } + | relation '^' '@' %prec p8 { + $$ = new Relation(); + try { + *$$ = ApproxClosure(*$1); + } + catch (const std::exception &e) { + delete $$; + delete $1; + yyerror(e.what()); + YYERROR; + } + delete $1; + } + | relation '^' '+' %prec p8 { + $$ = new Relation(); + try { + *$$ = calculateTransitiveClosure(*$1); + } + catch (const std::exception &e) { + delete $$; + delete $1; + yyerror(e.what()); + YYERROR; + } + delete $1; + } + | MINIMIZE_RANGE relation %prec p8 { + $$ = new Relation(); + try { + Relation o(*$2); + Relation r(*$2); + r = Join(r,LexForward($2->n_out())); + *$$ = Difference(o,r); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | MAXIMIZE_RANGE relation %prec p8 { + $$ = new Relation(); + try { + Relation o(*$2); + Relation r(*$2); + r = Join(r,Inverse(LexForward($2->n_out()))); + *$$ = Difference(o,r); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | MINIMIZE_DOMAIN relation %prec p8 { + $$ = new Relation(); + try { + Relation o(*$2); + Relation r(*$2); + r = Join(LexForward($2->n_inp()),r); + *$$ = Difference(o,r); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | MAXIMIZE_DOMAIN relation %prec p8 { + $$ = new Relation(); + try { + Relation o(*$2); + Relation r(*$2); + r = Join(Inverse(LexForward($2->n_inp())),r); + *$$ = Difference(o,r); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | MAXIMIZE relation %prec p8 { + $$ = new Relation(); + try { + Relation c(*$2); + Relation r(*$2); + *$$ = Cross_Product(Relation(*$2),c); + *$$ = Difference(r,Domain(Intersection(*$$,LexForward($$->n_inp())))); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | MINIMIZE relation %prec p8 { + $$ = new Relation(); + try { + Relation c(*$2); + Relation r(*$2); + *$$ = Cross_Product(Relation(*$2),c); + *$$ = Difference(r,Range(Intersection(*$$,LexForward($$->n_inp())))); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | FARKAS relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Farkas(*$2, Basic_Farkas); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | DECOUPLED_FARKAS relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Farkas(*$2, Decoupled_Farkas); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | relation '@' %prec p9 { + $$ = new Relation(); + try { + *$$ = ConicClosure(*$1); + } + catch (const std::exception &e) { + delete $$; + delete $1; + yyerror(e.what()); + YYERROR; + } + delete $1; + } + | PROJECT_AWAY_SYMBOLS relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Project_Sym(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | PROJECT_ON_SYMBOLS relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Project_On_Sym(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | DIFFERENCE relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Deltas(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | DIFFERENCE_TO_RELATION relation %prec p8 { + $$ = new Relation(); + try { + *$$ = DeltasToRelation(*$2,$2->n_set(),$2->n_set()); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | DOMAIN relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Domain(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | VENN relation %prec p8 { + $$ = new Relation(); + try { + *$$ = VennDiagramForm(*$2,Relation::True(*$2)); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | VENN relation GIVEN relation %prec p8 { + $$ = new Relation(); + try { + *$$ = VennDiagramForm(*$2,*$4); + } + catch (const std::exception &e) { + delete $$; + delete $2; + delete $4; + yyerror(e.what()); + YYERROR; + } + delete $2; + delete $4; + } + | CONVEX_HULL relation %prec p8 { + $$ = new Relation(); + try { + *$$ = ConvexHull(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | DECOUPLED_CONVEX_HULL relation %prec p8 { + $$ = new Relation(); + try { + *$$ = DecoupledConvexHull(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | POSITIVE_COMBINATION relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Farkas(*$2,Positive_Combination_Farkas); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | LINEAR_COMBINATION relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Farkas(*$2,Linear_Combination_Farkas); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | AFFINE_COMBINATION relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Farkas(*$2,Affine_Combination_Farkas); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | CONVEX_COMBINATION relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Farkas(*$2,Convex_Combination_Farkas); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | PAIRWISE_CHECK relation %prec p8 { + $$ = new Relation(); + try { + *$$ = CheckForConvexRepresentation(CheckForConvexPairs(*$2)); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | CONVEX_CHECK relation %prec p8 { + $$ = new Relation(); + try { + *$$ = CheckForConvexRepresentation(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | CONVEX_REPRESENTATION relation %prec p8 { + $$ = new Relation(); + try { + *$$ = ConvexRepresentation(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | AFFINE_HULL relation %prec p8 { + $$ = new Relation(); + try { + *$$ = AffineHull(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | CONIC_HULL relation %prec p8 { + $$ = new Relation(); + try { + *$$ = ConicHull(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | LINEAR_HULL relation %prec p8 { + $$ = new Relation(); + try { + *$$ = LinearHull(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | QUICK_HULL relation %prec p8 { + $$ = new Relation(); + try { + *$$ = QuickHull(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | RECT_HULL relation %prec p8 { + $$ = new Relation(); + try { + *$$ = RectHull(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | HULL relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Hull(*$2,false,1,Relation::Null()); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | HULL relation GIVEN relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Hull(*$2,false,1,*$4); + } + catch (const std::exception &e) { + delete $$; + delete $2; + delete $4; + yyerror(e.what()); + YYERROR; + } + delete $2; + delete $4; + } + | APPROX relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Approximate(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | RANGE relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Range(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | INVERSE relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Inverse(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | COMPLEMENT relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Complement(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | GIST relation GIVEN relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Gist(*$2,*$4,1); + } + catch (const std::exception &e) { + delete $$; + delete $2; + delete $4; + yyerror(e.what()); + YYERROR; + } + delete $2; + delete $4; + } + | relation '(' relation ')' { + $$ = new Relation(); + try { + *$$ = Composition(*$1,*$3); + } + catch (const std::exception &e) { + delete $$; + delete $1; + delete $3; + yyerror(e.what()); + YYERROR; + } + delete $1; + delete $3; + } + | relation COMPOSE relation { + $$ = new Relation(); + try { + *$$ = Composition(*$1,*$3); + } + catch (const std::exception &e) { + delete $$; + delete $1; + delete $3; + yyerror(e.what()); + YYERROR; + } + delete $1; + delete $3; + } + | relation CARRIED_BY INT { + $$ = new Relation(); + try { + *$$ = After(*$1,$3,$3); + (*$$).prefix_print(stdout); + } + catch (const std::exception &e) { + delete $$; + delete $1; + yyerror(e.what()); + YYERROR; + } + delete $1; + } + | relation JOIN relation { + $$ = new Relation(); + try { + *$$ = Composition(*$3,*$1); + } + catch (const std::exception &e) { + delete $$; + delete $1; + delete $3; + yyerror(e.what()); + YYERROR; + } + delete $1; + delete $3; + } + | relation RESTRICT_RANGE relation { + $$ = new Relation(); + try { + *$$ = Restrict_Range(*$1,*$3); + } + catch (const std::exception &e) { + delete $$; + delete $1; + delete $3; + yyerror(e.what()); + YYERROR; + } + delete $1; + delete $3; + } + | relation RESTRICT_DOMAIN relation { + $$ = new Relation(); + try { + *$$ = Restrict_Domain(*$1,*$3); + } + catch (const std::exception &e) { + delete $$; + delete $1; + delete $3; + yyerror(e.what()); + YYERROR; + } + delete $1; + delete $3; + } + | relation INTERSECTION relation { + $$ = new Relation(); + try { + *$$ = Intersection(*$1,*$3); + } + catch (const std::exception &e) { + delete $$; + delete $1; + delete $3; + yyerror(e.what()); + YYERROR; + } + delete $1; + delete $3; + } + | relation '-' relation %prec INTERSECTION { + $$ = new Relation(); + try { + *$$ = Difference(*$1,*$3); + } + catch (const std::exception &e) { + delete $$; + delete $1; + delete $3; + yyerror(e.what()); + YYERROR; + } + delete $1; + delete $3; + } + | relation UNION relation { + $$ = new Relation(); + try { + *$$ = Union(*$1,*$3); + } + catch (const std::exception &e) { + delete $$; + delete $1; + delete $3; + yyerror(e.what()); + YYERROR; + } + delete $1; + delete $3; + } + | relation '*' relation { + $$ = new Relation(); + try { + *$$ = Cross_Product(*$1,*$3); + } + catch (const std::exception &e) { + delete $$; + delete $1; + delete $3; + yyerror(e.what()); + YYERROR; + } + delete $1; + delete $3; + } + | SUPERSETOF relation { + $$ = new Relation(); + try { + *$$ = Union(*$2, Relation::Unknown(*$2)); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | SUBSETOF relation { + $$ = new Relation(); + try { + *$$ = Intersection(*$2, Relation::Unknown(*$2)); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | MAKE_UPPER_BOUND relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Upper_Bound(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | MAKE_LOWER_BOUND relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Lower_Bound(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | SAMPLE relation { + $$ = new Relation(); + try { + *$$ = Sample_Solution(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | SYM_SAMPLE relation { + $$ = new Relation(); + try { + *$$ = Symbolic_Solution(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | reachable_of { $$ = $1; } + | ASSERT_UNSAT relation { + if (($2)->is_satisfiable()) { + fprintf(stderr,"assert_unsatisfiable failed on "); + ($2)->print_with_subs(stderr); + exit(1); + } + $$=$2; + } +; + +builtRelation : tupleDeclaration GOES_TO {currentTuple = Output_Tuple;} + tupleDeclaration {currentTuple = Input_Tuple;} optionalFormula { + Relation * r = new Relation($1->size,$4->size); + resetGlobals(); + F_And *f = r->add_and(); + for(int i=1;i<=$1->size;i++) { + $1->vars[i]->vid = r->input_var(i); + if (!$1->vars[i]->anonymous) + r->name_input_var(i,$1->vars[i]->stripped_name); + } + for(int i=1;i<=$4->size;i++) { + $4->vars[i]->vid = r->output_var(i); + if (!$4->vars[i]->anonymous) + r->name_output_var(i,$4->vars[i]->stripped_name); + } + r->setup_names(); + foreach(e,Exp*,$1->eq_constraints, install_eq(f,e,0)); + foreach(e,Exp*,$1->geq_constraints, install_geq(f,e,0)); + foreach(c,strideConstraint*,$1->stride_constraints, install_stride(f,c)); + foreach(e,Exp*,$4->eq_constraints, install_eq(f,e,0)); + foreach(e,Exp*,$4->geq_constraints, install_geq(f,e,0)); + foreach(c,strideConstraint*,$4->stride_constraints, install_stride(f,c)); + if ($6) $6->install(f); + delete $1; + delete $4; + delete $6; + $$ = r; + } + | tupleDeclaration optionalFormula { + Relation * r = new Relation($1->size); + resetGlobals(); + F_And *f = r->add_and(); + for(int i=1;i<=$1->size;i++) { + $1->vars[i]->vid = r->set_var(i); + if (!$1->vars[i]->anonymous) + r->name_set_var(i,$1->vars[i]->stripped_name); + } + r->setup_names(); + foreach(e,Exp*,$1->eq_constraints, install_eq(f,e,0)); + foreach(e,Exp*,$1->geq_constraints, install_geq(f,e,0)); + foreach(c,strideConstraint*,$1->stride_constraints, install_stride(f,c)); + if ($2) $2->install(f); + delete $1; + delete $2; + $$ = r; + } + | formula { + Relation * r = new Relation(0,0); + F_And *f = r->add_and(); + $1->install(f); + delete $1; + $$ = r; + } +; + +optionalFormula : formula_sep formula {$$ = $2;} + | {$$ = 0;} +; + +formula_sep : ':' + | VERTICAL_BAR + | SUCH_THAT +; + +tupleDeclaration : {currentTupleDescriptor = new tupleDescriptor; tuplePos = 1;} + '[' optionalTupleVarList ']' + {$$ = currentTupleDescriptor; tuplePos = 0;} +; + +optionalTupleVarList : /* empty */ + | tupleVar + | optionalTupleVarList ',' tupleVar +; + +tupleVar : VAR %prec p10 { + Declaration_Site *ds = defined($1); + if (!ds) + currentTupleDescriptor->extend($1,currentTuple,tuplePos); + else { + Variable_Ref *v = lookupScalar($1); + if (v == NULL) { + yyerror(std::string("cannot find declaration for variable ") + to_string($1)); + delete []$1; + YYERROR; + } + if (ds != globalDecls) + currentTupleDescriptor->extend($1, new Exp(v)); + else + currentTupleDescriptor->extend(new Exp(v)); + } + tuplePos++; + delete []$1; + } + | '*' {currentTupleDescriptor->extend(); tuplePos++;} + | exp %prec p1 { + currentTupleDescriptor->extend($1); + tuplePos++; + } + | exp ':' exp %prec p1 { + currentTupleDescriptor->extend($1,$3); + tuplePos++; + } + | exp ':' exp ':' COEF %prec p1 { + currentTupleDescriptor->extend($1,$3,$5); + tuplePos++; + } +; + +varList : varList ',' VAR {$$ = $1; $$->insert($3); $3 = NULL;} + | VAR {$$ = new VarList; $$->insert($1); $1 = NULL;} +; + +varDecl : varList { + $$ = current_Declaration_Site = new Declaration_Site($1); + foreach(s,char *, *$1, delete []s); + delete $1; + } +; + +varDeclOptBrackets : varDecl {$$ = $1;} + |'[' varDecl ']' {$$ = $2;} +; + +globVarList : globVarList ',' globVar + | globVar +; + +globVar : VAR '(' INT ')' {globalDecls->extend_both_tuples($1, $3); delete []$1;} + | VAR { + globalDecls->extend($1); + delete []$1; + } +; + +formula : formula AND formula {$$ = new AST_And($1,$3);} + | formula OR formula {$$ = new AST_Or($1,$3);} + | constraintChain {$$ = $1;} + | '(' formula ')' {$$ = $2;} + | NOT formula {$$ = new AST_Not($2);} + | start_exists varDeclOptBrackets exists_sep formula end_quant {$$ = new AST_exists($2,$4);} + | start_forall varDeclOptBrackets forall_sep formula end_quant {$$ = new AST_forall($2,$4);} +; + +start_exists : '(' EXISTS + | EXISTS '(' +; + +exists_sep : ':' + | VERTICAL_BAR + | SUCH_THAT +; + +start_forall : '(' FORALL + | FORALL '(' +; + +forall_sep : ':' +; + +end_quant : ')' {popScope();} +; + +expList : exp ',' expList {$$ = $3; $$->insert($1);} + | exp {$$ = new ExpList; $$->insert($1);} +; + +constraintChain : expList REL_OP expList {$$ = new AST_constraints($1,$2,$3);} + | expList REL_OP constraintChain {$$ = new AST_constraints($1,$2,$3);} +; + +simpleExp : VAR %prec p9 { + Variable_Ref *v = lookupScalar($1); + if (v == NULL) { + yyerror(std::string("cannot find declaration for variable ") + to_string($1)); + delete []$1; + YYERROR; + } + $$ = new Exp(v); + delete []$1; + } + | VAR '(' {argCount = 1;} argumentList ')' %prec p9 { + Variable_Ref *v; + if ($4 == Input_Tuple) + v = functionOfInput[$1]; + else + v = functionOfOutput[$1]; + if (v == NULL) { + yyerror(std::string("Function ") + to_string($1) + std::string(" not declared")); + delete []$1; + YYERROR; + } + $$ = new Exp(v); + delete []$1; + } + | '(' exp ')' { $$ = $2; } +; + +argumentList : argumentList ',' VAR { + Variable_Ref *v = lookupScalar($3); + if (v == NULL) { + yyerror(std::string("cannot find declaration for variable ") + to_string($1)); + delete []$3; + YYERROR; + } + if (v->pos != argCount || v->of != $1 || (v->of != Input_Tuple && v->of != Output_Tuple)) { + yyerror("arguments to function must be prefix of input or output tuple"); + delete []$3; + YYERROR; + } + $$ = v->of; + argCount++; + delete []$3; + } + | VAR { + Variable_Ref *v = lookupScalar($1); + if (v == NULL) { + yyerror(std::string("cannot find declaration for variable ") + to_string($1)); + delete []$1; + YYERROR; + } + if (v->pos != argCount || (v->of != Input_Tuple && v->of != Output_Tuple)) { + yyerror("arguments to function must be prefix of input or output tuple"); + delete []$1; + YYERROR; + } + $$ = v->of; + argCount++; + delete []$1; + } +; + +exp : COEF {$$ = new Exp($1);} + | COEF simpleExp %prec '*' {$$ = multiply($1,$2);} + | simpleExp {$$ = $1; } + | '-' exp %prec '*' {$$ = negate($2);} + | exp '+' exp {$$ = add($1,$3);} + | exp '-' exp {$$ = subtract($1,$3);} + | exp '*' exp {$$ = multiply($1,$3);} +; + + +reachable : REACHABLE_FROM nodeNameList nodeSpecificationList { + Dynamic_Array1<Relation> *final = Reachable_Nodes(reachable_info); + $$ = final; + } +; + +reachable_of : REACHABLE_OF VAR IN nodeNameList nodeSpecificationList { + Dynamic_Array1<Relation> *final = Reachable_Nodes(reachable_info); + int index = reachable_info->node_names.index(std::string($2)); + if (index == 0) { + yyerror(std::string("no such node ") + to_string($2)); + delete []$2; + delete final; + delete reachable_info; + YYERROR; + } + $$ = new Relation; + *$$ = (*final)[index]; + delete final; + delete reachable_info; + delete []$2; + } +; + +nodeNameList : '(' realNodeNameList ')' { + int sz = reachable_info->node_names.size(); + reachable_info->node_arity.reallocate(sz); + reachable_info->transitions.resize(sz+1,sz+1); + reachable_info->start_nodes.resize(sz+1); + } +; + +realNodeNameList : realNodeNameList ',' VAR { + reachable_info->node_names.append(std::string($3)); + delete []$3; + } + | VAR { + reachable_info = new reachable_information; + reachable_info->node_names.append(std::string($1)); + delete []$1; + } +; + + +nodeSpecificationList : OPEN_BRACE realNodeSpecificationList CLOSE_BRACE { + int i,j; + int n_nodes = reachable_info->node_names.size(); + Tuple<int> &arity = reachable_info->node_arity; + Dynamic_Array2<Relation> &transitions = reachable_info->transitions; + + /* fixup unspecified transitions to be false */ + /* find arity */ + for(i = 1; i <= n_nodes; i++) arity[i] = -1; + for(i = 1; i <= n_nodes; i++) + for(j = 1; j <= n_nodes; j++) + if(! transitions[i][j].is_null()) { + int in_arity = transitions[i][j].n_inp(); + int out_arity = transitions[i][j].n_out(); + if(arity[i] < 0) arity[i] = in_arity; + if(arity[j] < 0) arity[j] = out_arity; + if(in_arity != arity[i] || out_arity != arity[j]) { + yyerror(std::string("arity mismatch in node transition: ") + to_string(reachable_info->node_names[i]) + std::string(" -> ") + to_string(reachable_info->node_names[j])); + delete reachable_info; + YYERROR; + } + } + for(i = 1; i <= n_nodes; i++) + if(arity[i] < 0) arity[i] = 0; + /* Fill in false relations */ + for(i = 1; i <= n_nodes; i++) + for(j = 1; j <= n_nodes; j++) + if(transitions[i][j].is_null()) + transitions[i][j] = Relation::False(arity[i],arity[j]); + + /* fixup unused start node positions */ + Dynamic_Array1<Relation> &nodes = reachable_info->start_nodes; + for(i = 1; i <= n_nodes; i++) + if(nodes[i].is_null()) + nodes[i] = Relation::False(arity[i]); + else + if(nodes[i].n_set() != arity[i]){ + yyerror(std::string("arity mismatch in start node ") + to_string(reachable_info->node_names[i])); + delete reachable_info; + YYERROR; + } + } +; + +realNodeSpecificationList : realNodeSpecificationList ',' VAR ':' relation { + int n_nodes = reachable_info->node_names.size(); + int index = reachable_info->node_names.index($3); + if (!(index > 0 && index <= n_nodes)) { + yyerror(std::string("no such node ")+to_string($3)); + delete $5; + delete []$3; + delete reachable_info; + YYERROR; + } + reachable_info->start_nodes[index] = *$5; + delete $5; + delete []$3; + } + | realNodeSpecificationList ',' VAR GOES_TO VAR ':' relation { + int n_nodes = reachable_info->node_names.size(); + int from_index = reachable_info->node_names.index($3); + if (!(from_index > 0 && from_index <= n_nodes)) { + yyerror(std::string("no such node ")+to_string($3)); + delete $7; + delete []$3; + delete []$5; + delete reachable_info; + YYERROR; + } + int to_index = reachable_info->node_names.index($5); + if (!(to_index > 0 && to_index <= n_nodes)) { + yyerror(std::string("no such node ")+to_string($5)); + delete $7; + delete []$3; + delete []$5; + delete reachable_info; + YYERROR; + } + reachable_info->transitions[from_index][to_index] = *$7; + delete $7; + delete []$3; + delete []$5; + } + | VAR GOES_TO VAR ':' relation { + int n_nodes = reachable_info->node_names.size(); + int from_index = reachable_info->node_names.index($1); + if (!(from_index > 0 && from_index <= n_nodes)) { + yyerror(std::string("no such node ")+to_string($1)); + delete $5; + delete []$1; + delete []$3; + delete reachable_info; + YYERROR; + } + int to_index = reachable_info->node_names.index($3); + if (!(to_index > 0 && to_index <= n_nodes)) { + yyerror(std::string("no such node ")+to_string($3)); + delete $5; + delete []$1; + delete []$3; + delete reachable_info; + YYERROR; + } + reachable_info->transitions[from_index][to_index] = *$5; + delete $5; + delete []$1; + delete []$3; + } + | VAR ':' relation { + int n_nodes = reachable_info->node_names.size(); + int index = reachable_info->node_names.index($1); + if (!(index > 0 && index <= n_nodes)) { + yyerror(std::string("no such node ")+to_string($1)); + delete $3; + delete []$1; + delete reachable_info; + YYERROR; + } + reachable_info->start_nodes[index] = *$3; + delete $3; + delete []$1; + } +; + +%% + + +void printUsage(FILE *outf, char **argv) { + fprintf(outf, "usage: %s {-R} {-D[facility][level]...} infile\n -R means skip redundant conjunct elimination\n -D sets debugging level as follows:\n a = all debugging flags\n g = code generation\n l = calculator\n c = omega core\n p = presburger functions\n r = relational operators\n t = transitive closure\n", argv[0]); +} + + +bool process_calc_debugging_flags(char *arg,int &j) { + char debug_type; + while((debug_type=arg[j]) != 0) { + j++; + int level; + if(isdigit(arg[j])) + level = (arg[j++]) - '0'; + else + if(arg[j] == 0 || isalpha(arg[j])) + level = 1; + else + return false; + if (level < 0 || level > 4) { + fprintf(stderr,"Debug level %c out of range: %d\n", debug_type, level); + return false; + } + switch(debug_type) { + case 'a': + omega_core_debug = relation_debug = hull_debug = + closure_presburger_debug = + farkas_debug = + pres_debug = omega_calc_debug = code_gen_debug = level; + break; + case 'g': + code_gen_debug = level; break; + case 'f': + farkas_debug = level; break; + case 'h': + hull_debug = level; break; + case 'c': + omega_core_debug = level; break; + case 'r': + relation_debug = level; break; + case 'p': + pres_debug = level; break; + case 't': + closure_presburger_debug = level; break; + case 'l': + omega_calc_debug = level; break; +#if defined STUDY_EVACUATIONS + case 'e': + evac_debug = level; break; +#endif + default: + fprintf(stderr, "Unknown debug type %c\n", debug_type); + return false; + } + } + return true; +} + + +int main(int argc, char **argv) { +#if YYDEBUG != 0 + yydebug = 1; +#endif + + /* process flags */ + char *fileName = 0; + for(int i=1; i<argc; i++) { + if(argv[i][0] == '-') { + int j = 1, c; + while((c=argv[i][j++]) != 0) { + switch(c) { + case 'D': + if (!process_calc_debugging_flags(argv[i],j)) { + printUsage(stderr, argv); + exit(1); + } + break; + case 'G': + fprintf(stderr,"Note: specifying number of GEQ's is no longer useful.\n"); + while(argv[i][j] != 0) j++; + break; + case 'E': + fprintf(stderr,"Note: specifying number of EQ's is no longer useful.\n"); + while(argv[i][j] != 0) j++; + break; + case 'R': + redundant_conj_level = 1; + break; + /* Other future options go here */ + case 'h': + printUsage(stderr, argv); + exit(1); + break; + default: + fprintf(stderr, "\nUnknown flag -%c\n", c); + printUsage(stderr, argv); + exit(1); + } + } + } + else { + /* Make sure this is a file name */ + if (fileName) { + fprintf(stderr,"\nCan only handle a single input file\n"); + printUsage(stderr,argv); + exit(1); + } + fileName = argv[i]; + yyin = fopen(fileName, "r"); + if (!yyin) { + fprintf(stderr, "\nCan't open input file %s\n",fileName); + printUsage(stderr,argv); + exit(1); + } + } + } + + if (fileName || !isatty((int)fileno(stdin))) { + is_interactive = false; + } + else { + is_interactive = true; + setbuf(DebugFile, NULL); + printf("Calculator for Omega+ v20110204snapshot (built on %s)\n", OMEGA_BUILD_DATE); + printf("Copyright (C) 1994-2000 University of Maryland the Omega Project Team\n"); + printf("Copyright (C) 2008 University of Southern California\n"); + printf("Copyright (C) 2009-2011 University of Utah\n"); + printf("%s ", PROMPT_STRING); + } + need_coef = false; + current_Declaration_Site = globalDecls = new Global_Declaration_Site(); + + if (yyparse() != 0) { + if (!is_interactive) + std::cout << "syntax error at the end of the file, missing ';'" << std::endl; + else + std::cout << std::endl; + delete relationDecl; + relationDecl = NULL; + } + else { + if (is_interactive) + std::cout << std::endl; + } + + foreach_map(cs,Const_String,r,Relation *,relationMap, + {delete r; relationMap[cs]=0;}); + delete globalDecls; + fclose(yyin); + + return 0; +} + +Relation LexForward(int n) { + Relation r(n,n); + F_Or *f = r.add_or(); + for (int i=1; i <= n; i++) { + F_And *g = f->add_and(); + for(int j=1;j<i;j++) { + EQ_Handle e = g->add_EQ(); + e.update_coef(r.input_var(j),-1); + e.update_coef(r.output_var(j),1); + e.finalize(); + } + GEQ_Handle e = g->add_GEQ(); + e.update_coef(r.input_var(i),-1); + e.update_coef(r.output_var(i),1); + e.update_const(-1); + e.finalize(); + } + r.finalize(); + return r; +} diff --git a/omega/omega_calc/src/parser.yy b/omega/omega_calc/src/parser.yy new file mode 100755 index 0000000..cad6e8e --- /dev/null +++ b/omega/omega_calc/src/parser.yy @@ -0,0 +1,1928 @@ +/***************************************************************************** + Copyright (C) 1994-2000 the Omega Project Team + Copyright (C) 2005-2011 Chun Chen + All Rights Reserved. + + Purpose: + yacc parser for calculator. + + Notes: + + History: + 02/04/11 work with flex c++ mode, Chun Chen +*****************************************************************************/ + +%{ +//#define YYDEBUG 1 +#include <basic/Dynamic_Array.h> +#include <basic/Iterator.h> +#include <omega_calc/AST.h> +#include <omega/hull.h> +#include <omega/closure.h> +#include <omega/reach.h> +#include <string> +#include <iostream> +#include <fstream> +#include "parser.tab.hh" +#include <omega_calc/myflex.h> +//#include <stdio.h> + +#if defined __USE_POSIX +#include <unistd.h> +#elif defined __WIN32 +#include <io.h> +#endif + + +#ifndef WIN32 +#include <sys/time.h> +#include <sys/resource.h> +#endif +#if !defined(OMIT_GETRUSAGE) +#include <sys/types.h> +#include <sys/time.h> +#include <sys/resource.h> +#endif + +#if !defined(OMIT_GETRUSAGE) +#ifdef __sparc__ +extern "C" int getrusage (int, struct rusage*); +#endif + + + + +struct rusage start_time; +bool anyTimingDone = false; + +void start_clock( void ) { + getrusage(RUSAGE_SELF, &start_time); +} + +int clock_diff( void ) { + struct rusage current_time; + getrusage(RUSAGE_SELF, ¤t_time); + return (current_time.ru_utime.tv_sec -start_time.ru_utime.tv_sec)*1000000 + (current_time.ru_utime.tv_usec-start_time.ru_utime.tv_usec); +} +#endif + + +#ifdef BUILD_CODEGEN +#include <code_gen/codegen.h> +#endif + +extern myFlexLexer mylexer; +#define yylex mylexer.yylex + + + + +int omega_calc_debug = 0; + +extern bool is_interactive; +extern const char *PROMPT_STRING; +bool simplify = true; +using namespace omega; + +extern std::string err_msg; + +bool need_coef; + +namespace { + int redundant_conj_level = 2; // default maximum 2 + int redundant_constr_level = 4; // default maximum 4 +} + +std::map<std::string, Relation *> relationMap; +int argCount = 0; +int tuplePos = 0; +Argument_Tuple currentTuple = Input_Tuple; + +Relation LexForward(int n); +reachable_information *reachable_info; + +void yyerror(const std::string &s); +void flushScanBuffer(); + +%} + +%union { + int INT_VALUE; + omega::coef_t COEF_VALUE; + Rel_Op REL_OPERATOR; + char *VAR_NAME; + std::set<char *> *VAR_LIST; + Exp *EXP; + std::set<Exp *> *EXP_LIST; + AST *ASTP; + omega::Argument_Tuple ARGUMENT_TUPLE; + AST_constraints *ASTCP; + Declaration_Site *DECLARATION_SITE; + omega::Relation *RELATION; + tupleDescriptor *TUPLE_DESCRIPTOR; + std::pair<std::vector<omega::Relation>, std::vector<omega::Relation> > *REL_TUPLE_PAIR; + omega::Dynamic_Array1<omega::Relation> * RELATION_ARRAY_1D; + std::string *STRING_VALUE; +} + +%token <VAR_NAME> VAR +%token <INT_VALUE> INT +%token <COEF_VALUE> COEF +%token <STRING_VALUE> STRING +%token OPEN_BRACE CLOSE_BRACE +%token SYMBOLIC NO_SIMPLIFY +%token OR AND NOT +%token ST APPROX +%token IS_ASSIGNED +%token FORALL EXISTS +%token DOMAIN RANGE +%token DIFFERENCE DIFFERENCE_TO_RELATION +%token GIST GIVEN HULL WITHIN MAXIMIZE MINIMIZE +%token AFFINE_HULL VENN CONVEX_COMBINATION POSITIVE_COMBINATION LINEAR_COMBINATION AFFINE_COMBINATION CONVEX_HULL CONIC_HULL LINEAR_HULL QUICK_HULL PAIRWISE_CHECK CONVEX_CHECK CONVEX_REPRESENTATION RECT_HULL SIMPLE_HULL DECOUPLED_CONVEX_HULL +%token MAXIMIZE_RANGE MINIMIZE_RANGE +%token MAXIMIZE_DOMAIN MINIMIZE_DOMAIN +%token LEQ GEQ NEQ +%token GOES_TO +%token COMPOSE JOIN INVERSE COMPLEMENT IN CARRIED_BY TIME TIMECLOSURE +%token UNION INTERSECTION +%token VERTICAL_BAR SUCH_THAT +%token SUBSET CODEGEN DECOUPLED_FARKAS FARKAS +%token MAKE_UPPER_BOUND MAKE_LOWER_BOUND +%token <REL_OPERATOR> REL_OP +%token RESTRICT_DOMAIN RESTRICT_RANGE +%token SUPERSETOF SUBSETOF SAMPLE SYM_SAMPLE +%token PROJECT_AWAY_SYMBOLS PROJECT_ON_SYMBOLS REACHABLE_FROM REACHABLE_OF +%token ASSERT_UNSAT +%token PARSE_EXPRESSION PARSE_FORMULA PARSE_RELATION + +%type <EXP> exp simpleExp +%type <EXP_LIST> expList +%type <VAR_LIST> varList +%type <ARGUMENT_TUPLE> argumentList +%type <ASTP> formula optionalFormula +%type <ASTCP> constraintChain +%type <TUPLE_DESCRIPTOR> tupleDeclaration +%type <DECLARATION_SITE> varDecl varDeclOptBrackets +%type <RELATION> relation builtRelation context +%type <RELATION> reachable_of +%type <REL_TUPLE_PAIR> relPairList +%type <RELATION_ARRAY_1D> reachable + +%destructor {delete []$$;} VAR +%destructor {delete $$;} STRING +%destructor {delete $$;} relation builtRelation tupleDeclaration formula optionalFormula context reachable_of constraintChain varDecl varDeclOptBrackets relPairList reachable +%destructor {delete $$;} exp simpleExp +%destructor { + for (std::set<Exp *>::iterator i = $$->begin(); i != $$->end(); i++) + delete *i; + delete $$; + } expList; +%destructor { + for (std::set<char *>::iterator i = $$->begin(); i != $$->end(); i++) + delete []*i; + delete $$; + } varList; + +%nonassoc ASSERT_UNSAT +%left UNION p1 '+' '-' +%nonassoc SUPERSETOF SUBSETOF +%left p2 RESTRICT_DOMAIN RESTRICT_RANGE +%left INTERSECTION p3 '*' '@' +%left p4 +%left OR p5 +%left AND p6 +%left COMPOSE JOIN CARRIED_BY +%right NOT APPROX DOMAIN RANGE HULL PROJECT_AWAY_SYMBOLS PROJECT_ON_SYMBOLS DIFFERENCE DIFFERENCE_TO_RELATION INVERSE COMPLEMENT FARKAS SAMPLE SYM_SAMPLE MAKE_UPPER_BOUND MAKE_LOWER_BOUND p7 +%left p8 +%nonassoc GIVEN +%left p9 +%left '(' p10 + +%% + +inputSequence : /*empty*/ + | inputSequence { assert( current_Declaration_Site == globalDecls);} + inputItem; +; + +inputItem : ';' /*empty*/ + | NO_SIMPLIFY ';'{ + simplify = false; + } + | error ';' { + flushScanBuffer(); + std::cout << err_msg; + err_msg.clear(); + current_Declaration_Site = globalDecls; + need_coef = false; + std::cout << "...skipping to statement end..." << std::endl; + delete relationDecl; + relationDecl = NULL; + } + | SYMBOLIC globVarList ';' {flushScanBuffer();} + | VAR IS_ASSIGNED relation ';' { + flushScanBuffer(); + try { + if(simplify) + $3->simplify(redundant_conj_level, redundant_constr_level); + else + $3->simplify(); + Relation *r = relationMap[std::string($1)]; + if (r != NULL) delete r; + relationMap[std::string($1)] = $3; + } + catch(const std::exception &e){ + std::cout << e.what() << std::endl; + } + + delete []$1; + } + | relation ';' { + flushScanBuffer(); + if(simplify) + $1->simplify(redundant_conj_level, redundant_constr_level); + else + $1->simplify(); + $1->print_with_subs(stdout); + delete $1; + } + | TIME relation ';' { +#if defined(OMIT_GETRUSAGE) + printf("'time' requires getrusage, but the omega calclator was compiled with OMIT_GETRUSAGE set!\n"); +#else + flushScanBuffer(); + printf("\n"); + int t; + Relation R; + bool SKIP_FULL_CHECK = getenv("OC_TIMING_SKIP_FULL_CHECK"); + ($2)->and_with_GEQ(); + start_clock(); + for (t=1;t<=100;t++) { + R = *$2; + R.finalize(); + } + int copyTime = clock_diff(); + start_clock(); + for (t=1;t<=100;t++) { + R = *$2; + R.finalize(); + R.simplify(); /* default simplification effort */ + } + int simplifyTime = clock_diff() -copyTime; + Relation R2; + if (!SKIP_FULL_CHECK) { + start_clock(); + for (t=1;t<=100;t++) { + R2 = *$2; + R2.finalize(); + R2.simplify(2,4); /* maximal simplification effort */ + } + } + int excessiveTime = clock_diff() - copyTime; + printf("Times (in microseconds): \n"); + printf("%5d us to copy original set of constraints\n",copyTime/100); + printf("%5d us to do the default amount of simplification, obtaining: \n\t", simplifyTime/100); + R.print_with_subs(stdout); + printf("\n"); + if (!SKIP_FULL_CHECK) { + printf("%5d us to do the maximum (i.e., excessive) amount of simplification, obtaining: \n\t", excessiveTime/100); + R2.print_with_subs(stdout); + printf("\n"); + } + if (!anyTimingDone) { + bool warn = false; +#ifndef SPEED + warn =true; +#endif +#ifndef NDEBUG + warn = true; +#endif + if (warn) { + printf("WARNING: The Omega calculator was compiled with options that force\n"); + printf("it to perform additional consistency and error checks\n"); + printf("that may slow it down substantially\n"); + printf("\n"); + } + printf("NOTE: These times relect the time of the current _implementation_\n"); + printf("of our algorithms. Performance bugs do exist. If you intend to publish or \n"); + printf("report on the performance on the Omega test, we respectfully but strongly \n"); + printf("request that send your test cases to us to allow us to determine if the \n"); + printf("times are appropriate, and if the way you are using the Omega library to \n"); + printf("solve your problem is the most effective way.\n"); + printf("\n"); + + printf("Also, please be aware that over the past two years, we have focused our \n"); + printf("efforts on the expressive power of the Omega library, sometimes at the\n"); + printf("expensive of raw speed. Our original implementation of the Omega test\n"); + printf("was substantially faster on the limited domain it handled.\n"); + printf("\n"); + printf(" Thanks, \n"); + printf(" the Omega Team \n"); + } + anyTimingDone = true; + delete $2; +#endif + } + | TIMECLOSURE relation ';' { +#if defined(OMIT_GETRUSAGE) + printf("'timeclosure' requires getrusage, but the omega calclator was compiled with OMIT_GETRUSAGE set!\n"); +#else + flushScanBuffer(); + try { + int t; + Relation R; + ($2)->and_with_GEQ(); + start_clock(); + for (t=1;t<=100;t++) { + R = *$2; + R.finalize(); + } + int copyTime = clock_diff(); + start_clock(); + for (t=1;t<=100;t++) { + R = *$2; + R.finalize(); + R.simplify(); + } + int simplifyTime = clock_diff() -copyTime; + Relation Rclosed; + start_clock(); + for (t=1;t<=100;t++) { + Rclosed = *$2; + Rclosed.finalize(); + Rclosed = TransitiveClosure(Rclosed, 1,Relation::Null()); + } + int closureTime = clock_diff() - copyTime; + Relation R2; + start_clock(); + for (t=1;t<=100;t++) { + R2 = *$2; + R2.finalize(); + R2.simplify(2,4); + } + int excessiveTime = clock_diff() - copyTime; + printf("Times (in microseconds): \n"); + printf("%5d us to copy original set of constraints\n",copyTime/100); + printf("%5d us to do the default amount of simplification, obtaining: \n\t", simplifyTime/100); + R.print_with_subs(stdout); + printf("\n"); + printf("%5d us to do the maximum (i.e., excessive) amount of simplification, obtaining: \n\t", excessiveTime/100); + R2.print_with_subs(stdout); + printf("%5d us to do the transitive closure, obtaining: \n\t", closureTime/100); + Rclosed.print_with_subs(stdout); + printf("\n"); + if (!anyTimingDone) { + bool warn = false; +#ifndef SPEED + warn =true; +#endif +#ifndef NDEBUG + warn = true; +#endif + if (warn) { + printf("WARNING: The Omega calculator was compiled with options that force\n"); + printf("it to perform additional consistency and error checks\n"); + printf("that may slow it down substantially\n"); + printf("\n"); + } + printf("NOTE: These times relect the time of the current _implementation_\n"); + printf("of our algorithms. Performance bugs do exist. If you intend to publish or \n"); + printf("report on the performance on the Omega test, we respectfully but strongly \n"); + printf("request that send your test cases to us to allow us to determine if the \n"); + printf("times are appropriate, and if the way you are using the Omega library to \n"); + printf("solve your problem is the most effective way.\n"); + printf("\n"); + + printf("Also, please be aware that over the past two years, we have focused our \n"); + printf("efforts on the expressive power of the Omega library, sometimes at the\n"); + printf("expensive of raw speed. Our original implementation of the Omega test\n"); + printf("was substantially faster on the limited domain it handled.\n"); + printf("\n"); + printf(" Thanks, \n"); + printf(" the Omega Team \n"); + } + anyTimingDone = true; + } + catch (const std::exception &e) { + std::cout << e.what() << std::endl; + } + delete $2; +#endif + } + | relation SUBSET relation ';' { + flushScanBuffer(); + try { + if (Must_Be_Subset(copy(*$1), copy(*$3))) + std::cout << "True" << std::endl; + else if (Might_Be_Subset(copy(*$1), copy(*$3))) + std::cout << "Possible" << std::endl; + else + std::cout << "False" << std::endl; + } + catch (const std::exception &e) { + std::cout << e.what() << std::endl; + } + delete $1; + delete $3; + } + | CODEGEN relPairList context';' { + flushScanBuffer(); +#ifdef BUILD_CODEGEN + try { + CodeGen cg($2->first, $2->second, *$3); + CG_result *cgr = cg.buildAST(); + if (cgr != NULL) { + std::string s = cgr->printString(); + std::cout << s << std::endl; + delete cgr; + } + else + std::cout << "/* empty */" << std::endl; + } + catch (const std::exception &e) { + std::cout << e.what() << std::endl; + } +#else + std::cout << "CodeGen package not built" << std::endl; +#endif + delete $3; + delete $2; + } + | CODEGEN INT relPairList context';' { + flushScanBuffer(); +#ifdef BUILD_CODEGEN + try { + CodeGen cg($3->first, $3->second, *$4); + CG_result *cgr = cg.buildAST($2); + if (cgr != NULL) { + std::string s = cgr->printString(); + std::cout << s << std::endl; + delete cgr; + } + else + std::cout << "/* empty */" << std::endl; + } + catch (const std::exception &e) { + std::cout << e.what() << std::endl; + } +#else + std::cout << "CodeGen package not built" << std::endl; +#endif + delete $4; + delete $3; + } + | reachable ';' { + flushScanBuffer(); + Dynamic_Array1<Relation> &final = *$1; + bool any_sat = false; + int i,n_nodes = reachable_info->node_names.size(); + for(i = 1; i <= n_nodes; i++) + if(final[i].is_upper_bound_satisfiable()) { + any_sat = true; + std::cout << "Node " << reachable_info->node_names[i] << ": "; + final[i].print_with_subs(stdout); + } + if(!any_sat) + std::cout << "No nodes reachable.\n"; + delete $1; + delete reachable_info; + } +; + + +context : {$$ = new Relation(); *$$ = Relation::Null();} + | GIVEN relation {$$ = $2; } +; + +relPairList : relPairList ',' relation ':' relation { + try { + $1->first.push_back(*$3); + $1->second.push_back(*$5); + } + catch (const std::exception &e) { + delete $1; + delete $3; + delete $5; + yyerror(e.what()); + YYERROR; + } + delete $3; + delete $5; + $$ = $1; + } + | relPairList ',' relation { + try { + $1->first.push_back(Identity($3->n_set())); + $1->second.push_back(*$3); + } + catch (const std::exception &e) { + delete $1; + delete $3; + yyerror(e.what()); + YYERROR; + } + delete $3; + $$ = $1; + } + | relation ':' relation { + std::pair<std::vector<Relation>, std::vector<Relation> > *rtp = new std::pair<std::vector<Relation>, std::vector<Relation> >(); + try { + rtp->first.push_back(*$1); + rtp->second.push_back(*$3); + } + catch (const std::exception &e) { + delete rtp; + delete $1; + delete $3; + yyerror(e.what()); + YYERROR; + } + delete $1; + delete $3; + $$ = rtp; + } + | relation { + std::pair<std::vector<Relation>, std::vector<Relation> > *rtp = new std::pair<std::vector<Relation>, std::vector<Relation> >(); + try { + rtp->first.push_back(Identity($1->n_set())); + rtp->second.push_back(*$1); + } + catch (const std::exception &e) { + delete rtp; + delete $1; + yyerror(e.what()); + YYERROR; + } + delete $1; + $$ = rtp; + } +; + +relation : OPEN_BRACE {need_coef = true; relationDecl = new Declaration_Site();} + builtRelation CLOSE_BRACE { + need_coef = false; + $$ = $3; + current_Declaration_Site = globalDecls; + delete relationDecl; + relationDecl = NULL; + } + | VAR { + Relation *r = relationMap[std::string($1)]; + if (r == NULL) { + yyerror(std::string("relation ") + to_string($1) + std::string(" not declared")); + delete []$1; + YYERROR; + } + $$ = new Relation(*r); + delete []$1; + } + | '(' relation ')' {$$ = $2;} + | relation '+' %prec p9 { + $$ = new Relation(); + try { + *$$ = TransitiveClosure(*$1, 1, Relation::Null()); + } + catch (const std::exception &e) { + delete $$; + delete $1; + yyerror(e.what()); + YYERROR; + } + delete $1; + } + | relation '*' %prec p9 { + $$ = new Relation(); + try { + int vars = $1->n_inp(); + *$$ = Union(Identity(vars), TransitiveClosure(*$1, 1, Relation::Null())); + } + catch (const std::exception &e) { + delete $$; + delete $1; + yyerror(e.what()); + YYERROR; + } + delete $1; + } + | relation '+' WITHIN relation %prec p9 { + $$ = new Relation(); + try { + *$$= TransitiveClosure(*$1, 1, *$4); + } + catch (const std::exception &e) { + delete $$; + delete $1; + delete $4; + yyerror(e.what()); + YYERROR; + } + delete $1; + delete $4; + } + | relation '^' '@' %prec p8 { + $$ = new Relation(); + try { + *$$ = ApproxClosure(*$1); + } + catch (const std::exception &e) { + delete $$; + delete $1; + yyerror(e.what()); + YYERROR; + } + delete $1; + } + | relation '^' '+' %prec p8 { + $$ = new Relation(); + try { + *$$ = calculateTransitiveClosure(*$1); + } + catch (const std::exception &e) { + delete $$; + delete $1; + yyerror(e.what()); + YYERROR; + } + delete $1; + } + | MINIMIZE_RANGE relation %prec p8 { + $$ = new Relation(); + try { + Relation o(*$2); + Relation r(*$2); + r = Join(r,LexForward($2->n_out())); + *$$ = Difference(o,r); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | MAXIMIZE_RANGE relation %prec p8 { + $$ = new Relation(); + try { + Relation o(*$2); + Relation r(*$2); + r = Join(r,Inverse(LexForward($2->n_out()))); + *$$ = Difference(o,r); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | MINIMIZE_DOMAIN relation %prec p8 { + $$ = new Relation(); + try { + Relation o(*$2); + Relation r(*$2); + r = Join(LexForward($2->n_inp()),r); + *$$ = Difference(o,r); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | MAXIMIZE_DOMAIN relation %prec p8 { + $$ = new Relation(); + try { + Relation o(*$2); + Relation r(*$2); + r = Join(Inverse(LexForward($2->n_inp())),r); + *$$ = Difference(o,r); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | MAXIMIZE relation %prec p8 { + $$ = new Relation(); + try { + Relation c(*$2); + Relation r(*$2); + *$$ = Cross_Product(Relation(*$2),c); + *$$ = Difference(r,Domain(Intersection(*$$,LexForward($$->n_inp())))); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | MINIMIZE relation %prec p8 { + $$ = new Relation(); + try { + Relation c(*$2); + Relation r(*$2); + *$$ = Cross_Product(Relation(*$2),c); + *$$ = Difference(r,Range(Intersection(*$$,LexForward($$->n_inp())))); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | FARKAS relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Farkas(*$2, Basic_Farkas); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | DECOUPLED_FARKAS relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Farkas(*$2, Decoupled_Farkas); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | relation '@' %prec p9 { + $$ = new Relation(); + try { + *$$ = ConicClosure(*$1); + } + catch (const std::exception &e) { + delete $$; + delete $1; + yyerror(e.what()); + YYERROR; + } + delete $1; + } + | PROJECT_AWAY_SYMBOLS relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Project_Sym(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | PROJECT_ON_SYMBOLS relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Project_On_Sym(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | DIFFERENCE relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Deltas(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | DIFFERENCE_TO_RELATION relation %prec p8 { + $$ = new Relation(); + try { + *$$ = DeltasToRelation(*$2,$2->n_set(),$2->n_set()); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | DOMAIN relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Domain(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | VENN relation %prec p8 { + $$ = new Relation(); + try { + *$$ = VennDiagramForm(*$2,Relation::True(*$2)); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | VENN relation GIVEN relation %prec p8 { + $$ = new Relation(); + try { + *$$ = VennDiagramForm(*$2,*$4); + } + catch (const std::exception &e) { + delete $$; + delete $2; + delete $4; + yyerror(e.what()); + YYERROR; + } + delete $2; + delete $4; + } + | CONVEX_HULL relation %prec p8 { + $$ = new Relation(); + try { + *$$ = ConvexHull(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | DECOUPLED_CONVEX_HULL relation %prec p8 { + $$ = new Relation(); + try { + *$$ = DecoupledConvexHull(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | POSITIVE_COMBINATION relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Farkas(*$2,Positive_Combination_Farkas); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | LINEAR_COMBINATION relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Farkas(*$2,Linear_Combination_Farkas); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | AFFINE_COMBINATION relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Farkas(*$2,Affine_Combination_Farkas); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | CONVEX_COMBINATION relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Farkas(*$2,Convex_Combination_Farkas); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | PAIRWISE_CHECK relation %prec p8 { + $$ = new Relation(); + try { + *$$ = CheckForConvexRepresentation(CheckForConvexPairs(*$2)); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | CONVEX_CHECK relation %prec p8 { + $$ = new Relation(); + try { + *$$ = CheckForConvexRepresentation(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | CONVEX_REPRESENTATION relation %prec p8 { + $$ = new Relation(); + try { + *$$ = ConvexRepresentation(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | AFFINE_HULL relation %prec p8 { + $$ = new Relation(); + try { + *$$ = AffineHull(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | CONIC_HULL relation %prec p8 { + $$ = new Relation(); + try { + *$$ = ConicHull(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | LINEAR_HULL relation %prec p8 { + $$ = new Relation(); + try { + *$$ = LinearHull(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | QUICK_HULL relation %prec p8 { + $$ = new Relation(); + try { + *$$ = QuickHull(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | RECT_HULL relation %prec p8 { + $$ = new Relation(); + try { + *$$ = RectHull(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | SIMPLE_HULL relation %prec p8 { + $$ = new Relation(); + try { + *$$ = SimpleHull(*$2, true, true); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | HULL relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Hull(*$2,true,1,Relation::Null()); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | HULL relation GIVEN relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Hull(*$2,true,1,*$4); + } + catch (const std::exception &e) { + delete $$; + delete $2; + delete $4; + yyerror(e.what()); + YYERROR; + } + delete $2; + delete $4; + } + | APPROX relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Approximate(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | RANGE relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Range(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | INVERSE relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Inverse(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | COMPLEMENT relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Complement(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | GIST relation GIVEN relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Gist(*$2,*$4,1); + } + catch (const std::exception &e) { + delete $$; + delete $2; + delete $4; + yyerror(e.what()); + YYERROR; + } + delete $2; + delete $4; + } + | relation '(' relation ')' { + $$ = new Relation(); + try { + *$$ = Composition(*$1,*$3); + } + catch (const std::exception &e) { + delete $$; + delete $1; + delete $3; + yyerror(e.what()); + YYERROR; + } + delete $1; + delete $3; + } + | relation COMPOSE relation { + $$ = new Relation(); + try { + *$$ = Composition(*$1,*$3); + } + catch (const std::exception &e) { + delete $$; + delete $1; + delete $3; + yyerror(e.what()); + YYERROR; + } + delete $1; + delete $3; + } + | relation CARRIED_BY INT { + $$ = new Relation(); + try { + *$$ = After(*$1,$3,$3); + (*$$).prefix_print(stdout); + } + catch (const std::exception &e) { + delete $$; + delete $1; + yyerror(e.what()); + YYERROR; + } + delete $1; + } + | relation JOIN relation { + $$ = new Relation(); + try { + *$$ = Composition(*$3,*$1); + } + catch (const std::exception &e) { + delete $$; + delete $1; + delete $3; + yyerror(e.what()); + YYERROR; + } + delete $1; + delete $3; + } + | relation RESTRICT_RANGE relation { + $$ = new Relation(); + try { + *$$ = Restrict_Range(*$1,*$3); + } + catch (const std::exception &e) { + delete $$; + delete $1; + delete $3; + yyerror(e.what()); + YYERROR; + } + delete $1; + delete $3; + } + | relation RESTRICT_DOMAIN relation { + $$ = new Relation(); + try { + *$$ = Restrict_Domain(*$1,*$3); + } + catch (const std::exception &e) { + delete $$; + delete $1; + delete $3; + yyerror(e.what()); + YYERROR; + } + delete $1; + delete $3; + } + | relation INTERSECTION relation { + $$ = new Relation(); + try { + *$$ = Intersection(*$1,*$3); + } + catch (const std::exception &e) { + delete $$; + delete $1; + delete $3; + yyerror(e.what()); + YYERROR; + } + delete $1; + delete $3; + } + | relation '-' relation %prec INTERSECTION { + $$ = new Relation(); + try { + *$$ = Difference(*$1,*$3); + } + catch (const std::exception &e) { + delete $$; + delete $1; + delete $3; + yyerror(e.what()); + YYERROR; + } + delete $1; + delete $3; + } + | relation UNION relation { + $$ = new Relation(); + try { + *$$ = Union(*$1,*$3); + } + catch (const std::exception &e) { + delete $$; + delete $1; + delete $3; + yyerror(e.what()); + YYERROR; + } + delete $1; + delete $3; + } + | relation '*' relation { + $$ = new Relation(); + try { + *$$ = Cross_Product(*$1,*$3); + } + catch (const std::exception &e) { + delete $$; + delete $1; + delete $3; + yyerror(e.what()); + YYERROR; + } + delete $1; + delete $3; + } + | SUPERSETOF relation { + $$ = new Relation(); + try { + *$$ = Union(*$2, Relation::Unknown(*$2)); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | SUBSETOF relation { + $$ = new Relation(); + try { + *$$ = Intersection(*$2, Relation::Unknown(*$2)); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | MAKE_UPPER_BOUND relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Upper_Bound(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | MAKE_LOWER_BOUND relation %prec p8 { + $$ = new Relation(); + try { + *$$ = Lower_Bound(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | SAMPLE relation { + $$ = new Relation(); + try { + *$$ = Sample_Solution(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | SYM_SAMPLE relation { + $$ = new Relation(); + try { + *$$ = Symbolic_Solution(*$2); + } + catch (const std::exception &e) { + delete $$; + delete $2; + yyerror(e.what()); + YYERROR; + } + delete $2; + } + | reachable_of { $$ = $1; } + | ASSERT_UNSAT relation { + if (($2)->is_satisfiable()) { + fprintf(stderr,"assert_unsatisfiable failed on "); + ($2)->print_with_subs(stderr); + exit(1); + } + $$=$2; + } +; + +builtRelation : tupleDeclaration GOES_TO {currentTuple = Output_Tuple;} + tupleDeclaration {currentTuple = Input_Tuple;} optionalFormula { + Relation * r = new Relation($1->size,$4->size); + resetGlobals(); + F_And *f = r->add_and(); + for(int i = 1; i <= $1->size; i++) { + $1->vars[i-1]->vid = r->input_var(i); + if (!$1->vars[i-1]->anonymous) + r->name_input_var(i, $1->vars[i-1]->stripped_name); + } + for(int i = 1; i <= $4->size; i++) { + $4->vars[i-1]->vid = r->output_var(i); + if (!$4->vars[i-1]->anonymous) + r->name_output_var(i, $4->vars[i-1]->stripped_name); + } + r->setup_names(); + for (std::set<Exp *>::iterator i = $1->eq_constraints.begin(); i != $1->eq_constraints.end(); i++) + install_eq(f, *i, 0); + for (std::set<Exp *>::iterator i = $1->geq_constraints.begin(); i != $1->geq_constraints.end(); i++) + install_geq(f, *i, 0); + for (std::set<strideConstraint *>::iterator i = $1->stride_constraints.begin(); i != $1->stride_constraints.end(); i++) + install_stride(f, *i); + for (std::set<Exp *>::iterator i = $4->eq_constraints.begin(); i != $4->eq_constraints.end(); i++) + install_eq(f, *i, 0); + for (std::set<Exp *>::iterator i = $4->geq_constraints.begin(); i != $4->geq_constraints.end(); i++) + install_geq(f, *i, 0); + for (std::set<strideConstraint *>::iterator i = $4->stride_constraints.begin(); i != $4->stride_constraints.end(); i++) + install_stride(f, *i); + if ($6) $6->install(f); + delete $1; + delete $4; + delete $6; + $$ = r; + } + | tupleDeclaration optionalFormula { + Relation * r = new Relation($1->size); + resetGlobals(); + F_And *f = r->add_and(); + for(int i = 1; i <= $1->size; i++) { + $1->vars[i-1]->vid = r->set_var(i); + if (!$1->vars[i-1]->anonymous) + r->name_set_var(i, $1->vars[i-1]->stripped_name); + } + r->setup_names(); + for (std::set<Exp *>::iterator i = $1->eq_constraints.begin(); i != $1->eq_constraints.end(); i++) + install_eq(f, *i, 0); + for (std::set<Exp *>::iterator i = $1->geq_constraints.begin(); i != $1->geq_constraints.end(); i++) + install_geq(f, *i, 0); + for (std::set<strideConstraint *>::iterator i = $1->stride_constraints.begin(); i != $1->stride_constraints.end(); i++) + install_stride(f, *i); + if ($2) $2->install(f); + delete $1; + delete $2; + $$ = r; + } + | formula { + Relation * r = new Relation(0,0); + F_And *f = r->add_and(); + $1->install(f); + delete $1; + $$ = r; + } +; + +optionalFormula : formula_sep formula {$$ = $2;} + | {$$ = 0;} +; + +formula_sep : ':' + | VERTICAL_BAR + | SUCH_THAT +; + +tupleDeclaration : {currentTupleDescriptor = new tupleDescriptor; tuplePos = 1;} + '[' optionalTupleVarList ']' + {$$ = currentTupleDescriptor; tuplePos = 0;} +; + +optionalTupleVarList : /* empty */ + | tupleVar + | optionalTupleVarList ',' tupleVar +; + +tupleVar : VAR %prec p10 { + Declaration_Site *ds = defined($1); + if (!ds) + currentTupleDescriptor->extend($1,currentTuple,tuplePos); + else { + Variable_Ref *v = lookupScalar($1); + if (v == NULL) { + yyerror(std::string("cannot find declaration for variable ") + to_string($1)); + delete []$1; + YYERROR; + } + if (ds != globalDecls) + currentTupleDescriptor->extend($1, new Exp(v)); + else + currentTupleDescriptor->extend(new Exp(v)); + } + tuplePos++; + delete []$1; + } + | '*' {currentTupleDescriptor->extend(); tuplePos++;} + | exp %prec p1 { + currentTupleDescriptor->extend($1); + tuplePos++; + } + | exp ':' exp %prec p1 { + currentTupleDescriptor->extend($1,$3); + tuplePos++; + } + | exp ':' exp ':' COEF %prec p1 { + currentTupleDescriptor->extend($1,$3,$5); + tuplePos++; + } +; + +varList : varList ',' VAR {$$ = $1; $$->insert($3); $3 = NULL;} + | VAR {$$ = new std::set<char *>(); $$->insert($1); $1 = NULL;} +; + +varDecl : varList { + $$ = current_Declaration_Site = new Declaration_Site($1); + for (std::set<char *>::iterator i = $1->begin(); i != $1->end(); i++) + delete [](*i); + delete $1; + } +; + +varDeclOptBrackets : varDecl {$$ = $1;} + |'[' varDecl ']' {$$ = $2;} +; + +globVarList : globVarList ',' globVar + | globVar +; + +globVar : VAR '(' INT ')' {globalDecls->extend_both_tuples($1, $3); delete []$1;} + | VAR { + globalDecls->extend($1); + delete []$1; + } +; + +formula : formula AND formula {$$ = new AST_And($1,$3);} + | formula OR formula {$$ = new AST_Or($1,$3);} + | constraintChain {$$ = $1;} + | '(' formula ')' {$$ = $2;} + | NOT formula {$$ = new AST_Not($2);} + | start_exists varDeclOptBrackets exists_sep formula end_quant {$$ = new AST_exists($2,$4);} + | start_forall varDeclOptBrackets forall_sep formula end_quant {$$ = new AST_forall($2,$4);} +; + +start_exists : '(' EXISTS + | EXISTS '(' +; + +exists_sep : ':' + | VERTICAL_BAR + | SUCH_THAT +; + +start_forall : '(' FORALL + | FORALL '(' +; + +forall_sep : ':' +; + +end_quant : ')' {popScope();} +; + +expList : exp ',' expList {$$ = $3; $$->insert($1);} + | exp {$$ = new std::set<Exp *>(); $$->insert($1);} +; + +constraintChain : expList REL_OP expList {$$ = new AST_constraints($1,$2,$3);} + | expList REL_OP constraintChain {$$ = new AST_constraints($1,$2,$3);} +; + +simpleExp : VAR %prec p9 { + Variable_Ref *v = lookupScalar($1); + if (v == NULL) { + yyerror(std::string("cannot find declaration for variable ") + to_string($1)); + delete []$1; + YYERROR; + } + $$ = new Exp(v); + delete []$1; + } + | VAR '(' {argCount = 1;} argumentList ')' %prec p9 { + Variable_Ref *v; + if ($4 == Input_Tuple) + v = functionOfInput[$1]; + else + v = functionOfOutput[$1]; + if (v == NULL) { + yyerror(std::string("Function ") + to_string($1) + std::string(" not declared")); + delete []$1; + YYERROR; + } + $$ = new Exp(v); + delete []$1; + } + | '(' exp ')' { $$ = $2; } +; + +argumentList : argumentList ',' VAR { + Variable_Ref *v = lookupScalar($3); + if (v == NULL) { + yyerror(std::string("cannot find declaration for variable ") + to_string($1)); + delete []$3; + YYERROR; + } + if (v->pos != argCount || v->of != $1 || (v->of != Input_Tuple && v->of != Output_Tuple)) { + yyerror("arguments to function must be prefix of input or output tuple"); + delete []$3; + YYERROR; + } + $$ = v->of; + argCount++; + delete []$3; + } + | VAR { + Variable_Ref *v = lookupScalar($1); + if (v == NULL) { + yyerror(std::string("cannot find declaration for variable ") + to_string($1)); + delete []$1; + YYERROR; + } + if (v->pos != argCount || (v->of != Input_Tuple && v->of != Output_Tuple)) { + yyerror("arguments to function must be prefix of input or output tuple"); + delete []$1; + YYERROR; + } + $$ = v->of; + argCount++; + delete []$1; + } +; + +exp : COEF {$$ = new Exp($1);} + | COEF simpleExp %prec '*' {$$ = multiply($1,$2);} + | simpleExp {$$ = $1; } + | '-' exp %prec '*' {$$ = negate($2);} + | exp '+' exp {$$ = add($1,$3);} + | exp '-' exp {$$ = subtract($1,$3);} + | exp '*' exp { + try { + $$ = multiply($1,$3); + } + catch (const std::exception &e) { + yyerror(e.what()); + YYERROR; + } + } +; + + +reachable : REACHABLE_FROM nodeNameList nodeSpecificationList { + Dynamic_Array1<Relation> *final = Reachable_Nodes(reachable_info); + $$ = final; + } +; + +reachable_of : REACHABLE_OF VAR IN nodeNameList nodeSpecificationList { + Dynamic_Array1<Relation> *final = Reachable_Nodes(reachable_info); + int index = reachable_info->node_names.index(std::string($2)); + if (index == 0) { + yyerror(std::string("no such node ") + to_string($2)); + delete []$2; + delete final; + delete reachable_info; + YYERROR; + } + $$ = new Relation; + *$$ = (*final)[index]; + delete final; + delete reachable_info; + delete []$2; + } +; + +nodeNameList : '(' realNodeNameList ')' { + int sz = reachable_info->node_names.size(); + reachable_info->node_arity.reallocate(sz); + reachable_info->transitions.resize(sz+1,sz+1); + reachable_info->start_nodes.resize(sz+1); + } +; + +realNodeNameList : realNodeNameList ',' VAR { + reachable_info->node_names.append(std::string($3)); + delete []$3; + } + | VAR { + reachable_info = new reachable_information; + reachable_info->node_names.append(std::string($1)); + delete []$1; + } +; + + +nodeSpecificationList : OPEN_BRACE realNodeSpecificationList CLOSE_BRACE { + int i,j; + int n_nodes = reachable_info->node_names.size(); + Tuple<int> &arity = reachable_info->node_arity; + Dynamic_Array2<Relation> &transitions = reachable_info->transitions; + + /* fixup unspecified transitions to be false */ + /* find arity */ + for(i = 1; i <= n_nodes; i++) arity[i] = -1; + for(i = 1; i <= n_nodes; i++) + for(j = 1; j <= n_nodes; j++) + if(! transitions[i][j].is_null()) { + int in_arity = transitions[i][j].n_inp(); + int out_arity = transitions[i][j].n_out(); + if(arity[i] < 0) arity[i] = in_arity; + if(arity[j] < 0) arity[j] = out_arity; + if(in_arity != arity[i] || out_arity != arity[j]) { + yyerror(std::string("arity mismatch in node transition: ") + to_string(reachable_info->node_names[i]) + std::string(" -> ") + to_string(reachable_info->node_names[j])); + delete reachable_info; + YYERROR; + } + } + for(i = 1; i <= n_nodes; i++) + if(arity[i] < 0) arity[i] = 0; + /* Fill in false relations */ + for(i = 1; i <= n_nodes; i++) + for(j = 1; j <= n_nodes; j++) + if(transitions[i][j].is_null()) + transitions[i][j] = Relation::False(arity[i],arity[j]); + + /* fixup unused start node positions */ + Dynamic_Array1<Relation> &nodes = reachable_info->start_nodes; + for(i = 1; i <= n_nodes; i++) + if(nodes[i].is_null()) + nodes[i] = Relation::False(arity[i]); + else + if(nodes[i].n_set() != arity[i]){ + yyerror(std::string("arity mismatch in start node ") + to_string(reachable_info->node_names[i])); + delete reachable_info; + YYERROR; + } + } +; + +realNodeSpecificationList : realNodeSpecificationList ',' VAR ':' relation { + int n_nodes = reachable_info->node_names.size(); + int index = reachable_info->node_names.index($3); + if (!(index > 0 && index <= n_nodes)) { + yyerror(std::string("no such node ")+to_string($3)); + delete $5; + delete []$3; + delete reachable_info; + YYERROR; + } + reachable_info->start_nodes[index] = *$5; + delete $5; + delete []$3; + } + | realNodeSpecificationList ',' VAR GOES_TO VAR ':' relation { + int n_nodes = reachable_info->node_names.size(); + int from_index = reachable_info->node_names.index($3); + if (!(from_index > 0 && from_index <= n_nodes)) { + yyerror(std::string("no such node ")+to_string($3)); + delete $7; + delete []$3; + delete []$5; + delete reachable_info; + YYERROR; + } + int to_index = reachable_info->node_names.index($5); + if (!(to_index > 0 && to_index <= n_nodes)) { + yyerror(std::string("no such node ")+to_string($5)); + delete $7; + delete []$3; + delete []$5; + delete reachable_info; + YYERROR; + } + reachable_info->transitions[from_index][to_index] = *$7; + delete $7; + delete []$3; + delete []$5; + } + | VAR GOES_TO VAR ':' relation { + int n_nodes = reachable_info->node_names.size(); + int from_index = reachable_info->node_names.index($1); + if (!(from_index > 0 && from_index <= n_nodes)) { + yyerror(std::string("no such node ")+to_string($1)); + delete $5; + delete []$1; + delete []$3; + delete reachable_info; + YYERROR; + } + int to_index = reachable_info->node_names.index($3); + if (!(to_index > 0 && to_index <= n_nodes)) { + yyerror(std::string("no such node ")+to_string($3)); + delete $5; + delete []$1; + delete []$3; + delete reachable_info; + YYERROR; + } + reachable_info->transitions[from_index][to_index] = *$5; + delete $5; + delete []$1; + delete []$3; + } + | VAR ':' relation { + int n_nodes = reachable_info->node_names.size(); + int index = reachable_info->node_names.index($1); + if (!(index > 0 && index <= n_nodes)) { + yyerror(std::string("no such node ")+to_string($1)); + delete $3; + delete []$1; + delete reachable_info; + YYERROR; + } + reachable_info->start_nodes[index] = *$3; + delete $3; + delete []$1; + } +; + +%% + +void yyerror(const std::string &s) { + std::stringstream ss; + if (is_interactive) + ss << s << "\n"; + else + ss << s << " at line " << mylexer.lineno() << "\n"; + err_msg = ss.str(); +} + + +int main(int argc, char **argv) { + if (argc > 2){ + fprintf(stderr, "Usage: %s [script_file]\n", argv[0]); + exit(1); + } + + if (argc == 2) { + std::ifstream *ifs = new std::ifstream; + ifs->open(argv[1], std::ifstream::in); + if (!ifs->is_open()) { + fprintf(stderr, "can't open input file %s\n", argv[1]); + exit(1); + } + yy_buffer_state *bs = mylexer.yy_create_buffer(ifs, 8092); + mylexer.yypush_buffer_state(bs); + } + + //yydebug = 1; + is_interactive = false; + if (argc == 1) { +#if defined __USE_POSIX + if (isatty((int)fileno(stdin))) + is_interactive = true; +#elif defined __WIN32 + if (_isatty(_fileno(stdin))) + is_interactive = true; +#endif + } + + if (is_interactive) { +#ifdef BUILD_CODEGEN + std::cout << "Omega+ and CodeGen+ "; +#else + std::cout << "Omega+ "; +#endif + std::cout << "v2.2.3 (built on " OMEGA_BUILD_DATE ")" << std::endl; + std::cout << "Copyright (C) 1994-2000 the Omega Project Team" << std::endl; + std::cout << "Copyright (C) 2005-2011 Chun Chen" << std::endl; + std::cout << "Copyright (C) 2011-2012 University of Utah" << std::endl; + std::cout << PROMPT_STRING << ' '; + std::cout.flush(); + } + + need_coef = false; + current_Declaration_Site = globalDecls = new Global_Declaration_Site(); + + if (yyparse() != 0) { + if (!is_interactive) + std::cout << "syntax error at the end of the file, missing ';'" << std::endl; + else + std::cout << std::endl; + delete relationDecl; + relationDecl = NULL; + } + else { + if (is_interactive) + std::cout << std::endl; + } + + for (std::map<std::string, Relation *>::iterator i = relationMap.begin(); i != relationMap.end(); i++) + delete (*i).second; + delete globalDecls; + + return 0; +} + +Relation LexForward(int n) { + Relation r(n,n); + F_Or *f = r.add_or(); + for (int i=1; i <= n; i++) { + F_And *g = f->add_and(); + for(int j=1;j<i;j++) { + EQ_Handle e = g->add_EQ(); + e.update_coef(r.input_var(j),-1); + e.update_coef(r.output_var(j),1); + e.finalize(); + } + GEQ_Handle e = g->add_GEQ(); + e.update_coef(r.input_var(i),-1); + e.update_coef(r.output_var(i),1); + e.update_const(-1); + e.finalize(); + } + r.finalize(); + return r; +} |