Changeset View
Changeset View
Standalone View
Standalone View
support/xhpast/xhpast.cpp
| #include "ast.hpp" | #include "ast.hpp" | ||||
| #include <vector> | #include <vector> | ||||
| #include <string> | #include <string> | ||||
| #include <iostream> | #include <iostream> | ||||
| #include <sstream> | #include <sstream> | ||||
| #include <fstream> | #include <fstream> | ||||
| using namespace std; | using namespace std; | ||||
| int xhpastparse(void*, xhpast::Node **); | int xhpastparse(void*, xhpast::Node **); | ||||
| int xhpast_process(std::string &in); | int xhpast_process(std::string &in); | ||||
| void print_node(xhpast::Node *node); | void print_node(xhpast::Node *node); | ||||
| int main(int argc, char* argv[]) { | int main(int argc, char* argv[]) { | ||||
| if (argc != 1) { | if (argc != 1) { | ||||
| // Coupling: modify also src/parser/xhpast/bin/PhutilXHPASTBinary.php | // Coupling: modify also src/parser/xhpast/bin/PhutilXHPASTBinary.php | ||||
| cout << "5.6.1\n"; | cout << "5.6.2\n"; | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| ifstream inputFile; | ifstream inputFile; | ||||
| istream *inputStream; | istream *inputStream; | ||||
| inputStream = &cin; | inputStream = &cin; | ||||
| std::stringbuf sb; | std::stringbuf sb; | ||||
| ▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | if (l == -1) { | ||||
| printf("[%u]", node->type); | printf("[%u]", node->type); | ||||
| } else { | } else { | ||||
| int r = -1; | int r = -1; | ||||
| if (node->r_tok != -1) { | if (node->r_tok != -1) { | ||||
| r = node->r_tok; | r = node->r_tok; | ||||
| } | } | ||||
| printf("[%u, %d, %d", node->type, l, r); | printf("[%u,%d,%d", node->type, l, r); | ||||
| if (!node->children.empty()) { | if (!node->children.empty()) { | ||||
| printf(", ["); | printf(",["); | ||||
| for (xhpast::node_list_t::iterator ii = node->children.begin();;) { | for (xhpast::node_list_t::iterator ii = node->children.begin();;) { | ||||
| print_node(*ii); | print_node(*ii); | ||||
| if (++ii != node->children.end()) { | if (++ii != node->children.end()) { | ||||
| printf(","); | printf(","); | ||||
| } else { | } else { | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| printf("]"); | printf("]"); | ||||
| } | } | ||||
| printf("]"); | printf("]"); | ||||
| } | } | ||||
| } | } | ||||