Esempio n. 1
0
function ParseConstant(TokenStream $it)
{
    $const = new ASTConst();
    $it->getToken(SyntaxMap::Keyword);
    $identifier = $it->getToken(SyntaxMap::Identifier);
    $it->getToken(SyntaxMap::AssignOp);
    $value = $it->getToken(SyntaxMap::String);
    $it->getToken(SyntaxMap::Semicolon);
    $const->name = $identifier->value;
    $const->value = $value->value;
    $key = strtolower($const->name);
    if (isset($it->constants[$key])) {
        throw ParserException::constantDefined($identifier);
    }
    $it->constants[$key] = $const;
    return $const;
}