-%{\r
-//\r
-// Mono.MonoBASIC.Parser.cs (from .jay): The Parser for the MonoBASIC compiler\r
-//\r
-// Author: A Rafael D Teixeira (rafaelteixeirabr@hotmail.com)\r
-//\r
-// Licensed under the terms of the GNU GPL\r
-//\r
-// Copyright (C) 2001 A Rafael D Teixeira\r
-//\r
-// TODO:\r
-// Nearly everything\r
-//\r
-\r
-namespace Mono.MonoBASIC\r
-{\r
- using System.Text;\r
- using System;\r
- using System.Collections;\r
- using Mono.Languages;\r
- using Mono.CSharp;\r
-\r
- /// <summary>\r
- /// The MonoBASIC Parser\r
- /// </summary>\r
- public class Parser : GenericParser \r
- {\r
- Namespace current_namespace;\r
- TypeContainer current_container;\r
- \r
-/*\r
- /// <summary>\r
- /// Current block is used to add statements as we find\r
- /// them. \r
- /// </summary>\r
- Block current_block;\r
-\r
- /// <summary>\r
- /// Current interface is used by the various declaration\r
- /// productions in the interface declaration to "add"\r
- /// the interfaces as we find them.\r
- /// </summary>\r
- Interface current_interface;\r
-\r
- /// <summary>\r
- /// This is used by the unary_expression code to resolve\r
- /// a name against a parameter. \r
- /// </summary>\r
- Parameters current_local_parameters;\r
-\r
- /// <summary>\r
- /// Using during property parsing to describe the implicit\r
- /// value parameter that is passed to the "set" accessor\r
- /// method\r
- /// </summary>\r
- Parameter [] implicit_value_parameters;\r
-\r
-*/\r
- bool UseExtendedSyntax; // for ".mbs" files\r
-\r
- public override string[] extensions()\r
- {\r
- string [] list = { ".vb", ".mbs" };\r
- return list;\r
- }\r
-\r
-%}\r
-\r
-%token EOF\r
-%token NONE /* This token is never returned by our lexer */\r
-%token ERROR // This is used not by the parser, but by the tokenizer.\r
- // do not remove.\r
-\r
-/*\r
- *These are the MonoBASIC keywords\r
- */\r
-%token ADDHANDLER\r
-%token ADDRESSOF\r
-%token ALIAS\r
-%token AND\r
-%token ANDALSO\r
-%token ANSI\r
-%token AS\r
-%token ASSEMBLY\r
-%token AUTO\r
-%token BOOLEAN \r
-%token BYREF\r
-%token BYTE\r
-%token BYVAL \r
-%token CALL\r
-%token CASE \r
-%token CATCH \r
-%token CBOOL\r
-%token CBYTE\r
-%token CCHAR \r
-%token CDATE\r
-%token CDEC\r
-%token CDBL\r
-%token CHAR \r
-%token CINT\r
-%token CLASS\r
-%token CLNG\r
-%token COBJ\r
-//%token COMPARE \r
-%token CONST \r
-%token CSHORT \r
-%token CSNG\r
-%token CSTR\r
-%token CTYPE\r
-%token DATE\r
-%token DECIMAL \r
-%token DECLARE\r
-%token DEFAULT \r
-%token DELEGATE \r
-%token DESCRIPTION // MonoBASIC extension\r
-%token DIM\r
-%token DO \r
-%token DOUBLE \r
-%token EACH \r
-%token ELSE\r
-%token ELSEIF\r
-%token END \r
-%token ENUM \r
-%token EOL\r
-%token ERASE\r
-%token ERROR\r
-%token EVENT\r
-%token EXIT \r
-//%token EXPLICIT \r
-%token FALSE \r
-%token FINALLY \r
-%token FOR \r
-%token FRIEND\r
-%token FUNCTION\r
-%token GET\r
-%token GETTYPE\r
-%token GOTO \r
-%token HANDLES\r
-%token IF \r
-%token IMPLEMENTS\r
-%token IMPORTS \r
-%token IN \r
-%token INHERITS\r
-%token INTEGER \r
-%token INTERFACE\r
-%token IS\r
-%token LET\r
-%token LIB \r
-%token LIKE \r
-%token LONG \r
-%token LOOP\r
-%token ME\r
-%token MOD\r
-%token MODULE\r
-%token MUSTINHERIT \r
-%token MUSTOVERRIDE\r
-%token MYBASE\r
-%token MYCLASS\r
-%token NAMESPACE\r
-%token NEW\r
-%token NEXT \r
-%token NOT\r
-%token NOTHING\r
-%token NOTINHERITABLE\r
-%token NOTOVERRIDABLE\r
-%token OBJECT \r
-%token ON\r
-%token OPTION \r
-%token OPTIONAL \r
-%token OR\r
-%token ORELSE\r
-%token OVERLOADS\r
-%token OVERRIDABLE \r
-%token OVERRIDES \r
-%token PARAMETER // MonoBASIC extension\r
-%token PARAM_ARRAY\r
-%token PRESERVE\r
-%token PRIVATE \r
-%token PROPERTY\r
-%token PROTECTED\r
-%token PUBLIC\r
-%token RAISEEVENT\r
-%token READONLY \r
-%token REDIM\r
-%token REM\r
-%token REMOVEHANDLER\r
-%token RESUME \r
-%token RETURN \r
-%token SELECT\r
-%token SET\r
-%token SHADOWS\r
-%token SHARED\r
-%token SHORT \r
-%token SINGLE\r
-%token SIZEOF \r
-%token STATIC \r
-%token STEP\r
-%token STOP\r
-%token STRING \r
-%token STRUCTURE \r
-%token SUB\r
-%token SUMMARY // MonoBASIC extension\r
-%token SYNCLOCK\r
-%token THEN\r
-%token THROW\r
-%token TO\r
-%token TRUE \r
-%token TRY \r
-%token TYPEOF \r
-%token UNICODE\r
-%token UNTIL\r
-%token VARIANT \r
-%token WHEN \r
-%token WHILE \r
-%token WITH\r
-%token WITHEVENTS\r
-%token WRITEONLY\r
-%token XOR\r
-\r
-/* MonoBASIC single character operators/punctuation. */\r
-%token OPEN_BRACKET "["\r
-%token CLOSE_BRACKET "]"\r
-%token OPEN_PARENS "("\r
-%token CLOSE_PARENS ")"\r
-%token DOT "."\r
-%token COMMA ","\r
-%token COLON ":"\r
-\r
-%token PLUS "+"\r
-%token MINUS "-"\r
-%token ASSIGN "="\r
-%token OP_LT "<"\r
-%token OP_GT ">"\r
-%token STAR "*"\r
-%token PERCENT "%"\r
-%token DIV "/"\r
-%token OP_EXP "^"\r
-%token INTERR "?"\r
-%token OP_IDIV "\\"\r
-%token OP_CONCAT "&"\r
-\r
-/* MonoBASIC multi-character operators. */\r
-%token OP_LE "<="\r
-%token OP_GE ">="\r
-%token OP_EQ "=="\r
-%token OP_NE "<>"\r
-%token OP_AND //"and"\r
-%token OP_OR //"or"\r
-%token OP_XOR //"xor"\r
-%token OP_MODULUS //"mod"\r
-%token OP_MULT_ASSIGN "*="\r
-%token OP_DIV_ASSIGN "/="\r
-%token OP_IDIV_ASSIGN "\\="\r
-%token OP_ADD_ASSIGN "+="\r
-%token OP_SUB_ASSIGN "-="\r
-%token OP_CONCAT_ASSIGN "&="\r
-%token OP_EXP_ASSIGN "^="\r
-\r
-/* Numbers */\r
-%token LITERAL_INTEGER "int literal"\r
-%token LITERAL_SINGLE "float literal"\r
-%token LITERAL_DOUBLE "double literal"\r
-%token LITERAL_DECIMAL "decimal literal"\r
-%token LITERAL_CHARACTER "character literal"\r
-%token LITERAL_STRING "string literal"\r
-\r
-%token IDENTIFIER\r
-\r
-/* Add precedence rules to solve dangling else s/r conflict */\r
-%nonassoc LOWPREC\r
-%nonassoc IF\r
-%nonassoc ELSE\r
-%right ASSIGN\r
-%left OP_OR\r
-%left OP_AND\r
-%left BITWISE_OR\r
-%left BITWISE_AND\r
-%left OP_SHIFT_LEFT OP_SHIFT_RIGHT\r
-%left PLUS MINUS\r
-%left STAR DIV PERCENT\r
-%right BITWISE_NOT CARRET UMINUS\r
-%nonassoc OP_INC OP_DEC\r
-%left OPEN_PARENS\r
-%left OPEN_BRACKET OPEN_BRACE\r
-%left DOT\r
-%nonassoc HIGHPREC\r
-\r
-%start compilation_unit\r
-%%\r
-\r
-compilation_unit\r
- : opt_imports_directives \r
- opt_attributes\r
- opt_declarations \r
- EOF\r
- {\r
- $$ = $3;\r
- }\r
- ;\r
- \r
-opt_declarations\r
- : /* empty */\r
- | declarations\r
- ;\r
-\r
-declarations\r
- : declaration\r
- | declarations declaration\r
- ;\r
- \r
-declaration\r
- : namespace_declaration\r
- | module_declaration\r
- | class_declaration\r
- ;\r
-\r
-qualified_identifier\r
- : IDENTIFIER\r
- | qualified_identifier DOT IDENTIFIER \r
- { \r
- $$ = (($1).ToString ()) + "." + ($3.ToString ()); \r
- }\r
- ;\r
-opt_imports_directives\r
- : /* empty */\r
- | imports_directives\r
- ;\r
-\r
-imports_directives\r
- : imports_directive \r
- | imports_directives imports_directive \r
- ;\r
-\r
-imports_directive\r
- : /* imports_alias_directive\r
- | */ imports_namespace_directive\r
- ;\r
-\r
-imports_namespace_directive\r
- : IMPORTS namespace_name EOL \r
- {\r
- current_namespace.Using ((string) $2);\r
- }\r
- ;\r
-\r
-opt_attributes\r
- : /* empty */\r
- ;\r
-\r
-namespace_declaration\r
- : NAMESPACE qualified_identifier EOL\r
- {\r
- current_namespace = new Namespace (current_namespace, (string) $2); \r
- } \r
- opt_imports_directives\r
- opt_namespace_member_declarations\r
- END NAMESPACE EOL\r
- { \r
- current_namespace = current_namespace.Parent;\r
- }\r
- ;\r
-\r
-namespace_name\r
- : qualified_identifier\r
- ;\r
-\r
-opt_namespace_member_declarations\r
- : /* empty */\r
- | namespace_member_declarations\r
- ;\r
-\r
-namespace_member_declarations\r
- : namespace_member_declaration\r
- | namespace_member_declarations namespace_member_declaration\r
- ;\r
-\r
-namespace_member_declaration\r
- : namespace_declaration\r
- | module_declaration\r
- | class_declaration\r
- ;\r
-/* | type_declaration\r
- {\r
- int mod_flags = 0;\r
- string name = "";\r
-\r
- if ($1 is Class){\r
- Class c = (Class) $1;\r
- mod_flags = c.ModFlags;\r
- name = c.Name;\r
- } else if ($1 is Struct){\r
- Struct s = (Struct) $1;\r
- mod_flags = s.ModFlags;\r
- name = s.Name;\r
- } else\r
- break;\r
-\r
- }\r
- ;\r
-\r
-type_declaration\r
- : /* empty * /\r
- | class_declaration\r
- ;\r
-\r
-*/\r
-\r
-class_declaration\r
- : /* opt_attributes opt_modifiers */\r
- CLASS IDENTIFIER /* opt_class_interfaces */ EOL\r
- { \r
- }\r
- opt_class_member_declarations\r
- END CLASS EOL\r
- {\r
- }\r
- ;\r
-\r
-module_declaration\r
- : /* opt_attributes opt_modifiers */\r
- MODULE IDENTIFIER EOL\r
- { \r
- }\r
- opt_class_member_declarations\r
- END MODULE EOL\r
- {\r
- }\r
- ;\r
-\r
-opt_class_member_declarations\r
- : /* empty */\r
- | class_member_declarations\r
- ;\r
-\r
-class_member_declarations\r
- : class_member_declaration\r
- | class_member_declarations class_member_declaration\r
- ;\r
-\r
-class_member_declaration\r
- : /* type_declaration\r
- | */ sub_declaration\r
- ;\r
-\r
-sub_declaration\r
- : SUB qualified_identifier OPEN_PARENS opt_formal_parameters CLOSE_PARENS EOL\r
- opt_statements\r
- END SUB EOL\r
- ;\r
-\r
-opt_statements\r
- : /* empty */\r
- | qualified_identifier OPEN_PARENS opt_actual_parameters CLOSE_PARENS EOL\r
- ;\r
-\r
-opt_formal_parameters \r
- : /* empty */\r
- | qualified_identifier AS qualified_identifier\r
- ;\r
-\r
-opt_actual_parameters \r
- : /* empty */\r
- | qualified_identifier\r
- | LITERAL_STRING\r
- ;\r
-\r
-%%\r
-\r
-\r
-Tokenizer lexer;\r
-\r
-public Tokenizer Lexer {\r
- get {\r
- return lexer;\r
- }\r
-} \r
-\r
-public override int parse ()\r
-{\r
- current_namespace = new Namespace (null, "");\r
- current_container = RootContext.Tree.Types;\r
- current_container.Namespace = current_namespace;\r
-\r
- UseExtendedSyntax = name.EndsWith(".mbs");\r
-\r
- lexer = new Tokenizer (input, name, defines);\r
- StringBuilder value = new StringBuilder ();\r
-\r
- global_errors = 0;\r
- try \r
- {\r
- if (yacc_verbose_flag)\r
- yyparse (lexer, new yydebug.yyDebugSimple ());\r
- else\r
- yyparse (lexer);\r
- } \r
- catch (Exception e)\r
- {\r
- Console.WriteLine (lexer.location + " : Parsing error ");\r
- Console.WriteLine (e);\r
- global_errors++;\r
- }\r
-\r
- return global_errors;\r
-}\r
-\r
-/* end end end */\r
-}\r
-\r
-\r
+%{
+//
+// Mono.MonoBASIC.Parser.cs (from .jay): The Parser for the MonoBASIC compiler
+//
+// Author: A Rafael D Teixeira (rafaelteixeirabr@hotmail.com)
+//
+// Licensed under the terms of the GNU GPL
+//
+// Copyright (C) 2001 A Rafael D Teixeira
+//
+// TODO:
+// Nearly everything
+//
+
+namespace Mono.MonoBASIC
+{
+ using System.Text;
+ using System;
+ using System.Collections;
+ using Mono.Languages;
+ using Mono.CSharp;
+
+ /// <summary>
+ /// The MonoBASIC Parser
+ /// </summary>
+ public class Parser : GenericParser
+ {
+
+/*
+ /// <summary>
+ /// Current block is used to add statements as we find
+ /// them.
+ /// </summary>
+ Block current_block;
+
+ /// <summary>
+ /// Current interface is used by the various declaration
+ /// productions in the interface declaration to "add"
+ /// the interfaces as we find them.
+ /// </summary>
+ Interface current_interface;
+
+ /// <summary>
+ /// This is used by the unary_expression code to resolve
+ /// a name against a parameter.
+ /// </summary>
+ Parameters current_local_parameters;
+
+ /// <summary>
+ /// Using during property parsing to describe the implicit
+ /// value parameter that is passed to the "set" accessor
+ /// method
+ /// </summary>
+ Parameter [] implicit_value_parameters;
+
+*/
+ bool UseExtendedSyntax; // for ".mbs" files
+
+ public override string[] extensions()
+ {
+ string [] list = { ".vb", ".mbs" };
+ return list;
+ }
+
+%}
+
+%token EOF
+%token NONE /* This token is never returned by our lexer */
+%token ERROR // This is used not by the parser, but by the tokenizer.
+ // do not remove.
+
+/*
+ *These are the MonoBASIC keywords
+ */
+%token ADDHANDLER
+%token ADDRESSOF
+%token ALIAS
+%token AND
+%token ANDALSO
+%token ANSI
+%token AS
+%token ASSEMBLY
+%token AUTO
+%token BOOLEAN
+%token BYREF
+%token BYTE
+%token BYVAL
+%token CALL
+%token CASE
+%token CATCH
+%token CBOOL
+%token CBYTE
+%token CCHAR
+%token CDATE
+%token CDEC
+%token CDBL
+%token CHAR
+%token CINT
+%token CLASS
+%token CLNG
+%token COBJ
+//%token COMPARE
+%token CONST
+%token CSHORT
+%token CSNG
+%token CSTR
+%token CTYPE
+%token DATE
+%token DECIMAL
+%token DECLARE
+%token DEFAULT
+%token DELEGATE
+%token DESCRIPTION // MonoBASIC extension
+%token DIM
+%token DO
+%token DOUBLE
+%token EACH
+%token ELSE
+%token ELSEIF
+%token END
+%token ENUM
+%token EOL
+%token ERASE
+%token ERROR
+%token EVENT
+%token EXIT
+//%token EXPLICIT
+%token FALSE
+%token FINALLY
+%token FOR
+%token FRIEND
+%token FUNCTION
+%token GET
+%token GETTYPE
+%token GOTO
+%token HANDLES
+%token IF
+%token IMPLEMENTS
+%token IMPORTS
+%token IN
+%token INHERITS
+%token INTEGER
+%token INTERFACE
+%token IS
+%token LET
+%token LIB
+%token LIKE
+%token LONG
+%token LOOP
+%token ME
+%token MOD
+%token MODULE
+%token MUSTINHERIT
+%token MUSTOVERRIDE
+%token MYBASE
+%token MYCLASS
+%token NAMESPACE
+%token NEW
+%token NEXT
+%token NOT
+%token NOTHING
+%token NOTINHERITABLE
+%token NOTOVERRIDABLE
+%token OBJECT
+%token ON
+%token OPTION
+%token OPTIONAL
+%token OR
+%token ORELSE
+%token OVERLOADS
+%token OVERRIDABLE
+%token OVERRIDES
+%token PARAMETER // MonoBASIC extension
+%token PARAM_ARRAY
+%token PRESERVE
+%token PRIVATE
+%token PROPERTY
+%token PROTECTED
+%token PUBLIC
+%token RAISEEVENT
+%token READONLY
+%token REDIM
+%token REM
+%token REMOVEHANDLER
+%token RESUME
+%token RETURN
+%token SELECT
+%token SET
+%token SHADOWS
+%token SHARED
+%token SHORT
+%token SINGLE
+%token SIZEOF
+%token STATIC
+%token STEP
+%token STOP
+%token STRING
+%token STRUCTURE
+%token SUB
+%token SUMMARY // MonoBASIC extension
+%token SYNCLOCK
+%token THEN
+%token THROW
+%token TO
+%token TRUE
+%token TRY
+%token TYPEOF
+%token UNICODE
+%token UNTIL
+%token VARIANT
+%token WHEN
+%token WHILE
+%token WITH
+%token WITHEVENTS
+%token WRITEONLY
+%token XOR
+
+/* MonoBASIC single character operators/punctuation. */
+%token OPEN_BRACKET "["
+%token CLOSE_BRACKET "]"
+%token OPEN_PARENS "("
+%token CLOSE_PARENS ")"
+%token DOT "."
+%token COMMA ","
+%token COLON ":"
+
+%token PLUS "+"
+%token MINUS "-"
+%token ASSIGN "="
+%token OP_LT "<"
+%token OP_GT ">"
+%token STAR "*"
+%token PERCENT "%"
+%token DIV "/"
+%token OP_EXP "^"
+%token INTERR "?"
+%token OP_IDIV "\\"
+%token OP_CONCAT "&"
+
+/* MonoBASIC multi-character operators. */
+%token OP_LE "<="
+%token OP_GE ">="
+%token OP_EQ "=="
+%token OP_NE "<>"
+%token OP_AND //"and"
+%token OP_OR //"or"
+%token OP_XOR //"xor"
+%token OP_MODULUS //"mod"
+%token OP_MULT_ASSIGN "*="
+%token OP_DIV_ASSIGN "/="
+%token OP_IDIV_ASSIGN "\\="
+%token OP_ADD_ASSIGN "+="
+%token OP_SUB_ASSIGN "-="
+%token OP_CONCAT_ASSIGN "&="
+%token OP_EXP_ASSIGN "^="
+
+/* Numbers */
+%token LITERAL_INTEGER "int literal"
+%token LITERAL_SINGLE "float literal"
+%token LITERAL_DOUBLE "double literal"
+%token LITERAL_DECIMAL "decimal literal"
+%token LITERAL_CHARACTER "character literal"
+%token LITERAL_STRING "string literal"
+
+%token IDENTIFIER
+
+/* Add precedence rules to solve dangling else s/r conflict */
+%nonassoc LOWPREC
+%nonassoc IF
+%nonassoc ELSE
+%right ASSIGN
+%left OP_OR
+%left OP_AND
+%left BITWISE_OR
+%left BITWISE_AND
+%left OP_SHIFT_LEFT OP_SHIFT_RIGHT
+%left PLUS MINUS
+%left STAR DIV PERCENT
+%right BITWISE_NOT CARRET UMINUS
+%nonassoc OP_INC OP_DEC
+%left OPEN_PARENS
+%left OPEN_BRACKET OPEN_BRACE
+%left DOT
+%nonassoc HIGHPREC
+
+%start compilation_unit
+%%
+
+compilation_unit
+ : opt_imports_directives
+ opt_attributes
+ opt_declarations
+ EOF
+ {
+ $$ = $3;
+ }
+ ;
+
+opt_declarations
+ : /* empty */
+ | declarations
+ ;
+
+declarations
+ : declaration
+ | declarations declaration
+ ;
+
+declaration
+ : namespace_declaration
+ | type_declaration
+ {
+ string name = "";
+ int mod_flags;
+
+ if ($1 is Class){
+ Class c = (Class) $1;
+ mod_flags = c.ModFlags;
+ name = c.Name;
+ } else if ($1 is Struct){
+ Struct s = (Struct) $1;
+ mod_flags = s.ModFlags;
+ name = s.Name;
+ } else
+ break;
+
+ if ((mod_flags & (Modifiers.PRIVATE|Modifiers.PROTECTED)) != 0){
+ Report.Error (
+ 1527, lexer.Location,
+ "Namespace elements cannot be explicitly " +
+ "declared private or protected in '" + name + "'");
+ }
+ }
+ ;
+
+qualified_identifier
+ : IDENTIFIER
+ | qualified_identifier DOT IDENTIFIER
+ {
+ $$ = (($1).ToString ()) + "." + ($3.ToString ());
+ }
+ ;
+opt_imports_directives
+ : /* empty */
+ | imports_directives
+ ;
+
+imports_directives
+ : imports_directive
+ | imports_directives imports_directive
+ ;
+
+imports_directive
+ : /* imports_alias_directive
+ | */ imports_namespace_directive
+ ;
+
+imports_namespace_directive
+ : IMPORTS qualified_identifier EOL
+ {
+ current_namespace.Using ((string) $2, lexer.Location);
+ }
+ ;
+
+opt_attributes
+ : /* empty */
+ ;
+
+namespace_declaration
+ : NAMESPACE qualified_identifier EOL
+ {
+ current_namespace = RootContext.Tree.RecordNamespace(current_namespace, name, (string)$2);
+ }
+ opt_imports_directives
+ opt_declarations
+ END NAMESPACE EOL
+ {
+ current_namespace = current_namespace.Parent;
+ }
+ ;
+
+type_declaration
+ : class_declaration
+ | module_declaration
+// | struct_declaration
+// | interface_declaration
+// | enum_declaration
+// | delegate_declaration
+ ;
+
+class_declaration
+ : /* opt_attributes opt_modifiers */
+ CLASS IDENTIFIER /* opt_class_interfaces */ EOL
+ {
+ }
+ opt_class_member_declarations
+ END CLASS EOL
+ {
+ }
+ ;
+
+opt_module_modifiers
+ : /* empty */ { $$ = (int) 0; }
+ | PUBLIC { $$ = Modifiers.PUBLIC; }
+ | FRIEND { $$ = Modifiers.INTERNAL; }
+ ;
+
+module_declaration
+ : opt_attributes opt_module_modifiers
+ MODULE IDENTIFIER EOL
+ {
+ Module new_module;
+ string name;
+
+ name = MakeName((string) $4);
+ new_module = new Module(current_container,
+ name,
+ (int) $2,
+ (Attributes) $1,
+ lexer.Location);
+ current_container = new_module;
+ current_container.Namespace = current_namespace;
+ RootContext.Tree.RecordDecl(name, new_module);
+ }
+ opt_class_member_declarations
+ END MODULE EOL
+ {
+ Module new_module = (Module)current_container;
+
+ current_container = current_container.Parent;
+ CheckDef (current_container.AddClass(new_module), new_module.Name, new_module.Location);
+
+ $$ = new_module;
+ }
+ ;
+
+opt_class_member_declarations
+ : /* empty */
+ | class_member_declarations
+ ;
+
+class_member_declarations
+ : class_member_declaration
+ | class_member_declarations class_member_declaration
+ ;
+
+class_member_declaration
+ : /* type_declaration
+ | */ sub_declaration
+ ;
+
+sub_declaration
+ : SUB qualified_identifier OPEN_PARENS opt_formal_parameters CLOSE_PARENS EOL
+ opt_statements
+ END SUB EOL
+ ;
+
+opt_statements
+ : /* empty */
+ | qualified_identifier OPEN_PARENS opt_actual_parameters CLOSE_PARENS EOL
+ ;
+
+opt_formal_parameters
+ : /* empty */
+ | qualified_identifier AS qualified_identifier
+ ;
+
+opt_actual_parameters
+ : /* empty */
+ | qualified_identifier
+ | LITERAL_STRING
+ ;
+
+%%
+
+
+Tokenizer lexer;
+
+public Tokenizer Lexer {
+ get {
+ return lexer;
+ }
+}
+
+public override int parse ()
+{
+ current_namespace = new Namespace (null, "");
+ current_container = RootContext.Tree.Types;
+ current_container.Namespace = current_namespace;
+
+ UseExtendedSyntax = name.EndsWith(".mbs");
+
+ lexer = new Tokenizer (input, name, defines);
+ StringBuilder value = new StringBuilder ();
+
+ try
+ {
+ if (yacc_verbose_flag)
+ yyparse (lexer, new yydebug.yyDebugSimple ());
+ else
+ yyparse (lexer);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine (lexer.location + " : Parsing error ");
+ Console.WriteLine (e);
+ }
+
+ return Report.Errors;
+}
+
+/* end end end */
+}
+
+