Exemplo n.º 1
0
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);
}
Exemplo n.º 2
0
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));
        }
    }
}
Exemplo n.º 3
0
 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);
 }