コード例 #1
0
ファイル: grokit_codegen_expr.php プロジェクト: gokulp/grokit
function parseJsonFile($ast)
{
    assert_ast_type($ast, NodeType::JSON_FILE);
    $value = ast_node_data($ast);
    $source = ast_node_source($ast);
    return new JsonFile($source, $value);
}
コード例 #2
0
ファイル: grokit_ast.php プロジェクト: gokulp/grokit
function assert_ast_type($ast, $expected)
{
    $type = ast_node_type($ast);
    if (is_string($expected)) {
        grokit_logic_assert($type == $expected, 'Node Type Mismatch: Exptected ' . $expected . ', got ' . $type . ' from ' . ast_node_source($ast));
    } else {
        if (is_array($expected)) {
            grokit_logic_assert(in_array($type, $expected), 'Node Type Mismatch: Expected one of [' . implode(', ', $expected) . '] got ' . $type . ' from ' . ast_node_source($ast));
        }
    }
}
コード例 #3
0
ファイル: grokit_codegen_top.php プロジェクト: gokulp/grokit
 function parseImport($ast)
 {
     assert_ast_type($ast, NodeType::IMPORT);
     $lib = parseIdentifier(ast_node_data($ast));
     $source = ast_node_source($ast);
     $base_dir = getenv('GROKIT_INSTALLED_LIBRARY_PATH');
     $parts = LibraryManager::SplitNamespace($lib);
     $file = $base_dir . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $parts) . '.php';
     $result = (include_once $file);
     grokit_assert($result !== false, 'Failed to include library ' . $lib . ', no library file ' . $file . ' found ' . $source);
 }