private static bool ConstructorDeclaration() { if (Tokens.GetToken().type != Token.Type.Identifier) { return(false); } currentIdentifier = Tokens.GetToken().lexeme; identifierToken = Tokens.GetToken(); if (semanticPass) { SemanticActions.dup(identifierToken, scope); SemanticActions.CD(identifierToken, scope); } Tokens.NextToken(); if (Tokens.GetToken().lexeme != "(") { SyntaxError(Tokens.GetToken(), "("); } Tokens.NextToken(); offset = 0; sizeParameters = 0; ParameterList(); string[] data = new string[2]; data[0] = "returnType:" + currentIdentifier; data[1] = "accessMod:" + accessMod; Symbol symbol = new Symbol(scope, ("X" + uniqueCounter++), currentIdentifier, "constructor", data); currentMethodName = symbol.symid; if (!semanticPass) { currentClassConstructorSymid = symbol.symid; } data[0] = "returnType:" + currentIdentifier; data[1] = "accessMod:" + accessMod; Symbol symbol2 = new Symbol(scope, ("Y" + symbol.symid.Substring(1)), currentIdentifier + "StaticInit", "Init", data); if (semanticPass) { ICode.RETURN("this"); ICode.FUNC(symbol.symid); ICode.FRAME(symbol2.symid, "this"); ICode.CALL(symbol2.symid); } symbol.parameters = parameters; if (Tokens.GetToken().lexeme != ")") { SyntaxError(Tokens.GetToken(), ")"); } Tokens.NextToken(); if (!MethodBody()) { SyntaxError(Tokens.GetToken(), "method body"); } symbol.size = methodSize; symbol2.size = 0; SymbolTable.Add(symbol); SymbolTable.Add(symbol2); offset = 0; methodSize = 0; return(true); }