Next I'll include the code for parsing the language with the exception of expressions.
// Generic name rules
<simpleName> ::= <IDENTIFIER>;
<qualifiedName> ::= <IDENTIFIER> ("." <IDENTIFIER>)*;
// Generic type name rules
<typeName> ::= <qualifiedName> [<templateSpec>];
<templateSpec> ::= "<" <typeName> ">";
// Packages
<packageDeclaration> ::= node("PACKAGE", "package" <packageName> "{" <packageBody> "}");
<packageName> ::= attribute("NAME", <simpleName>);
<packageBody> ::= <packageScope>*;
<packageScope> ::= <packageDeclaration> |
<classDeclaration> |
<interfaceDeclaration>;
// Classes
<classDeclaration> ::= node("CLASS", node("DECLARATION", <classVisibility> "class" <className> [<classInherits>]) node("BODY", "{" <classBody> "}"));
<classVisibility> ::= attribute("SCOPE", "public") |
attribute("SCOPE", "protected") |
attribute("SCOPE", "private") |
attributeEx("SCOPE", "public");
<className> ::= attribute("NAME", <simpleName>);
<classInherits> ::= ":" attribute("PARENT", <qualifiedName>) ("," attribute("PARENT", <qualifiedName>))*;
<classBody> ::= <classScope>*;
<classScope> ::= <constructorDeclaration> |
<destructorDeclaration> |
<attributeDeclaration> |
<operationDeclaration>;
// Interfaces
<interfaceDeclaration> ::= node("INTERFACE", <interfaceVisibility> node("DECLARATION", "interface" <interfaceName> [<interfaceInherits>]) node("BODY", "{" <interfaceBody> "}"));
<interfaceVisibility> ::= attribute("SCOPE", "public") |
attribute("SCOPE", "protected") |
attribute("SCOPE", "private") |
attributeEx("SCOPE", "public");
<interfaceName> ::= <simpleName>;
<interfaceInherits> ::= ":" <qualifiedName> ("," <qualifiedName>)*;
<interfaceBody> ::= <interfaceScope>*;
<interfaceScope> ::= <operationDeclaration>;
// Constructors
<constructorDeclaration> ::= node("METHOD", attributeEx("SCOPE", "public") attribute("NAME", <simpleName>) "(" [<parameterList>] ")" [<constructorBody>] ";");
<constructorBody> ::= "{" <statement>* "}";
// Destructors
<destructorDeclaration> ::= node("METHOD", attributeEx("SCOPE", "public") attribute("NAME", "~" <simpleName>) "(" ")" [<destructorBody>] ";");
<destructorBody> ::= "{" <statement>* "}";
// Attributes
<attributeDeclaration> ::= node("FIELD", [<attributeVisibility>] node("TYPE", <attributeType>) node("DECLARATOR", <attributeName>) [<attributeDefault>] ";");
<attributeVisibility> ::= attribute("SCOPE", "public") |
attribute("SCOPE", "protected") |
attribute("SCOPE", "private") |
attributeEx("SCOPE", "public");
<attributeType> ::= attribute("TYPE", <typeName>);
<attributeName> ::= attribute("NAME", <simpleName>);
<attributeDefault> ::= node("DEFAULT", "=" attribute("VALUE", <constantExpression>));
// Operations
<operationDeclaration> ::= node("METHOD", node("DECLARATION", <operationVisibility> <operationType> <operationName> <operationParameters>) [<operationBody>] ";");
<operationVisibility> ::= attribute("SCOPE", "public") |
attribute("SCOPE", "protected") |
attribute("SCOPE", "private") |
attributeEx("SCOPE", "public");
<operationType> ::= attribute("TYPE", <typeName>);
<operationName> ::= attribute("NAME", <simpleName>);
<operationParameters> ::= "(" [<parameterList>] ")";
<parameterList> ::= <parameter> ("," <parameter>)*;
<parameter> ::= node("PARAMETER", <parameterType> <parameterName>);
<parameterType> ::= attribute("TYPE", <typeName>);
<parameterName> ::= attribute("NAME", <simpleName>);
<operationBody> ::= "{" <statement>* "}";
// Statements
<statement> ::= <variableDeclarationStatement> |
<assignmentExpression> ";"|
<methodAccess> ";";
<variableDeclarationStatement> ::= <variableType> <variableName> [<variableDefault>] ";";
<variableType> ::= <qualifiedName>;
<variableName> ::= <simpleName>;
<variableDefault> ::= "=" <constantExpression>;