public object Visit(ClassDeclaringNode n, object o) { _currentScopeLevel = 1; _currentClassST = new ClassSymbolTable(n, _stdlib, _errorSummary); n.Implements.Accept(this, null); n.Variables.Accept(this, null); n.Constructor.Accept(this, null); n.Methods.Accept(this, null); AddToGlobalTable(n.Identifier.Value, _currentClassST); return(null); }
private ClassDeclaringNode ClassDeclaring() { ClassDeclaringNode itsAST; SourceCodePosition itsPos = _currentToken.SourcePosition; Accept(Token.TokenType.Class); IdentifierNode itsName = new IdentifierNode(_currentToken); Accept(Token.TokenType.Identifier); DeclaringSequenceNode itsImplements = Implements(); Accept(Token.TokenType.LeftBrace); DeclaringSequenceNode itsVars = VariableDeclarings(); DeclaringNode itsConstructor = ConstructorDeclaring(); DeclaringSequenceNode itsMethods = MethodDeclarings(); Accept(Token.TokenType.RightBrace); itsAST = new ClassDeclaringNode(itsName, itsImplements, itsVars, itsConstructor, itsMethods, itsPos); return(itsAST); }
public object Visit(ClassDeclaringNode n, object o) { _currentScopeLevel = 1; Append($"{AddIndent()}public class {n.Identifier.Value}"); if (!(n.Implements is EmptyDeclaringSequenceNode)) { Append(" : "); // check for empty sequence to avoid writing this code when no interfaces are listed on the class _buildingImplSequence = true; n.Implements.Accept(this, null); _buildingImplSequence = false; } AppendLine(); _CSharpCode.AppendLine($"{AddIndent()}{{"); IncreaseIndent(); n.Variables.Accept(this, null); n.Constructor.Accept(this, null); n.Methods.Accept(this, null); DecreaseIndent(); AppendLine($"{AddIndent()}}}"); AppendLine(); return(null); }