+%}
+
+//%glr-parser
+//%expect-rr 1
+%error-verbose
+
+%union tokenunion {
+ tokenptr_t token;
+ multiname_t*multiname;
+ multiname_list_t*multiname_list;
+}
+
+
+%token<token> T_IDENTIFIER
+%token<token> T_STRING
+%token<token> T_REGEXP
+%token<token> T_IMPLEMENTS
+%token<token> T_NAMESPACE
+%token<token> T_PACKAGE
+%token<token> T_PROTECTED
+%token<token> T_PUBLIC
+%token<token> T_PRIVATE
+%token<token> T_UINT
+%token<token> T_USE
+%token<token> T_INTERNAL
+%token<token> T_INT
+%token<token> T_NEW
+%token<token> T_NATIVE
+%token<token> T_FUNCTION
+%token<token> T_FOR
+%token<token> T_CLASS
+%token<token> T_CONST
+%token<token> T_SET
+%token<token> T_STATIC
+%token<token> T_IMPORT
+%token<token> T_INTERFACE
+%token<token> T_NUMBER
+%token<token> T_NULL
+%token<token> T_FALSE
+%token<token> T_TRUE
+%token<token> T_BOOLEAN
+%token<token> T_VAR
+%token<token> T_DYNAMIC
+%token<token> T_OVERRIDE
+%token<token> T_FINAL
+%token<token> T_GET
+%token<token> T_EXTENDS
+%token<token> T_EMPTY
+%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_IS "is"
+%token<token> T_AS "as"
+%token<token> T_SEMICOLON ';'
+%token<token> T_STAR '*'
+%token<token> T_DOT '.'
+
+// 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
+
+%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 '.' ".." "::"
+%left '('
+
+%type <token> CODE
+%type <token> CODEPIECE
+%type <token> PACKAGE_DECLARATION
+%type <token> FUNCTION_DECLARATION
+%type <token> VARIABLE_DECLARATION
+%type <token> CLASS_DECLARATION
+%type <token> NAMESPACE_DECLARATION
+%type <token> INTERFACE_DECLARATION
+%type <token> EXPRESSION
+%type <token> E
+%type <token> 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 <token> NEW
+%type <token> FUNCTIONCALL
+%type <token> X_IDENTIFIER
+%type <token> MODIFIER
+%type <token> PACKAGE
+
+
+%{