//------------------------------------------------------------ // DeclarationStatement。 DeclarationStatement parseDeclarationStatement() { // 属性のパース Token isConst = null; while (true) { if (currentToken().Value == Token.Kind.KeyConst) {// const if (isConst == null) { setErrorKind(ErrorKind.DECLARATION_STATEMENT_ALREADY_ASSIGNED_ATTRIBUTE_CONST); return(null); } isConst = currentToken(); } else { break; } nextToken(); } // TypePath TypePath typePath = parseTypePath(); if (typePath == null) { return(null); } // Identifier if (currentToken().Value != Token.Kind.Identifier) { return(null); } Identifier ident = new Identifier(currentToken()); nextToken(); // '=' IExpression expr = null; if (currentToken().Value == Token.Kind.OpAssign) { nextToken(); // Expression expr = parseExpression(); if (expr == null) { return(null); } } // ';' if (currentToken().Value != Token.Kind.OpSemicolon) { setErrorKind(ErrorKind.DECLARATION_STATEMENT_SEMICOLON_EXPECTED); return(null); } nextToken(); return(new DeclarationStatement( new VariableDecl(typePath, ident, expr) , isConst != null )); }
//------------------------------------------------------------ // 指定のIdentのノードを探す。 public ISymbolNode FindChildNode(Identifier aIdent) { return(mNodeList.FindNode(aIdent)); }