+#include "code.h"
+#include "opcodes.h"
+%}
+
+//%glr-parser
+//%expect-rr 1
+%error-verbose
+
+%union tokenunion {
+ tokenptr_t token;
+ multiname_t*multiname;
+ multiname_list_t*multiname_list;
+ int number_int;
+ unsigned int number_uint;
+ double number_float;
+ struct _code*code;
+ struct _code_list*code_list;
+}
+
+
+%token<token> T_IDENTIFIER
+%token<token> T_STRING
+%token<token> T_REGEXP
+%token<token> T_EMPTY
+%token<number_int> T_INT
+%token<number_uint> T_UINT
+%token<number_uint> T_BYTE
+%token<number_uint> T_SHORT
+%token<number_float> T_FLOAT
+
+%token<token> KW_IMPLEMENTS
+%token<token> KW_NAMESPACE
+%token<token> KW_PACKAGE "package"
+%token<token> KW_PROTECTED
+%token<token> KW_PUBLIC
+%token<token> KW_PRIVATE
+%token<token> KW_USE "use"
+%token<token> KW_INTERNAL
+%token<token> KW_NEW "new"
+%token<token> KW_NATIVE
+%token<token> KW_FUNCTION "function"
+%token<token> KW_FOR "for"
+%token<token> KW_CLASS "class"
+%token<token> KW_CONST "const"
+%token<token> KW_SET "set"
+%token<token> KW_STATIC
+%token<token> KW_IMPORT "import"
+%token<token> KW_INTERFACE "interface"
+%token<token> KW_NULL
+%token<token> KW_VAR "var"
+%token<token> KW_DYNAMIC
+%token<token> KW_OVERRIDE
+%token<token> KW_FINAL
+%token<token> KW_GET "get"
+%token<token> KW_EXTENDS
+%token<token> KW_FALSE "False"
+%token<token> KW_TRUE "True"
+%token<token> KW_BOOLEAN "Boolean"
+%token<token> KW_UINT "uint"
+%token<token> KW_INT "int"
+%token<token> KW_NUMBER "Number"
+%token<token> KW_STRING "String"
+%token<token> KW_IS "is"
+%token<token> KW_AS "as"
+
+%token<token> T_EQEQ "=="
+%token<token> T_LE "<="
+%token<token> T_GE ">="
+%token<token> T_DIVBY "/="
+%token<token> T_MODBY "%="
+%token<token> T_PLUSBY "+="
+%token<token> T_MINUSBY "-="
+%token<token> T_SHRBY ">>="
+%token<token> T_SHLBY "<<="
+%token<token> T_USHRBY ">>>="
+%token<token> T_OROR "||"
+%token<token> T_ANDAND "&&"
+%token<token> T_COLONCOLON "::"
+%token<token> T_MINUSMINUS "--"
+%token<token> T_PLUSPLUS "++"
+%token<token> T_DOTDOT ".."
+%token<token> T_SHL "<<"
+%token<token> T_USHR ">>>"
+%token<token> T_SHR ">>"
+%token<token> T_SEMICOLON ';'
+%token<token> T_STAR '*'
+%token<token> T_DOT '.'
+
+%type <token> CODE
+%type <code> CODEPIECE CODEPIECE2
+%type <token> PACKAGE_DECLARATION
+%type <token> FUNCTION_DECLARATION
+%type <code> VARIABLE_DECLARATION
+%type <token> CLASS_DECLARATION
+%type <token> NAMESPACE_DECLARATION
+%type <token> INTERFACE_DECLARATION
+%type <code> EXPRESSION
+%type <code> MAYBEEXPRESSION
+%type <code> E
+%type <code> CONSTANT
+%type <token> FOR
+%type <token> USE
+%type <token> ASSIGNMENT
+%type <token> IMPORT
+%type <multiname> MAYBETYPE
+%type <token> PACKAGESPEC
+%type <token> GETSET
+%type <token> PARAM
+%type <token> PARAMS
+%type <token> PARAM_LIST
+%type <token> MODIFIERS
+%type <token> MODIFIER_LIST
+%type <multiname_list> IMPLEMENTS_LIST
+%type <multiname> EXTENDS
+%type <multiname_list> EXTENDS_LIST
+%type <multiname> PACKAGEANDCLASS
+%type <multiname_list> PACKAGEANDCLASS_LIST
+%type <token> MULTILEVELIDENTIFIER
+%type <multiname> TYPE
+%type <token> VAR
+%type <token> VARIABLE
+%type <code> VAR_READ
+%type <token> NEW
+%type <token> X_IDENTIFIER
+%type <token> MODIFIER
+%type <token> PACKAGE
+%type <code> FUNCTIONCALL
+%type <code_list> MAYBE_EXPRESSION_LIST EXPRESSION_LIST
+
+// precendence: from low to high
+// http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00000012.html
+
+%left prec_none
+%right '?' ':'
+%nonassoc '='
+%nonassoc "/=" "%="
+%nonassoc "+=" "-="
+%nonassoc ">>="
+%nonassoc "<<="
+%nonassoc ">>>="
+%nonassoc "||"
+%nonassoc "&&"
+%nonassoc '|'
+%nonassoc '^'
+%nonassoc '&'
+%nonassoc "!=" "==" "<=" '<' ">=" '>' // TODO: support "a < b < c" syntax?
+%nonassoc "is"
+%left '-'
+%left '+'
+%left "<<"
+%left ">>>"
+%left ">>"
+%left '%'
+%left '/'
+%left '*'
+%left '!'
+%left '~'
+%left "--" "++"
+%left '['
+%nonassoc "as"
+%left '.' ".." "::"
+%nonassoc T_IDENTIFIER
+%left '('
+
+
+%{