aboutsummaryrefslogtreecommitdiffstats
path: root/moon-abe/pbc-0.5.14/pbc
diff options
context:
space:
mode:
Diffstat (limited to 'moon-abe/pbc-0.5.14/pbc')
-rw-r--r--moon-abe/pbc-0.5.14/pbc/.dirstamp0
-rwxr-xr-xmoon-abe/pbc-0.5.14/pbc/.libs/pbcbin0 -> 63516 bytes
-rw-r--r--moon-abe/pbc-0.5.14/pbc/bilinear.test50
-rw-r--r--moon-abe/pbc-0.5.14/pbc/g2_test.pbc37
-rw-r--r--moon-abe/pbc-0.5.14/pbc/lex.yy.c1923
-rw-r--r--moon-abe/pbc-0.5.14/pbc/lex.yy.h333
-rw-r--r--moon-abe/pbc-0.5.14/pbc/oldpbc.c1221
-rw-r--r--moon-abe/pbc-0.5.14/pbc/pairing_test.pbc21
-rw-r--r--moon-abe/pbc-0.5.14/pbc/parser.lex56
-rw-r--r--moon-abe/pbc-0.5.14/pbc/parser.tab.c1906
-rw-r--r--moon-abe/pbc-0.5.14/pbc/parser.tab.h82
-rw-r--r--moon-abe/pbc-0.5.14/pbc/parser.y112
-rwxr-xr-xmoon-abe/pbc-0.5.14/pbc/pbc228
-rw-r--r--moon-abe/pbc-0.5.14/pbc/pbc.c953
-rw-r--r--moon-abe/pbc-0.5.14/pbc/pbc_getline.c17
-rw-r--r--moon-abe/pbc-0.5.14/pbc/pbc_getline.readline.c10
-rw-r--r--moon-abe/pbc-0.5.14/pbc/pbc_tree.h30
17 files changed, 6979 insertions, 0 deletions
diff --git a/moon-abe/pbc-0.5.14/pbc/.dirstamp b/moon-abe/pbc-0.5.14/pbc/.dirstamp
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/moon-abe/pbc-0.5.14/pbc/.dirstamp
diff --git a/moon-abe/pbc-0.5.14/pbc/.libs/pbc b/moon-abe/pbc-0.5.14/pbc/.libs/pbc
new file mode 100755
index 00000000..a8120f82
--- /dev/null
+++ b/moon-abe/pbc-0.5.14/pbc/.libs/pbc
Binary files differ
diff --git a/moon-abe/pbc-0.5.14/pbc/bilinear.test b/moon-abe/pbc-0.5.14/pbc/bilinear.test
new file mode 100644
index 00000000..956c792e
--- /dev/null
+++ b/moon-abe/pbc-0.5.14/pbc/bilinear.test
@@ -0,0 +1,50 @@
+define test_element_order(group) {
+ a := random(group);
+ o := order(group);
+ b := a^o;
+ CHECK(b == group(0));
+}
+
+define test_group_order() {
+ CHECK(order(G1) == order(G2));
+ CHECK(order(G2) == order(GT));
+ a := pairing(random(G1), random(G2));
+ o := order(GT);
+ b := a^o;
+ CHECK(b == GT(0));
+}
+
+define test_pairing_with_zero() {
+ CHECK(GT(0) == GT(1));
+ CHECK(pairing(G1(0), random(G2)) == GT(0));
+ CHECK(pairing(random(G1), G2(0)) == GT(0));
+ CHECK(pairing(G1(0), G2(0)) == GT(0));
+}
+
+define test_bilinear() {
+ a1 := random(G1);
+ b1 := random(G2);
+ x := random(Zr);
+ y := random(Zr);
+ CHECK(pairing(a1^x, b1) == pairing(a1, b1^x));
+ CHECK(pairing(a1^x, b1) == pairing(a1, b1)^x);
+ CHECK(pairing(a1, b1^x) == pairing(a1, b1)^x);
+ CHECK(pairing(a1^x, b1^y) == pairing(a1, b1)^(x*y));
+}
+
+define test(initfn) {
+ initfn();
+ test_element_order(G1);
+ test_element_order(G2);
+ test_element_order(GT);
+ test_group_order();
+ test_pairing_with_zero();
+ test_bilinear();
+}
+
+test(init_pairing_a);
+test(init_pairing_d);
+test(init_pairing_e);
+test(init_pairing_f);
+test(init_pairing_g);
+test(init_pairing_i);
diff --git a/moon-abe/pbc-0.5.14/pbc/g2_test.pbc b/moon-abe/pbc-0.5.14/pbc/g2_test.pbc
new file mode 100644
index 00000000..892660f9
--- /dev/null
+++ b/moon-abe/pbc-0.5.14/pbc/g2_test.pbc
@@ -0,0 +1,37 @@
+# Exercises a bug found by Zhang Ye.
+
+define test_cmp_0(initfn) {
+ initfn();
+ CHECK(random(G2) != G2(0));
+ CHECK(G2(0) != random(G2));
+ CHECK(G2(0) == G2(0));
+ CHECK(random(G1) != G1(0));
+ CHECK(G1(0) != random(G1));
+ CHECK(G1(0) == G1(0));
+}
+
+test_cmp_0(init_pairing_a);
+test_cmp_0(init_pairing_d);
+test_cmp_0(init_pairing_e);
+test_cmp_0(init_pairing_f);
+test_cmp_0(init_pairing_g);
+test_cmp_0(init_pairing_i);
+
+# Exercises a bug found by Mario Di Raimondo.
+
+define test_g2_cmp(initfn) {
+ initfn();
+ a := rnd(G2);
+ m := rnd(Zr);
+ n := rnd(Zr);
+ CHECK((a^m)^n == a^(m*n));
+ CHECK(a != a^m);
+ CHECK(a != a^n);
+}
+
+test_g2_cmp(init_pairing_a);
+test_g2_cmp(init_pairing_d);
+test_g2_cmp(init_pairing_e);
+test_g2_cmp(init_pairing_f);
+test_g2_cmp(init_pairing_g);
+test_g2_cmp(init_pairing_i);
diff --git a/moon-abe/pbc-0.5.14/pbc/lex.yy.c b/moon-abe/pbc-0.5.14/pbc/lex.yy.c
new file mode 100644
index 00000000..319a8cb7
--- /dev/null
+++ b/moon-abe/pbc-0.5.14/pbc/lex.yy.c
@@ -0,0 +1,1923 @@
+#line 2 "pbc/lex.yy.c"
+
+#line 4 "pbc/lex.yy.c"
+
+#define YY_INT_ALIGNED short int
+
+/* A lexical scanner generated by flex */
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+#define YY_FLEX_SUBMINOR_VERSION 35
+#if YY_FLEX_SUBMINOR_VERSION > 0
+#define FLEX_BETA
+#endif
+
+/* First, we deal with platform-specific or compiler-specific issues. */
+
+/* begin standard C headers. */
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+
+/* 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 */
+
+#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;
+
+extern FILE *yyin, *yyout;
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+ #define YY_LESS_LINENO(n)
+
+/* 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
+ {
+ FILE *yy_input_file;
+
+ char *yy_ch_buf; /* input buffer */
+ char *yy_buf_pos; /* current position in input buffer */
+
+ /* Size of input buffer in bytes, not including room for EOB
+ * characters.
+ */
+ yy_size_t yy_buf_size;
+
+ /* Number of characters read into yy_ch_buf, not including EOB
+ * characters.
+ */
+ int yy_n_chars;
+
+ /* Whether we "own" the buffer - i.e., we know we created it,
+ * and can realloc() it to grow it, and should free() it to
+ * delete it.
+ */
+ int yy_is_our_buffer;
+
+ /* Whether this is an "interactive" input source; if so, and
+ * if we're using stdio for input, then we want to use getc()
+ * instead of fread(), to make sure we stop fetching input after
+ * each newline.
+ */
+ int yy_is_interactive;
+
+ /* Whether we're considered to be at the beginning of a line.
+ * If so, '^' rules will be active on the next match, otherwise
+ * not.
+ */
+ int yy_at_bol;
+
+ int yy_bs_lineno; /**< The line count. */
+ int yy_bs_column; /**< The column count. */
+
+ /* Whether to try to fill the input buffer when we reach the
+ * end of it.
+ */
+ int yy_fill_buffer;
+
+ int yy_buffer_status;
+
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+ /* When an EOF's been seen but there's still some text to process
+ * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+ * shouldn't try reading from the input source any more. We might
+ * still have a bunch of tokens to match, though, because of
+ * possible backing-up.
+ *
+ * When we actually see the EOF, we change the status to "new"
+ * (via yyrestart()), so that the user can continue scanning by
+ * just pointing yyin at a new input file.
+ */
+#define YY_BUFFER_EOF_PENDING 2
+
+ };
+#endif /* !YY_STRUCT_YY_BUFFER_STATE */
+
+/* Stack of input buffers. */
+static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
+static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
+static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ *
+ * Returns the top of the stack, or NULL.
+ */
+#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
+ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
+ : NULL)
+
+/* Same as previous macro, but useful when we know that the buffer stack is not
+ * NULL or when we need an lvalue. For internal use only.
+ */
+#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
+
+/* yy_hold_char holds the character lost when yytext is formed. */
+static char yy_hold_char;
+static int yy_n_chars; /* number of characters read into yy_ch_buf */
+int yyleng;
+
+/* Points to current character in buffer. */
+static char *yy_c_buf_p = (char *) 0;
+static int yy_init = 0; /* whether we need to initialize */
+static int yy_start = 0; /* start state number */
+
+/* Flag which is used to allow yywrap()'s to do buffer switches
+ * instead of setting up a fresh yyin. A bit of a hack ...
+ */
+static int yy_did_buffer_switch_on_eof;
+
+void yyrestart (FILE *input_file );
+void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer );
+YY_BUFFER_STATE yy_create_buffer (FILE *file,int size );
+void yy_delete_buffer (YY_BUFFER_STATE b );
+void yy_flush_buffer (YY_BUFFER_STATE b );
+void yypush_buffer_state (YY_BUFFER_STATE new_buffer );
+void yypop_buffer_state (void );
+
+static void yyensure_buffer_stack (void );
+static void yy_load_buffer_state (void );
+static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
+
+#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
+
+YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
+YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
+YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len );
+
+void *yyalloc (yy_size_t );
+void *yyrealloc (void *,yy_size_t );
+void yyfree (void * );
+
+#define yy_new_buffer yy_create_buffer
+
+#define yy_set_interactive(is_interactive) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){ \
+ yyensure_buffer_stack (); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ yy_create_buffer(yyin,YY_BUF_SIZE ); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
+ }
+
+#define yy_set_bol(at_bol) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){\
+ yyensure_buffer_stack (); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ yy_create_buffer(yyin,YY_BUF_SIZE ); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
+ }
+
+#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
+
+/* Begin user sect3 */
+
+typedef unsigned char YY_CHAR;
+
+FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
+
+typedef int yy_state_type;
+
+extern int yylineno;
+
+int yylineno = 1;
+
+extern char *yytext;
+#define yytext_ptr yytext
+
+static yy_state_type yy_get_previous_state (void );
+static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
+static int yy_get_next_buffer (void );
+static void yy_fatal_error (yyconst char msg[] );
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up yytext.
+ */
+#define YY_DO_BEFORE_ACTION \
+ (yytext_ptr) = yy_bp; \
+ yyleng = (size_t) (yy_cp - yy_bp); \
+ (yy_hold_char) = *yy_cp; \
+ *yy_cp = '\0'; \
+ (yy_c_buf_p) = yy_cp;
+
+#define YY_NUM_RULES 35
+#define YY_END_OF_BUFFER 36
+/* 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[53] =
+ { 0,
+ 6, 6, 0, 0, 36, 34, 6, 32, 34, 34,
+ 26, 27, 20, 17, 23, 18, 19, 8, 25, 22,
+ 13, 33, 14, 24, 9, 28, 29, 21, 9, 30,
+ 31, 3, 4, 3, 6, 12, 0, 5, 1, 8,
+ 10, 15, 11, 16, 9, 9, 2, 9, 9, 9,
+ 7, 0
+ } ;
+
+static yyconst flex_int32_t yy_ec[256] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
+ 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 2, 4, 1, 5, 1, 1, 1, 1, 6,
+ 7, 8, 9, 10, 11, 1, 12, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 14, 15, 16,
+ 17, 18, 19, 1, 20, 20, 20, 20, 20, 20,
+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+ 21, 1, 22, 23, 20, 1, 20, 20, 20, 24,
+
+ 25, 26, 20, 20, 27, 20, 20, 20, 20, 28,
+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+ 20, 20, 29, 1, 30, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 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[31] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 2, 1, 1, 1, 1, 1, 1, 2,
+ 1, 1, 1, 2, 2, 2, 2, 2, 1, 1
+ } ;
+
+static yyconst flex_int16_t yy_base[56] =
+ { 0,
+ 0, 0, 28, 29, 58, 59, 55, 59, 39, 52,
+ 59, 59, 59, 59, 59, 59, 46, 40, 35, 59,
+ 34, 33, 32, 59, 0, 59, 59, 59, 23, 59,
+ 59, 59, 59, 35, 44, 59, 42, 59, 59, 31,
+ 59, 59, 59, 59, 0, 17, 59, 15, 7, 9,
+ 0, 59, 37, 39, 31
+ } ;
+
+static yyconst flex_int16_t yy_def[56] =
+ { 0,
+ 52, 1, 53, 53, 52, 52, 52, 52, 52, 54,
+ 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
+ 52, 52, 52, 52, 55, 52, 52, 52, 55, 52,
+ 52, 52, 52, 52, 52, 52, 54, 52, 52, 52,
+ 52, 52, 52, 52, 55, 55, 52, 55, 55, 55,
+ 55, 0, 52, 52, 52
+ } ;
+
+static yyconst flex_int16_t yy_nxt[90] =
+ { 0,
+ 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
+ 26, 27, 28, 29, 25, 25, 25, 25, 30, 31,
+ 33, 33, 45, 51, 50, 34, 34, 32, 32, 37,
+ 37, 49, 48, 40, 38, 35, 47, 46, 44, 43,
+ 42, 41, 40, 39, 38, 36, 35, 52, 5, 52,
+ 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
+ 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
+ 52, 52, 52, 52, 52, 52, 52, 52, 52
+ } ;
+
+static yyconst flex_int16_t yy_chk[90] =
+ { 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,
+ 3, 4, 55, 50, 49, 3, 4, 53, 53, 54,
+ 54, 48, 46, 40, 37, 35, 34, 29, 23, 22,
+ 21, 19, 18, 17, 10, 9, 7, 5, 52, 52,
+ 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
+ 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
+ 52, 52, 52, 52, 52, 52, 52, 52, 52
+ } ;
+
+static yy_state_type yy_last_accepting_state;
+static char *yy_last_accepting_cpos;
+
+extern int yy_flex_debug;
+int yy_flex_debug = 0;
+
+/* The intent behind this definition is that it'll catch
+ * any uses of REJECT which flex missed.
+ */
+#define REJECT reject_used_but_not_detected
+#define yymore() yymore_used_but_not_detected
+#define YY_MORE_ADJ 0
+#define YY_RESTORE_YY_MORE_OFFSET
+char *yytext;
+#line 1 "pbc/parser.lex"
+#line 2 "pbc/parser.lex"
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdint.h> // for intptr_t
+#include <gmp.h>
+#include "pbc_utils.h"
+#include "pbc_field.h"
+
+#include "pbc_tree.h"
+#define YYSTYPE tree_ptr
+#include "parser.tab.h"
+
+extern int option_easy;
+
+#define YY_NO_INPUT 1
+
+#line 508 "pbc/lex.yy.c"
+
+#define INITIAL 0
+#define COMMENT 1
+
+#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
+
+static int yy_init_globals (void );
+
+/* Accessor methods to globals.
+ These are made visible to non-reentrant scanners for convenience. */
+
+int yylex_destroy (void );
+
+int yyget_debug (void );
+
+void yyset_debug (int debug_flag );
+
+YY_EXTRA_TYPE yyget_extra (void );
+
+void yyset_extra (YY_EXTRA_TYPE user_defined );
+
+FILE *yyget_in (void );
+
+void yyset_in (FILE * in_str );
+
+FILE *yyget_out (void );
+
+void yyset_out (FILE * out_str );
+
+int yyget_leng (void );
+
+char *yyget_text (void );
+
+int yyget_lineno (void );
+
+void yyset_lineno (int line_number );
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int yywrap (void );
+#else
+extern int yywrap (void );
+#endif
+#endif
+
+#ifndef 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
+
+#ifdef __cplusplus
+static int yyinput (void );
+#else
+static int input (void );
+#endif
+
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k */
+#define YY_READ_BUF_SIZE 16384
+#else
+#define YY_READ_BUF_SIZE 8192
+#endif /* __ia64__ */
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+#ifndef ECHO
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
+#endif
+
+/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
+ { \
+ int c = '*'; \
+ size_t n; \
+ for ( n = 0; n < max_size && \
+ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
+ buf[n] = (char) c; \
+ if ( c == '\n' ) \
+ buf[n++] = (char) c; \
+ if ( c == EOF && ferror( yyin ) ) \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ result = n; \
+ } \
+ else \
+ { \
+ errno=0; \
+ while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
+ { \
+ if( errno != EINTR) \
+ { \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ break; \
+ } \
+ errno=0; \
+ clearerr(yyin); \
+ } \
+ }\
+\
+
+#endif
+
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
+#endif
+
+/* end tables serialization structures and prototypes */
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL_IS_OURS 1
+
+extern int yylex (void);
+
+#define YY_DECL int yylex (void)
+#endif /* !YY_DECL */
+
+/* Code executed at the beginning of each rule, after yytext and yyleng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK 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 20 "pbc/parser.lex"
+
+#line 696 "pbc/lex.yy.c"
+
+ if ( !(yy_init) )
+ {
+ (yy_init) = 1;
+
+#ifdef YY_USER_INIT
+ YY_USER_INIT;
+#endif
+
+ if ( ! (yy_start) )
+ (yy_start) = 1; /* first start state */
+
+ if ( ! yyin )
+ yyin = stdin;
+
+ if ( ! yyout )
+ yyout = stdout;
+
+ if ( ! YY_CURRENT_BUFFER ) {
+ yyensure_buffer_stack ();
+ YY_CURRENT_BUFFER_LVALUE =
+ yy_create_buffer(yyin,YY_BUF_SIZE );
+ }
+
+ yy_load_buffer_state( );
+ }
+
+ 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 >= 53 )
+ 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] != 59 );
+
+yy_find_action:
+ yy_act = yy_accept[yy_current_state];
+ if ( yy_act == 0 )
+ { /* have to back up */
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+ yy_act = yy_accept[yy_current_state];
+ }
+
+ YY_DO_BEFORE_ACTION;
+
+do_action: /* This label is used only to access EOF actions. */
+
+ switch ( yy_act )
+ { /* beginning of action switch */
+ case 0: /* must back up */
+ /* undo the effects of YY_DO_BEFORE_ACTION */
+ *yy_cp = (yy_hold_char);
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+ goto yy_find_action;
+
+case 1:
+YY_RULE_SETUP
+#line 21 "pbc/parser.lex"
+BEGIN(COMMENT); // Open C-style comment.
+ YY_BREAK
+case 2:
+YY_RULE_SETUP
+#line 22 "pbc/parser.lex"
+BEGIN(0); // Close C-style comment.
+ YY_BREAK
+case 3:
+YY_RULE_SETUP
+#line 23 "pbc/parser.lex"
+// Within a C-style comment.
+ YY_BREAK
+case 4:
+/* rule 4 can match eol */
+YY_RULE_SETUP
+#line 24 "pbc/parser.lex"
+// Within a C-style comment.
+ YY_BREAK
+case 5:
+*yy_cp = (yy_hold_char); /* undo effects of setting up yytext */
+(yy_c_buf_p) = yy_cp -= 1;
+YY_DO_BEFORE_ACTION; /* set up yytext again */
+YY_RULE_SETUP
+#line 25 "pbc/parser.lex"
+// Comment.
+ YY_BREAK
+case 6:
+YY_RULE_SETUP
+#line 26 "pbc/parser.lex"
+// Whitespace.
+ YY_BREAK
+case 7:
+YY_RULE_SETUP
+#line 28 "pbc/parser.lex"
+return DEFINE;
+ YY_BREAK
+case 8:
+YY_RULE_SETUP
+#line 29 "pbc/parser.lex"
+yylval = tree_new_z(yytext); return NUM;
+ YY_BREAK
+case 9:
+YY_RULE_SETUP
+#line 30 "pbc/parser.lex"
+yylval = tree_new_id(yytext); return ID;
+ YY_BREAK
+case 10:
+YY_RULE_SETUP
+#line 31 "pbc/parser.lex"
+return ASSIGN;
+ YY_BREAK
+case 11:
+YY_RULE_SETUP
+#line 32 "pbc/parser.lex"
+return EQ;
+ YY_BREAK
+case 12:
+YY_RULE_SETUP
+#line 33 "pbc/parser.lex"
+return NE;
+ YY_BREAK
+case 13:
+YY_RULE_SETUP
+#line 34 "pbc/parser.lex"
+return LT;
+ YY_BREAK
+case 14:
+YY_RULE_SETUP
+#line 35 "pbc/parser.lex"
+return T_GT;
+ YY_BREAK
+case 15:
+YY_RULE_SETUP
+#line 36 "pbc/parser.lex"
+return LE;
+ YY_BREAK
+case 16:
+YY_RULE_SETUP
+#line 37 "pbc/parser.lex"
+return GE;
+ YY_BREAK
+case 17:
+YY_RULE_SETUP
+#line 38 "pbc/parser.lex"
+return PLUS;
+ YY_BREAK
+case 18:
+YY_RULE_SETUP
+#line 39 "pbc/parser.lex"
+return MINUS;
+ YY_BREAK
+case 19:
+YY_RULE_SETUP
+#line 40 "pbc/parser.lex"
+return DIVIDE;
+ YY_BREAK
+case 20:
+YY_RULE_SETUP
+#line 41 "pbc/parser.lex"
+return TIMES;
+ YY_BREAK
+case 21:
+YY_RULE_SETUP
+#line 42 "pbc/parser.lex"
+return POW;
+ YY_BREAK
+case 22:
+YY_RULE_SETUP
+#line 43 "pbc/parser.lex"
+return TERMINATOR;
+ YY_BREAK
+case 23:
+YY_RULE_SETUP
+#line 44 "pbc/parser.lex"
+return COMMA;
+ YY_BREAK
+case 24:
+YY_RULE_SETUP
+#line 45 "pbc/parser.lex"
+return QUESTION;
+ YY_BREAK
+case 25:
+YY_RULE_SETUP
+#line 46 "pbc/parser.lex"
+return COLON;
+ YY_BREAK
+case 26:
+YY_RULE_SETUP
+#line 47 "pbc/parser.lex"
+return LPAR;
+ YY_BREAK
+case 27:
+YY_RULE_SETUP
+#line 48 "pbc/parser.lex"
+return RPAR;
+ YY_BREAK
+case 28:
+YY_RULE_SETUP
+#line 49 "pbc/parser.lex"
+return LSQU;
+ YY_BREAK
+case 29:
+YY_RULE_SETUP
+#line 50 "pbc/parser.lex"
+return RSQU;
+ YY_BREAK
+case 30:
+YY_RULE_SETUP
+#line 51 "pbc/parser.lex"
+return LBRACE;
+ YY_BREAK
+case 31:
+YY_RULE_SETUP
+#line 52 "pbc/parser.lex"
+return RBRACE;
+ YY_BREAK
+case 32:
+/* rule 32 can match eol */
+YY_RULE_SETUP
+#line 53 "pbc/parser.lex"
+if (option_easy) return TERMINATOR;
+ YY_BREAK
+case 33:
+YY_RULE_SETUP
+#line 54 "pbc/parser.lex"
+return option_easy ? ASSIGN : UNKNOWN;
+ YY_BREAK
+case 34:
+YY_RULE_SETUP
+#line 55 "pbc/parser.lex"
+return UNKNOWN;
+ YY_BREAK
+case 35:
+YY_RULE_SETUP
+#line 56 "pbc/parser.lex"
+ECHO;
+ YY_BREAK
+#line 959 "pbc/lex.yy.c"
+case YY_STATE_EOF(INITIAL):
+case YY_STATE_EOF(COMMENT):
+ yyterminate();
+
+ case YY_END_OF_BUFFER:
+ {
+ /* Amount of text matched not including the EOB char. */
+ int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
+
+ /* Undo the effects of YY_DO_BEFORE_ACTION. */
+ *yy_cp = (yy_hold_char);
+ YY_RESTORE_YY_MORE_OFFSET
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
+ {
+ /* We're scanning a new file or input source. It's
+ * possible that this happened because the user
+ * just pointed yyin at a new source and called
+ * yylex(). If so, then we have to assure
+ * consistency between YY_CURRENT_BUFFER and our
+ * globals. Here is the right place to do so, because
+ * this is the first action (other than possibly a
+ * back-up) that will match for the new input source.
+ */
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
+ }
+
+ /* Note that here we test for yy_c_buf_p "<=" to the position
+ * of the first EOB in the buffer, since yy_c_buf_p will
+ * already have been incremented past the NUL character
+ * (since all states make transitions on EOB to the
+ * end-of-buffer state). Contrast this with the test
+ * in input().
+ */
+ if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+ { /* This was really a NUL. */
+ yy_state_type yy_next_state;
+
+ (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( );
+
+ /* Okay, we're now positioned to make the NUL
+ * transition. We couldn't have
+ * yy_get_previous_state() go ahead and do it
+ * for us because it doesn't know how to deal
+ * with the possibility of jamming (and we don't
+ * want to build jamming into it because then it
+ * will run more slowly).
+ */
+
+ yy_next_state = yy_try_NUL_trans( yy_current_state );
+
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+
+ if ( yy_next_state )
+ {
+ /* Consume the NUL. */
+ yy_cp = ++(yy_c_buf_p);
+ yy_current_state = yy_next_state;
+ goto yy_match;
+ }
+
+ else
+ {
+ yy_cp = (yy_c_buf_p);
+ goto yy_find_action;
+ }
+ }
+
+ else switch ( yy_get_next_buffer( ) )
+ {
+ case EOB_ACT_END_OF_FILE:
+ {
+ (yy_did_buffer_switch_on_eof) = 0;
+
+ if ( yywrap( ) )
+ {
+ /* Note: because we've taken care in
+ * yy_get_next_buffer() to have set up
+ * yytext, we can now set up
+ * yy_c_buf_p so that if some total
+ * hoser (like flex itself) wants to
+ * call the scanner after we return the
+ * YY_NULL, it'll still work - another
+ * YY_NULL will get returned.
+ */
+ (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
+
+ yy_act = YY_STATE_EOF(YY_START);
+ goto do_action;
+ }
+
+ else
+ {
+ if ( ! (yy_did_buffer_switch_on_eof) )
+ YY_NEW_FILE;
+ }
+ break;
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ (yy_c_buf_p) =
+ (yytext_ptr) + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( );
+
+ yy_cp = (yy_c_buf_p);
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+ goto yy_match;
+
+ case EOB_ACT_LAST_MATCH:
+ (yy_c_buf_p) =
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
+
+ yy_current_state = yy_get_previous_state( );
+
+ yy_cp = (yy_c_buf_p);
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+ goto yy_find_action;
+ }
+ break;
+ }
+
+ default:
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--no action found" );
+ } /* end of action switch */
+ } /* end of scanning one token */
+} /* end of yylex */
+
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ * EOB_ACT_LAST_MATCH -
+ * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ * EOB_ACT_END_OF_FILE - end of file
+ */
+static int yy_get_next_buffer (void)
+{
+ 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 */
+
+ static yy_state_type yy_get_previous_state (void)
+{
+ 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 >= 53 )
+ 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 );
+ */
+ static yy_state_type 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 >= 53 )
+ 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 == 52);
+
+ return yy_is_jam ? 0 : yy_current_state;
+}
+
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+ static int yyinput (void)
+#else
+ static int input (void)
+#endif
+
+{
+ int c;
+
+ *(yy_c_buf_p) = (yy_hold_char);
+
+ if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
+ {
+ /* yy_c_buf_p now points to the character we want to return.
+ * If this occurs *before* the EOB characters, then it's a
+ * valid NUL; if not, then we've hit the end of the buffer.
+ */
+ if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+ /* This was really a NUL. */
+ *(yy_c_buf_p) = '\0';
+
+ else
+ { /* need more input */
+ int offset = (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);
+
+ return c;
+}
+#endif /* ifndef YY_NO_INPUT */
+
+/** Immediately switch to a different input stream.
+ * @param input_file A readable stream.
+ *
+ * @note This function does not reset the start condition to @c INITIAL .
+ */
+ void yyrestart (FILE * input_file )
+{
+
+ if ( ! YY_CURRENT_BUFFER ){
+ yyensure_buffer_stack ();
+ YY_CURRENT_BUFFER_LVALUE =
+ yy_create_buffer(yyin,YY_BUF_SIZE );
+ }
+
+ yy_init_buffer(YY_CURRENT_BUFFER,input_file );
+ yy_load_buffer_state( );
+}
+
+/** Switch to a different input buffer.
+ * @param new_buffer The new input buffer.
+ *
+ */
+ void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
+{
+
+ /* TODO. We should be able to replace this entire function body
+ * with
+ * yypop_buffer_state();
+ * yypush_buffer_state(new_buffer);
+ */
+ yyensure_buffer_stack ();
+ if ( YY_CURRENT_BUFFER == new_buffer )
+ return;
+
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *(yy_c_buf_p) = (yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+ yy_load_buffer_state( );
+
+ /* We don't actually know whether we did this switch during
+ * EOF (yywrap()) processing, but the only time this flag
+ * is looked at is after yywrap() is called, so it's safe
+ * to go ahead and always set it.
+ */
+ (yy_did_buffer_switch_on_eof) = 1;
+}
+
+static void yy_load_buffer_state (void)
+{
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
+ yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
+ (yy_hold_char) = *(yy_c_buf_p);
+}
+
+/** Allocate and initialize an input buffer state.
+ * @param file A readable stream.
+ * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
+ *
+ * @return the allocated buffer state.
+ */
+ YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
+{
+ YY_BUFFER_STATE b;
+
+ b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+ b->yy_buf_size = size;
+
+ /* yy_ch_buf has to be 2 characters longer than the size given because
+ * we need to put in 2 end-of-buffer characters.
+ */
+ b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 );
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+ b->yy_is_our_buffer = 1;
+
+ yy_init_buffer(b,file );
+
+ return b;
+}
+
+/** Destroy the buffer.
+ * @param b a buffer created with yy_create_buffer()
+ *
+ */
+ void yy_delete_buffer (YY_BUFFER_STATE b )
+{
+
+ if ( ! b )
+ return;
+
+ if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
+ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
+
+ if ( b->yy_is_our_buffer )
+ yyfree((void *) b->yy_ch_buf );
+
+ yyfree((void *) b );
+}
+
+#ifndef __cplusplus
+extern int isatty (int );
+#endif /* __cplusplus */
+
+/* Initializes or reinitializes a buffer.
+ * This function is sometimes called more than once on the same buffer,
+ * such as during a yyrestart() or at EOF.
+ */
+ static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
+
+{
+ int oerrno = errno;
+
+ yy_flush_buffer(b );
+
+ b->yy_input_file = file;
+ b->yy_fill_buffer = 1;
+
+ /* If b is the current buffer, then yy_init_buffer was _probably_
+ * called from yyrestart() or through yy_get_next_buffer.
+ * In that case, we don't want to reset the lineno or column.
+ */
+ if (b != YY_CURRENT_BUFFER){
+ b->yy_bs_lineno = 1;
+ b->yy_bs_column = 0;
+ }
+
+ b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
+
+ errno = oerrno;
+}
+
+/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
+ * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
+ *
+ */
+ void yy_flush_buffer (YY_BUFFER_STATE b )
+{
+ if ( ! b )
+ return;
+
+ b->yy_n_chars = 0;
+
+ /* We always need two end-of-buffer characters. The first causes
+ * a transition to the end-of-buffer state. The second causes
+ * a jam in that state.
+ */
+ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+ b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+ b->yy_buf_pos = &b->yy_ch_buf[0];
+
+ b->yy_at_bol = 1;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ if ( b == YY_CURRENT_BUFFER )
+ yy_load_buffer_state( );
+}
+
+/** Pushes the new state onto the stack. The new state becomes
+ * the current state. This function will allocate the stack
+ * if necessary.
+ * @param new_buffer The new state.
+ *
+ */
+void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
+{
+ if (new_buffer == NULL)
+ return;
+
+ yyensure_buffer_stack();
+
+ /* This block is copied from yy_switch_to_buffer. */
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *(yy_c_buf_p) = (yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ /* Only push if top exists. Otherwise, replace top. */
+ if (YY_CURRENT_BUFFER)
+ (yy_buffer_stack_top)++;
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+
+ /* copied from yy_switch_to_buffer. */
+ yy_load_buffer_state( );
+ (yy_did_buffer_switch_on_eof) = 1;
+}
+
+/** Removes and deletes the top of the stack, if present.
+ * The next element becomes the new top.
+ *
+ */
+void yypop_buffer_state (void)
+{
+ if (!YY_CURRENT_BUFFER)
+ return;
+
+ yy_delete_buffer(YY_CURRENT_BUFFER );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ if ((yy_buffer_stack_top) > 0)
+ --(yy_buffer_stack_top);
+
+ if (YY_CURRENT_BUFFER) {
+ yy_load_buffer_state( );
+ (yy_did_buffer_switch_on_eof) = 1;
+ }
+}
+
+/* Allocates the stack if it does not exist.
+ * Guarantees space for at least one push.
+ */
+static void yyensure_buffer_stack (void)
+{
+ 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;
+ }
+}
+
+/** Setup the input buffer state to scan directly from a user-specified character buffer.
+ * @param base the character buffer
+ * @param size the size in bytes of the character buffer
+ *
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
+{
+ YY_BUFFER_STATE b;
+
+ if ( size < 2 ||
+ base[size-2] != YY_END_OF_BUFFER_CHAR ||
+ base[size-1] != YY_END_OF_BUFFER_CHAR )
+ /* They forgot to leave room for the EOB's. */
+ return 0;
+
+ b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
+
+ b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
+ b->yy_buf_pos = b->yy_ch_buf = base;
+ b->yy_is_our_buffer = 0;
+ b->yy_input_file = 0;
+ b->yy_n_chars = b->yy_buf_size;
+ b->yy_is_interactive = 0;
+ b->yy_at_bol = 1;
+ b->yy_fill_buffer = 0;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ yy_switch_to_buffer(b );
+
+ return b;
+}
+
+/** Setup the input buffer state to scan a string. The next call to yylex() will
+ * scan from a @e copy of @a str.
+ * @param yystr a NUL-terminated string to scan
+ *
+ * @return the newly allocated buffer state object.
+ * @note If you want to scan bytes that may contain NUL values, then use
+ * yy_scan_bytes() instead.
+ */
+YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
+{
+
+ return yy_scan_bytes(yystr,strlen(yystr) );
+}
+
+/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
+ * scan from a @e copy of @a bytes.
+ * @param yybytes the byte buffer to scan
+ * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
+ *
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len )
+{
+ YY_BUFFER_STATE b;
+ char *buf;
+ yy_size_t n;
+ int i;
+
+ /* Get memory for full buffer, including space for trailing EOB's. */
+ n = _yybytes_len + 2;
+ buf = (char *) yyalloc(n );
+ if ( ! buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
+
+ for ( i = 0; i < _yybytes_len; ++i )
+ buf[i] = yybytes[i];
+
+ buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
+
+ b = yy_scan_buffer(buf,n );
+ if ( ! b )
+ YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
+
+ /* It's okay to grow etc. this buffer, and we should throw it
+ * away when we're done.
+ */
+ b->yy_is_our_buffer = 1;
+
+ return b;
+}
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+static void yy_fatal_error (yyconst char* msg )
+{
+ (void) fprintf( stderr, "%s\n", msg );
+ exit( YY_EXIT_FAILURE );
+}
+
+/* Redefine yyless() so it works in section 3 code. */
+
+#undef yyless
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up yytext. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ yytext[yyleng] = (yy_hold_char); \
+ (yy_c_buf_p) = yytext + yyless_macro_arg; \
+ (yy_hold_char) = *(yy_c_buf_p); \
+ *(yy_c_buf_p) = '\0'; \
+ yyleng = yyless_macro_arg; \
+ } \
+ while ( 0 )
+
+/* Accessor methods (get/set functions) to struct members. */
+
+/** Get the current line number.
+ *
+ */
+int yyget_lineno (void)
+{
+
+ return yylineno;
+}
+
+/** Get the input stream.
+ *
+ */
+FILE *yyget_in (void)
+{
+ return yyin;
+}
+
+/** Get the output stream.
+ *
+ */
+FILE *yyget_out (void)
+{
+ return yyout;
+}
+
+/** Get the length of the current token.
+ *
+ */
+int yyget_leng (void)
+{
+ return yyleng;
+}
+
+/** Get the current token.
+ *
+ */
+
+char *yyget_text (void)
+{
+ return yytext;
+}
+
+/** Set the current line number.
+ * @param line_number
+ *
+ */
+void yyset_lineno (int line_number )
+{
+
+ yylineno = line_number;
+}
+
+/** Set the input stream. This does not discard the current
+ * input buffer.
+ * @param in_str A readable stream.
+ *
+ * @see yy_switch_to_buffer
+ */
+void yyset_in (FILE * in_str )
+{
+ yyin = in_str ;
+}
+
+void yyset_out (FILE * out_str )
+{
+ yyout = out_str ;
+}
+
+int yyget_debug (void)
+{
+ return yy_flex_debug;
+}
+
+void yyset_debug (int bdebug )
+{
+ yy_flex_debug = bdebug ;
+}
+
+static int yy_init_globals (void)
+{
+ /* Initialization is the same as for the non-reentrant scanner.
+ * This function is called from yylex_destroy(), so don't allocate here.
+ */
+
+ (yy_buffer_stack) = 0;
+ (yy_buffer_stack_top) = 0;
+ (yy_buffer_stack_max) = 0;
+ (yy_c_buf_p) = (char *) 0;
+ (yy_init) = 0;
+ (yy_start) = 0;
+
+/* Defined in main.c */
+#ifdef YY_STDINIT
+ yyin = stdin;
+ yyout = stdout;
+#else
+ yyin = (FILE *) 0;
+ yyout = (FILE *) 0;
+#endif
+
+ /* For future reference: Set errno on error, since we are called by
+ * yylex_init()
+ */
+ return 0;
+}
+
+/* yylex_destroy is for both reentrant and non-reentrant scanners. */
+int yylex_destroy (void)
+{
+
+ /* Pop the buffer stack, destroying each element. */
+ while(YY_CURRENT_BUFFER){
+ yy_delete_buffer(YY_CURRENT_BUFFER );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ yypop_buffer_state();
+ }
+
+ /* Destroy the stack itself. */
+ yyfree((yy_buffer_stack) );
+ (yy_buffer_stack) = NULL;
+
+ /* Reset the globals. This is important in a non-reentrant scanner so the next time
+ * yylex() is called, initialization will occur. */
+ yy_init_globals( );
+
+ return 0;
+}
+
+/*
+ * Internal utility routines.
+ */
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char* s1, 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 56 "pbc/parser.lex"
+
+
+
diff --git a/moon-abe/pbc-0.5.14/pbc/lex.yy.h b/moon-abe/pbc-0.5.14/pbc/lex.yy.h
new file mode 100644
index 00000000..d3ca9887
--- /dev/null
+++ b/moon-abe/pbc-0.5.14/pbc/lex.yy.h
@@ -0,0 +1,333 @@
+#ifndef yyHEADER_H
+#define yyHEADER_H 1
+#define yyIN_HEADER 1
+
+#line 6 "pbc/lex.yy.h"
+
+#line 8 "pbc/lex.yy.h"
+
+#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
+
+/* First, we deal with platform-specific or compiler-specific issues. */
+
+/* begin standard C headers. */
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+
+/* 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 */
+
+#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
+
+/* 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
+
+#ifndef YY_TYPEDEF_YY_BUFFER_STATE
+#define YY_TYPEDEF_YY_BUFFER_STATE
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+#endif
+
+extern int yyleng;
+
+extern FILE *yyin, *yyout;
+
+#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
+ {
+ FILE *yy_input_file;
+
+ char *yy_ch_buf; /* input buffer */
+ char *yy_buf_pos; /* current position in input buffer */
+
+ /* Size of input buffer in bytes, not including room for EOB
+ * characters.
+ */
+ yy_size_t yy_buf_size;
+
+ /* Number of characters read into yy_ch_buf, not including EOB
+ * characters.
+ */
+ int yy_n_chars;
+
+ /* Whether we "own" the buffer - i.e., we know we created it,
+ * and can realloc() it to grow it, and should free() it to
+ * delete it.
+ */
+ int yy_is_our_buffer;
+
+ /* Whether this is an "interactive" input source; if so, and
+ * if we're using stdio for input, then we want to use getc()
+ * instead of fread(), to make sure we stop fetching input after
+ * each newline.
+ */
+ int yy_is_interactive;
+
+ /* Whether we're considered to be at the beginning of a line.
+ * If so, '^' rules will be active on the next match, otherwise
+ * not.
+ */
+ int yy_at_bol;
+
+ 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;
+
+ };
+#endif /* !YY_STRUCT_YY_BUFFER_STATE */
+
+void yyrestart (FILE *input_file );
+void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer );
+YY_BUFFER_STATE yy_create_buffer (FILE *file,int size );
+void yy_delete_buffer (YY_BUFFER_STATE b );
+void yy_flush_buffer (YY_BUFFER_STATE b );
+void yypush_buffer_state (YY_BUFFER_STATE new_buffer );
+void yypop_buffer_state (void );
+
+YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
+YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
+YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len );
+
+void *yyalloc (yy_size_t );
+void *yyrealloc (void *,yy_size_t );
+void yyfree (void * );
+
+/* Begin user sect3 */
+
+extern int yylineno;
+
+extern char *yytext;
+#define yytext_ptr yytext
+
+#ifdef YY_HEADER_EXPORT_START_CONDITIONS
+#define INITIAL 0
+#define COMMENT 1
+
+#endif
+
+#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
+
+/* Accessor methods to globals.
+ These are made visible to non-reentrant scanners for convenience. */
+
+int yylex_destroy (void );
+
+int yyget_debug (void );
+
+void yyset_debug (int debug_flag );
+
+YY_EXTRA_TYPE yyget_extra (void );
+
+void yyset_extra (YY_EXTRA_TYPE user_defined );
+
+FILE *yyget_in (void );
+
+void yyset_in (FILE * in_str );
+
+FILE *yyget_out (void );
+
+void yyset_out (FILE * out_str );
+
+int yyget_leng (void );
+
+char *yyget_text (void );
+
+int yyget_lineno (void );
+
+void yyset_lineno (int line_number );
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int yywrap (void );
+#else
+extern int yywrap (void );
+#endif
+#endif
+
+#ifndef 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
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL_IS_OURS 1
+
+extern int yylex (void);
+
+#define YY_DECL int yylex (void)
+#endif /* !YY_DECL */
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+#undef YY_NEW_FILE
+#undef YY_FLUSH_BUFFER
+#undef yy_set_bol
+#undef yy_new_buffer
+#undef yy_set_interactive
+#undef YY_DO_BEFORE_ACTION
+
+#ifdef YY_DECL_IS_OURS
+#undef YY_DECL_IS_OURS
+#undef YY_DECL
+#endif
+
+#line 56 "pbc/parser.lex"
+
+
+#line 332 "pbc/lex.yy.h"
+#undef yyIN_HEADER
+#endif /* yyHEADER_H */
diff --git a/moon-abe/pbc-0.5.14/pbc/oldpbc.c b/moon-abe/pbc-0.5.14/pbc/oldpbc.c
new file mode 100644
index 00000000..525fe8f2
--- /dev/null
+++ b/moon-abe/pbc-0.5.14/pbc/oldpbc.c
@@ -0,0 +1,1221 @@
+// Pairing-Based Calculator.
+// Mainly for demonstration purposes.
+//
+// It's times like these I wish C had garbage collection.
+
+#include <string.h>
+#include <ctype.h>
+#include <stdarg.h>
+#include <unistd.h> //for getopt
+#include "pbc.h"
+#include "pbc_z.h"
+#include "pbc_fp.h"
+
+#include "misc/darray.h"
+#include "misc/symtab.h"
+
+char *pbc_getline(const char *);
+
+enum {
+ t_none = 0,
+ t_id,
+ t_int,
+ t_string,
+ t_comma,
+ t_lparen,
+ t_rparen,
+ t_add,
+ t_sub,
+ t_mul,
+ t_div,
+ t_set,
+ t_pow,
+ t_unk,
+ t_function,
+ t_pairing,
+ t_element,
+ t_field,
+ t_err,
+};
+
+enum {
+ pe_expect_factor = 100,
+ pe_expect_rparen,
+ pe_arglist,
+ re_varnotfound = 200,
+ re_badlvalue,
+ re_funnotfound,
+ re_unimplemented,
+ re_badargcount,
+ re_badarg,
+ re_fieldmismatch,
+};
+
+static int option_echo = 0;
+
+static field_t Z;
+
+static int tok_type;
+//TODO: dynamic allocation:
+static char word[1024];
+
+struct id_s {
+ char *data;
+ int alloc;
+};
+typedef struct id_s *id_ptr;
+
+id_ptr id_new(char *id) {
+ id_ptr res = pbc_malloc(sizeof(struct id_s));
+ res->alloc = strlen(id) + 1;
+ res->data = pbc_malloc(res->alloc);
+ strcpy(res->data, id);
+ return res;
+}
+
+void id_delete(id_ptr id) {
+ pbc_free(id->data);
+ pbc_free(id);
+}
+
+struct tree_s {
+ int type;
+ void *data;
+ darray_t child;
+};
+typedef struct tree_s *tree_ptr;
+
+tree_ptr tree_new(int type, void *data) {
+ tree_ptr res = pbc_malloc(sizeof(struct tree_s));
+ res->type = type;
+ res->data = data;
+ darray_init(res->child);
+ return res;
+}
+
+static void delete_child(void *p) {
+ tree_delete(p);
+}
+
+void tree_delete(tree_ptr t) {
+ darray_forall(t->child, delete_child);
+ darray_clear(t->child);
+ switch(t->type) {
+ case t_id:
+ case t_string:
+ case t_function:
+ case t_int:
+ id_delete(t->data);
+ break;
+ }
+ pbc_free(t);
+}
+
+static char *currentline;
+static char *lexcp;
+
+
+static void lex(void) {
+ char c;
+ if (!lexcp) {
+ tok_type = t_none;
+ return;
+ }
+ c = *lexcp++;
+ skipwhitespace:
+ for (;;) {
+ if (!strchr(" \t\r\n", c)) break;
+ if (!c) {
+ tok_type = t_none;
+ return;
+ }
+ c = *lexcp++;
+ }
+
+ //comments start with '#' and end at a newline
+ if (c == '#') {
+ for (;;) {
+ c = *lexcp++;
+ if (!c) {
+ tok_type = t_none;
+ return;
+ }
+ if (c == '\n') break;
+ }
+ goto skipwhitespace;
+ }
+
+ //strings
+ if (c == '"') {
+ tok_type = t_string;
+ int i = 0;
+ for (;;) {
+ c = *lexcp++;
+ if (!c) {
+ //string continues on next line
+ word[i++] = '\n';
+ pbc_free(currentline);
+ currentline = pbc_getline(NULL);
+ if (!currentline) break;
+ if (option_echo) puts(currentline);
+ lexcp = currentline;
+ c = *lexcp++;
+ }
+ if (c == '"') {
+ break;
+ }
+ word[i++] = c;
+ }
+ word[i] = '\0';
+ return;
+ }
+
+ if (isdigit(c)) {
+ tok_type = t_int;
+ word[0] = c;
+
+ int i = 1;
+ for (;;) {
+ c = *lexcp++;
+ if (isdigit(c)) {
+ word[i++] = c;
+ } else {
+ word[i] = '\0';
+ lexcp--;
+ break;
+ }
+ }
+ return;
+ }
+
+ if (isalpha(c) || c == '_') {
+ tok_type = t_id;
+ word[0] = c;
+
+ int i = 1;
+ for (;;) {
+ c = *lexcp++;
+ if (isalnum(c) || c == '_') {
+ word[i++] = c;
+ } else {
+ word[i] = '\0';
+ lexcp--;
+ break;
+ }
+ }
+ return;
+ }
+
+ switch(c) {
+ case ',':
+ tok_type = t_comma;
+ break;
+ case '=':
+ tok_type = t_set;
+ break;
+ case '^':
+ tok_type = t_pow;
+ break;
+ case '*':
+ tok_type = t_mul;
+ break;
+ case '/':
+ tok_type = t_div;
+ break;
+ case '+':
+ tok_type = t_add;
+ break;
+ case '-':
+ tok_type = t_sub;
+ break;
+ case '(':
+ tok_type = t_lparen;
+ break;
+ case ')':
+ tok_type = t_rparen;
+ break;
+ default:
+ tok_type = t_unk;
+ break;
+ }
+}
+
+static int lastparseerror;
+static void setparseerror(int i) {
+ lastparseerror = i;
+}
+
+static tree_ptr parsesetexpr(void);
+
+static tree_ptr parseexprlist(tree_ptr t) {
+ tree_ptr c;
+ lex(); // expect lparen
+ if (tok_type == t_rparen) {
+ lex();
+ return t;
+ }
+ c = parsesetexpr();
+ if (!c) return NULL;
+ darray_append(t->child, c);
+ for (;;) {
+ if (tok_type == t_rparen) {
+ lex();
+ return t;
+ }
+ if (tok_type != t_comma) {
+ setparseerror(pe_arglist);
+ return NULL;
+ }
+ lex(); //expect comma
+ c = parsesetexpr();
+ if (!c) return NULL;
+ darray_append(t->child, c);
+ }
+}
+
+static tree_ptr parseprimitive(void) {
+ tree_ptr t;
+ switch(tok_type) {
+ id_ptr id;
+ case t_id:
+ id = id_new(word);
+ lex();
+ if (tok_type == t_lparen) {
+ if (parseexprlist(t = tree_new(t_function, id))) {
+ return t;
+ }
+ tree_delete(t);
+ return NULL;
+ } else {
+ return tree_new(t_id, id);
+ }
+ case t_string:
+ lex();
+ return tree_new(t_string, id_new(word));
+ case t_lparen:
+ lex();
+ t = parsesetexpr();
+ if (!t) return NULL;
+ if (tok_type != t_rparen) {
+ tree_delete(t);
+ setparseerror(pe_expect_rparen);
+ return NULL;
+ }
+ lex();
+ return t;
+ case t_int:
+ id = id_new(word);
+ lex();
+ return tree_new(t_int, id);
+ default:
+ setparseerror(pe_expect_factor);
+ return NULL;
+ }
+}
+
+static tree_ptr parsepow(void) {
+ tree_ptr t1;
+ t1 = parseprimitive();
+ if (tok_type == t_pow) {
+ tree_ptr t2, res;
+ lex();
+ t2 = parseprimitive();
+ if (!t2) {
+ tree_delete(t1);
+ return NULL;
+ }
+ res = tree_new(t_function, id_new("pow"));
+ darray_append(res->child, t1);
+ darray_append(res->child, t2);
+ return res;
+ }
+ return t1;
+}
+
+static tree_ptr parsefactor(void) {
+ tree_ptr t;
+ if (tok_type == t_sub) {
+ lex();
+ t = parsefactor();
+ if (!t) return NULL;
+ tree_ptr t1 = tree_new(t_function, id_new("neg"));
+ darray_append(t1->child, t);
+ return t1;
+ }
+
+ t = parsepow();
+ return t;
+}
+
+static tree_ptr parseterm(void) {
+ tree_ptr t1, t2, res;
+ res = parsefactor();
+ if (!res) return NULL;
+ for (;;) {
+ switch(tok_type) {
+ case t_mul:
+ lex();
+ t2 = parsefactor();
+ if (!t2) {
+ tree_delete(res);
+ return NULL;
+ }
+ t1 = tree_new(t_function, id_new("mul"));
+ darray_append(t1->child, res);
+ darray_append(t1->child, t2);
+ res = t1;
+ break;
+ case t_div:
+ lex();
+ t2 = parsefactor();
+ if (!t2) {
+ tree_delete(res);
+ return NULL;
+ }
+ t1 = tree_new(t_function, id_new("div"));
+ darray_append(t1->child, res);
+ darray_append(t1->child, t2);
+ res = t1;
+ break;
+ default:
+ return res;
+ }
+ }
+}
+
+static tree_ptr parseexpr(void) {
+ tree_ptr t1, t2, res;
+ res = parseterm();
+ if (!res) {
+ return NULL;
+ }
+ for (;;) {
+ switch(tok_type) {
+ case t_add:
+ lex();
+ t2 = parseterm();
+ if (!t2) {
+ tree_delete(res);
+ return NULL;
+ }
+ //t1 = tree_new(t_add, NULL);
+ t1 = tree_new(t_function, id_new("add"));
+ darray_append(t1->child, res);
+ darray_append(t1->child, t2);
+ res = t1;
+ break;
+ case t_sub:
+ lex();
+ t2 = parseterm();
+ if (!t2) {
+ tree_delete(res);
+ return NULL;
+ }
+ //t1 = tree_new(t_sub, NULL);
+ t1 = tree_new(t_function, id_new("sub"));
+ darray_append(t1->child, res);
+ darray_append(t1->child, t2);
+ res = t1;
+ break;
+ default:
+ return res;
+ }
+ }
+}
+
+static tree_ptr parsesetexpr(void) {
+ tree_ptr t1, t2, res;
+ t1 = parseexpr();
+ if (!t1) return NULL;
+ if (tok_type == t_set) {
+ lex();
+ t2 = parsesetexpr();
+ if (!t2) {
+ tree_delete(t1);
+ return NULL;
+ }
+ res = tree_new(t_set, NULL);
+ darray_append(res->child, t1);
+ darray_append(res->child, t2);
+ return res;
+ }
+ return t1;
+}
+
+static void print_tree(tree_ptr t) {
+ id_ptr id;
+ int i;
+ if (!t) {
+ printf("NULL");
+ return;
+ }
+ switch (t->type) {
+ case t_set:
+ print_tree(t->child->item[0]);
+ printf(" = ");
+ print_tree(t->child->item[1]);
+ break;
+ case t_id:
+ id = t->data;
+ printf("%s", id->data);
+ break;
+ case t_function:
+ id = t->data;
+ printf("%s(", id->data);
+ for (i=0; i<t->child->count; i++) {
+ print_tree(t->child->item[i]);
+ if (i < t->child->count - 1) printf(", ");
+ }
+ printf(")");
+ break;
+ default:
+ printf("?!?");
+ break;
+ }
+}
+
+static symtab_t var;
+static symtab_t builtin;
+
+struct val_s {
+ int type;
+ void *data;
+};
+typedef struct val_s *val_ptr;
+
+static int lastruntimeerror;
+static val_ptr newruntimeerror(int i) {
+ val_ptr res = pbc_malloc(sizeof(struct val_s));
+ lastruntimeerror = i;
+ res->type = t_err;
+ res->data = int_to_voidp(i);
+ return res;
+}
+
+val_ptr val_new(int type, void *data) {
+ val_ptr res = pbc_malloc(sizeof(struct val_s));
+ res->type = type;
+ res->data = data;
+ return res;
+}
+
+static void val_print(val_ptr v) {
+ pairing_ptr pairing;
+ field_ptr field;
+ element_ptr e;
+ switch (v->type) {
+ case t_element:
+ e = v->data;
+ element_out_str(stdout, 0, e);
+ printf("\n");
+ break;
+ case t_pairing:
+ pairing = v->data;
+ printf("pairing: G1bits=%d G2bits=%d GTbits=%d\n",
+ pairing_length_in_bytes_x_only_G1(pairing) * 8,
+ pairing_length_in_bytes_x_only_G2(pairing) * 8,
+ pairing_length_in_bytes_GT(pairing) * 8);
+ break;
+ case t_field:
+ field = v->data;
+ field_out_info(stdout, field);
+ break;
+ case t_string:
+ printf("%s", (char *) v->data);
+ break;
+ default:
+ printf("val type %d unknown\n", v->type);
+ break;
+ }
+}
+
+val_ptr val_copy(val_ptr v) {
+ val_ptr res = pbc_malloc(sizeof(struct val_s));
+ res->type = v->type;
+ if (v->type == t_element) {
+ //current policy: always clear elements, always copy elements
+ res->data = pbc_malloc(sizeof(element_t));
+ element_ptr e = v->data;
+ element_init(res->data, e->field);
+ element_set(res->data, e);
+ } else if (v->type == t_string) {
+ res->data = pbc_strdup(v->data);
+ } else {
+ res->data = v->data;
+ }
+
+ return res;
+}
+
+void val_delete(val_ptr v) {
+ switch(v->type) {
+ case t_element:
+ //current policy: always clear elements, always copy elements
+ element_clear(v->data);
+ pbc_free(v->data);
+ break;
+ case t_string:
+ pbc_free(v->data);
+ break;
+ case t_err:
+ break;
+ case t_pairing:
+ break;
+ case t_field:
+ break;
+ default:
+ printf("val_delete: case %d not handled: memory leak\n", v->type);
+ break;
+ }
+ pbc_free(v);
+}
+
+struct fun_s {
+ val_ptr (*f)(darray_ptr);
+ int arity;
+ int type[32]; //TODO: replace with darray? who needs more than 32 args?
+};
+
+typedef val_ptr (*fun)(darray_ptr);
+
+static val_ptr check_arg(darray_ptr arg, int n, ...) {
+ va_list ap;
+ int i;
+ val_ptr res = NULL;
+
+ va_start(ap, n);
+ if (arg->count != n) {
+ printf("expect %d argument(s)\n", n);
+ res = newruntimeerror(re_badargcount);
+ } else for (i=0; i<n; i++) {
+ int t = va_arg(ap, int);
+ val_ptr vp = arg->item[i];
+ if (vp->type != t) {
+ printf("arg not type %d\n", t);
+ return newruntimeerror(re_badarg);
+ break;
+ }
+ }
+
+ va_end(ap);
+ return res;
+}
+
+static val_ptr f_pairing_get_group(
+ field_ptr (*get_group)(pairing_ptr p), darray_ptr arg) {
+ val_ptr res;
+ res = check_arg(arg, 1, t_pairing);
+ if (res) return res;
+ val_ptr a0 = arg->item[0];
+ pairing_ptr pairing = a0->data;
+ res = val_new(t_field, get_group(pairing));
+ return res;
+}
+
+static val_ptr f_pairing_G1(darray_ptr arg) {
+ field_ptr getG1(pairing_ptr p) { return p->G1; }
+ return f_pairing_get_group(getG1, arg);
+}
+
+static val_ptr f_pairing_G2(darray_ptr arg) {
+ field_ptr getG2(pairing_ptr p) { return p->G2; }
+ return f_pairing_get_group(getG2, arg);
+}
+
+static val_ptr f_pairing_GT(darray_ptr arg) {
+ field_ptr getGT(pairing_ptr p) { return p->GT; }
+ return f_pairing_get_group(getGT, arg);
+}
+
+static val_ptr f_pairing_Zr(darray_ptr arg) {
+ field_ptr getZr(pairing_ptr p) { return p->Zr; }
+ return f_pairing_get_group(getZr, arg);
+}
+
+static val_ptr f_random(darray_ptr arg) {
+ val_ptr res;
+ res = check_arg(arg, 1, t_field);
+ if (res) return res;
+ val_ptr a0 = arg->item[0];
+ field_ptr f = a0->data;
+ element_ptr e = pbc_malloc(sizeof(element_t));
+ element_init(e, f);
+ element_random(e);
+ res = val_new(t_element, e);
+ return res;
+}
+
+static val_ptr f_order(darray_ptr arg) {
+ val_ptr res;
+ res = check_arg(arg, 1, t_field);
+ if (res) return res;
+ val_ptr a0 = arg->item[0];
+ field_ptr f = a0->data;
+
+ element_ptr e = pbc_malloc(sizeof(element_t));
+ element_init(e, Z);
+ element_set_mpz(e, f->order);
+ res = val_new(t_element, e);
+ return res;
+}
+
+static val_ptr f_unary(
+ void (*unary)(element_ptr, element_ptr), darray_ptr arg) {
+ val_ptr res;
+ res = check_arg(arg, 1, t_element);
+ if (res) return res;
+ val_ptr a0 = arg->item[0];
+ element_ptr e0 = a0->data;
+ element_ptr e = pbc_malloc(sizeof(element_t));
+ element_init(e, e0->field);
+ unary(e, e0);
+ res = val_new(t_element, e);
+ return res;
+}
+
+static val_ptr f_bin_op(
+ void (*binop)(element_ptr, element_ptr, element_ptr),
+ darray_ptr arg) {
+ val_ptr res;
+ res = check_arg(arg, 2, t_element, t_element);
+ if (res) return res;
+ val_ptr a0 = arg->item[0];
+ val_ptr a1 = arg->item[1];
+ element_ptr e0 = a0->data;
+ element_ptr e1 = a1->data;
+ if (e0->field != e1->field) {
+ printf("field mismatch!\n");
+ return newruntimeerror(re_fieldmismatch);
+ }
+ element_ptr e = pbc_malloc(sizeof(element_t));
+ element_init(e, e0->field);
+ binop(e, e0, e1);
+ res = val_new(t_element, e);
+ return res;
+}
+
+
+static val_ptr f_add(darray_ptr arg) {
+ return f_bin_op(element_add, arg);
+}
+
+static val_ptr f_mul(darray_ptr arg) {
+ return f_bin_op(element_mul, arg);
+}
+
+static val_ptr f_sub(darray_ptr arg) {
+ return f_bin_op(element_sub, arg);
+}
+
+static val_ptr f_div(darray_ptr arg) {
+ return f_bin_op(element_div, arg);
+}
+
+static val_ptr f_inv(darray_ptr arg) {
+ return f_unary(element_invert, arg);
+}
+
+static val_ptr f_neg(darray_ptr arg) {
+ return f_unary(element_neg, arg);
+}
+
+static val_ptr f_pow(darray_ptr arg) {
+ val_ptr res;
+ res = check_arg(arg, 2, t_element, t_element);
+ if (res) return res;
+ val_ptr a0 = arg->item[0];
+ val_ptr a1 = arg->item[1];
+ element_ptr e0 = a0->data;
+ element_ptr e1 = a1->data;
+ element_ptr e = pbc_malloc(sizeof(element_t));
+ mpz_t z;
+ mpz_init(z);
+ element_to_mpz(z, e1);
+ element_init(e, e0->field);
+ element_pow_mpz(e, e0, z);
+ res = val_new(t_element, e);
+ mpz_clear(z);
+ return res;
+}
+
+static pairing_ptr current_pairing;
+static val_ptr f_pairing(darray_ptr arg) {
+ val_ptr res;
+ if (arg->count != 2) {
+ printf("expect two arguments\n");
+ return newruntimeerror(re_badargcount);
+ }
+ val_ptr a0 = arg->item[0];
+ val_ptr a1 = arg->item[1];
+ if (a0->type != t_element) {
+ printf("arg 1 not element!\n");
+ return newruntimeerror(re_badarg);
+ }
+ if (a1->type != t_element) {
+ printf("arg 2 not element!\n");
+ return newruntimeerror(re_badarg);
+ }
+ pairing_ptr p;
+ element_ptr e0 = a0->data;
+ element_ptr e1 = a1->data;
+ p = e0->field->pairing;
+ if (e0->field != p->G1) {
+ printf("arg 1 not from G1!\n");
+ return newruntimeerror(re_badarg);
+ }
+ if (e1->field != p->G2) {
+ printf("arg 2 not from G2!\n");
+ return newruntimeerror(re_badarg);
+ }
+ element_ptr e = pbc_malloc(sizeof(element_t));
+ element_init(e, p->GT);
+ pairing_apply(e, e0, e1, p);
+ res = val_new(t_element, e);
+ return res;
+}
+
+static val_ptr execute_tree(tree_ptr t) {
+ darray_t arg;
+ id_ptr id;
+ fun fn;
+ int i;
+ val_ptr res, v;
+ tree_ptr t1, t2;
+
+ switch (t->type) {
+ case t_id:
+ id = t->data;
+ v = symtab_at(var, id->data);
+ if (!v) {
+ return newruntimeerror(re_varnotfound);
+ }
+ return val_copy(v);
+ case t_set:
+ t1 = t->child->item[0];
+ if (t1->type != t_id) {
+ return newruntimeerror(re_badlvalue);
+ }
+ t2 = t->child->item[1];
+ v = execute_tree(t2);
+ if (v->type == t_err) return v;
+ id = t1->data;
+ // clear what's there first
+ if ((res = symtab_at(var, id->data))) {
+ val_delete(res);
+ }
+ symtab_put(var, v, id->data);
+ v = symtab_at(var, id->data);
+ return val_copy(v);
+ case t_function:
+ id = t->data;
+ fn = symtab_at(builtin, id->data);
+ if (!fn) {
+ return newruntimeerror(re_funnotfound);
+ }
+ darray_init(arg);
+ for (i=0; i<t->child->count; i++) {
+ v = execute_tree(t->child->item[i]);
+ if (v->type == t_err) {
+ darray_forall(arg, (void (*)(void *)) val_delete);
+ return v;
+ }
+ darray_append(arg, v);
+ }
+ res = fn(arg);
+ for (i=0; i<arg->count; i++) {
+ val_delete(arg->item[i]);
+ }
+ darray_clear(arg);
+ return res;
+ case t_int:
+ id = t->data;
+ char *cp;
+ mpz_t z;
+ mpz_init(z);
+ for (cp = id->data; *cp; cp++) {
+ mpz_mul_ui(z, z, 10);
+ mpz_add_ui(z, z, *cp - '0');
+ }
+ element_ptr e = pbc_malloc(sizeof(element_t));
+ element_init(e, Z);
+ element_set_mpz(e, z);
+ mpz_clear(z);
+ return val_new(t_element, e);
+ case t_string:
+ id = t->data;
+ return val_new(t_string, pbc_strdup(id->data));
+ default:
+ return newruntimeerror(re_unimplemented);
+ }
+}
+
+static void parseline(void) {
+ val_ptr v;
+
+ tree_ptr t;
+ lex();
+ if (tok_type == t_none) return;
+ t = parsesetexpr();
+ if (0) {
+ print_tree(t);
+ printf("\n");
+ }
+ if (t) {
+ v = execute_tree(t);
+ if (v) {
+ if (v->type == t_err) {
+ printf("runtime error (error code = %d)\n", lastruntimeerror);
+ } else {
+ if (t->type != t_set) val_print(v);
+ }
+ val_delete(v);
+ }
+ tree_delete(t);
+ } else {
+ printf("parse error (error code = %d)\n", lastparseerror);
+ }
+}
+
+static char *aparam =
+"type a\n"
+"q 8780710799663312522437781984754049815806883199414208211028653399266475630880222957078625179422662221423155858769582317459277713367317481324925129998224791\n"
+"h 12016012264891146079388821366740534204802954401251311822919615131047207289359704531102844802183906537786776\n"
+"r 730750818665451621361119245571504901405976559617\n"
+"exp2 159\n"
+"exp1 107\n"
+"sign1 1\n"
+"sign0 1\n";
+
+static char *dparam =
+"type d\n"
+"q 625852803282871856053922297323874661378036491717\n"
+"n 625852803282871856053923088432465995634661283063\n"
+"h 3\n"
+"r 208617601094290618684641029477488665211553761021\n"
+"a 581595782028432961150765424293919699975513269268\n"
+"b 517921465817243828776542439081147840953753552322\n"
+"k 6\n"
+"nk 60094290356408407130984161127310078516360031868417968262992864809623507269833854678414046779817844853757026858774966331434198257512457993293271849043664655146443229029069463392046837830267994222789160047337432075266619082657640364986415435746294498140589844832666082434658532589211525696\n"
+"hk 1380801711862212484403205699005242141541629761433899149236405232528956996854655261075303661691995273080620762287276051361446528504633283152278831183711301329765591450680250000592437612973269056\n"
+"coeff0 472731500571015189154958232321864199355792223347\n"
+"coeff1 352243926696145937581894994871017455453604730246\n"
+"coeff2 289113341693870057212775990719504267185772707305\n"
+"nqr 431211441436589568382088865288592347194866189652\n";
+
+static char *eparam =
+"type e\n"
+"q 7245986106510086080714203333362098431608853335867425877960916928496629182991629664903654100214900946450053872786629995869445693724001299041657434948257845644905153122838458864000479326695430719258600053239930483226650953770354174712511646273516974069245462534034085895319225452125649979474047163305307830001\n"
+"r 730750862221594424981965739670091261094297337857\n"
+"h 13569343110918781839835249021482970252603216587988030044836106948825516930173270978617489032334001006615524543925753725725046733884363846960470444404747241287743773746682188521738728797153760275116924829183670000\n"
+"a 7130970454025799000067946137594446075551569949583815943390108723282396973737794273397246892274981883807989525599540630855644968426794929215599380425269625872763801485968007136000471718335185787206876242871042697778608875139078711621836858237429403052273312335081163896980825048123655535355411494046493419999\n"
+"b 7169309004853894693616698536183663527570664411678352588247044791687141043489072737232715961588288238022010974661903752526911876859197052490952065266265699130144252031591491045333807587788600764557450846327338626261289568016170532652061787582791926724597362401398804563093625182790987016728290050466098223333\n"
+"exp2 159\n"
+"exp1 135\n"
+"sign1 1\n"
+"sign0 1\n";
+
+static char *fparam =
+"type f\n"
+"q 205523667896953300194896352429254920972540065223\n"
+"r 205523667896953300194895899082072403858390252929\n"
+"b 40218105156867728698573668525883168222119515413\n"
+"beta 115334401956802802075595682801335644058796914268\n"
+"alpha0 191079354656274778837764015557338301375963168470\n"
+"alpha1 71445317903696340296199556072836940741717506375\n";
+
+static char *gparam =
+"type g\n"
+"q 503189899097385532598615948567975432740967203\n"
+"n 503189899097385532598571084778608176410973351\n"
+"h 1\n"
+"r 503189899097385532598571084778608176410973351\n"
+"a 465197998498440909244782433627180757481058321\n"
+"b 463074517126110479409374670871346701448503064\n"
+"k 10\n"
+"nk 1040684643531490707494989587381629956832530311976146077888095795458709511789670022388326295177424065807612879371896982185473788988016190582073591316127396374860265835641044035656044524481121528846249501655527462202999638159773731830375673076317719519977183373353791119388388468745670818193868532404392452816602538968163226713846951514831917487400267590451867746120591750902040267826351982737642689423713163967384383105678367875981348397359466338807\n"
+"hk 4110127713690841149713310614420858884651261781185442551927080083178682965171097172366598236129731931693425629387502221804555636704708008882811353539555915064049685663790355716130262332064327767695339422323460458479884756000782939428852120522712008037615051139080628734566850259704397643028017435446110322024094259858170303605703280329322675124728639532674407\n"
+"coeff0 67343110967802947677845897216565803152319250\n"
+"coeff1 115936772834120270862756636148166314916823221\n"
+"coeff2 87387877425076080433559927080662339215696505\n"
+"coeff3 433223145899090928132052677121692683015058909\n"
+"coeff4 405367866213598664862417230702935310328613596\n"
+"nqr 22204504160560785687198080413579021865783099\n";
+
+static pairing_t pairing_A, pairing_D, pairing_E, pairing_F, pairing_G;
+
+static void set_pairing_groups(pairing_ptr p) {
+ symtab_put(var, val_new(t_field, p->G1), "G1");
+ symtab_put(var, val_new(t_field, p->G2), "G2");
+ symtab_put(var, val_new(t_field, p->GT), "GT");
+ symtab_put(var, val_new(t_field, p->Zr), "Zr");
+ symtab_put(var, val_new(t_pairing, p), "current_pairing");
+ current_pairing = p;
+}
+
+static val_ptr f_init_pairing(darray_ptr arg) {
+ val_ptr res;
+
+ res = check_arg(arg, 1, t_pairing);
+ if (res) return res;
+
+ val_ptr a0 = arg->item[0];
+ pairing_ptr p = a0->data;
+ set_pairing_groups(p);
+ return NULL;
+}
+
+static val_ptr f_nextprime(darray_ptr arg) {
+ mpz_t p;
+ val_ptr res;
+
+ res = check_arg(arg, 1, t_element);
+ if (res) return res;
+ val_ptr a0 = arg->item[0];
+ element_ptr e0 = a0->data;
+ if (e0->field != Z) {
+ printf("arg not integer!\n");
+ return newruntimeerror(re_badarg);
+ }
+ element_ptr e = pbc_malloc(sizeof(element_t));
+ element_init(e, Z);
+ mpz_init(p);
+ element_to_mpz(p, e0);
+ mpz_nextprime(p, p);
+ element_set_mpz(e, p);
+ res = val_new(t_element, e);
+ mpz_clear(p);
+ return res;
+}
+
+static val_ptr f_brute_force_dlog(darray_ptr arg) {
+ val_ptr res;
+ res = check_arg(arg, 2, t_element, t_element);
+ if (res) return res;
+ val_ptr a0 = arg->item[0];
+ val_ptr a1 = arg->item[1];
+ element_ptr e0 = a0->data;
+ element_ptr e1 = a1->data;
+ if (e0->field != e1->field) {
+ printf("arg field mismatch!\n");
+ return newruntimeerror(re_badarg);
+ }
+ element_ptr e = pbc_malloc(sizeof(element_t));
+ element_init(e, Z);
+ element_dlog_brute_force(e, e0, e1);
+ res = val_new(t_element, e);
+ return res;
+}
+static val_ptr f_pollard_rho(darray_ptr arg) {
+ val_ptr res;
+ res = check_arg(arg, 3, t_element, t_element, t_field);
+ if (res) return res;
+ val_ptr a0 = arg->item[0];
+ val_ptr a1 = arg->item[1];
+ val_ptr a2 = arg->item[2];
+ element_ptr e0 = a0->data;
+ element_ptr e1 = a1->data;
+ if (e0->field != e1->field) {
+ printf("arg field mismatch!\n");
+ return newruntimeerror(re_badarg);
+ }
+ field_ptr f = a2->data;
+ element_ptr e = pbc_malloc(sizeof(element_t));
+ element_init(e, f);
+ element_dlog_pollard_rho(e, e0, e1);
+ res = val_new(t_element, e);
+ return res;
+}
+
+static val_ptr f_zz(darray_ptr arg) {
+ mpz_t p;
+ val_ptr res;
+ res = check_arg(arg, 1, t_element);
+ if (res) return res;
+ val_ptr a0 = arg->item[0];
+ element_ptr e0 = a0->data;
+ if (e0->field != Z) {
+ printf("arg not integer!\n");
+ return newruntimeerror(re_badarg);
+ }
+ field_ptr f = pbc_malloc(sizeof(field_t));
+ mpz_init(p);
+ element_to_mpz(p, e0);
+ field_init_fp(f, p);
+ res = val_new(t_field, f);
+ mpz_clear(p);
+ return res;
+}
+
+static val_ptr f_gen_A(darray_ptr arg) {
+ mpz_t rbits, qbits;
+ pairing_ptr p;
+ val_ptr res;
+ res = check_arg(arg, 2, t_element, t_element);
+ if (res) return res;
+ val_ptr a0 = arg->item[0];
+ val_ptr a1 = arg->item[1];
+ element_ptr e0 = a0->data;
+ if (e0->field != Z) {
+ printf("arg not integer!\n");
+ return newruntimeerror(re_badarg);
+ }
+ element_ptr e1 = a1->data;
+ if (e1->field != Z) {
+ printf("arg not integer!\n");
+ return newruntimeerror(re_badarg);
+ }
+ mpz_init(rbits);
+ mpz_init(qbits);
+ element_to_mpz(rbits, e0);
+ element_to_mpz(qbits, e1);
+ //TODO: check rbits and qbits aren't too big
+ pbc_param_t param;
+ pbc_param_init_a_gen(param, mpz_get_ui(rbits), mpz_get_ui(qbits));
+ p = pbc_malloc(sizeof(pairing_t));
+ pairing_init_pbc_param(p, param);
+ res = val_new(t_pairing, p);
+ mpz_clear(rbits);
+ mpz_clear(qbits);
+ pbc_param_clear(param);
+ return res;
+}
+
+static val_ptr f_fromZZ(darray_ptr arg) {
+ val_ptr res;
+ res = check_arg(arg, 2, t_element, t_field);
+ if (res) return res;
+ val_ptr a0 = arg->item[0];
+ val_ptr a1 = arg->item[1];
+ element_ptr e = a0->data;
+ field_ptr f = a1->data;
+ if (e->field != Z) {
+ printf("arg not integer!\n");
+ return newruntimeerror(re_badarg);
+ }
+ element_ptr e1 = pbc_malloc(sizeof(element_t));
+ element_init(e1, f);
+ element_set_mpz(e1, e->data);
+ res = val_new(t_element, e1);
+ return res;
+}
+
+static val_ptr f_fromstr(darray_ptr arg) {
+ val_ptr res;
+ res = check_arg(arg, 2, t_string, t_field);
+ if (res) return res;
+ val_ptr a0 = arg->item[0];
+ val_ptr a1 = arg->item[1];
+ field_ptr f = a1->data;
+ element_ptr e1 = pbc_malloc(sizeof(element_t));
+ element_init(e1, f);
+ element_set_str(e1, a0->data, 0);
+ res = val_new(t_element, e1);
+ return res;
+}
+
+/* I'll probably never finish this :(
+static val_ptr f_index_calculus(darray_ptr arg) {
+ val_ptr res;
+ res = check_arg(arg, 2, t_element, t_element);
+ if (res) return res;
+ val_ptr a0 = arg->item[0];
+ val_ptr a1 = arg->item[1];
+ element_ptr e0 = a0->data;
+ element_ptr e1 = a1->data;
+ element_ptr e = pbc_malloc(sizeof(element_t));
+ mpz_t x, g, h, q1;
+
+ //TODO: check e0, e1 are from an integer mod ring
+ mpz_init(x);
+ mpz_init(g);
+ mpz_init(h);
+ mpz_init(q1);
+
+ mpz_sub_ui(q1, e0->field->order, 1);
+
+ element_init(e, Z);
+ element_to_mpz(g, e0);
+ element_to_mpz(h, e1);
+ pbc_mpz_index_calculus(x, g, h, q1);
+ element_set_mpz(e, x);
+ res = val_new(t_element, e);
+ mpz_clear(x);
+ mpz_clear(g);
+ mpz_clear(h);
+ mpz_clear(q1);
+ return res;
+}
+*/
+
+int main(int argc, char **argv) {
+ for (;;) {
+ int c = getopt(argc, argv, "e");
+ if (c == -1) break;
+ switch (c) {
+ case 'e':
+ option_echo = 1;
+ break;
+ default:
+ fprintf(stderr, "unrecognized option: %c\n", c);
+ break;
+ }
+ }
+
+ symtab_init(var);
+ symtab_init(builtin);
+
+ pairing_init_set_str(pairing_A, aparam);
+ pairing_init_set_str(pairing_D, dparam);
+ pairing_init_set_str(pairing_E, eparam);
+ pairing_init_set_str(pairing_F, fparam);
+ pairing_init_set_str(pairing_G, gparam);
+ symtab_put(var, val_new(t_pairing, pairing_A), "A");
+ symtab_put(var, val_new(t_pairing, pairing_D), "D");
+ symtab_put(var, val_new(t_pairing, pairing_E), "E");
+ symtab_put(var, val_new(t_pairing, pairing_F), "F");
+ symtab_put(var, val_new(t_pairing, pairing_G), "G");
+
+ set_pairing_groups(pairing_A);
+
+ symtab_put(builtin, f_init_pairing, "init_pairing");
+ symtab_put(builtin, f_pairing_G1, "get_G1");
+ symtab_put(builtin, f_pairing_G2, "get_G2");
+ symtab_put(builtin, f_pairing_GT, "get_GT");
+ symtab_put(builtin, f_pairing_Zr, "get_Zr");
+ symtab_put(builtin, f_random, "random");
+ symtab_put(builtin, f_random, "rand");
+ symtab_put(builtin, f_random, "rnd");
+ symtab_put(builtin, f_order, "order");
+ symtab_put(builtin, f_order, "ord");
+ symtab_put(builtin, f_neg, "neg");
+ symtab_put(builtin, f_sub, "sub");
+ symtab_put(builtin, f_add, "add");
+ symtab_put(builtin, f_pow, "pow");
+ symtab_put(builtin, f_mul, "mul");
+ symtab_put(builtin, f_inv, "inv");
+ symtab_put(builtin, f_inv, "invert");
+ symtab_put(builtin, f_div, "div");
+ symtab_put(builtin, f_pairing, "pairing");
+ symtab_put(builtin, f_nextprime, "nextprime");
+ symtab_put(builtin, f_brute_force_dlog, "element_dlog_brute_force");
+ symtab_put(builtin, f_pollard_rho, "element_dlog_pollard_rho");
+ //symtab_put(builtin, f_index_calculus, "index_calculus");
+ symtab_put(builtin, f_zz, "ZZ");
+ symtab_put(builtin, f_gen_A, "gen_A");
+ symtab_put(builtin, f_fromZZ, "fromZZ");
+ symtab_put(builtin, f_fromstr, "fromstr");
+
+ field_init_z(Z);
+
+ fprintf(stderr, "pbc\n");
+
+ for (;;) {
+ currentline = pbc_getline(NULL);
+ if (!currentline) break;
+ if (option_echo) puts(currentline);
+ lexcp = currentline;
+ parseline();
+ free(currentline);
+ }
+ return 0;
+}
diff --git a/moon-abe/pbc-0.5.14/pbc/pairing_test.pbc b/moon-abe/pbc-0.5.14/pbc/pairing_test.pbc
new file mode 100644
index 00000000..c57189f7
--- /dev/null
+++ b/moon-abe/pbc-0.5.14/pbc/pairing_test.pbc
@@ -0,0 +1,21 @@
+# Tests sample type A pairing.
+
+g := G1([2382389466570123849673299401984867521337122094157231907755149435707124249269394670242462497382963719723036281844079382411446883273020125104982896098602669, 2152768906589770702756591740710760107878949212304343787392475836859241438597588807103470081101790991563152395601123682809718038151417122294066319979967168]);
+
+h := G2([5832612417453786541700129157230442590988122495898645678468800815872828277169950107203266157735206975228912899931278160262081308603240860553459187732968543, 5825590786822892934138376868455818413990615826926356662470129700411774690868351658310187202553513693344017463065909279569624651155563430675084173630054336]);
+
+a := 171583727262251826931173602797951212789946235851;
+b := 233634857565210859330459959563397971304462340857;
+
+CHECK(pairing(g, h) == GT([1352478452661998164151215014828915385601138645645403926287105573769451214277485326392786454433874957123922454604362337349978217917242114505658729401276644, 2809858014072341042857607405424304552357466023841122154308055820747972163307396014445308786731013691659356362568425895483877936945589613445697089590886519]));
+
+CHECK(g^a == G1([3727290142167731134589933003026410141163353118002821914170365887139605219852868537686435214464927363733592858325260588072422405672197113236445369761687270, 8313413520789037477320458888316489483781506373846006723006557775349684878102042826049292521482530556981023752851151672326421296204733037418468523296005577]));
+
+CHECK(h^b == G2([302169045606583472168811217560382970305157511680176350745436990853463473855962841196184541109617397027480204774682450915021848512168573082843355648090809, 7428193877404140917518137438384425427600294220905786853638038223349096573857683866658575603565175187399696035468569929483731011292133989973187846752806084]));
+
+res := GT([5401677742232403160612802517983583823254857216272776607059355607024091426935935872461700304196658606704085604766577186374528948004140797833341187234647180, 4255900207739859478558185000995524505026245539159946661271849714832846423204570340979120001638894488614502770175520505048836617405342161594891740961421000]);
+
+CHECK(res == pairing(g^a, h^b));
+CHECK(res == pairing(g, h)^(Zr(a)*Zr(b)));
+CHECK(res == pairing(g^a, h)^b);
+CHECK(res == pairing(g, h^b)^a);
diff --git a/moon-abe/pbc-0.5.14/pbc/parser.lex b/moon-abe/pbc-0.5.14/pbc/parser.lex
new file mode 100644
index 00000000..1d0b9f23
--- /dev/null
+++ b/moon-abe/pbc-0.5.14/pbc/parser.lex
@@ -0,0 +1,56 @@
+%{
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdint.h> // for intptr_t
+#include <gmp.h>
+#include "pbc_utils.h"
+#include "pbc_field.h"
+
+#include "pbc_tree.h"
+#define YYSTYPE tree_ptr
+#include "parser.tab.h"
+
+extern int option_easy;
+
+%}
+
+%option nounput noinput
+
+%x COMMENT
+%%
+\/\* BEGIN(COMMENT); // Open C-style comment.
+<COMMENT>\*\/ BEGIN(0); // Close C-style comment.
+<COMMENT>. // Within a C-style comment.
+<COMMENT>\n // Within a C-style comment.
+#.*$ // Comment.
+[ \t\r]* // Whitespace.
+
+define return DEFINE;
+[0-9]+ yylval = tree_new_z(yytext); return NUM;
+[a-zA-Z_][a-zA-Z0-9_]* yylval = tree_new_id(yytext); return ID;
+:= return ASSIGN;
+== return EQ;
+!= return NE;
+\< return LT;
+\> return T_GT;
+\<= return LE;
+\>= return GE;
+\+ return PLUS;
+- return MINUS;
+\/ return DIVIDE;
+\* return TIMES;
+\^ return POW;
+; return TERMINATOR;
+\, return COMMA;
+\? return QUESTION;
+: return COLON;
+\( return LPAR;
+\) return RPAR;
+\[ return LSQU;
+\] return RSQU;
+\{ return LBRACE;
+\} return RBRACE;
+\n if (option_easy) return TERMINATOR;
+= return option_easy ? ASSIGN : UNKNOWN;
+. return UNKNOWN;
+%%
diff --git a/moon-abe/pbc-0.5.14/pbc/parser.tab.c b/moon-abe/pbc-0.5.14/pbc/parser.tab.c
new file mode 100644
index 00000000..71542304
--- /dev/null
+++ b/moon-abe/pbc-0.5.14/pbc/parser.tab.c
@@ -0,0 +1,1906 @@
+/* A Bison parser, made by GNU Bison 2.5. */
+
+/* Bison implementation for Yacc-like parsers in C
+
+ Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* As a special exception, you may create a larger work that contains
+ part or all of the Bison parser skeleton and distribute that work
+ under terms of your choice, so long as that work isn't itself a
+ parser generator using the skeleton or a modified version thereof
+ as a parser skeleton. Alternatively, if you modify or redistribute
+ the parser skeleton itself, you may (at your option) remove this
+ special exception, which will cause the skeleton and the resulting
+ Bison output files to be licensed under the GNU General Public
+ License without this special exception.
+
+ This special exception was added by the Free Software Foundation in
+ version 2.2 of Bison. */
+
+/* C LALR(1) parser skeleton written by Richard Stallman, by
+ simplifying the original so-called "semantic" parser. */
+
+/* All symbols defined below should begin with yy or YY, to avoid
+ infringing on user name space. This should be done even for local
+ variables, as they might otherwise be expanded by user macros.
+ There are some unavoidable exceptions within include files to
+ define necessary library symbols; they are noted "INFRINGES ON
+ USER NAME SPACE" below. */
+
+/* Identify Bison output. */
+#define YYBISON 1
+
+/* Bison version. */
+#define YYBISON_VERSION "2.5"
+
+/* Skeleton name. */
+#define YYSKELETON_NAME "yacc.c"
+
+/* Pure parsers. */
+#define YYPURE 0
+
+/* Push parsers. */
+#define YYPUSH 0
+
+/* Pull parsers. */
+#define YYPULL 1
+
+/* Using locations. */
+#define YYLSP_NEEDED 0
+
+
+
+/* Copy the first part of user declarations. */
+
+/* Line 268 of yacc.c */
+#line 1 "pbc/parser.y"
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdint.h> // for intptr_t
+#include <gmp.h>
+#include "pbc_utils.h"
+#include "pbc_field.h"
+
+#include "pbc_tree.h"
+#define YYSTYPE tree_ptr
+void yyerror(const char *s);
+int yylex(void);
+
+#define YY_NO_INPUT
+#define YY_NO_UNPUT
+
+extern int option_easy;
+
+
+/* Line 268 of yacc.c */
+#line 91 "pbc/parser.tab.c"
+
+/* Enabling traces. */
+#ifndef YYDEBUG
+# define YYDEBUG 0
+#endif
+
+/* Enabling verbose error messages. */
+#ifdef YYERROR_VERBOSE
+# undef YYERROR_VERBOSE
+# define YYERROR_VERBOSE 1
+#else
+# define YYERROR_VERBOSE 1
+#endif
+
+/* Enabling the token table. */
+#ifndef YYTOKEN_TABLE
+# define YYTOKEN_TABLE 0
+#endif
+
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ END = 0,
+ DEFINE = 258,
+ TERMINATOR = 259,
+ NUM = 260,
+ ID = 261,
+ LPAR = 262,
+ RPAR = 263,
+ LSQU = 264,
+ RSQU = 265,
+ LBRACE = 266,
+ RBRACE = 267,
+ COMMA = 268,
+ COLON = 269,
+ QUESTION = 270,
+ GE = 271,
+ LE = 272,
+ T_GT = 273,
+ LT = 274,
+ NE = 275,
+ EQ = 276,
+ ASSIGN = 277,
+ MINUS = 278,
+ PLUS = 279,
+ TIMES = 280,
+ DIVIDE = 281,
+ UMINUS = 282,
+ POW = 283,
+ UNKNOWN = 284
+ };
+#endif
+
+
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef int YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+
+/* Copy the second part of user declarations. */
+
+
+/* Line 343 of yacc.c */
+#line 163 "pbc/parser.tab.c"
+
+#ifdef short
+# undef short
+#endif
+
+#ifdef YYTYPE_UINT8
+typedef YYTYPE_UINT8 yytype_uint8;
+#else
+typedef unsigned char yytype_uint8;
+#endif
+
+#ifdef YYTYPE_INT8
+typedef YYTYPE_INT8 yytype_int8;
+#elif (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+typedef signed char yytype_int8;
+#else
+typedef short int yytype_int8;
+#endif
+
+#ifdef YYTYPE_UINT16
+typedef YYTYPE_UINT16 yytype_uint16;
+#else
+typedef unsigned short int yytype_uint16;
+#endif
+
+#ifdef YYTYPE_INT16
+typedef YYTYPE_INT16 yytype_int16;
+#else
+typedef short int yytype_int16;
+#endif
+
+#ifndef YYSIZE_T
+# ifdef __SIZE_TYPE__
+# define YYSIZE_T __SIZE_TYPE__
+# elif defined size_t
+# define YYSIZE_T size_t
+# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
+# define YYSIZE_T size_t
+# else
+# define YYSIZE_T unsigned int
+# endif
+#endif
+
+#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
+
+#ifndef YY_
+# if defined YYENABLE_NLS && YYENABLE_NLS
+# if ENABLE_NLS
+# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
+# define YY_(msgid) dgettext ("bison-runtime", msgid)
+# endif
+# endif
+# ifndef YY_
+# define YY_(msgid) msgid
+# endif
+#endif
+
+/* Suppress unused-variable warnings by "using" E. */
+#if ! defined lint || defined __GNUC__
+# define YYUSE(e) ((void) (e))
+#else
+# define YYUSE(e) /* empty */
+#endif
+
+/* Identity function, used to suppress warnings about constant conditions. */
+#ifndef lint
+# define YYID(n) (n)
+#else
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static int
+YYID (int yyi)
+#else
+static int
+YYID (yyi)
+ int yyi;
+#endif
+{
+ return yyi;
+}
+#endif
+
+#if ! defined yyoverflow || YYERROR_VERBOSE
+
+/* The parser invokes alloca or malloc; define the necessary symbols. */
+
+# ifdef YYSTACK_USE_ALLOCA
+# if YYSTACK_USE_ALLOCA
+# ifdef __GNUC__
+# define YYSTACK_ALLOC __builtin_alloca
+# elif defined __BUILTIN_VA_ARG_INCR
+# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
+# elif defined _AIX
+# define YYSTACK_ALLOC __alloca
+# elif defined _MSC_VER
+# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
+# define alloca _alloca
+# else
+# define YYSTACK_ALLOC alloca
+# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+# ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+# endif
+# endif
+# endif
+# endif
+# endif
+
+# ifdef YYSTACK_ALLOC
+ /* Pacify GCC's `empty if-body' warning. */
+# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
+# ifndef YYSTACK_ALLOC_MAXIMUM
+ /* The OS might guarantee only one guard page at the bottom of the stack,
+ and a page size can be as small as 4096 bytes. So we cannot safely
+ invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
+ to allow for a few compiler-allocated temporary stack slots. */
+# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
+# endif
+# else
+# define YYSTACK_ALLOC YYMALLOC
+# define YYSTACK_FREE YYFREE
+# ifndef YYSTACK_ALLOC_MAXIMUM
+# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
+# endif
+# if (defined __cplusplus && ! defined EXIT_SUCCESS \
+ && ! ((defined YYMALLOC || defined malloc) \
+ && (defined YYFREE || defined free)))
+# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+# ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+# endif
+# endif
+# ifndef YYMALLOC
+# define YYMALLOC malloc
+# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# ifndef YYFREE
+# define YYFREE free
+# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+void free (void *); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# endif
+#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
+
+
+#if (! defined yyoverflow \
+ && (! defined __cplusplus \
+ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
+
+/* A type that is properly aligned for any stack member. */
+union yyalloc
+{
+ yytype_int16 yyss_alloc;
+ YYSTYPE yyvs_alloc;
+};
+
+/* The size of the maximum gap between one aligned stack and the next. */
+# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
+
+/* The size of an array large to enough to hold all stacks, each with
+ N elements. */
+# define YYSTACK_BYTES(N) \
+ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
+ + YYSTACK_GAP_MAXIMUM)
+
+# define YYCOPY_NEEDED 1
+
+/* Relocate STACK from its old location to the new one. The
+ local variables YYSIZE and YYSTACKSIZE give the old and new number of
+ elements in the stack, and YYPTR gives the new location of the
+ stack. Advance YYPTR to a properly aligned location for the next
+ stack. */
+# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
+ do \
+ { \
+ YYSIZE_T yynewbytes; \
+ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
+ Stack = &yyptr->Stack_alloc; \
+ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
+ yyptr += yynewbytes / sizeof (*yyptr); \
+ } \
+ while (YYID (0))
+
+#endif
+
+#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
+/* Copy COUNT objects from FROM to TO. The source and destination do
+ not overlap. */
+# ifndef YYCOPY
+# if defined __GNUC__ && 1 < __GNUC__
+# define YYCOPY(To, From, Count) \
+ __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
+# else
+# define YYCOPY(To, From, Count) \
+ do \
+ { \
+ YYSIZE_T yyi; \
+ for (yyi = 0; yyi < (Count); yyi++) \
+ (To)[yyi] = (From)[yyi]; \
+ } \
+ while (YYID (0))
+# endif
+# endif
+#endif /* !YYCOPY_NEEDED */
+
+/* YYFINAL -- State number of the termination state. */
+#define YYFINAL 2
+/* YYLAST -- Last index in YYTABLE. */
+#define YYLAST 148
+
+/* YYNTOKENS -- Number of terminals. */
+#define YYNTOKENS 30
+/* YYNNTS -- Number of nonterminals. */
+#define YYNNTS 13
+/* YYNRULES -- Number of rules. */
+#define YYNRULES 40
+/* YYNRULES -- Number of states. */
+#define YYNSTATES 73
+
+/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
+#define YYUNDEFTOK 2
+#define YYMAXUTOK 284
+
+#define YYTRANSLATE(YYX) \
+ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+
+/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
+static const yytype_uint8 yytranslate[] =
+{
+ 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
+ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+ 25, 26, 27, 28, 29
+};
+
+#if YYDEBUG
+/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
+ YYRHS. */
+static const yytype_uint8 yyprhs[] =
+{
+ 0, 0, 3, 4, 7, 10, 19, 20, 23, 24,
+ 26, 28, 32, 34, 38, 44, 46, 51, 55, 59,
+ 63, 67, 71, 75, 79, 83, 87, 91, 95, 98,
+ 103, 107, 109, 110, 112, 114, 118, 120, 122, 126,
+ 128
+};
+
+/* YYRHS -- A `-1'-separated list of the rules' RHS. */
+static const yytype_int8 yyrhs[] =
+{
+ 31, 0, -1, -1, 31, 32, -1, 36, 4, -1,
+ 3, 6, 7, 34, 8, 11, 33, 12, -1, -1,
+ 33, 32, -1, -1, 35, -1, 6, -1, 35, 13,
+ 6, -1, 40, -1, 6, 22, 36, -1, 36, 15,
+ 36, 14, 36, -1, 37, -1, 37, 9, 36, 10,
+ -1, 36, 21, 36, -1, 36, 20, 36, -1, 36,
+ 17, 36, -1, 36, 16, 36, -1, 36, 19, 36,
+ -1, 36, 18, 36, -1, 36, 24, 36, -1, 36,
+ 23, 36, -1, 36, 25, 36, -1, 36, 26, 36,
+ -1, 36, 28, 36, -1, 23, 36, -1, 37, 7,
+ 38, 8, -1, 7, 36, 8, -1, 6, -1, -1,
+ 39, -1, 36, -1, 39, 13, 36, -1, 5, -1,
+ 41, -1, 9, 42, 10, -1, 36, -1, 42, 13,
+ 36, -1
+};
+
+/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
+static const yytype_uint8 yyrline[] =
+{
+ 0, 35, 35, 37, 41, 42, 48, 49, 53, 54,
+ 58, 59, 63, 64, 65, 66, 67, 68, 69, 70,
+ 71, 72, 73, 74, 75, 76, 77, 78, 79, 84,
+ 85, 86, 90, 91, 95, 96, 100, 101, 105, 109,
+ 110
+};
+#endif
+
+#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
+/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
+static const char *const yytname[] =
+{
+ "\"end of file\"", "error", "$undefined", "DEFINE", "TERMINATOR", "NUM",
+ "ID", "LPAR", "RPAR", "LSQU", "RSQU", "LBRACE", "RBRACE", "COMMA",
+ "COLON", "QUESTION", "GE", "LE", "T_GT", "LT", "NE", "EQ", "ASSIGN",
+ "MINUS", "PLUS", "TIMES", "DIVIDE", "UMINUS", "POW", "UNKNOWN",
+ "$accept", "input", "stmt", "stmtlist", "parms", "parms1", "expr",
+ "molecule", "exprlist", "nonemptyexprlist", "multinomial", "numlist",
+ "sequence", 0
+};
+#endif
+
+# ifdef YYPRINT
+/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
+ token YYLEX-NUM. */
+static const yytype_uint16 yytoknum[] =
+{
+ 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
+ 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
+ 275, 276, 277, 278, 279, 280, 281, 282, 283, 284
+};
+# endif
+
+/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
+static const yytype_uint8 yyr1[] =
+{
+ 0, 30, 31, 31, 32, 32, 33, 33, 34, 34,
+ 35, 35, 36, 36, 36, 36, 36, 36, 36, 36,
+ 36, 36, 36, 36, 36, 36, 36, 36, 36, 37,
+ 37, 37, 38, 38, 39, 39, 40, 40, 41, 42,
+ 42
+};
+
+/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
+static const yytype_uint8 yyr2[] =
+{
+ 0, 2, 0, 2, 2, 8, 0, 2, 0, 1,
+ 1, 3, 1, 3, 5, 1, 4, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 2, 4,
+ 3, 1, 0, 1, 1, 3, 1, 1, 3, 1,
+ 3
+};
+
+/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
+ Performed when YYTABLE doesn't specify something else to do. Zero
+ means the default is an error. */
+static const yytype_uint8 yydefact[] =
+{
+ 2, 0, 1, 0, 36, 31, 0, 0, 0, 3,
+ 0, 15, 12, 37, 0, 0, 0, 39, 0, 28,
+ 4, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 32, 0, 8, 13, 30, 38, 0,
+ 0, 20, 19, 22, 21, 18, 17, 24, 23, 25,
+ 26, 27, 34, 0, 33, 0, 10, 0, 9, 40,
+ 0, 29, 0, 16, 0, 0, 14, 35, 6, 11,
+ 0, 5, 7
+};
+
+/* YYDEFGOTO[NTERM-NUM]. */
+static const yytype_int8 yydefgoto[] =
+{
+ -1, 1, 9, 70, 57, 58, 10, 11, 53, 54,
+ 12, 13, 18
+};
+
+/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+ STATE-NUM. */
+#define YYPACT_NINF -21
+static const yytype_int8 yypact[] =
+{
+ -21, 52, -21, 1, -21, 8, 110, 110, 110, -21,
+ 25, 5, -21, -21, 28, 110, 61, 120, 21, 4,
+ -21, 110, 110, 110, 110, 110, 110, 110, 110, 110,
+ 110, 110, 110, 110, 110, 30, -20, -21, -21, 110,
+ 106, -20, -20, -20, -20, -20, -20, -15, -15, 4,
+ 4, 4, 120, 29, 26, 86, -21, 39, 47, 120,
+ 110, -21, 110, -21, 27, 56, 120, 120, -21, -21,
+ 85, -21, -21
+};
+
+/* YYPGOTO[NTERM-NUM]. */
+static const yytype_int8 yypgoto[] =
+{
+ -21, -21, -7, -21, -21, -21, -6, -21, -21, -21,
+ -21, -21, -21
+};
+
+/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
+ positive, shift that token. If negative, reduce the rule which
+ number is the opposite. If YYTABLE_NINF, syntax error. */
+#define YYTABLE_NINF -1
+static const yytype_uint8 yytable[] =
+{
+ 16, 17, 19, 28, 29, 30, 31, 14, 32, 36,
+ 30, 31, 33, 32, 34, 40, 41, 42, 43, 44,
+ 45, 46, 47, 48, 49, 50, 51, 52, 55, 20,
+ 15, 38, 32, 59, 39, 35, 56, 61, 68, 62,
+ 21, 22, 23, 24, 25, 26, 27, 64, 28, 29,
+ 30, 31, 2, 32, 66, 3, 67, 4, 5, 6,
+ 65, 7, 69, 72, 0, 0, 0, 0, 0, 37,
+ 0, 0, 0, 0, 0, 8, 21, 22, 23, 24,
+ 25, 26, 27, 0, 28, 29, 30, 31, 3, 32,
+ 4, 5, 6, 0, 7, 0, 63, 71, 0, 0,
+ 0, 21, 22, 23, 24, 25, 26, 27, 8, 28,
+ 29, 30, 31, 0, 32, 4, 5, 6, 0, 7,
+ 60, 21, 22, 23, 24, 25, 26, 27, 0, 28,
+ 29, 30, 31, 8, 32, 21, 22, 23, 24, 25,
+ 26, 27, 0, 28, 29, 30, 31, 0, 32
+};
+
+#define yypact_value_is_default(yystate) \
+ ((yystate) == (-21))
+
+#define yytable_value_is_error(yytable_value) \
+ YYID (0)
+
+static const yytype_int8 yycheck[] =
+{
+ 6, 7, 8, 23, 24, 25, 26, 6, 28, 15,
+ 25, 26, 7, 28, 9, 21, 22, 23, 24, 25,
+ 26, 27, 28, 29, 30, 31, 32, 33, 34, 4,
+ 22, 10, 28, 39, 13, 7, 6, 8, 11, 13,
+ 15, 16, 17, 18, 19, 20, 21, 8, 23, 24,
+ 25, 26, 0, 28, 60, 3, 62, 5, 6, 7,
+ 13, 9, 6, 70, -1, -1, -1, -1, -1, 8,
+ -1, -1, -1, -1, -1, 23, 15, 16, 17, 18,
+ 19, 20, 21, -1, 23, 24, 25, 26, 3, 28,
+ 5, 6, 7, -1, 9, -1, 10, 12, -1, -1,
+ -1, 15, 16, 17, 18, 19, 20, 21, 23, 23,
+ 24, 25, 26, -1, 28, 5, 6, 7, -1, 9,
+ 14, 15, 16, 17, 18, 19, 20, 21, -1, 23,
+ 24, 25, 26, 23, 28, 15, 16, 17, 18, 19,
+ 20, 21, -1, 23, 24, 25, 26, -1, 28
+};
+
+/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
+ symbol of state STATE-NUM. */
+static const yytype_uint8 yystos[] =
+{
+ 0, 31, 0, 3, 5, 6, 7, 9, 23, 32,
+ 36, 37, 40, 41, 6, 22, 36, 36, 42, 36,
+ 4, 15, 16, 17, 18, 19, 20, 21, 23, 24,
+ 25, 26, 28, 7, 9, 7, 36, 8, 10, 13,
+ 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
+ 36, 36, 36, 38, 39, 36, 6, 34, 35, 36,
+ 14, 8, 13, 10, 8, 13, 36, 36, 11, 6,
+ 33, 12, 32
+};
+
+#define yyerrok (yyerrstatus = 0)
+#define yyclearin (yychar = YYEMPTY)
+#define YYEMPTY (-2)
+#define YYEOF 0
+
+#define YYACCEPT goto yyacceptlab
+#define YYABORT goto yyabortlab
+#define YYERROR goto yyerrorlab
+
+
+/* Like YYERROR except do call yyerror. This remains here temporarily
+ to ease the transition to the new meaning of YYERROR, for GCC.
+ Once GCC version 2 has supplanted version 1, this can go. However,
+ YYFAIL appears to be in use. Nevertheless, it is formally deprecated
+ in Bison 2.4.2's NEWS entry, where a plan to phase it out is
+ discussed. */
+
+#define YYFAIL goto yyerrlab
+#if defined YYFAIL
+ /* This is here to suppress warnings from the GCC cpp's
+ -Wunused-macros. Normally we don't worry about that warning, but
+ some users do, and we want to make it easy for users to remove
+ YYFAIL uses, which will produce warnings from Bison 2.5. */
+#endif
+
+#define YYRECOVERING() (!!yyerrstatus)
+
+#define YYBACKUP(Token, Value) \
+do \
+ if (yychar == YYEMPTY && yylen == 1) \
+ { \
+ yychar = (Token); \
+ yylval = (Value); \
+ YYPOPSTACK (1); \
+ goto yybackup; \
+ } \
+ else \
+ { \
+ yyerror (YY_("syntax error: cannot back up")); \
+ YYERROR; \
+ } \
+while (YYID (0))
+
+
+#define YYTERROR 1
+#define YYERRCODE 256
+
+
+/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
+ If N is 0, then set CURRENT to the empty location which ends
+ the previous symbol: RHS[0] (always defined). */
+
+#define YYRHSLOC(Rhs, K) ((Rhs)[K])
+#ifndef YYLLOC_DEFAULT
+# define YYLLOC_DEFAULT(Current, Rhs, N) \
+ do \
+ if (YYID (N)) \
+ { \
+ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
+ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
+ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
+ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
+ } \
+ else \
+ { \
+ (Current).first_line = (Current).last_line = \
+ YYRHSLOC (Rhs, 0).last_line; \
+ (Current).first_column = (Current).last_column = \
+ YYRHSLOC (Rhs, 0).last_column; \
+ } \
+ while (YYID (0))
+#endif
+
+
+/* This macro is provided for backward compatibility. */
+
+#ifndef YY_LOCATION_PRINT
+# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
+#endif
+
+
+/* YYLEX -- calling `yylex' with the right arguments. */
+
+#ifdef YYLEX_PARAM
+# define YYLEX yylex (YYLEX_PARAM)
+#else
+# define YYLEX yylex ()
+#endif
+
+/* Enable debugging if requested. */
+#if YYDEBUG
+
+# ifndef YYFPRINTF
+# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
+# define YYFPRINTF fprintf
+# endif
+
+# define YYDPRINTF(Args) \
+do { \
+ if (yydebug) \
+ YYFPRINTF Args; \
+} while (YYID (0))
+
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
+do { \
+ if (yydebug) \
+ { \
+ YYFPRINTF (stderr, "%s ", Title); \
+ yy_symbol_print (stderr, \
+ Type, Value); \
+ YYFPRINTF (stderr, "\n"); \
+ } \
+} while (YYID (0))
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
+#else
+static void
+yy_symbol_value_print (yyoutput, yytype, yyvaluep)
+ FILE *yyoutput;
+ int yytype;
+ YYSTYPE const * const yyvaluep;
+#endif
+{
+ if (!yyvaluep)
+ return;
+# ifdef YYPRINT
+ if (yytype < YYNTOKENS)
+ YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+# else
+ YYUSE (yyoutput);
+# endif
+ switch (yytype)
+ {
+ default:
+ break;
+ }
+}
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
+#else
+static void
+yy_symbol_print (yyoutput, yytype, yyvaluep)
+ FILE *yyoutput;
+ int yytype;
+ YYSTYPE const * const yyvaluep;
+#endif
+{
+ if (yytype < YYNTOKENS)
+ YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
+ else
+ YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
+
+ yy_symbol_value_print (yyoutput, yytype, yyvaluep);
+ YYFPRINTF (yyoutput, ")");
+}
+
+/*------------------------------------------------------------------.
+| yy_stack_print -- Print the state stack from its BOTTOM up to its |
+| TOP (included). |
+`------------------------------------------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
+#else
+static void
+yy_stack_print (yybottom, yytop)
+ yytype_int16 *yybottom;
+ yytype_int16 *yytop;
+#endif
+{
+ YYFPRINTF (stderr, "Stack now");
+ for (; yybottom <= yytop; yybottom++)
+ {
+ int yybot = *yybottom;
+ YYFPRINTF (stderr, " %d", yybot);
+ }
+ YYFPRINTF (stderr, "\n");
+}
+
+# define YY_STACK_PRINT(Bottom, Top) \
+do { \
+ if (yydebug) \
+ yy_stack_print ((Bottom), (Top)); \
+} while (YYID (0))
+
+
+/*------------------------------------------------.
+| Report that the YYRULE is going to be reduced. |
+`------------------------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
+#else
+static void
+yy_reduce_print (yyvsp, yyrule)
+ YYSTYPE *yyvsp;
+ int yyrule;
+#endif
+{
+ int yynrhs = yyr2[yyrule];
+ int yyi;
+ unsigned long int yylno = yyrline[yyrule];
+ YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
+ yyrule - 1, yylno);
+ /* The symbols being reduced. */
+ for (yyi = 0; yyi < yynrhs; yyi++)
+ {
+ YYFPRINTF (stderr, " $%d = ", yyi + 1);
+ yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
+ &(yyvsp[(yyi + 1) - (yynrhs)])
+ );
+ YYFPRINTF (stderr, "\n");
+ }
+}
+
+# define YY_REDUCE_PRINT(Rule) \
+do { \
+ if (yydebug) \
+ yy_reduce_print (yyvsp, Rule); \
+} while (YYID (0))
+
+/* Nonzero means print parse trace. It is left uninitialized so that
+ multiple parsers can coexist. */
+int yydebug;
+#else /* !YYDEBUG */
+# define YYDPRINTF(Args)
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
+# define YY_STACK_PRINT(Bottom, Top)
+# define YY_REDUCE_PRINT(Rule)
+#endif /* !YYDEBUG */
+
+
+/* YYINITDEPTH -- initial size of the parser's stacks. */
+#ifndef YYINITDEPTH
+# define YYINITDEPTH 200
+#endif
+
+/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
+ if the built-in stack extension method is used).
+
+ Do not make this value too large; the results are undefined if
+ YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
+ evaluated with infinite-precision integer arithmetic. */
+
+#ifndef YYMAXDEPTH
+# define YYMAXDEPTH 10000
+#endif
+
+
+#if YYERROR_VERBOSE
+
+# ifndef yystrlen
+# if defined __GLIBC__ && defined _STRING_H
+# define yystrlen strlen
+# else
+/* Return the length of YYSTR. */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static YYSIZE_T
+yystrlen (const char *yystr)
+#else
+static YYSIZE_T
+yystrlen (yystr)
+ const char *yystr;
+#endif
+{
+ YYSIZE_T yylen;
+ for (yylen = 0; yystr[yylen]; yylen++)
+ continue;
+ return yylen;
+}
+# endif
+# endif
+
+# ifndef yystpcpy
+# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
+# define yystpcpy stpcpy
+# else
+/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
+ YYDEST. */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static char *
+yystpcpy (char *yydest, const char *yysrc)
+#else
+static char *
+yystpcpy (yydest, yysrc)
+ char *yydest;
+ const char *yysrc;
+#endif
+{
+ char *yyd = yydest;
+ const char *yys = yysrc;
+
+ while ((*yyd++ = *yys++) != '\0')
+ continue;
+
+ return yyd - 1;
+}
+# endif
+# endif
+
+# ifndef yytnamerr
+/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
+ quotes and backslashes, so that it's suitable for yyerror. The
+ heuristic is that double-quoting is unnecessary unless the string
+ contains an apostrophe, a comma, or backslash (other than
+ backslash-backslash). YYSTR is taken from yytname. If YYRES is
+ null, do not copy; instead, return the length of what the result
+ would have been. */
+static YYSIZE_T
+yytnamerr (char *yyres, const char *yystr)
+{
+ if (*yystr == '"')
+ {
+ YYSIZE_T yyn = 0;
+ char const *yyp = yystr;
+
+ for (;;)
+ switch (*++yyp)
+ {
+ case '\'':
+ case ',':
+ goto do_not_strip_quotes;
+
+ case '\\':
+ if (*++yyp != '\\')
+ goto do_not_strip_quotes;
+ /* Fall through. */
+ default:
+ if (yyres)
+ yyres[yyn] = *yyp;
+ yyn++;
+ break;
+
+ case '"':
+ if (yyres)
+ yyres[yyn] = '\0';
+ return yyn;
+ }
+ do_not_strip_quotes: ;
+ }
+
+ if (! yyres)
+ return yystrlen (yystr);
+
+ return yystpcpy (yyres, yystr) - yyres;
+}
+# endif
+
+/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
+ about the unexpected token YYTOKEN for the state stack whose top is
+ YYSSP.
+
+ Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
+ not large enough to hold the message. In that case, also set
+ *YYMSG_ALLOC to the required number of bytes. Return 2 if the
+ required number of bytes is too large to store. */
+static int
+yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
+ yytype_int16 *yyssp, int yytoken)
+{
+ YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
+ YYSIZE_T yysize = yysize0;
+ YYSIZE_T yysize1;
+ enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
+ /* Internationalized format string. */
+ const char *yyformat = 0;
+ /* Arguments of yyformat. */
+ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
+ /* Number of reported tokens (one for the "unexpected", one per
+ "expected"). */
+ int yycount = 0;
+
+ /* There are many possibilities here to consider:
+ - Assume YYFAIL is not used. It's too flawed to consider. See
+ <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
+ for details. YYERROR is fine as it does not invoke this
+ function.
+ - If this state is a consistent state with a default action, then
+ the only way this function was invoked is if the default action
+ is an error action. In that case, don't check for expected
+ tokens because there are none.
+ - The only way there can be no lookahead present (in yychar) is if
+ this state is a consistent state with a default action. Thus,
+ detecting the absence of a lookahead is sufficient to determine
+ that there is no unexpected or expected token to report. In that
+ case, just report a simple "syntax error".
+ - Don't assume there isn't a lookahead just because this state is a
+ consistent state with a default action. There might have been a
+ previous inconsistent state, consistent state with a non-default
+ action, or user semantic action that manipulated yychar.
+ - Of course, the expected token list depends on states to have
+ correct lookahead information, and it depends on the parser not
+ to perform extra reductions after fetching a lookahead from the
+ scanner and before detecting a syntax error. Thus, state merging
+ (from LALR or IELR) and default reductions corrupt the expected
+ token list. However, the list is correct for canonical LR with
+ one exception: it will still contain any token that will not be
+ accepted due to an error action in a later state.
+ */
+ if (yytoken != YYEMPTY)
+ {
+ int yyn = yypact[*yyssp];
+ yyarg[yycount++] = yytname[yytoken];
+ if (!yypact_value_is_default (yyn))
+ {
+ /* Start YYX at -YYN if negative to avoid negative indexes in
+ YYCHECK. In other words, skip the first -YYN actions for
+ this state because they are default actions. */
+ int yyxbegin = yyn < 0 ? -yyn : 0;
+ /* Stay within bounds of both yycheck and yytname. */
+ int yychecklim = YYLAST - yyn + 1;
+ int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
+ int yyx;
+
+ for (yyx = yyxbegin; yyx < yyxend; ++yyx)
+ if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
+ && !yytable_value_is_error (yytable[yyx + yyn]))
+ {
+ if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
+ {
+ yycount = 1;
+ yysize = yysize0;
+ break;
+ }
+ yyarg[yycount++] = yytname[yyx];
+ yysize1 = yysize + yytnamerr (0, yytname[yyx]);
+ if (! (yysize <= yysize1
+ && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ return 2;
+ yysize = yysize1;
+ }
+ }
+ }
+
+ switch (yycount)
+ {
+# define YYCASE_(N, S) \
+ case N: \
+ yyformat = S; \
+ break
+ YYCASE_(0, YY_("syntax error"));
+ YYCASE_(1, YY_("syntax error, unexpected %s"));
+ YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
+ YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
+ YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
+ YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
+# undef YYCASE_
+ }
+
+ yysize1 = yysize + yystrlen (yyformat);
+ if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ return 2;
+ yysize = yysize1;
+
+ if (*yymsg_alloc < yysize)
+ {
+ *yymsg_alloc = 2 * yysize;
+ if (! (yysize <= *yymsg_alloc
+ && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
+ *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
+ return 1;
+ }
+
+ /* Avoid sprintf, as that infringes on the user's name space.
+ Don't have undefined behavior even if the translation
+ produced a string with the wrong number of "%s"s. */
+ {
+ char *yyp = *yymsg;
+ int yyi = 0;
+ while ((*yyp = *yyformat) != '\0')
+ if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
+ {
+ yyp += yytnamerr (yyp, yyarg[yyi++]);
+ yyformat += 2;
+ }
+ else
+ {
+ yyp++;
+ yyformat++;
+ }
+ }
+ return 0;
+}
+#endif /* YYERROR_VERBOSE */
+
+/*-----------------------------------------------.
+| Release the memory associated to this symbol. |
+`-----------------------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
+#else
+static void
+yydestruct (yymsg, yytype, yyvaluep)
+ const char *yymsg;
+ int yytype;
+ YYSTYPE *yyvaluep;
+#endif
+{
+ YYUSE (yyvaluep);
+
+ if (!yymsg)
+ yymsg = "Deleting";
+ YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
+
+ switch (yytype)
+ {
+
+ default:
+ break;
+ }
+}
+
+
+/* Prevent warnings from -Wmissing-prototypes. */
+#ifdef YYPARSE_PARAM
+#if defined __STDC__ || defined __cplusplus
+int yyparse (void *YYPARSE_PARAM);
+#else
+int yyparse ();
+#endif
+#else /* ! YYPARSE_PARAM */
+#if defined __STDC__ || defined __cplusplus
+int yyparse (void);
+#else
+int yyparse ();
+#endif
+#endif /* ! YYPARSE_PARAM */
+
+
+/* The lookahead symbol. */
+int yychar;
+
+/* The semantic value of the lookahead symbol. */
+YYSTYPE yylval;
+
+/* Number of syntax errors so far. */
+int yynerrs;
+
+
+/*----------.
+| yyparse. |
+`----------*/
+
+#ifdef YYPARSE_PARAM
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (void *YYPARSE_PARAM)
+#else
+int
+yyparse (YYPARSE_PARAM)
+ void *YYPARSE_PARAM;
+#endif
+#else /* ! YYPARSE_PARAM */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (void)
+#else
+int
+yyparse ()
+
+#endif
+#endif
+{
+ int yystate;
+ /* Number of tokens to shift before error messages enabled. */
+ int yyerrstatus;
+
+ /* The stacks and their tools:
+ `yyss': related to states.
+ `yyvs': related to semantic values.
+
+ Refer to the stacks thru separate pointers, to allow yyoverflow
+ to reallocate them elsewhere. */
+
+ /* The state stack. */
+ yytype_int16 yyssa[YYINITDEPTH];
+ yytype_int16 *yyss;
+ yytype_int16 *yyssp;
+
+ /* The semantic value stack. */
+ YYSTYPE yyvsa[YYINITDEPTH];
+ YYSTYPE *yyvs;
+ YYSTYPE *yyvsp;
+
+ YYSIZE_T yystacksize;
+
+ int yyn;
+ int yyresult;
+ /* Lookahead token as an internal (translated) token number. */
+ int yytoken;
+ /* The variables used to return semantic value and location from the
+ action routines. */
+ YYSTYPE yyval;
+
+#if YYERROR_VERBOSE
+ /* Buffer for error messages, and its allocated size. */
+ char yymsgbuf[128];
+ char *yymsg = yymsgbuf;
+ YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
+#endif
+
+#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
+
+ /* The number of symbols on the RHS of the reduced rule.
+ Keep to zero when no symbol should be popped. */
+ int yylen = 0;
+
+ yytoken = 0;
+ yyss = yyssa;
+ yyvs = yyvsa;
+ yystacksize = YYINITDEPTH;
+
+ YYDPRINTF ((stderr, "Starting parse\n"));
+
+ yystate = 0;
+ yyerrstatus = 0;
+ yynerrs = 0;
+ yychar = YYEMPTY; /* Cause a token to be read. */
+
+ /* Initialize stack pointers.
+ Waste one element of value and location stack
+ so that they stay on the same level as the state stack.
+ The wasted elements are never initialized. */
+ yyssp = yyss;
+ yyvsp = yyvs;
+
+ goto yysetstate;
+
+/*------------------------------------------------------------.
+| yynewstate -- Push a new state, which is found in yystate. |
+`------------------------------------------------------------*/
+ yynewstate:
+ /* In all cases, when you get here, the value and location stacks
+ have just been pushed. So pushing a state here evens the stacks. */
+ yyssp++;
+
+ yysetstate:
+ *yyssp = yystate;
+
+ if (yyss + yystacksize - 1 <= yyssp)
+ {
+ /* Get the current used size of the three stacks, in elements. */
+ YYSIZE_T yysize = yyssp - yyss + 1;
+
+#ifdef yyoverflow
+ {
+ /* Give user a chance to reallocate the stack. Use copies of
+ these so that the &'s don't force the real ones into
+ memory. */
+ YYSTYPE *yyvs1 = yyvs;
+ yytype_int16 *yyss1 = yyss;
+
+ /* Each stack pointer address is followed by the size of the
+ data in use in that stack, in bytes. This used to be a
+ conditional around just the two extra args, but that might
+ be undefined if yyoverflow is a macro. */
+ yyoverflow (YY_("memory exhausted"),
+ &yyss1, yysize * sizeof (*yyssp),
+ &yyvs1, yysize * sizeof (*yyvsp),
+ &yystacksize);
+
+ yyss = yyss1;
+ yyvs = yyvs1;
+ }
+#else /* no yyoverflow */
+# ifndef YYSTACK_RELOCATE
+ goto yyexhaustedlab;
+# else
+ /* Extend the stack our own way. */
+ if (YYMAXDEPTH <= yystacksize)
+ goto yyexhaustedlab;
+ yystacksize *= 2;
+ if (YYMAXDEPTH < yystacksize)
+ yystacksize = YYMAXDEPTH;
+
+ {
+ yytype_int16 *yyss1 = yyss;
+ union yyalloc *yyptr =
+ (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
+ if (! yyptr)
+ goto yyexhaustedlab;
+ YYSTACK_RELOCATE (yyss_alloc, yyss);
+ YYSTACK_RELOCATE (yyvs_alloc, yyvs);
+# undef YYSTACK_RELOCATE
+ if (yyss1 != yyssa)
+ YYSTACK_FREE (yyss1);
+ }
+# endif
+#endif /* no yyoverflow */
+
+ yyssp = yyss + yysize - 1;
+ yyvsp = yyvs + yysize - 1;
+
+ YYDPRINTF ((stderr, "Stack size increased to %lu\n",
+ (unsigned long int) yystacksize));
+
+ if (yyss + yystacksize - 1 <= yyssp)
+ YYABORT;
+ }
+
+ YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+
+ if (yystate == YYFINAL)
+ YYACCEPT;
+
+ goto yybackup;
+
+/*-----------.
+| yybackup. |
+`-----------*/
+yybackup:
+
+ /* Do appropriate processing given the current state. Read a
+ lookahead token if we need one and don't already have one. */
+
+ /* First try to decide what to do without reference to lookahead token. */
+ yyn = yypact[yystate];
+ if (yypact_value_is_default (yyn))
+ goto yydefault;
+
+ /* Not known => get a lookahead token if don't already have one. */
+
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
+ if (yychar == YYEMPTY)
+ {
+ YYDPRINTF ((stderr, "Reading a token: "));
+ yychar = YYLEX;
+ }
+
+ if (yychar <= YYEOF)
+ {
+ yychar = yytoken = YYEOF;
+ YYDPRINTF ((stderr, "Now at end of input.\n"));
+ }
+ else
+ {
+ yytoken = YYTRANSLATE (yychar);
+ YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
+ }
+
+ /* If the proper action on seeing token YYTOKEN is to reduce or to
+ detect an error, take that action. */
+ yyn += yytoken;
+ if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
+ goto yydefault;
+ yyn = yytable[yyn];
+ if (yyn <= 0)
+ {
+ if (yytable_value_is_error (yyn))
+ goto yyerrlab;
+ yyn = -yyn;
+ goto yyreduce;
+ }
+
+ /* Count tokens shifted since error; after three, turn off error
+ status. */
+ if (yyerrstatus)
+ yyerrstatus--;
+
+ /* Shift the lookahead token. */
+ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
+
+ /* Discard the shifted token. */
+ yychar = YYEMPTY;
+
+ yystate = yyn;
+ *++yyvsp = yylval;
+
+ goto yynewstate;
+
+
+/*-----------------------------------------------------------.
+| yydefault -- do the default action for the current state. |
+`-----------------------------------------------------------*/
+yydefault:
+ yyn = yydefact[yystate];
+ if (yyn == 0)
+ goto yyerrlab;
+ goto yyreduce;
+
+
+/*-----------------------------.
+| yyreduce -- Do a reduction. |
+`-----------------------------*/
+yyreduce:
+ /* yyn is the number of a rule to reduce with. */
+ yylen = yyr2[yyn];
+
+ /* If YYLEN is nonzero, implement the default value of the action:
+ `$$ = $1'.
+
+ Otherwise, the following line sets YYVAL to garbage.
+ This behavior is undocumented and Bison
+ users should not rely upon it. Assigning to YYVAL
+ unconditionally makes the parser a bit smaller, and it avoids a
+ GCC warning that YYVAL may be used uninitialized. */
+ yyval = yyvsp[1-yylen];
+
+
+ YY_REDUCE_PRINT (yyn);
+ switch (yyn)
+ {
+ case 3:
+
+/* Line 1806 of yacc.c */
+#line 37 "pbc/parser.y"
+ { tree_eval_stmt((yyvsp[(2) - (2)])); }
+ break;
+
+ case 5:
+
+/* Line 1806 of yacc.c */
+#line 42 "pbc/parser.y"
+ {
+ (yyval) = tree_new_define((yyvsp[(2) - (8)]), (yyvsp[(4) - (8)]), (yyvsp[(7) - (8)]));
+ }
+ break;
+
+ case 6:
+
+/* Line 1806 of yacc.c */
+#line 48 "pbc/parser.y"
+ { (yyval) = tree_new_empty_stmt_list(); }
+ break;
+
+ case 7:
+
+/* Line 1806 of yacc.c */
+#line 49 "pbc/parser.y"
+ { tree_append((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); }
+ break;
+
+ case 8:
+
+/* Line 1806 of yacc.c */
+#line 53 "pbc/parser.y"
+ { (yyval) = tree_new_empty_parms(); }
+ break;
+
+ case 10:
+
+/* Line 1806 of yacc.c */
+#line 58 "pbc/parser.y"
+ { (yyval) = tree_new_empty_parms(); tree_append((yyval), (yyvsp[(1) - (1)])); }
+ break;
+
+ case 11:
+
+/* Line 1806 of yacc.c */
+#line 59 "pbc/parser.y"
+ { tree_append((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); }
+ break;
+
+ case 13:
+
+/* Line 1806 of yacc.c */
+#line 64 "pbc/parser.y"
+ { (yyval) = tree_new_assign((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); }
+ break;
+
+ case 14:
+
+/* Line 1806 of yacc.c */
+#line 65 "pbc/parser.y"
+ { (yyval) = tree_new_ternary((yyvsp[(1) - (5)]), (yyvsp[(3) - (5)]), (yyvsp[(5) - (5)])); }
+ break;
+
+ case 16:
+
+/* Line 1806 of yacc.c */
+#line 67 "pbc/parser.y"
+ { (yyval) = tree_new_item((yyvsp[(1) - (4)]), (yyvsp[(3) - (4)])); }
+ break;
+
+ case 17:
+
+/* Line 1806 of yacc.c */
+#line 68 "pbc/parser.y"
+ { (yyval) = tree_new_eq((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); }
+ break;
+
+ case 18:
+
+/* Line 1806 of yacc.c */
+#line 69 "pbc/parser.y"
+ { (yyval) = tree_new_ne((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); }
+ break;
+
+ case 19:
+
+/* Line 1806 of yacc.c */
+#line 70 "pbc/parser.y"
+ { (yyval) = tree_new_le((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); }
+ break;
+
+ case 20:
+
+/* Line 1806 of yacc.c */
+#line 71 "pbc/parser.y"
+ { (yyval) = tree_new_ge((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); }
+ break;
+
+ case 21:
+
+/* Line 1806 of yacc.c */
+#line 72 "pbc/parser.y"
+ { (yyval) = tree_new_lt((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); }
+ break;
+
+ case 22:
+
+/* Line 1806 of yacc.c */
+#line 73 "pbc/parser.y"
+ { (yyval) = tree_new_gt((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); }
+ break;
+
+ case 23:
+
+/* Line 1806 of yacc.c */
+#line 74 "pbc/parser.y"
+ { (yyval) = tree_new_add((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); }
+ break;
+
+ case 24:
+
+/* Line 1806 of yacc.c */
+#line 75 "pbc/parser.y"
+ { (yyval) = tree_new_sub((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); }
+ break;
+
+ case 25:
+
+/* Line 1806 of yacc.c */
+#line 76 "pbc/parser.y"
+ { (yyval) = tree_new_mul((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); }
+ break;
+
+ case 26:
+
+/* Line 1806 of yacc.c */
+#line 77 "pbc/parser.y"
+ { (yyval) = tree_new_div((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); }
+ break;
+
+ case 27:
+
+/* Line 1806 of yacc.c */
+#line 78 "pbc/parser.y"
+ { (yyval) = tree_new_pow((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); }
+ break;
+
+ case 28:
+
+/* Line 1806 of yacc.c */
+#line 79 "pbc/parser.y"
+ { (yyval) = tree_new_neg((yyvsp[(2) - (2)])); }
+ break;
+
+ case 29:
+
+/* Line 1806 of yacc.c */
+#line 84 "pbc/parser.y"
+ { (yyval) = (yyvsp[(3) - (4)]); tree_set_fun((yyval), (yyvsp[(1) - (4)])); }
+ break;
+
+ case 30:
+
+/* Line 1806 of yacc.c */
+#line 85 "pbc/parser.y"
+ { (yyval) = (yyvsp[(2) - (3)]); }
+ break;
+
+ case 32:
+
+/* Line 1806 of yacc.c */
+#line 90 "pbc/parser.y"
+ { (yyval) = tree_new_funcall(); }
+ break;
+
+ case 34:
+
+/* Line 1806 of yacc.c */
+#line 95 "pbc/parser.y"
+ { tree_append((yyval) = tree_new_funcall(), (yyvsp[(1) - (1)])); }
+ break;
+
+ case 35:
+
+/* Line 1806 of yacc.c */
+#line 96 "pbc/parser.y"
+ { tree_append((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); }
+ break;
+
+ case 38:
+
+/* Line 1806 of yacc.c */
+#line 105 "pbc/parser.y"
+ { (yyval) = (yyvsp[(2) - (3)]); }
+ break;
+
+ case 39:
+
+/* Line 1806 of yacc.c */
+#line 109 "pbc/parser.y"
+ { (yyval) = tree_new_list((yyvsp[(1) - (1)])); }
+ break;
+
+ case 40:
+
+/* Line 1806 of yacc.c */
+#line 110 "pbc/parser.y"
+ { tree_append((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); }
+ break;
+
+
+
+/* Line 1806 of yacc.c */
+#line 1674 "pbc/parser.tab.c"
+ default: break;
+ }
+ /* User semantic actions sometimes alter yychar, and that requires
+ that yytoken be updated with the new translation. We take the
+ approach of translating immediately before every use of yytoken.
+ One alternative is translating here after every semantic action,
+ but that translation would be missed if the semantic action invokes
+ YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
+ if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
+ incorrect destructor might then be invoked immediately. In the
+ case of YYERROR or YYBACKUP, subsequent parser actions might lead
+ to an incorrect destructor call or verbose syntax error message
+ before the lookahead is translated. */
+ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
+
+ YYPOPSTACK (yylen);
+ yylen = 0;
+ YY_STACK_PRINT (yyss, yyssp);
+
+ *++yyvsp = yyval;
+
+ /* Now `shift' the result of the reduction. Determine what state
+ that goes to, based on the state we popped back to and the rule
+ number reduced by. */
+
+ yyn = yyr1[yyn];
+
+ yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
+ if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
+ yystate = yytable[yystate];
+ else
+ yystate = yydefgoto[yyn - YYNTOKENS];
+
+ goto yynewstate;
+
+
+/*------------------------------------.
+| yyerrlab -- here on detecting error |
+`------------------------------------*/
+yyerrlab:
+ /* Make sure we have latest lookahead translation. See comments at
+ user semantic actions for why this is necessary. */
+ yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
+
+ /* If not already recovering from an error, report this error. */
+ if (!yyerrstatus)
+ {
+ ++yynerrs;
+#if ! YYERROR_VERBOSE
+ yyerror (YY_("syntax error"));
+#else
+# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
+ yyssp, yytoken)
+ {
+ char const *yymsgp = YY_("syntax error");
+ int yysyntax_error_status;
+ yysyntax_error_status = YYSYNTAX_ERROR;
+ if (yysyntax_error_status == 0)
+ yymsgp = yymsg;
+ else if (yysyntax_error_status == 1)
+ {
+ if (yymsg != yymsgbuf)
+ YYSTACK_FREE (yymsg);
+ yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
+ if (!yymsg)
+ {
+ yymsg = yymsgbuf;
+ yymsg_alloc = sizeof yymsgbuf;
+ yysyntax_error_status = 2;
+ }
+ else
+ {
+ yysyntax_error_status = YYSYNTAX_ERROR;
+ yymsgp = yymsg;
+ }
+ }
+ yyerror (yymsgp);
+ if (yysyntax_error_status == 2)
+ goto yyexhaustedlab;
+ }
+# undef YYSYNTAX_ERROR
+#endif
+ }
+
+
+
+ if (yyerrstatus == 3)
+ {
+ /* If just tried and failed to reuse lookahead token after an
+ error, discard it. */
+
+ if (yychar <= YYEOF)
+ {
+ /* Return failure if at end of input. */
+ if (yychar == YYEOF)
+ YYABORT;
+ }
+ else
+ {
+ yydestruct ("Error: discarding",
+ yytoken, &yylval);
+ yychar = YYEMPTY;
+ }
+ }
+
+ /* Else will try to reuse lookahead token after shifting the error
+ token. */
+ goto yyerrlab1;
+
+
+/*---------------------------------------------------.
+| yyerrorlab -- error raised explicitly by YYERROR. |
+`---------------------------------------------------*/
+yyerrorlab:
+
+ /* Pacify compilers like GCC when the user code never invokes
+ YYERROR and the label yyerrorlab therefore never appears in user
+ code. */
+ if (/*CONSTCOND*/ 0)
+ goto yyerrorlab;
+
+ /* Do not reclaim the symbols of the rule which action triggered
+ this YYERROR. */
+ YYPOPSTACK (yylen);
+ yylen = 0;
+ YY_STACK_PRINT (yyss, yyssp);
+ yystate = *yyssp;
+ goto yyerrlab1;
+
+
+/*-------------------------------------------------------------.
+| yyerrlab1 -- common code for both syntax error and YYERROR. |
+`-------------------------------------------------------------*/
+yyerrlab1:
+ yyerrstatus = 3; /* Each real token shifted decrements this. */
+
+ for (;;)
+ {
+ yyn = yypact[yystate];
+ if (!yypact_value_is_default (yyn))
+ {
+ yyn += YYTERROR;
+ if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
+ {
+ yyn = yytable[yyn];
+ if (0 < yyn)
+ break;
+ }
+ }
+
+ /* Pop the current state because it cannot handle the error token. */
+ if (yyssp == yyss)
+ YYABORT;
+
+
+ yydestruct ("Error: popping",
+ yystos[yystate], yyvsp);
+ YYPOPSTACK (1);
+ yystate = *yyssp;
+ YY_STACK_PRINT (yyss, yyssp);
+ }
+
+ *++yyvsp = yylval;
+
+
+ /* Shift the error token. */
+ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
+
+ yystate = yyn;
+ goto yynewstate;
+
+
+/*-------------------------------------.
+| yyacceptlab -- YYACCEPT comes here. |
+`-------------------------------------*/
+yyacceptlab:
+ yyresult = 0;
+ goto yyreturn;
+
+/*-----------------------------------.
+| yyabortlab -- YYABORT comes here. |
+`-----------------------------------*/
+yyabortlab:
+ yyresult = 1;
+ goto yyreturn;
+
+#if !defined(yyoverflow) || YYERROR_VERBOSE
+/*-------------------------------------------------.
+| yyexhaustedlab -- memory exhaustion comes here. |
+`-------------------------------------------------*/
+yyexhaustedlab:
+ yyerror (YY_("memory exhausted"));
+ yyresult = 2;
+ /* Fall through. */
+#endif
+
+yyreturn:
+ if (yychar != YYEMPTY)
+ {
+ /* Make sure we have latest lookahead translation. See comments at
+ user semantic actions for why this is necessary. */
+ yytoken = YYTRANSLATE (yychar);
+ yydestruct ("Cleanup: discarding lookahead",
+ yytoken, &yylval);
+ }
+ /* Do not reclaim the symbols of the rule which action triggered
+ this YYABORT or YYACCEPT. */
+ YYPOPSTACK (yylen);
+ YY_STACK_PRINT (yyss, yyssp);
+ while (yyssp != yyss)
+ {
+ yydestruct ("Cleanup: popping",
+ yystos[*yyssp], yyvsp);
+ YYPOPSTACK (1);
+ }
+#ifndef yyoverflow
+ if (yyss != yyssa)
+ YYSTACK_FREE (yyss);
+#endif
+#if YYERROR_VERBOSE
+ if (yymsg != yymsgbuf)
+ YYSTACK_FREE (yymsg);
+#endif
+ /* Make sure YYID is used. */
+ return YYID (yyresult);
+}
+
+
+
+/* Line 2067 of yacc.c */
+#line 112 "pbc/parser.y"
+
+
diff --git a/moon-abe/pbc-0.5.14/pbc/parser.tab.h b/moon-abe/pbc-0.5.14/pbc/parser.tab.h
new file mode 100644
index 00000000..bbea9735
--- /dev/null
+++ b/moon-abe/pbc-0.5.14/pbc/parser.tab.h
@@ -0,0 +1,82 @@
+/* A Bison parser, made by GNU Bison 2.5. */
+
+/* Bison interface for Yacc-like parsers in C
+
+ Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* As a special exception, you may create a larger work that contains
+ part or all of the Bison parser skeleton and distribute that work
+ under terms of your choice, so long as that work isn't itself a
+ parser generator using the skeleton or a modified version thereof
+ as a parser skeleton. Alternatively, if you modify or redistribute
+ the parser skeleton itself, you may (at your option) remove this
+ special exception, which will cause the skeleton and the resulting
+ Bison output files to be licensed under the GNU General Public
+ License without this special exception.
+
+ This special exception was added by the Free Software Foundation in
+ version 2.2 of Bison. */
+
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ END = 0,
+ DEFINE = 258,
+ TERMINATOR = 259,
+ NUM = 260,
+ ID = 261,
+ LPAR = 262,
+ RPAR = 263,
+ LSQU = 264,
+ RSQU = 265,
+ LBRACE = 266,
+ RBRACE = 267,
+ COMMA = 268,
+ COLON = 269,
+ QUESTION = 270,
+ GE = 271,
+ LE = 272,
+ T_GT = 273,
+ LT = 274,
+ NE = 275,
+ EQ = 276,
+ ASSIGN = 277,
+ MINUS = 278,
+ PLUS = 279,
+ TIMES = 280,
+ DIVIDE = 281,
+ UMINUS = 282,
+ POW = 283,
+ UNKNOWN = 284
+ };
+#endif
+
+
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef int YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+extern YYSTYPE yylval;
+
+
diff --git a/moon-abe/pbc-0.5.14/pbc/parser.y b/moon-abe/pbc-0.5.14/pbc/parser.y
new file mode 100644
index 00000000..d51cebcc
--- /dev/null
+++ b/moon-abe/pbc-0.5.14/pbc/parser.y
@@ -0,0 +1,112 @@
+%{
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdint.h> // for intptr_t
+#include <gmp.h>
+#include "pbc_utils.h"
+#include "pbc_field.h"
+
+#include "pbc_tree.h"
+#define YYSTYPE tree_ptr
+void yyerror(const char *s);
+int yylex(void);
+
+#define YY_NO_INPUT
+#define YY_NO_UNPUT
+
+extern int option_easy;
+%}
+
+%error-verbose
+%token DEFINE
+%token TERMINATOR
+%token NUM ID
+%token LPAR RPAR LSQU RSQU LBRACE RBRACE COMMA
+%right QUESTION COLON
+%left EQ NE LT T_GT LE GE
+%right ASSIGN
+%left PLUS MINUS
+%left DIVIDE TIMES
+%right UMINUS
+%right POW
+%token UNKNOWN
+%token END 0 "end of file"
+%%
+input
+ : // Empty.
+ | input stmt { tree_eval_stmt($2); }
+ ;
+
+stmt
+ : expr TERMINATOR
+ | DEFINE ID LPAR parms RPAR LBRACE stmtlist RBRACE {
+ $$ = tree_new_define($2, $4, $7);
+ }
+ ;
+
+stmtlist
+ : { $$ = tree_new_empty_stmt_list(); } // Empty.
+ | stmtlist stmt { tree_append($1, $2); }
+ ;
+
+parms
+ : { $$ = tree_new_empty_parms(); } // Empty.
+ | parms1
+ ;
+
+parms1
+ : ID { $$ = tree_new_empty_parms(); tree_append($$, $1); }
+ | parms1 COMMA ID { tree_append($1, $3); }
+ ;
+
+expr
+ : multinomial
+ | ID ASSIGN expr { $$ = tree_new_assign($1, $3); }
+ | expr QUESTION expr COLON expr { $$ = tree_new_ternary($1, $3, $5); }
+ | molecule
+ | molecule LSQU expr RSQU { $$ = tree_new_item($1, $3); }
+ | expr EQ expr { $$ = tree_new_eq($1, $3); }
+ | expr NE expr { $$ = tree_new_ne($1, $3); }
+ | expr LE expr { $$ = tree_new_le($1, $3); }
+ | expr GE expr { $$ = tree_new_ge($1, $3); }
+ | expr LT expr { $$ = tree_new_lt($1, $3); }
+ | expr T_GT expr { $$ = tree_new_gt($1, $3); }
+ | expr PLUS expr { $$ = tree_new_add($1, $3); }
+ | expr MINUS expr { $$ = tree_new_sub($1, $3); }
+ | expr TIMES expr { $$ = tree_new_mul($1, $3); }
+ | expr DIVIDE expr { $$ = tree_new_div($1, $3); }
+ | expr POW expr { $$ = tree_new_pow($1, $3); }
+ | MINUS expr %prec UMINUS { $$ = tree_new_neg($2); }
+ ;
+
+// Not quite atoms.
+molecule
+ : molecule LPAR exprlist RPAR { $$ = $3; tree_set_fun($$, $1); }
+ | LPAR expr RPAR { $$ = $2; }
+ | ID
+ ;
+
+exprlist
+ : { $$ = tree_new_funcall(); } // Empty.
+ | nonemptyexprlist
+ ;
+
+nonemptyexprlist
+ : expr { tree_append($$ = tree_new_funcall(), $1); }
+ | nonemptyexprlist COMMA expr { tree_append($1, $3); }
+ ;
+
+multinomial
+ : NUM
+ | numlist
+ ;
+
+numlist
+ : LSQU sequence RSQU { $$ = $2; }
+ ;
+
+sequence
+ : expr { $$ = tree_new_list($1); }
+ | sequence COMMA expr { tree_append($1, $3); }
+ ;
+%%
diff --git a/moon-abe/pbc-0.5.14/pbc/pbc b/moon-abe/pbc-0.5.14/pbc/pbc
new file mode 100755
index 00000000..4e46481f
--- /dev/null
+++ b/moon-abe/pbc-0.5.14/pbc/pbc
@@ -0,0 +1,228 @@
+#! /bin/sh
+
+# pbc/pbc - temporary wrapper script for .libs/pbc
+# Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1
+#
+# The pbc/pbc program cannot be directly executed until all the libtool
+# libraries that it depends on are installed.
+#
+# This wrapper script should never be moved out of the build directory.
+# If it is, it will not operate correctly.
+
+# Sed substitution that helps us do robust quoting. It backslashifies
+# metacharacters that are still active within double-quoted strings.
+sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+relink_command="(cd /home/wukong/Dropbox/04_Workspace/opnfv-moon/moon-abe/pbc-0.5.14; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=/sbin:/usr/sbin:/usr/bin:/bin:/usr/local/sbin:/usr/local/bin; export PATH; gcc -Wall -W -Wfloat-equal -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wredundant-decls -Wendif-labels -Wshadow -pipe -ffast-math -U__STRICT_ANSI__ -std=gnu99 -fomit-frame-pointer -O3 -o \$progdir/\$file pbc_pbc-parser.tab.o pbc_pbc-lex.yy.o pbc_pbc-pbc.o pbc_pbc-pbc_getline.o pbc_pbc-darray.o pbc_pbc-symtab.o ./.libs/libpbc.so -lgmp -lm -Wl,-rpath -Wl,/home/wukong/Dropbox/04_Workspace/opnfv-moon/moon-abe/pbc-0.5.14/.libs)"
+
+# This environment variable determines our operation mode.
+if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then
+ # install mode needs the following variables:
+ generated_by_libtool_version='2.4.2'
+ notinst_deplibs=' libpbc.la'
+else
+ # When we are sourced in execute mode, $file and $ECHO are already set.
+ if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
+ file="$0"
+
+# A function that is used when there is no print builtin or printf.
+func_fallback_echo ()
+{
+ eval 'cat <<_LTECHO_EOF
+$1
+_LTECHO_EOF'
+}
+ ECHO="printf %s\\n"
+ fi
+
+# Very basic option parsing. These options are (a) specific to
+# the libtool wrapper, (b) are identical between the wrapper
+# /script/ and the wrapper /executable/ which is used only on
+# windows platforms, and (c) all begin with the string --lt-
+# (application programs are unlikely to have options which match
+# this pattern).
+#
+# There are only two supported options: --lt-debug and
+# --lt-dump-script. There is, deliberately, no --lt-help.
+#
+# The first argument to this parsing function should be the
+# script's ./libtool value, followed by no.
+lt_option_debug=
+func_parse_lt_options ()
+{
+ lt_script_arg0=$0
+ shift
+ for lt_opt
+ do
+ case "$lt_opt" in
+ --lt-debug) lt_option_debug=1 ;;
+ --lt-dump-script)
+ lt_dump_D=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%/[^/]*$%%'`
+ test "X$lt_dump_D" = "X$lt_script_arg0" && lt_dump_D=.
+ lt_dump_F=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%^.*/%%'`
+ cat "$lt_dump_D/$lt_dump_F"
+ exit 0
+ ;;
+ --lt-*)
+ $ECHO "Unrecognized --lt- option: '$lt_opt'" 1>&2
+ exit 1
+ ;;
+ esac
+ done
+
+ # Print the debug banner immediately:
+ if test -n "$lt_option_debug"; then
+ echo "pbc:pbc/pbc:${LINENO}: libtool wrapper (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1" 1>&2
+ fi
+}
+
+# Used when --lt-debug. Prints its arguments to stdout
+# (redirection is the responsibility of the caller)
+func_lt_dump_args ()
+{
+ lt_dump_args_N=1;
+ for lt_arg
+ do
+ $ECHO "pbc:pbc/pbc:${LINENO}: newargv[$lt_dump_args_N]: $lt_arg"
+ lt_dump_args_N=`expr $lt_dump_args_N + 1`
+ done
+}
+
+# Core function for launching the target application
+func_exec_program_core ()
+{
+
+ if test -n "$lt_option_debug"; then
+ $ECHO "pbc:pbc/pbc:${LINENO}: newargv[0]: $progdir/$program" 1>&2
+ func_lt_dump_args ${1+"$@"} 1>&2
+ fi
+ exec "$progdir/$program" ${1+"$@"}
+
+ $ECHO "$0: cannot exec $program $*" 1>&2
+ exit 1
+}
+
+# A function to encapsulate launching the target application
+# Strips options in the --lt-* namespace from $@ and
+# launches target application with the remaining arguments.
+func_exec_program ()
+{
+ case " $* " in
+ *\ --lt-*)
+ for lt_wr_arg
+ do
+ case $lt_wr_arg in
+ --lt-*) ;;
+ *) set x "$@" "$lt_wr_arg"; shift;;
+ esac
+ shift
+ done ;;
+ esac
+ func_exec_program_core ${1+"$@"}
+}
+
+ # Parse options
+ func_parse_lt_options "$0" ${1+"$@"}
+
+ # Find the directory that this script lives in.
+ thisdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'`
+ test "x$thisdir" = "x$file" && thisdir=.
+
+ # Follow symbolic links until we get to the real thisdir.
+ file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'`
+ while test -n "$file"; do
+ destdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'`
+
+ # If there was a directory component, then change thisdir.
+ if test "x$destdir" != "x$file"; then
+ case "$destdir" in
+ [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;;
+ *) thisdir="$thisdir/$destdir" ;;
+ esac
+ fi
+
+ file=`$ECHO "$file" | /bin/sed 's%^.*/%%'`
+ file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'`
+ done
+
+ # Usually 'no', except on cygwin/mingw when embedded into
+ # the cwrapper.
+ WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no
+ if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then
+ # special case for '.'
+ if test "$thisdir" = "."; then
+ thisdir=`pwd`
+ fi
+ # remove .libs from thisdir
+ case "$thisdir" in
+ *[\\/].libs ) thisdir=`$ECHO "$thisdir" | /bin/sed 's%[\\/][^\\/]*$%%'` ;;
+ .libs ) thisdir=. ;;
+ esac
+ fi
+
+ # Try to get the absolute directory name.
+ absdir=`cd "$thisdir" && pwd`
+ test -n "$absdir" && thisdir="$absdir"
+
+ program=lt-'pbc'
+ progdir="$thisdir/.libs"
+
+ if test ! -f "$progdir/$program" ||
+ { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \
+ test "X$file" != "X$progdir/$program"; }; then
+
+ file="$$-$program"
+
+ if test ! -d "$progdir"; then
+ mkdir "$progdir"
+ else
+ rm -f "$progdir/$file"
+ fi
+
+ # relink executable if necessary
+ if test -n "$relink_command"; then
+ if relink_command_output=`eval $relink_command 2>&1`; then :
+ else
+ printf %s\n "$relink_command_output" >&2
+ rm -f "$progdir/$file"
+ exit 1
+ fi
+ fi
+
+ mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null ||
+ { rm -f "$progdir/$program";
+ mv -f "$progdir/$file" "$progdir/$program"; }
+ rm -f "$progdir/$file"
+ fi
+
+ if test -f "$progdir/$program"; then
+ if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
+ # Run the actual program with our arguments.
+ func_exec_program ${1+"$@"}
+ fi
+ else
+ # The program doesn't exist.
+ $ECHO "$0: error: \`$progdir/$program' does not exist" 1>&2
+ $ECHO "This script is just a wrapper for $program." 1>&2
+ $ECHO "See the libtool documentation for more information." 1>&2
+ exit 1
+ fi
+fi
diff --git a/moon-abe/pbc-0.5.14/pbc/pbc.c b/moon-abe/pbc-0.5.14/pbc/pbc.c
new file mode 100644
index 00000000..6fb76046
--- /dev/null
+++ b/moon-abe/pbc-0.5.14/pbc/pbc.c
@@ -0,0 +1,953 @@
+// Pairing-Based Calculator.
+
+// TODO: Garbage collection.
+// TODO: Recursion (stack frames), anonymous functions.
+
+#include <unistd.h> // For getopt.
+
+#include "pbc.h"
+#include "pbc_fp.h"
+#include "pbc_z.h"
+#include "pbc_multiz.h"
+#include "pbc_poly.h"
+
+#include "misc/darray.h"
+#include "misc/symtab.h"
+
+#include "pbc_tree.h"
+
+#include "lex.yy.h"
+#include "parser.tab.h"
+
+int option_easy = 0;
+const char *option_prompt;
+
+char *pbc_getline(const char *prompt);
+
+void yyerror(char *s) { fprintf(stderr, "%s\n", s); }
+int yyparse(void);
+
+// Symbol table holding built-in functions and variables.
+static symtab_t reserved;
+// Symbol table holding user-defined variable and function names.
+static symtab_t tab;
+
+static field_t M;
+static field_t Z;
+static pairing_t pairing;
+
+struct val_s;
+typedef struct val_s *val_ptr;
+
+struct fun_s;
+typedef struct fun_s *fun_ptr;
+
+// Syntax tree node.
+struct tree_s {
+ // Evaluates this node.
+ val_ptr (*eval)(tree_ptr);
+ union {
+ const char *id;
+ element_ptr elem;
+ // Built-in function.
+ fun_ptr fun;
+ // Child nodes.
+ darray_ptr child;
+ };
+};
+
+enum {
+ ARITY_VARIABLE = -1,
+};
+
+// The interface of a val_ptr shared amongst many val_ptr objects.
+// Analog of C++ class.
+struct val_type_s {
+ // One of element, field, function, error.
+ char *name;
+ // Print out current value.
+ void (*out_str)(FILE *, val_ptr);
+ // Called when a variable is evaluated, e.g. "foo;".
+ val_ptr (*eval)(val_ptr);
+ // Called when a variable is used as a function, e.g. "foo();".
+ val_ptr (*funcall)(val_ptr, tree_ptr);
+};
+
+// Functions plus type checking data.
+struct fun_s {
+ const char *name;
+ val_ptr (*run)(val_ptr[]);
+ int arity;
+ const struct val_type_s **sig;
+};
+typedef struct fun_s fun_t[1];
+
+// When interpreting, each node of the syntax tree recursively evaluates
+// its children then returns a val_ptr.
+struct val_s {
+ struct val_type_s *type;
+ union {
+ element_ptr elem;
+ // User-defined function.
+ tree_ptr def;
+ // Built-in function.
+ fun_ptr fun;
+ field_ptr field;
+ const char *msg;
+ };
+};
+
+static val_ptr val_new_element(element_ptr e);
+static val_ptr val_new_field(field_ptr e);
+static val_ptr val_new_error(const char *msg, ...);
+
+// Evaluates syntax tree node.
+static val_ptr tree_eval(tree_ptr t) {
+ return t->eval(t);
+}
+
+static void v_elem_out(FILE* stream, val_ptr v) {
+ element_out_str(stream, 0, v->elem);
+}
+
+static val_ptr v_elem_eval(val_ptr v) {
+ element_ptr e = pbc_malloc(sizeof(*e));
+ element_init_same_as(e, v->elem);
+ element_set(e, v->elem);
+ return val_new_element(e);
+}
+
+static void v_builtin_out(FILE* stream, val_ptr v) {
+ // TODO: Print types of arguments.
+ fprintf(stream, "built-in function %s, arity %d",
+ v->fun->name, v->fun->arity);
+}
+
+static void v_define_out(FILE* stream, val_ptr v) {
+ fprintf(stream, "user-defined function %s",
+ ((tree_ptr) darray_at(v->def->child, 0))->id);
+}
+
+static val_ptr v_builtin(val_ptr v, tree_ptr t) {
+ fun_ptr fun = v->fun;
+ int n = fun->arity;
+ if (1 + n != darray_count(t->child)) {
+ return val_new_error("%s: wrong number of arguments", fun->name);
+ }
+ val_ptr arg[n];
+ int i;
+ for(i = 0; i < n; i++) {
+ arg[i] = tree_eval(darray_at(t->child, i));
+ if (fun->sig[i] && arg[i]->type != fun->sig[i]) {
+ return val_new_error("%s: argument %d type mismatch", fun->name, i + 1);
+ }
+ }
+ return fun->run(arg);
+}
+
+static void eval_stmt(void *ptr) {
+ tree_eval(ptr);
+}
+
+static val_ptr v_def_call(val_ptr v, tree_ptr t) {
+ int i;
+ const char* name = ((tree_ptr) darray_at(v->def->child, 0))->id;
+ darray_ptr parm = ((tree_ptr) darray_at(v->def->child, 1))->child;
+ int n = darray_count(parm);
+ if (1 + n != darray_count(t->child)) {
+ return val_new_error("%s: wrong number of arguments", name);
+ }
+ for(i = 0; i < n; i++) {
+ const char *id = ((tree_ptr) darray_at(parm, i))->id;
+ val_ptr v1 = tree_eval(darray_at(t->child, i));
+ // TODO: Stack frames for recursion.
+ symtab_put(tab, v1, id);
+ }
+ // Evaluate function body.
+ darray_ptr a = ((tree_ptr) darray_at(v->def->child, 2))->child;
+ darray_forall(a, eval_stmt);
+ return NULL;
+}
+
+static val_ptr v_field_cast(val_ptr v, tree_ptr t) {
+ // TODO: Check args, x is an element.
+ val_ptr x = tree_eval(darray_at(t->child, 0));
+ element_ptr e = x->elem;
+ if (e->field == M) {
+ if (v->field == M) return x;
+ element_ptr e2 = element_new(v->field);
+ if (element_is0(e)) // if 'set0' is not 'set1' in base field of GT, but we hope 'GT(0)' calls 'set1', we may directly call 'element_set0' here
+ element_set0(e2);
+ else if (element_is1(e)) // reason is same as above
+ element_set1(e2);
+ else
+ element_set_multiz(e2, e->data);
+ x->elem = e2;
+ return x;
+ }
+ if (v->field == M) {
+ // Map to/from integer. TODO: Map to/from multiz instead.
+ mpz_t z;
+ mpz_init(z);
+ element_to_mpz(z, e);
+ element_clear(e);
+ element_init(e, v->field);
+ element_set_mpz(e, z);
+ mpz_clear(z);
+ }
+ return x;
+}
+
+static void v_field_out(FILE* stream, val_ptr v) {
+ field_out_info(stream, v->field);
+}
+
+static val_ptr v_self(val_ptr v) {
+ return v;
+}
+
+static void v_err_out(FILE* stream, val_ptr v) {
+ fprintf(stream, "%s", v->msg);
+}
+
+static val_ptr v_errcall(val_ptr v, tree_ptr t) {
+ UNUSED_VAR(t);
+ return v;
+}
+
+static struct val_type_s
+ // TODO: Replace NULL with get_coeff.
+ v_elem[1] = {{ "element", v_elem_out, v_elem_eval, NULL }},
+ v_field[1] = {{ "field", v_field_out, v_self, v_field_cast }},
+ v_fun[1] = {{ "builtin", v_builtin_out, v_self, v_builtin }},
+ v_def[1] = {{ "function", v_define_out, v_self, v_def_call }},
+ v_error[1] = {{ "error", v_err_out, v_self, v_errcall }};
+
+// Function signature constants for type checking.
+const struct val_type_s *sig_field[] = { v_field };
+const struct val_type_s *sig_elem[] = { v_elem };
+const struct val_type_s *sig_any[] = { NULL };
+const struct val_type_s *sig_elem_elem[] = { v_elem, v_elem };
+const struct val_type_s *sig_field_elem[] = { v_field, v_elem };
+
+static val_ptr val_new_element(element_ptr e) {
+ val_ptr v = pbc_malloc(sizeof(*v));
+ v->type = v_elem;
+ v->elem = e;
+ return v;
+}
+
+static val_ptr val_new_field(field_ptr f) {
+ val_ptr v = pbc_malloc(sizeof(*v));
+ v->type = v_field;
+ v->field = f;
+ return v;
+}
+
+static val_ptr val_new_error(const char *msg, ...) {
+ va_list params;
+ char buf[80];
+
+ va_start(params, msg);
+ vsnprintf(buf, 80, msg, params);
+ va_end(params);
+
+ val_ptr v = pbc_malloc(sizeof(*v));
+ v->type = v_error;
+ v->msg = pbc_strdup(buf);
+ return v;
+}
+
+static val_ptr val_new_fun(fun_ptr fun) {
+ val_ptr v = pbc_malloc(sizeof(*v));
+ v->type = v_fun;
+ v->fun = fun;
+ return v;
+}
+
+static val_ptr fun_bin(
+ void (*binop)(element_ptr, element_ptr, element_ptr),
+ val_ptr v[]) {
+ binop(v[0]->elem, v[0]->elem, v[1]->elem);
+ return v[0];
+}
+
+static val_ptr run_add(val_ptr v[]) { return fun_bin(element_add, v); }
+static val_ptr run_sub(val_ptr v[]) { return fun_bin(element_sub, v); }
+static val_ptr run_mul(val_ptr v[]) { return fun_bin(element_mul, v); }
+static val_ptr run_div(val_ptr v[]) { return fun_bin(element_div, v); }
+static val_ptr run_pow(val_ptr v[]) { return fun_bin(element_pow_zn, v); }
+
+static fun_t fun_add = {{ "add", run_add, 2, sig_elem_elem }};
+static fun_t fun_sub = {{ "sub", run_sub, 2, sig_elem_elem }};
+static fun_t fun_mul = {{ "mul", run_mul, 2, sig_elem_elem }};
+static fun_t fun_div = {{ "div", run_div, 2, sig_elem_elem }};
+static fun_t fun_pow = {{ "pow", run_pow, 2, sig_elem_elem }};
+
+static val_ptr fun_cmp(val_ptr v[], int (*fun)(int)) {
+ int i = element_cmp(v[0]->elem, v[1]->elem);
+ element_ptr e = pbc_malloc(sizeof(*e));
+ element_init(e, M);
+ element_set_si(e, fun(i));
+ v[0]->elem = e;
+ return v[0];
+}
+
+static int is0(int i) {
+ return i == 0;
+}
+
+static int isnot0(int i) {
+ return i != 0;
+}
+
+static int isle(int i) {
+ return i <= 0;
+}
+
+static int isge(int i) {
+ return i >= 0;
+}
+
+static int islt(int i) {
+ return i < 0;
+}
+
+static int isgt(int i) {
+ return i > 0;
+}
+
+static val_ptr run_eq(val_ptr v[]) {
+ return fun_cmp(v, is0);
+}
+
+static val_ptr run_ne(val_ptr v[]) {
+ return fun_cmp(v, isnot0);
+}
+
+static val_ptr run_le(val_ptr v[]) {
+ return fun_cmp(v, isle);
+}
+
+static val_ptr run_ge(val_ptr v[]) {
+ return fun_cmp(v, isge);
+}
+static val_ptr run_lt(val_ptr v[]) {
+ return fun_cmp(v, islt);
+}
+static val_ptr run_gt(val_ptr v[]) {
+ return fun_cmp(v, isgt);
+}
+
+static fun_t fun_eq = {{ "==", run_eq, 2, sig_elem_elem }};
+static fun_t fun_ne = {{ "!=", run_ne, 2, sig_elem_elem }};
+static fun_t fun_le = {{ "<=", run_le, 2, sig_elem_elem }};
+static fun_t fun_ge = {{ ">=", run_ge, 2, sig_elem_elem }};
+static fun_t fun_lt = {{ "<", run_lt, 2, sig_elem_elem }};
+static fun_t fun_gt = {{ ">", run_gt, 2, sig_elem_elem }};
+
+static val_ptr eval_elem(tree_ptr t) {
+ // TODO: Write element_clone(), or at least element_new().
+ element_ptr e = pbc_malloc(sizeof(*e));
+ element_init_same_as(e, t->elem);
+ element_set(e, t->elem);
+ return val_new_element(e);
+}
+
+static val_ptr eval_list(tree_ptr t) {
+ element_ptr e = NULL;
+ int n = darray_count(t->child);
+ int i;
+ for(i = 0; i < n; i++) {
+ val_ptr x = tree_eval(darray_at(t->child, i));
+ // TODO: Also check x is a multiz.
+ if (v_error == x->type) {
+ return x;
+ }
+ if (v_elem != x->type) {
+ return val_new_error("element expected in list");
+ }
+ if (!i) e = multiz_new_list(x->elem);
+ else multiz_append(e, x->elem);
+ }
+ return val_new_element(e);
+}
+
+static val_ptr eval_ternary(tree_ptr t) {
+ val_ptr x = tree_eval(darray_at(t->child, 0));
+ if (v_error == x->type) {
+ return x;
+ }
+ if (x->type != v_elem) {
+ return val_new_error("element expected in ternary operator");
+ }
+ if (!element_is0(x->elem)) {
+ return tree_eval(darray_at(t->child, 1));
+ }
+ return tree_eval(darray_at(t->child, 2));
+}
+
+static val_ptr eval_id(tree_ptr t) {
+ val_ptr x = symtab_at(reserved, t->id);
+ if (!x) x = symtab_at(tab, t->id);
+ if (!x) {
+ return val_new_error("undefined variable %s", t->id);
+ }
+ return x->type->eval(x);
+}
+
+static val_ptr eval_funcall(tree_ptr t) {
+ val_ptr x = tree_eval(darray_last(t->child));
+ return x->type->funcall(x, t);
+}
+
+static val_ptr eval_fun(tree_ptr t) {
+ return val_new_fun(t->fun);
+}
+
+static val_ptr run_neg(val_ptr v[]) {
+ element_neg(v[0]->elem, v[0]->elem);
+ return v[0];
+}
+static fun_t fun_neg = {{ "neg", run_neg, 1, sig_elem }};
+
+static val_ptr eval_assign(tree_ptr t) {
+ tree_ptr tid = darray_at(t->child, 0);
+ val_ptr v = tree_eval(darray_at(t->child, 1));
+ if (symtab_at(reserved, tid->id)) {
+ return val_new_error("%s is reserved", tid->id);
+ }
+ symtab_put(tab, v, tid->id);
+ return v;
+}
+
+static void assign_field(field_ptr f, const char* s) {
+ symtab_put(tab, val_new_field(f), s);
+}
+
+tree_ptr tree_new(val_ptr (*eval)(tree_ptr)) {
+ tree_ptr res = pbc_malloc(sizeof(*res));
+ res->eval = eval;
+ return res;
+}
+
+tree_ptr tree_new_z(const char* s) {
+ element_ptr e = pbc_malloc(sizeof(*e));
+ element_init(e, M);
+ element_set_str(e, s, 0);
+ tree_ptr t = tree_new(eval_elem);
+ t->elem = e;
+ return t;
+}
+
+static val_ptr eval_err(tree_ptr t) {
+ UNUSED_VAR(t);
+ pbc_die("BUG: shouldn't reach here!");
+}
+
+tree_ptr tree_new_empty_stmt_list() {
+ tree_ptr t = tree_new(eval_err);
+ t->child = darray_new();
+ return t;
+}
+
+tree_ptr tree_new_empty_parms() {
+ tree_ptr t = tree_new(eval_err);
+ t->child = darray_new();
+ return t;
+}
+
+static val_ptr eval_define(tree_ptr t) {
+ val_ptr v = pbc_malloc(sizeof(*v));
+ v->type = v_def;
+ v->def = t;
+ symtab_put(tab, v, ((tree_ptr) darray_at(t->child, 0))->id);
+ return v;
+}
+
+tree_ptr tree_new_define(tree_ptr id, tree_ptr parm, tree_ptr body) {
+ tree_ptr t = tree_new(eval_define);
+ t->child = darray_new();
+ darray_append(t->child, id);
+ darray_append(t->child, parm);
+ darray_append(t->child, body);
+ return t;
+}
+
+tree_ptr tree_new_list(tree_ptr first) {
+ tree_ptr t = tree_new(eval_list);
+ t->child = darray_new();
+ darray_append(t->child, first);
+ return t;
+}
+
+tree_ptr tree_new_ternary(tree_ptr cond, tree_ptr t1, tree_ptr t2) {
+ tree_ptr t = tree_new(eval_ternary);
+ t->child = darray_new();
+ darray_append(t->child, cond);
+ darray_append(t->child, t1);
+ darray_append(t->child, t2);
+ return t;
+}
+
+tree_ptr tree_new_id(const char* s) {
+ tree_ptr t = tree_new(eval_id);
+ t->id = pbc_strdup(s);
+ return t;
+}
+
+tree_ptr tree_new_funcall(void) {
+ tree_ptr t = tree_new(eval_funcall);
+ t->child = darray_new();
+ return t;
+}
+
+static tree_ptr tree_new_fun(fun_ptr fun) {
+ tree_ptr t = tree_new(eval_fun);
+ t->fun = fun;
+ return t;
+}
+
+void tree_set_fun(tree_ptr f, tree_ptr src) {
+ darray_append(f->child, src);
+}
+
+void tree_append(tree_ptr f, tree_ptr p) {
+ darray_append(f->child, p);
+}
+
+tree_ptr tree_new_binary(fun_ptr fun, tree_ptr x, tree_ptr y) {
+ tree_ptr t = tree_new_funcall();
+ tree_append(t, x);
+ tree_append(t, y);
+ tree_set_fun(t, tree_new_fun(fun));
+ return t;
+}
+
+static tree_ptr tree_new_unary(fun_ptr fun, tree_ptr x) {
+ tree_ptr t = tree_new_funcall();
+ tree_append(t, x);
+ tree_set_fun(t, tree_new_fun(fun));
+ return t;
+}
+
+tree_ptr tree_new_neg(tree_ptr t) {
+ return tree_new_unary(fun_neg, t);
+}
+tree_ptr tree_new_add(tree_ptr x, tree_ptr y) {
+ return tree_new_binary(fun_add, x, y);
+}
+tree_ptr tree_new_sub(tree_ptr x, tree_ptr y) {
+ return tree_new_binary(fun_sub, x, y);
+}
+tree_ptr tree_new_mul(tree_ptr x, tree_ptr y) {
+ return tree_new_binary(fun_mul, x, y);
+}
+tree_ptr tree_new_div(tree_ptr x, tree_ptr y) {
+ return tree_new_binary(fun_div, x, y);
+}
+tree_ptr tree_new_pow(tree_ptr x, tree_ptr y) {
+ return tree_new_binary(fun_pow, x, y);
+}
+tree_ptr tree_new_eq(tree_ptr x, tree_ptr y) {
+ return tree_new_binary(fun_eq, x, y);
+}
+tree_ptr tree_new_ne(tree_ptr x, tree_ptr y) {
+ return tree_new_binary(fun_ne, x, y);
+}
+tree_ptr tree_new_le(tree_ptr x, tree_ptr y) {
+ return tree_new_binary(fun_le, x, y);
+}
+tree_ptr tree_new_ge(tree_ptr x, tree_ptr y) {
+ return tree_new_binary(fun_ge, x, y);
+}
+tree_ptr tree_new_lt(tree_ptr x, tree_ptr y) {
+ return tree_new_binary(fun_lt, x, y);
+}
+tree_ptr tree_new_gt(tree_ptr x, tree_ptr y) {
+ return tree_new_binary(fun_gt, x, y);
+}
+
+static val_ptr run_item(val_ptr v[]) {
+ mpz_t z;
+ mpz_init(z);
+ element_to_mpz(z, v[1]->elem);
+ int i = mpz_get_si(z);
+ mpz_clear(z);
+ element_ptr a = element_item(v[0]->elem, i);
+ element_ptr e = pbc_malloc(sizeof(*e));
+ element_init_same_as(e, a);
+ element_set(e, a);
+ return val_new_element(e);
+}
+static fun_t fun_item = {{ "item", run_item, 2, sig_elem_elem }};
+tree_ptr tree_new_item(tree_ptr x, tree_ptr y) {
+ return tree_new_binary(fun_item, x, y);
+}
+
+tree_ptr tree_new_assign(tree_ptr l, tree_ptr r) {
+ // TODO: Check l's type.
+ tree_ptr t = tree_new(eval_assign);
+ t->child = darray_new();
+ darray_append(t->child, l);
+ darray_append(t->child, r);
+ return t;
+}
+
+// Evaluate statement.
+void tree_eval_stmt(tree_ptr stmt) {
+ val_ptr v = tree_eval(stmt);
+ if (v && v_error == v->type) {
+ v->type->out_str(stdout, v);
+ putchar('\n');
+ } else if (stmt->eval != eval_assign && v) {
+ v->type->out_str(stdout, v);
+ putchar('\n');
+ }
+}
+
+static val_ptr run_nextprime(val_ptr v[]) {
+ element_ptr e = v[0]->elem;
+ mpz_t z;
+ mpz_init(z);
+ element_to_mpz(z, e);
+ mpz_nextprime(z, z);
+ element_set_mpz(e, z);
+ return v[0];
+}
+static fun_t fun_nextprime = {{ "nextprime", run_nextprime, 1, sig_elem }};
+
+static val_ptr run_order(val_ptr v[]) {
+ field_ptr f = v[0]->field;
+ element_ptr e = pbc_malloc(sizeof(*e));
+ element_init(e, M);
+ element_set_mpz(e, f->order);
+ return val_new_element(e);
+}
+static fun_t fun_ord = {{ "ord", run_order, 1, sig_field }};
+static fun_t fun_order = {{ "order", run_order, 1, sig_field }};
+
+static val_ptr run_random(val_ptr v[]) {
+ element_ptr e = pbc_malloc(sizeof(*e));
+ element_init(e, v[0]->field);
+ element_random(e);
+ return val_new_element(e);
+}
+static fun_t fun_rnd = {{ "rnd", run_random, 1, sig_field }};
+static fun_t fun_random = {{ "random", run_random, 1, sig_field }};
+
+static val_ptr run_sqrt(val_ptr v[]) {
+ // TODO: Check v[0] is square.
+ element_sqrt(v[0]->elem, v[0]->elem);
+ return v[0];
+}
+static fun_t fun_sqrt = {{ "sqrt", run_sqrt, 1, sig_elem }};
+
+static val_ptr run_invert(val_ptr v[]) {
+ // TODO: Check v[0] is invertible.
+ element_invert(v[0]->elem, v[0]->elem);
+ return v[0];
+}
+static fun_t fun_inv = {{ "inv", run_invert, 1, sig_elem }};
+
+static val_ptr run_type(val_ptr v[]) {
+ puts(v[0]->type->name);
+ return v[0];
+}
+static fun_t fun_type = {{ "type", run_type, 1, sig_any }};
+
+static val_ptr run_pairing(val_ptr v[]) {
+ element_ptr x = v[0]->elem;
+ element_ptr e = element_new(x->field->pairing->GT);
+ element_pairing(e, x, v[1]->elem);
+ return val_new_element(e);
+}
+static fun_t fun_pairing = {{ "pairing", run_pairing, 2, sig_elem_elem }};
+
+static val_ptr run_zmod(val_ptr v[]) {
+ element_ptr e = v[0]->elem;
+ mpz_t z;
+ mpz_init(z);
+ element_to_mpz(z, e);
+ field_ptr f = pbc_malloc(sizeof(*f));
+ field_init_fp(f, z);
+ mpz_clear(z);
+ return val_new_field(f);
+}
+static fun_t fun_zmod = {{ "zmod", run_zmod, 1, sig_elem }};
+
+static val_ptr run_poly(val_ptr v[]) {
+ field_ptr f = pbc_malloc(sizeof(*f));
+ field_init_poly(f, v[0]->field);
+ return val_new_field(f);
+}
+static fun_t fun_poly = {{ "poly", run_poly, 1, sig_field }};
+
+static val_ptr run_polymod(val_ptr v[]) {
+ // TODO: Check v[0] is a poly.
+ field_ptr f = pbc_malloc(sizeof(*f));
+ field_init_polymod(f, v[0]->elem);
+ return val_new_field(f);
+}
+static fun_t fun_polymod = {{ "polymod", run_polymod, 1, sig_elem }};
+
+static val_ptr run_extend(val_ptr v[]) {
+ // TODO: Check v[1] is multiz poly.
+ field_ptr fx = pbc_malloc(sizeof(*fx));
+ field_init_poly(fx, v[0]->field);
+ element_ptr poly = element_new(fx);
+ element_set_multiz(poly, v[1]->elem->data);
+ field_ptr f = pbc_malloc(sizeof(*f));
+ field_init_polymod(f, poly);
+ element_free(poly);
+ return val_new_field(f);
+}
+static fun_t fun_extend = {{ "extend", run_extend, 1, sig_field_elem }};
+
+static void init_pairing(const char *s) {
+ pairing_init_set_str(pairing, s);
+ assign_field(pairing->G1, "G1");
+ assign_field(pairing->G2, "G2");
+ assign_field(pairing->GT, "GT");
+ assign_field(pairing->Zr, "Zr");
+}
+
+static val_ptr run_exit(val_ptr v[]) {
+ mpz_t z;
+ mpz_init(z);
+ element_to_mpz(z, v[0]->elem);
+ exit(mpz_get_si(z));
+}
+static fun_t fun_exit = {{ "exit", run_exit, 1, sig_elem }};
+
+static val_ptr run_CHECK(val_ptr v[]) {
+ if (element_is0(v[0]->elem)) {
+ pbc_die("CHECK failed");
+ }
+ return v[0];
+}
+static fun_t fun_CHECK = {{ "CHECK", run_CHECK, 1, sig_elem }};
+
+static char *aparam =
+"type a\n"
+"q 8780710799663312522437781984754049815806883199414208211028653399266475630880222957078625179422662221423155858769582317459277713367317481324925129998224791\n"
+"h 12016012264891146079388821366740534204802954401251311822919615131047207289359704531102844802183906537786776\n"
+"r 730750818665451621361119245571504901405976559617\n"
+"exp2 159\n"
+"exp1 107\n"
+"sign1 1\n"
+"sign0 1\n";
+
+static char *dparam =
+"type d\n"
+"q 625852803282871856053922297323874661378036491717\n"
+"n 625852803282871856053923088432465995634661283063\n"
+"h 3\n"
+"r 208617601094290618684641029477488665211553761021\n"
+"a 581595782028432961150765424293919699975513269268\n"
+"b 517921465817243828776542439081147840953753552322\n"
+"k 6\n"
+"nk 60094290356408407130984161127310078516360031868417968262992864809623507269833854678414046779817844853757026858774966331434198257512457993293271849043664655146443229029069463392046837830267994222789160047337432075266619082657640364986415435746294498140589844832666082434658532589211525696\n"
+"hk 1380801711862212484403205699005242141541629761433899149236405232528956996854655261075303661691995273080620762287276051361446528504633283152278831183711301329765591450680250000592437612973269056\n"
+"coeff0 472731500571015189154958232321864199355792223347\n"
+"coeff1 352243926696145937581894994871017455453604730246\n"
+"coeff2 289113341693870057212775990719504267185772707305\n"
+"nqr 431211441436589568382088865288592347194866189652\n";
+
+static char *eparam =
+"type e\n"
+"q 7245986106510086080714203333362098431608853335867425877960916928496629182991629664903654100214900946450053872786629995869445693724001299041657434948257845644905153122838458864000479326695430719258600053239930483226650953770354174712511646273516974069245462534034085895319225452125649979474047163305307830001\n"
+"r 730750862221594424981965739670091261094297337857\n"
+"h 13569343110918781839835249021482970252603216587988030044836106948825516930173270978617489032334001006615524543925753725725046733884363846960470444404747241287743773746682188521738728797153760275116924829183670000\n"
+"a 7130970454025799000067946137594446075551569949583815943390108723282396973737794273397246892274981883807989525599540630855644968426794929215599380425269625872763801485968007136000471718335185787206876242871042697778608875139078711621836858237429403052273312335081163896980825048123655535355411494046493419999\n"
+"b 7169309004853894693616698536183663527570664411678352588247044791687141043489072737232715961588288238022010974661903752526911876859197052490952065266265699130144252031591491045333807587788600764557450846327338626261289568016170532652061787582791926724597362401398804563093625182790987016728290050466098223333\n"
+"exp2 159\n"
+"exp1 135\n"
+"sign1 1\n"
+"sign0 1\n";
+
+static char *fparam =
+"type f\n"
+"q 205523667896953300194896352429254920972540065223\n"
+"r 205523667896953300194895899082072403858390252929\n"
+"b 40218105156867728698573668525883168222119515413\n"
+"beta 115334401956802802075595682801335644058796914268\n"
+"alpha0 191079354656274778837764015557338301375963168470\n"
+"alpha1 71445317903696340296199556072836940741717506375\n";
+
+static char *gparam =
+"type g\n"
+"q 503189899097385532598615948567975432740967203\n"
+"n 503189899097385532598571084778608176410973351\n"
+"h 1\n"
+"r 503189899097385532598571084778608176410973351\n"
+"a 465197998498440909244782433627180757481058321\n"
+"b 463074517126110479409374670871346701448503064\n"
+"k 10\n"
+"nk 1040684643531490707494989587381629956832530311976146077888095795458709511789670022388326295177424065807612879371896982185473788988016190582073591316127396374860265835641044035656044524481121528846249501655527462202999638159773731830375673076317719519977183373353791119388388468745670818193868532404392452816602538968163226713846951514831917487400267590451867746120591750902040267826351982737642689423713163967384383105678367875981348397359466338807\n"
+"hk 4110127713690841149713310614420858884651261781185442551927080083178682965171097172366598236129731931693425629387502221804555636704708008882811353539555915064049685663790355716130262332064327767695339422323460458479884756000782939428852120522712008037615051139080628734566850259704397643028017435446110322024094259858170303605703280329322675124728639532674407\n"
+"coeff0 67343110967802947677845897216565803152319250\n"
+"coeff1 115936772834120270862756636148166314916823221\n"
+"coeff2 87387877425076080433559927080662339215696505\n"
+"coeff3 433223145899090928132052677121692683015058909\n"
+"coeff4 405367866213598664862417230702935310328613596\n"
+"nqr 22204504160560785687198080413579021865783099\n";
+
+static char *iparam =
+"type i\n"
+"m 97\n"
+"t 12\n"
+"n 2726865189058261010774960798134976187171462721\n"
+"n2 7\n";
+
+static val_ptr run_init_pairing_a(val_ptr v[]) {
+ UNUSED_VAR(v);
+ init_pairing(aparam);
+ return NULL;
+}
+static fun_t fun_init_pairing_a = {{
+ "init_pairing_a", run_init_pairing_a, 0, NULL
+ }};
+
+static val_ptr run_init_pairing_d(val_ptr v[]) {
+ UNUSED_VAR(v);
+ init_pairing(dparam);
+ return NULL;
+}
+static fun_t fun_init_pairing_d = {{
+ "init_pairing_d", run_init_pairing_d, 0, NULL
+ }};
+
+static val_ptr run_init_pairing_e(val_ptr v[]) {
+ UNUSED_VAR(v);
+ init_pairing(eparam);
+ return NULL;
+}
+static fun_t fun_init_pairing_e = {{
+ "init_pairing_e", run_init_pairing_e, 0, NULL
+ }};
+
+static val_ptr run_init_pairing_f(val_ptr v[]) {
+ UNUSED_VAR(v);
+ init_pairing(fparam);
+ return NULL;
+}
+static fun_t fun_init_pairing_f = {{
+ "init_pairing_f", run_init_pairing_f, 0, NULL
+ }};
+
+static val_ptr run_init_pairing_g(val_ptr v[]) {
+ UNUSED_VAR(v);
+ init_pairing(gparam);
+ return NULL;
+}
+static fun_t fun_init_pairing_g = {{
+ "init_pairing_g", run_init_pairing_g, 0, NULL
+ }};
+
+static val_ptr run_init_pairing_i(val_ptr v[]) {
+ UNUSED_VAR(v);
+ init_pairing(iparam);
+ return NULL;
+}
+static fun_t fun_init_pairing_i = {{
+ "init_pairing_i", run_init_pairing_i, 0, NULL
+ }};
+
+static void builtin(fun_ptr fun) {
+ symtab_put(reserved, val_new_fun(fun), fun->name);
+}
+
+int end_of_input;
+
+int yywrap_return1(void) { return 1; }
+
+int yywrap_readline(void) {
+ static char *currentline;
+ static YY_BUFFER_STATE st;
+ yy_delete_buffer(st);
+ free(currentline);
+ currentline = pbc_getline(option_prompt);
+ if (!currentline) {
+ end_of_input = 1;
+ return 1;
+ }
+ int n = strlen(currentline);
+ currentline = realloc(currentline, n + 2);
+ currentline[n] = '\n';
+ currentline[n + 1] = '\0';
+ st = yy_scan_string(currentline);
+ //if (option_echo) puts(currentline);
+ return 0;
+}
+
+static int (*yywrapfun)(void);
+int yywrap(void) {
+ return yywrapfun();
+}
+
+int main(int argc, char **argv) {
+ for (;;) {
+ int c = getopt(argc, argv, "y");
+ if (c == -1) break;
+ switch (c) {
+ case 'y':
+ option_easy = 1;
+ option_prompt = "> ";
+ break;
+ default:
+ fprintf(stderr, "unrecognized option: %c\n", c);
+ break;
+ }
+ }
+
+ field_init_z(Z);
+ field_init_multiz(M);
+ symtab_init(tab);
+
+ builtin(fun_rnd);
+ builtin(fun_random);
+ builtin(fun_ord);
+ builtin(fun_order);
+ builtin(fun_nextprime);
+ builtin(fun_sqrt);
+ builtin(fun_inv);
+ builtin(fun_type);
+ builtin(fun_pairing);
+ builtin(fun_zmod);
+ builtin(fun_poly);
+ builtin(fun_polymod);
+ builtin(fun_extend);
+ builtin(fun_exit);
+ builtin(fun_CHECK);
+ builtin(fun_init_pairing_a);
+ builtin(fun_init_pairing_d);
+ builtin(fun_init_pairing_e);
+ builtin(fun_init_pairing_f);
+ builtin(fun_init_pairing_g);
+ builtin(fun_init_pairing_i);
+ run_init_pairing_a(NULL);
+ symtab_put(reserved, val_new_field(M), "M");
+ symtab_put(reserved, val_new_field(Z), "Z");
+
+ if (argc > optind) {
+ FILE *fp = fopen(argv[optind], "r");
+ if (!fp) pbc_die("fopen failed on %s", argv[optind]);
+ YY_BUFFER_STATE st = yy_create_buffer(fp, YY_BUF_SIZE);
+ yy_switch_to_buffer(st);
+ yywrapfun = yywrap_return1;
+ yyparse();
+ yy_delete_buffer(st);
+ } else {
+ yywrapfun = yywrap_readline;
+ yywrap();
+ while (!end_of_input) {
+ if (2 == yyparse()) pbc_die("parser out of memory");
+ }
+ putchar('\n');
+ }
+
+ symtab_clear(tab);
+ field_clear(M);
+ return 0;
+}
diff --git a/moon-abe/pbc-0.5.14/pbc/pbc_getline.c b/moon-abe/pbc-0.5.14/pbc/pbc_getline.c
new file mode 100644
index 00000000..dc44cc40
--- /dev/null
+++ b/moon-abe/pbc-0.5.14/pbc/pbc_getline.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <string.h>
+
+#include "pbc_memory.h"
+
+char *pbc_getline(const char *prompt) {
+ char s[1024];
+ if (prompt) fputs(prompt, stdout);
+ if (!fgets(s, 1024, stdin)) return NULL;
+ if (feof(stdin)) return NULL;
+ /* use strdup rather than pbc_strdup. because
+ * 1. readline version of this function uses malloc.
+ * 2. pbc_malloc called by pbc_strdup may differ from malloc.
+ * here we keep consistency.
+ */
+ return strdup(s);
+}
diff --git a/moon-abe/pbc-0.5.14/pbc/pbc_getline.readline.c b/moon-abe/pbc-0.5.14/pbc/pbc_getline.readline.c
new file mode 100644
index 00000000..8d5e8f5a
--- /dev/null
+++ b/moon-abe/pbc-0.5.14/pbc/pbc_getline.readline.c
@@ -0,0 +1,10 @@
+#include <stdio.h>
+#include <readline/readline.h>
+#include <readline/history.h>
+
+char *pbc_getline(const char *prompt)
+{
+ char *line = readline(prompt);
+ if (line && *line) add_history(line);
+ return line;
+}
diff --git a/moon-abe/pbc-0.5.14/pbc/pbc_tree.h b/moon-abe/pbc-0.5.14/pbc/pbc_tree.h
new file mode 100644
index 00000000..2526ab61
--- /dev/null
+++ b/moon-abe/pbc-0.5.14/pbc/pbc_tree.h
@@ -0,0 +1,30 @@
+// Requires:
+// * field.h
+struct tree_s;
+typedef struct tree_s *tree_ptr;
+tree_ptr tree_new_z(const char* s);
+tree_ptr tree_new_empty_stmt_list(void);
+tree_ptr tree_new_empty_parms(void);
+tree_ptr tree_new_define(tree_ptr id, tree_ptr parm, tree_ptr body);
+tree_ptr tree_new_list(tree_ptr t);
+tree_ptr tree_new_id(const char* s);
+tree_ptr tree_new_assign(tree_ptr l, tree_ptr r);
+tree_ptr tree_new_funcall(void);
+void tree_append(tree_ptr f, tree_ptr p);
+void tree_set_fun(tree_ptr dst, tree_ptr src);
+void tree_eval_stmt(tree_ptr t);
+
+tree_ptr tree_new_neg(tree_ptr t);
+tree_ptr tree_new_add(tree_ptr x, tree_ptr y);
+tree_ptr tree_new_sub(tree_ptr x, tree_ptr y);
+tree_ptr tree_new_mul(tree_ptr x, tree_ptr y);
+tree_ptr tree_new_div(tree_ptr x, tree_ptr y);
+tree_ptr tree_new_pow(tree_ptr x, tree_ptr y);
+tree_ptr tree_new_eq(tree_ptr x, tree_ptr y);
+tree_ptr tree_new_ne(tree_ptr x, tree_ptr y);
+tree_ptr tree_new_le(tree_ptr x, tree_ptr y);
+tree_ptr tree_new_ge(tree_ptr x, tree_ptr y);
+tree_ptr tree_new_lt(tree_ptr x, tree_ptr y);
+tree_ptr tree_new_gt(tree_ptr x, tree_ptr y);
+tree_ptr tree_new_ternary(tree_ptr cond, tree_ptr t1, tree_ptr t2);
+tree_ptr tree_new_item(tree_ptr x, tree_ptr y);