Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

E4X parsing support

Summary:
This adds optional support for E4X as specified by ECMA-357. By default this is off, but you can enable it at run-time with PARSER_E4X.

Test Plan:
Basically nothing at all.

Reviewed By: epriestley
  • Loading branch information...
commit 9a77508a28744c21419a24e9447519eba4da74cc 1 parent bd9ed38
@laverdet laverdet authored
View
337 node.cpp
@@ -1208,6 +1208,22 @@ rope_t NodeForIn::render(render_guts_t* guts, int indentation) const {
}
//
+// NodeForEachIn
+NodeForEachIn::NodeForEachIn(const unsigned int lineno /* = 0 */) : Node(lineno) {}
+Node* NodeForEachIn::clone(Node* node) const {
+ return Node::clone(new NodeForEachIn());
+}
+
+rope_t NodeForEachIn::render(render_guts_t* guts, int indentation) const {
+ node_list_t::const_iterator node = this->_childNodes.begin();
+ rope_t ret(guts->pretty ? "for each (" : "for each(");
+ ret += (*node)->render(guts, indentation) + " in ";
+ ret += (*++node)->render(guts, indentation) + ")";
+ ret += (*++node)->renderBlock(false, guts, indentation);
+ return ret;
+}
+
+//
// NodeWhile
NodeWhile::NodeWhile(const unsigned int lineno /* = 0 */) : Node(lineno) {}
Node* NodeWhile::clone(Node* node) const {
@@ -1238,3 +1254,324 @@ rope_t NodeDoWhile::render(render_guts_t* guts, int indentation) const {
ret += this->_childNodes.back()->render(guts, indentation) + ")";
return ret;
}
+
+//
+// NodeXMLDefaultNamespace
+NodeXMLDefaultNamespace::NodeXMLDefaultNamespace(const unsigned int lineno /* = 0 */) : NodeStatement(lineno) {}
+
+Node* NodeXMLDefaultNamespace::clone(Node* node) const {
+ return Node::clone(new NodeXMLDefaultNamespace());
+}
+
+rope_t NodeXMLDefaultNamespace::render(render_guts_t* guts, int indentation) const {
+ return rope_t("default xml namespace = ") + this->_childNodes.front()->render(guts, indentation);
+}
+
+//
+// NodeXMLName
+NodeXMLName::NodeXMLName(const string &ns, const string &name, const unsigned int lineno /* = 0 */) : Node(lineno), _ns(ns), _name(name) {}
+
+Node* NodeXMLName::clone(Node* node) const {
+ return Node::clone(new NodeXMLName(this->_ns, this->_name));
+}
+
+rope_t NodeXMLName::render(render_guts_t* guts, int indentation) const {
+ if (this->_ns.empty()) {
+ return rope_t(this->_name.c_str());
+ } else {
+ return rope_t(this->_ns.c_str()) + rope_t(":") + rope_t(this->_name.c_str());
+ }
+}
+
+const string NodeXMLName::ns() const {
+ return this->_ns;
+}
+
+const string NodeXMLName::name() const {
+ return this->_name;
+}
+
+//
+// NodeXMLElement
+NodeXMLElement::NodeXMLElement(const unsigned int lineno /* = 0 */) : NodeExpression(lineno) {}
+
+Node* NodeXMLElement::clone(Node* node) const {
+ return Node::clone(new NodeXMLElement());
+}
+
+rope_t NodeXMLElement::render(render_guts_t* guts, int indentation) const {
+ rope_t ret("<");
+ node_list_t::const_iterator ii = this->_childNodes.begin();
+ if (*ii != NULL) {
+ ret += (*ii)->render(guts, indentation);
+ } else {
+ // xml list
+ ii++;
+ ret += ">";
+ ret += (*++ii)->render(guts, indentation);
+ ret += "</>";
+ return ret;
+ }
+ ++ii;
+ if (!(*ii)->empty()) {
+ ret += " ";
+ ret += (*ii)->render(guts, indentation);
+ }
+ ++ii;
+ if (!(*ii)->empty()) {
+ ret += ">";
+ ret += (*ii)->render(guts, indentation);
+ ret += "</";
+ ret += (*++ii)->render(guts, indentation);
+ ret += ">";
+ } else {
+ if ((*++ii) == NULL) {
+ ret += "/>";
+ } else {
+ ret += "</";
+ ret += (*ii)->render(guts, indentation);
+ ret += ">";
+ }
+ }
+ return ret;
+}
+
+//
+// NodeXMLComment
+NodeXMLComment::NodeXMLComment(const string &comment, const unsigned int lineno /* = 0 */) : Node(lineno), _comment(comment) {}
+
+Node* NodeXMLComment::clone(Node* node) const {
+ return Node::clone(new NodeXMLComment(this->_comment));
+}
+
+rope_t NodeXMLComment::render(render_guts_t* guts, int indentation) const {
+ rope_t ret("<!--");
+ ret += rope_t(this->_comment.c_str());
+ ret += "-->";
+ return ret;
+}
+
+const string NodeXMLComment::comment() const {
+ return this->_comment;
+}
+
+//
+// NodeXMLPI
+NodeXMLPI::NodeXMLPI(const string &data, const unsigned int lineno /* = 0 */) : Node(lineno), _data(data) {}
+
+Node* NodeXMLPI::clone(Node* node) const {
+ return Node::clone(new NodeXMLPI(this->_data));
+}
+
+rope_t NodeXMLPI::render(render_guts_t* guts, int indentation) const {
+ rope_t ret("<?");
+ ret += rope_t(this->_data.c_str());
+ ret += "?>";
+ return ret;
+}
+
+const string NodeXMLPI::data() const {
+ return this->_data;
+}
+
+//
+// NodeXMLContentList
+NodeXMLContentList::NodeXMLContentList(const unsigned int lineno /* = 0 */) : Node(lineno) {}
+
+Node* NodeXMLContentList::clone(Node* node) const {
+ return Node::clone(new NodeXMLContentList());
+}
+
+rope_t NodeXMLContentList::render(render_guts_t* guts, int indentation) const {
+ return this->renderImplodeChildren(guts, indentation, "");
+}
+
+//
+// NodeXMLTextData
+NodeXMLTextData::NodeXMLTextData(const unsigned int lineno /* = 0 */) : Node(lineno), whitespace(true) {}
+
+Node* NodeXMLTextData::clone(Node* node) const {
+ NodeXMLTextData* new_node = new NodeXMLTextData();
+ new_node->appendData(this->_data, this->whitespace);
+ return Node::clone(new_node);
+}
+
+rope_t NodeXMLTextData::render(render_guts_t* guts, int indentation) const {
+ return this->_data;
+}
+
+void NodeXMLTextData::appendData(rope_t str, bool isWhitespace /* = false */) {
+ this->_data += str;
+ if (!isWhitespace) {
+ this->whitespace = false;
+ }
+}
+
+bool NodeXMLTextData::isWhitespace() const {
+ return this->whitespace;
+}
+
+const char* NodeXMLTextData::data() const {
+ return this->_data.c_str();
+}
+
+//
+// NodeXMLEmbeddedExpression
+NodeXMLEmbeddedExpression::NodeXMLEmbeddedExpression(const unsigned int lineno /* = 0 */) : Node(lineno) {}
+
+Node* NodeXMLEmbeddedExpression::clone(Node* node) const {
+ return Node::clone(new NodeXMLEmbeddedExpression());
+}
+
+rope_t NodeXMLEmbeddedExpression::render(render_guts_t* guts, int indentation) const {
+ return rope_t("{") + this->_childNodes.front()->render(guts, indentation) + "}";
+}
+
+//
+// NodeXMLAttributeList
+NodeXMLAttributeList::NodeXMLAttributeList(const unsigned int lineno /* = 0 */) : Node(lineno) {}
+
+Node* NodeXMLAttributeList::clone(Node* node) const {
+ return Node::clone(new NodeXMLAttributeList());
+}
+
+rope_t NodeXMLAttributeList::render(render_guts_t* guts, int indentation) const {
+ return this->renderImplodeChildren(guts, indentation, " ");
+}
+
+//
+// NodeXMLAttribute
+NodeXMLAttribute::NodeXMLAttribute(const unsigned int lineno /* = 0 */) : Node(lineno) {}
+
+Node* NodeXMLAttribute::clone(Node* node) const {
+ return Node::clone(new NodeXMLAttribute());
+}
+
+rope_t NodeXMLAttribute::render(render_guts_t* guts, int indentation) const {
+ rope_t ret = this->_childNodes.front()->render(guts, indentation);
+ ret += "=";
+ Node* val = this->_childNodes.back();
+ if (typeid(*val) == typeid(NodeXMLTextData)) {
+ // TODO: Escape value, <foo bar="&amp;" /> will render to <foo bar="&" />
+ ret += "\"";
+ ret += val->render(guts, indentation);
+ ret += "\"";
+ } else {
+ ret += val->render(guts, indentation);
+ }
+ return ret;
+}
+
+//
+// NodeWildcardIdentifier
+NodeWildcardIdentifier::NodeWildcardIdentifier(const unsigned int lineno /* = 0 */) : NodeExpression(lineno) {}
+
+Node* NodeWildcardIdentifier::clone(Node* node) const {
+ return Node::clone(new NodeWildcardIdentifier());
+}
+
+rope_t NodeWildcardIdentifier::render(render_guts_t* guts, int indentation) const {
+ return rope_t("*");
+}
+
+bool NodeWildcardIdentifier::isValidlVal() const {
+ return true;
+}
+
+//
+// NodeStaticAttributeIdentifier
+NodeStaticAttributeIdentifier::NodeStaticAttributeIdentifier(const unsigned int lineno /* = 0 */) : NodeExpression(lineno) {}
+
+Node* NodeStaticAttributeIdentifier::clone(Node* node) const {
+ return Node::clone(new NodeStaticAttributeIdentifier());
+}
+
+rope_t NodeStaticAttributeIdentifier::render(render_guts_t* guts, int indentation) const {
+ return rope_t("@") + this->_childNodes.front()->render(guts, indentation);
+}
+
+bool NodeStaticAttributeIdentifier::isValidlVal() const {
+ return true;
+}
+
+//
+// NodeDynamicAttributeIdentifier
+NodeDynamicAttributeIdentifier::NodeDynamicAttributeIdentifier(const unsigned int lineno /* = 0 */) : NodeExpression(lineno) {}
+
+Node* NodeDynamicAttributeIdentifier::clone(Node* node) const {
+ return Node::clone(new NodeDynamicAttributeIdentifier());
+}
+
+rope_t NodeDynamicAttributeIdentifier::render(render_guts_t* guts, int indentation) const {
+ return rope_t("@[") + this->_childNodes.front()->render(guts, indentation) + "]";
+}
+
+bool NodeDynamicAttributeIdentifier::isValidlVal() const {
+ return true;
+}
+
+//
+// NodeStaticQualifiedIdentifier
+NodeStaticQualifiedIdentifier::NodeStaticQualifiedIdentifier(const unsigned int lineno /* = 0 */) : NodeExpression(lineno) {}
+
+Node* NodeStaticQualifiedIdentifier::clone(Node* node) const {
+ return Node::clone(new NodeStaticQualifiedIdentifier());
+}
+
+rope_t NodeStaticQualifiedIdentifier::render(render_guts_t* guts, int indentation) const {
+ return
+ this->_childNodes.front()->render(guts, indentation) + "::" +
+ this->_childNodes.back()->render(guts, indentation);
+}
+
+bool NodeStaticQualifiedIdentifier::isValidlVal() const {
+ return true;
+}
+
+//
+// NodeDynamicQualifiedIdentifier
+NodeDynamicQualifiedIdentifier::NodeDynamicQualifiedIdentifier(const unsigned int lineno /* = 0 */) : NodeExpression(lineno) {}
+
+Node* NodeDynamicQualifiedIdentifier::clone(Node* node) const {
+ return Node::clone(new NodeDynamicQualifiedIdentifier());
+}
+
+rope_t NodeDynamicQualifiedIdentifier::render(render_guts_t* guts, int indentation) const {
+ return
+ this->_childNodes.front()->render(guts, indentation) + "::[" +
+ this->_childNodes.back()->render(guts, indentation) + "]";
+}
+
+bool NodeDynamicQualifiedIdentifier::isValidlVal() const {
+ return true;
+}
+
+//
+// NodeFilteringPredicate
+NodeFilteringPredicate::NodeFilteringPredicate(const unsigned int lineno /* = 0 */) : NodeExpression(lineno) {}
+
+Node* NodeFilteringPredicate::clone(Node* node) const {
+ return Node::clone(new NodeFilteringPredicate());
+}
+
+rope_t NodeFilteringPredicate::render(render_guts_t* guts, int indentation) const {
+ return
+ this->_childNodes.front()->render(guts, indentation) + ".(" +
+ this->_childNodes.back()->render(guts, indentation) + ")";
+}
+
+bool NodeFilteringPredicate::isValidlVal() const {
+ return true;
+}
+
+//
+// NodeDescendantExpression
+NodeDescendantExpression::NodeDescendantExpression(const unsigned int lineno /* = 0 */) : NodeExpression(lineno) {}
+
+rope_t NodeDescendantExpression::render(render_guts_t* guts, int indentation) const {
+ return rope_t(this->_childNodes.front()->render(guts, indentation)) + ".." + this->_childNodes.back()->render(guts, indentation);
+}
+
+Node* NodeDescendantExpression::clone(Node* node) const {
+ return Node::clone(new NodeDescendantExpression());
+}
View
224 node.hpp
@@ -42,6 +42,7 @@ namespace fbjs {
PARSE_NONE = 0,
PARSE_TYPEHINT = 1,
PARSE_OBJECT_LITERAL_ELISON = 2,
+ PARSE_E4X = 4,
};
struct render_guts_t {
unsigned int lineno;
@@ -577,6 +578,16 @@ namespace fbjs {
};
//
+ // NodeForEachIn
+ class NodeForEachIn: public Node {
+ public:
+ NODE_WALKER_ACCEPT_DECL;
+ NodeForEachIn(const unsigned int lineno = 0);
+ virtual Node* clone(Node* node = NULL) const;
+ virtual rope_t render(render_guts_t* guts, int indentation) const;
+ };
+
+ //
// NodeWhile
class NodeWhile: public Node {
public:
@@ -597,6 +608,219 @@ namespace fbjs {
};
//
+ // NodeXMLDefaultNamespace
+ // children: NodeExpression
+ class NodeXMLDefaultNamespace: public NodeStatement {
+ public:
+ NODE_WALKER_ACCEPT_DECL;
+ NodeXMLDefaultNamespace(const unsigned int lineno = 0);
+ virtual Node* clone(Node* node = NULL) const;
+ virtual rope_t render(render_guts_t* guts, int indentation) const;
+ };
+
+ //
+ // NodeXMLName
+ // children: none
+ class NodeXMLName: public Node {
+ protected:
+ const std::string _ns;
+ const std::string _name;
+ public:
+ NODE_WALKER_ACCEPT_DECL;
+ NodeXMLName(const std::string &ns, const std::string &name, const unsigned int lineno = 0);
+ virtual Node* clone(Node* node = NULL) const;
+ virtual rope_t render(render_guts_t* guts, int indentation) const;
+ virtual const std::string ns() const;
+ virtual const std::string name() const;
+ };
+
+ //
+ // NodeXMLElement
+ // children:
+ // NodeXMLName | NodeXMLEmbeddedExpression | NULL,
+ // NodeXMLAttributeList,
+ // NodeXMLContentList,
+ // NodeXMLName | NodeXMLEmbeddedExpression | NULL
+ class NodeXMLElement: public NodeExpression {
+ public:
+ NODE_WALKER_ACCEPT_DECL;
+ NodeXMLElement(const unsigned int lineno = 0);
+ virtual Node* clone(Node* node = NULL) const;
+ virtual rope_t render(render_guts_t* guts, int indentation) const;
+ };
+
+ //
+ // NodeXMLComment
+ // children: none
+ class NodeXMLComment: public Node {
+ protected:
+ const std::string _comment;
+ public:
+ NODE_WALKER_ACCEPT_DECL;
+ NodeXMLComment(const std::string &comment, const unsigned int lineno = 0);
+ virtual Node* clone(Node* node = NULL) const;
+ virtual rope_t render(render_guts_t* guts, int indentation) const;
+ virtual const std::string comment() const;
+ };
+
+ //
+ // NodeXMLPI
+ // children: none
+ class NodeXMLPI: public Node {
+ protected:
+ const std::string _data;
+ public:
+ NODE_WALKER_ACCEPT_DECL;
+ NodeXMLPI(const std::string &data, const unsigned int lineno = 0);
+ virtual Node* clone(Node* node = NULL) const;
+ virtual rope_t render(render_guts_t* guts, int indentation) const;
+ virtual const std::string data() const;
+ };
+
+ //
+ // NodeXMLContentList
+ // children: NodeXMLElement*
+ class NodeXMLContentList: public Node {
+ public:
+ NODE_WALKER_ACCEPT_DECL;
+ NodeXMLContentList(const unsigned int lineno = 0);
+ virtual Node* clone(Node* node = NULL) const;
+ virtual rope_t render(render_guts_t* guts, int indentation) const;
+ };
+
+ //
+ // NodeXMLTextData
+ // children: none
+ class NodeXMLTextData: public Node {
+ protected:
+ rope_t _data;
+ bool whitespace;
+ public:
+ NODE_WALKER_ACCEPT_DECL;
+ NodeXMLTextData(const unsigned int lineno = 0);
+ virtual Node* clone(Node* node = NULL) const;
+ virtual rope_t render(render_guts_t* guts, int indentation) const;
+ virtual void appendData(rope_t str, bool isWhitespace = false);
+ virtual bool isWhitespace() const;
+ const char* data() const;
+ };
+
+ //
+ // NodeXMLEmbeddedExpression
+ // children: NodeExpression
+ class NodeXMLEmbeddedExpression: public Node {
+ public:
+ NODE_WALKER_ACCEPT_DECL;
+ NodeXMLEmbeddedExpression(const unsigned int lineno = 0);
+ virtual Node* clone(Node* node = NULL) const;
+ virtual rope_t render(render_guts_t* guts, int indentation) const;
+ };
+
+ //
+ // NodeXMLAttributeList
+ // children: NodeXMLAttribute*
+ class NodeXMLAttributeList: public Node {
+ public:
+ NODE_WALKER_ACCEPT_DECL;
+ NodeXMLAttributeList(const unsigned int lineno = 0);
+ virtual Node* clone(Node* node = NULL) const;
+ virtual rope_t render(render_guts_t* guts, int indentation) const;
+ };
+
+ //
+ // NodeXMLAttribute
+ // children: NodeXMLName, NodeXMLTextData | NodeExpression
+ class NodeXMLAttribute: public Node {
+ public:
+ NODE_WALKER_ACCEPT_DECL;
+ NodeXMLAttribute(const unsigned int lineno = 0);
+ virtual Node* clone(Node* node = NULL) const;
+ virtual rope_t render(render_guts_t* guts, int indentation) const;
+ };
+
+ //
+ // NodeWildcardIdentifier
+ // children: none
+ class NodeWildcardIdentifier: public NodeExpression {
+ public:
+ NODE_WALKER_ACCEPT_DECL;
+ NodeWildcardIdentifier(const unsigned int lineno = 0);
+ virtual Node* clone(Node* node = NULL) const;
+ virtual rope_t render(render_guts_t* guts, int indentation) const;
+ virtual bool isValidlVal() const;
+ };
+
+ //
+ // NodeStaticAttributeIdentifier
+ // children: NodeIdentifier | NodeWildcardIdentifier | NodeStaticQualifiedIdentifier
+ class NodeStaticAttributeIdentifier: public NodeExpression {
+ public:
+ NODE_WALKER_ACCEPT_DECL;
+ NodeStaticAttributeIdentifier(const unsigned int lineno = 0);
+ virtual Node* clone(Node* node = NULL) const;
+ virtual rope_t render(render_guts_t* guts, int indentation) const;
+ virtual bool isValidlVal() const;
+ };
+
+ //
+ // NodeDynamicAttributeIdentifier
+ // children: NodeExpression
+ class NodeDynamicAttributeIdentifier: public NodeExpression {
+ public:
+ NODE_WALKER_ACCEPT_DECL;
+ NodeDynamicAttributeIdentifier(const unsigned int lineno = 0);
+ virtual Node* clone(Node* node = NULL) const;
+ virtual rope_t render(render_guts_t* guts, int indentation) const;
+ virtual bool isValidlVal() const;
+ };
+
+ //
+ // NodeStaticQualifiedIdentifier
+ // children: NodeIdentifier | NodeWildcardIdentifier, NodeIdentifier | NodeWildcardIdentifier
+ class NodeStaticQualifiedIdentifier: public NodeExpression {
+ public:
+ NODE_WALKER_ACCEPT_DECL;
+ NodeStaticQualifiedIdentifier(const unsigned int lineno = 0);
+ virtual Node* clone(Node* node = NULL) const;
+ virtual rope_t render(render_guts_t* guts, int indentation) const;
+ virtual bool isValidlVal() const;
+ };
+
+ //
+ // NodeDynamicQualifiedIdentifier
+ // children: NodeIdentifier | NodeWildcardIdentifier, NodeExpression
+ class NodeDynamicQualifiedIdentifier: public NodeExpression {
+ public:
+ NODE_WALKER_ACCEPT_DECL;
+ NodeDynamicQualifiedIdentifier(const unsigned int lineno = 0);
+ virtual Node* clone(Node* node = NULL) const;
+ virtual rope_t render(render_guts_t* guts, int indentation) const;
+ virtual bool isValidlVal() const;
+ };
+
+ //
+ // NodeFilteringPredicate
+ // children: NodeExpression, NodeExpression
+ class NodeFilteringPredicate: public NodeExpression {
+ public:
+ NODE_WALKER_ACCEPT_DECL;
+ NodeFilteringPredicate(const unsigned int lineno = 0);
+ virtual Node* clone(Node* node = NULL) const;
+ virtual rope_t render(render_guts_t* guts, int indentation) const;
+ virtual bool isValidlVal() const;
+ };
+
+ //
+ // NodeDescendantExpression
+ class NodeDescendantExpression: public NodeExpression {
+ public:
+ NODE_WALKER_ACCEPT_DECL;
+ NodeDescendantExpression(const unsigned int lineno = 0);
+ virtual Node* clone(Node* node = NULL) const;
+ virtual rope_t render(render_guts_t* guts, int indentation) const;
+ };
+
+ //
// Parser exception
class ParseException: public std::runtime_error {
private:
View
2  parser.hpp
@@ -43,8 +43,10 @@ struct fbjs_parse_extra {
bool terminated;
std::stack<int> paren_stack;
std::stack<int> curly_stack;
+ std::stack<int> pre_xml_stack;
int virtual_semicolon_last_state;
int last_tok;
+ bool last_tok_xml;
int last_paren_tok;
int last_curly_tok;
int lineno;
View
170 parser.ll
@@ -60,6 +60,12 @@ using namespace fbjs;
case REGEX: \
fprintf(stderr, "BEGIN(REGEX)\n"); \
break; \
+ case XML: \
+ fprintf(stderr, "BEGIN(XML)\n"); \
+ break; \
+ case XML_CDATA: \
+ fprintf(stderr, "BEGIN(XML_CDATA)\n"); \
+ break; \
default: \
fprintf(stderr, "BEGIN(%d)\n", a); \
} \
@@ -69,6 +75,7 @@ using namespace fbjs;
#endif
#define parsertok(a) parsertok_(yyg, a);
+#define parsertok_xml(a) parsertok_(yyg, a, true);
int parsertok_(void*, int, bool = false);
void terminate(void* yyscanner, const char* str);
@@ -84,8 +91,16 @@ void terminate(void* yyscanner, const char* str);
%x VIRTUAL_SEMICOLON
%s NO_LINEBREAK
%x REGEX
+%x XML
+%x XML_CDATA
+%x XML_PI
FBJSBEGIN(IDENTIFIER);
+/* ECMA-262 and ECMA-357 disagree on the definition of whitespace. Note: both
+ macros omit \n. You must manually scan for \n and increment yylineno. */
+JS_WHITESPACE [ \t\x0b\x0c\xa0\r]*
+XML_WHITESPACE [ \t\r]*
+
%%
<NO_LINEBREAK>{
\n {
@@ -99,10 +114,10 @@ FBJSBEGIN(IDENTIFIER);
}
}
<INITIAL,IDENTIFIER,DOT,VIRTUAL_SEMICOLON,NO_LINEBREAK>{
- /* start conditon is all, minus REGEX */
+ /* start conditon is all, minus REGEX and XML */
"<!--".* /* om nom nom */
"//".* |
- [ \t\x0b\x0c\xa0\r]+ /* om nom nom */
+ {JS_WHITESPACE}+ /* om nom nom */
"/*" {
char c;
bool newline = false;
@@ -188,10 +203,26 @@ FBJSBEGIN(IDENTIFIER);
"case" return parsertok(t_CASE);
"continue" return parsertok(t_CONTINUE);
"default" return parsertok(t_DEFAULT);
+ "default"({JS_WHITESPACE}|\n)+"xml"({JS_WHITESPACE}|\n)+"namespace" {
+ while (*++yytext) {
+ if (*yytext == '\n') {
+ ++yylloc->first_line;
+ }
+ }
+ return parsertok(t_XML_DEFAULT_NAMESPACE);
+ }
"delete" return parsertok(t_DELETE);
"do" return parsertok(t_DO);
"else" return parsertok(t_ELSE);
"for" return parsertok(t_FOR);
+ "for"({JS_WHITESPACE}|\n)+"each" {
+ while (*++yytext) {
+ if (*yytext == '\n') {
+ ++yylloc->first_line;
+ }
+ }
+ return parsertok(t_FOR_EACH);
+ }
"function" return parsertok(t_FUNCTION);
"if" return parsertok(t_IF);
"new" return parsertok(t_NEW);
@@ -378,12 +409,119 @@ FBJSBEGIN(IDENTIFIER);
"!" return parsertok(t_NOT);
"~" return parsertok(t_BIT_NOT);
"=" return parsertok(t_ASSIGN);
+"@" return parsertok(t_XML_ATTRIBUTE);
+".." return parsertok(t_XML_DESCENDENT);
+"::" return parsertok(t_XML_QUALIFIER);
+<XML>{
+ [a-zA-Z_][a-zA-Z0-9.\-_]* {
+ yylval->string = strdup(yytext);
+ return parsertok(t_XML_NAME_FRAGMENT);
+ }
+ {XML_WHITESPACE}+ {
+ yylval->string = strdup(yytext);
+ return parsertok(t_XML_WHITESPACE);
+ }
+ \n {
+ ++yylloc->first_line;
+ yylval->string = strdup(yytext);
+ return parsertok(t_XML_WHITESPACE);
+ }
+ "<![CDATA[" {
+ FBJSBEGIN(XML_CDATA);
+ }
+ "<!--"([^\-\n]+|-[^\-\n])+"-->" {
+ yytext[yyleng - 3] = 0;
+ yylval->string = strdup(yytext + 4);
+ return t_XML_COMMENT;
+ }
+ "<?" {
+ FBJSBEGIN(XML_PI);
+ }
+ [^:={}<>"'/& \t\r\n]+ {
+ yylval->string = strdup(yytext);
+ return parsertok(t_XML_CDATA);
+ }
+ "&amp;" {
+ yylval->string = strdup("&");
+ return parsertok(t_XML_CDATA);
+ }
+ "&lt;" {
+ yylval->string = strdup("<");
+ return parsertok(t_XML_CDATA);
+ }
+ "&gt;" {
+ yylval->string = strdup(">");
+ return parsertok(t_XML_CDATA);
+ }
+ "&apos;" {
+ yylval->string = strdup("'");
+ return parsertok(t_XML_CDATA);
+ }
+ "&quot;" {
+ yylval->string = strdup("\"");
+ return parsertok(t_XML_CDATA);
+ }
+ "&" {
+ terminate(yyscanner, "invalid entity");
+ return 0;
+ }
+ ":" return parsertok(t_COLON);
+ "=" return parsertok(t_ASSIGN);
+ "{" return parsertok(t_LCURLY);
+ "}" return parsertok(t_RCURLY);
+ "<" return parsertok(t_LESS_THAN);
+ ">" return parsertok_xml(t_GREATER_THAN);
+ \" return parsertok(t_XML_QUOTE);
+ \' return parsertok(t_XML_APOS);
+ "/" return parsertok(t_DIV);
+ "</" return parsertok(t_XML_LT_DIV);
+}
+<XML_CDATA>{
+ [^\]\n]+ {
+ yymore();
+ }
+ \n {
+ ++yylloc->first_line;
+ yymore();
+ }
+ "]" {
+ yymore();
+ }
+ "]]>" {
+ /* 3 is length of "]]>" */
+ yytext[yyleng - 3] = 0;
+ yylval->string = strdup(yytext);
+ FBJSBEGIN(XML);
+ return t_XML_CDATA;
+ }
+}
+<XML_PI>{
+ [^?\n]+ {
+ yymore();
+ }
+ \n {
+ ++yylloc->first_line;
+ yymore();
+ }
+ "?" {
+ yymore();
+ }
+ "?>" {
+ /* 2 is length of "]]>" */
+ yytext[yyleng - 2] = 0;
+ yylval->string = strdup(yytext);
+ FBJSBEGIN(XML);
+ return t_XML_PI;
+ }
+}
\n {
++yylloc->first_line;
if (yyextra->last_tok == t_IDENTIFIER || yyextra->last_tok == t_NUMBER || yyextra->last_tok == t_STRING ||
yyextra->last_tok == t_REGEX || yyextra->last_tok == t_TRUE || yyextra->last_tok == t_FALSE ||
yyextra->last_tok == t_RPAREN || yyextra->last_tok == t_RCURLY || yyextra->last_tok == t_RBRACKET ||
- yyextra->last_tok == t_NULL || yyextra->last_tok == t_THIS) {
+ yyextra->last_tok == t_NULL || yyextra->last_tok == t_THIS ||
+ (yyextra->last_tok_xml && yyextra->last_tok == t_GREATER_THAN)
+ ) {
yyextra->virtual_semicolon_last_state = YY_START;
FBJSBEGIN(VIRTUAL_SEMICOLON);
// Not to spec... sec 7.9.1
@@ -402,8 +540,9 @@ FBJSBEGIN(IDENTIFIER);
}
%%
-int parsertok_(void* guts, int tok) {
+int parsertok_(void* guts, int tok, bool was_xml) {
yyguts_t *yyg = (struct yyguts_t*)guts;
+ if (YY_START != XML) {
switch (tok) {
case t_IDENTIFIER:
case t_NUMBER:
@@ -428,13 +567,36 @@ int parsertok_(void* guts, int tok) {
case t_PERIOD:
FBJSBEGIN(DOT);
break;
+ case '>':
+ FBJSBEGIN(was_xml ? INITIAL : IDENTIFIER);
+ break;
default:
FBJSBEGIN(IDENTIFIER);
break;
}
+ }
yyextra->last_tok = tok;
+ yyextra->last_tok_xml = was_xml;
#ifdef DEBUG_FLEX
fprintf(stderr, "--> %s\n", yytokname(tok));
#endif
return tok;
}
+
+void fbjs_push_xml_state(void* guts) {
+ yyguts_t *yyg = static_cast<yyguts_t*>(guts);
+ yyextra->pre_xml_stack.push(YY_START);
+ FBJSBEGIN(XML);
+}
+
+void fbjs_push_xml_embedded_expression_state(void* guts) {
+ yyguts_t *yyg = static_cast<yyguts_t*>(guts);
+ yyextra->pre_xml_stack.push(YY_START);
+ FBJSBEGIN(IDENTIFIER);
+}
+
+void fbjs_pop_xml_state(void* guts) {
+ yyguts_t *yyg = static_cast<yyguts_t*>(guts);
+ FBJSBEGIN(yyextra->pre_xml_stack.top());
+ yyextra->pre_xml_stack.pop();
+}
View
384 parser.yy
@@ -48,6 +48,10 @@
break; \
}
+ void fbjs_push_xml_state(void* guts);
+ void fbjs_push_xml_embedded_expression_state(void* guts);
+ void fbjs_pop_xml_state(void* guts);
+
void terminate(void* yyscanner, const char* str) {
fbjs_parse_extra* extra = yyget_extra(yyscanner);
if (!extra->terminated) {
@@ -76,9 +80,10 @@
%token t_LPAREN t_RPAREN
%token t_LBRACKET t_RBRACKET
%token t_SEMICOLON t_VIRTUAL_SEMICOLON
-%token t_BREAK t_CASE t_CATCH t_CONTINUE t_DEFAULT t_DO t_FINALLY t_FOR
+%token t_BREAK t_CASE t_CATCH t_CONTINUE t_DEFAULT t_DO t_FINALLY t_FOR t_FOR_EACH
%token t_FUNCTION t_IF t_IN t_INSTANCEOF t_RETURN t_SWITCH t_THIS t_THROW t_TRY
%token t_VAR t_WHILE t_WITH t_CONST t_NULL t_FALSE t_TRUE
+%token t_XML_QUOTE t_XML_APOS t_XML_LT_DIV t_XML_DEFAULT_NAMESPACE
// Special if \ else associativity
%nonassoc p_IF
@@ -88,6 +93,7 @@
%token<number> t_NUMBER
%token<string> t_IDENTIFIER t_STRING
%token<string_duple> t_REGEX
+%token<string> t_XML_NAME_FRAGMENT t_XML_CDATA t_XML_WHITESPACE t_XML_COMMENT t_XML_PI
// Operators + associativity
%token t_COMMA
@@ -105,7 +111,8 @@
%left t_DIV t_MULT t_MOD
%right t_NOT t_BIT_NOT t_INCR t_DECR t_DELETE t_TYPEOF t_VOID
%nonassoc p_POSTFIX
-%token t_NEW t_PERIOD
+%left t_XML_ATTRIBUTE
+%token t_NEW t_PERIOD t_XML_DESCENDENT t_XML_QUALIFIER
// Literals
%type<node> null_literal boolean_literal numeric_literal regex_literal string_literal array_literal element_list object_literal property_name property_name_and_value_list
@@ -133,6 +140,16 @@
// Functions
%type<node> function_expression function_declaration formal_parameter_list function_body
+// E4X / XML
+%type<node> xml_literal
+%type<node> xml_element xml_element_content xml_element_content_tag
+%type<node> xml_tag_content xml_name xml_tag_name
+%type<node> xml_attribute_list_opt xml_attribute_list xml_attribute_value
+%type<node> xml_cdata_no_quote xml_cdata_no_apos xml_cdata_xml_content
+%type<string> xml_cdata_fragment xml_cdata_fragment_attr
+%type<node> xml_embedded_expression
+%type<node> property_identifier attribute_identifier property_selector qualified_identifier wildcard_identifier
+
// Errors
%token t_UNTERMINATED_REGEX_LITERAL
@@ -971,6 +988,14 @@ iteration_statement:
| t_FOR t_LPAREN t_VAR variable_declaration_list_no_in t_IN expression t_RPAREN statement {
$$ = (new NodeForIn($4->lineno()))->appendChild(static_cast<NodeVarDeclaration*>($4)->setIterator(true))->appendChild($6)->appendChild($8);
}
+| t_FOR_EACH t_LPAREN left_hand_side_expression t_IN expression t_RPAREN statement {
+ require_support(PARSE_E4X, "E4X not supported");
+ $$ = (new NodeForEachIn($3->lineno()))->appendChild($3)->appendChild($5)->appendChild($7);
+ }
+| t_FOR_EACH t_LPAREN t_VAR variable_declaration_list_no_in t_IN expression t_RPAREN statement {
+ require_support(PARSE_E4X, "E4X not supported");
+ $$ = (new NodeForEachIn($4->lineno()))->appendChild(static_cast<NodeVarDeclaration*>($4)->setIterator(true))->appendChild($6)->appendChild($8);
+ }
;
continue_statement:
@@ -1150,6 +1175,361 @@ function_body:
| statement_list;
;
+//
+// E4X XML literals
+primary_expression_no_statement:
+ xml_literal {
+ require_support(PARSE_E4X, "E4X not supported");
+ $$ = $1;
+ }
+;
+
+xml_literal:
+ xml_element
+| xml_lt t_GREATER_THAN xml_element_content t_XML_LT_DIV t_GREATER_THAN {
+ fbjs_pop_xml_state(yyscanner);
+ $$ = (new NodeXMLElement(yylineno))
+ ->appendChild(NULL)->appendChild(NULL)->appendChild($3)->appendChild(NULL);
+ }
+;
+
+xml_element:
+ xml_tag_content t_DIV t_GREATER_THAN {
+ fbjs_pop_xml_state(yyscanner);
+ $$ = $1->appendChild(new NodeXMLContentList(yylineno))->appendChild(NULL);
+ }
+| xml_tag_content t_GREATER_THAN xml_element_content t_XML_LT_DIV xml_tag_name xml_ws_opt t_GREATER_THAN {
+ fbjs_pop_xml_state(yyscanner);
+ $$ = $1->appendChild($3)->appendChild($5);
+ }
+;
+
+xml_tag_content:
+ xml_lt xml_tag_name xml_attribute_list_opt {
+ $$ = (new NodeXMLElement(yylineno))->appendChild($2)->appendChild($3);
+ }
+;
+
+xml_lt:
+ t_LESS_THAN {
+ fbjs_push_xml_state(yyscanner);
+ }
+;
+
+xml_name:
+ t_XML_NAME_FRAGMENT {
+ $$ = new NodeXMLName("", $1, yylineno);
+ }
+| t_XML_NAME_FRAGMENT t_COLON t_XML_NAME_FRAGMENT {
+ $$ = new NodeXMLName($1, $3, yylineno);
+ }
+;
+
+xml_tag_name:
+ xml_name
+| xml_embedded_expression
+;
+
+xml_element_content:
+ /* empty */ {
+ $$ = new NodeXMLContentList(yylineno);
+ }
+| xml_cdata_xml_content {
+ $$ = (new NodeXMLContentList(yylineno))->appendChild($1);
+ }
+| xml_element_content xml_element_content_tag xml_cdata_xml_content {
+ $$ = $1->appendChild($2)->appendChild($3);
+ }
+| xml_element_content xml_element_content_tag {
+ $$ = $1->appendChild($2);
+ }
+;
+
+xml_element_content_tag:
+ xml_element
+| xml_embedded_expression
+| t_XML_COMMENT {
+ $$ = new NodeXMLComment($1, yylineno);
+ free($1);
+ }
+| t_XML_PI {
+ $$ = new NodeXMLPI($1, yylineno);
+ free($1);
+ }
+;
+
+xml_attribute_list_opt:
+ /* empty */ {
+ $$ = new NodeXMLAttributeList(yylineno);
+ }
+| xml_attribute_list
+;
+
+xml_attribute_list:
+ t_XML_WHITESPACE {
+ $$ = new NodeXMLAttributeList(yylineno);
+ }
+| xml_attribute_list t_XML_WHITESPACE
+| xml_attribute_list xml_name t_ASSIGN xml_attribute_value {
+ $$ = $1->appendChild((new NodeXMLAttribute(yylineno))->appendChild($2)->appendChild($4));
+ }
+;
+
+xml_attribute_value:
+ t_XML_APOS xml_cdata_no_apos t_XML_APOS {
+ $$ = $2;
+ }
+| t_XML_QUOTE xml_cdata_no_quote t_XML_QUOTE {
+ $$ = $2;
+ }
+| xml_embedded_expression {
+ $$ = $1;
+ }
+;
+
+xml_cdata_no_quote:
+ /* empty */ {
+ $$ = new NodeXMLTextData();
+ }
+| xml_cdata_no_quote xml_cdata_fragment_attr {
+ $$ = $1;
+ static_cast<NodeXMLTextData*>($$)->appendData($2);
+ free($2);
+ }
+| xml_cdata_no_quote t_XML_APOS {
+ $$ = $1;
+ static_cast<NodeXMLTextData*>($$)->appendData("'");
+ }
+;
+
+xml_cdata_no_apos:
+ /* empty */ {
+ $$ = new NodeXMLTextData();
+ }
+| xml_cdata_no_apos xml_cdata_fragment_attr {
+ $$ = $1;
+ static_cast<NodeXMLTextData*>($$)->appendData($2);
+ free($2);
+ }
+| xml_cdata_no_apos t_XML_QUOTE {
+ $$ = $1;
+ static_cast<NodeXMLTextData*>($$)->appendData("\"");
+ }
+;
+
+xml_cdata_xml_content:
+ xml_cdata_fragment {
+ $$ = new NodeXMLTextData(yylineno);
+ static_cast<NodeXMLTextData*>($$)->appendData($1);
+ free($1);
+ }
+| t_XML_APOS {
+ $$ = new NodeXMLTextData(yylineno);
+ static_cast<NodeXMLTextData*>($$)->appendData("'");
+ }
+| t_XML_QUOTE {
+ $$ = new NodeXMLTextData(yylineno);
+ static_cast<NodeXMLTextData*>($$)->appendData("\"");
+ }
+| t_XML_WHITESPACE {
+ $$ = new NodeXMLTextData(yylineno);
+ static_cast<NodeXMLTextData*>($$)->appendData($1, true);
+ free($1);
+ }
+| xml_cdata_xml_content xml_cdata_fragment {
+ $$ = $1;
+ static_cast<NodeXMLTextData*>($$)->appendData($2);
+ free($2);
+ }
+| xml_cdata_xml_content t_XML_APOS {
+ $$ = $1;
+ static_cast<NodeXMLTextData*>($$)->appendData("'");
+ }
+| xml_cdata_xml_content t_XML_QUOTE {
+ $$ = $1;
+ static_cast<NodeXMLTextData*>($$)->appendData("\"");
+ }
+| xml_cdata_xml_content t_XML_WHITESPACE {
+ $$ = $1;
+ static_cast<NodeXMLTextData*>($$)->appendData($2, true);
+ free($2);
+ }
+;
+
+xml_cdata_fragment:
+/* Does not include: t_LESS_THAN, t_XML_APOS, t_XML_QUOTE, t_LCURLY, t_XML_WHITESPACE */
+ t_XML_CDATA
+| t_XML_NAME_FRAGMENT
+| t_COLON {
+ $$ = strdup(":");
+ }
+| t_ASSIGN {
+ $$ = strdup("=");
+ }
+| t_RCURLY {
+ $$ = strdup("}");
+ }
+| t_GREATER_THAN {
+ $$ = strdup(">");
+ }
+| t_DIV {
+ $$ = strdup("/");
+ }
+;
+
+xml_cdata_fragment_attr:
+/* Does not include: t_XML_APOS, t_XML_QUOTE */
+ xml_cdata_fragment
+| t_LESS_THAN {
+ $$ = strdup("<");
+ }
+| t_LCURLY {
+ $$ = strdup("{");
+ }
+| t_XML_WHITESPACE
+;
+
+xml_embedded_expression:
+ t_LCURLY { fbjs_push_xml_embedded_expression_state(yyscanner); } expression t_VIRTUAL_SEMICOLON t_RCURLY {
+ fbjs_pop_xml_state(yyscanner);
+ $$ = (new NodeXMLEmbeddedExpression($3->lineno()))->appendChild($3);
+ }
+;
+
+xml_ws_opt:
+ /* empty */
+| t_XML_WHITESPACE
+;
+
+//
+// E4X expressions
+statement:
+ t_XML_DEFAULT_NAMESPACE t_ASSIGN expression semicolon {
+ require_support(PARSE_E4X, "E4X not supported");
+ $$ = (new NodeXMLDefaultNamespace(yylineno))->appendChild($3);
+ }
+;
+primary_expression_no_statement:
+ property_identifier {
+ require_support(PARSE_E4X, "E4X not supported");
+ $$ = $1;
+ }
+;
+
+property_identifier:
+ attribute_identifier
+| qualified_identifier
+| wildcard_identifier
+;
+
+attribute_identifier:
+ t_XML_ATTRIBUTE property_selector {
+ $$ = (new NodeStaticAttributeIdentifier(yylineno))->appendChild($2);
+ }
+| t_XML_ATTRIBUTE qualified_identifier {
+ $$ = (new NodeStaticAttributeIdentifier(yylineno))->appendChild($2);
+ }
+| t_XML_ATTRIBUTE t_LBRACKET expression t_RBRACKET {
+ $$ = (new NodeDynamicAttributeIdentifier(yylineno))->appendChild($3);
+ }
+;
+
+property_selector:
+ identifier
+| wildcard_identifier
+;
+
+qualified_identifier:
+ property_selector t_XML_QUALIFIER property_selector {
+ $$ = (new NodeStaticQualifiedIdentifier($1->lineno()))->appendChild($1)->appendChild($3);
+ }
+| property_selector t_XML_QUALIFIER t_LBRACKET expression t_RBRACKET {
+ $$ = (new NodeDynamicQualifiedIdentifier($1->lineno()))->appendChild($1)->appendChild($4);
+ }
+;
+
+wildcard_identifier:
+ t_MULT {
+ $$ = new NodeWildcardIdentifier(yylineno);
+ }
+;
+
+member_expression:
+ member_expression t_PERIOD property_identifier {
+ require_support(PARSE_E4X, "E4X not supported");
+ $$ = (new NodeStaticMemberExpression(yylineno))->appendChild($1)->appendChild($3);
+ }
+| member_expression t_PERIOD t_LPAREN expression t_RPAREN {
+ require_support(PARSE_E4X, "E4X not supported");
+ $$ = (new NodeFilteringPredicate(yylineno))->appendChild($1)->appendChild($4);
+ }
+| member_expression t_XML_DESCENDENT identifier {
+ require_support(PARSE_E4X, "E4X not supported");
+ $$ = (new NodeDescendantExpression(yylineno))->appendChild($1)->appendChild($3);
+ }
+| member_expression t_XML_DESCENDENT property_identifier {
+ require_support(PARSE_E4X, "E4X not supported");
+ $$ = (new NodeDescendantExpression(yylineno))->appendChild($1)->appendChild($3);
+ }
+;
+
+member_expression_no_statement:
+ member_expression_no_statement t_PERIOD property_identifier {
+ require_support(PARSE_E4X, "E4X not supported");
+ $$ = (new NodeStaticMemberExpression(yylineno))->appendChild($1)->appendChild($3);
+ }
+| member_expression_no_statement t_PERIOD t_LPAREN expression t_RPAREN {
+ require_support(PARSE_E4X, "E4X not supported");
+ $$ = (new NodeFilteringPredicate(yylineno))->appendChild($1)->appendChild($4);
+ }
+| member_expression_no_statement t_XML_DESCENDENT identifier {
+ require_support(PARSE_E4X, "E4X not supported");
+ $$ = (new NodeDescendantExpression(yylineno))->appendChild($1)->appendChild($3);
+ }
+| member_expression_no_statement t_XML_DESCENDENT property_identifier {
+ require_support(PARSE_E4X, "E4X not supported");
+ $$ = (new NodeDescendantExpression(yylineno))->appendChild($1)->appendChild($3);
+ }
+;
+
+call_expression:
+ call_expression t_PERIOD property_identifier {
+ require_support(PARSE_E4X, "E4X not supported");
+ $$ = (new NodeStaticMemberExpression(yylineno))->appendChild($1)->appendChild($3);
+ }
+| call_expression t_PERIOD t_LPAREN expression t_RPAREN {
+ require_support(PARSE_E4X, "E4X not supported");
+ $$ = (new NodeFilteringPredicate(yylineno))->appendChild($1)->appendChild($4);
+ }
+| call_expression t_XML_DESCENDENT identifier {
+ require_support(PARSE_E4X, "E4X not supported");
+ $$ = (new NodeDescendantExpression(yylineno))->appendChild($1)->appendChild($3);
+ }
+| call_expression t_XML_DESCENDENT property_identifier {
+ require_support(PARSE_E4X, "E4X not supported");
+ $$ = (new NodeDescendantExpression(yylineno))->appendChild($1)->appendChild($3);
+ }
+;
+
+call_expression_no_statement:
+ call_expression_no_statement t_PERIOD property_identifier {
+ require_support(PARSE_E4X, "E4X not supported");
+ $$ = (new NodeStaticMemberExpression(yylineno))->appendChild($1)->appendChild($3);
+ }
+| call_expression_no_statement t_PERIOD t_LPAREN expression t_RPAREN {
+ require_support(PARSE_E4X, "E4X not supported");
+ $$ = (new NodeFilteringPredicate(yylineno))->appendChild($1)->appendChild($4);
+ }
+| call_expression_no_statement t_XML_DESCENDENT identifier {
+ require_support(PARSE_E4X, "E4X not supported");
+ $$ = (new NodeDescendantExpression(yylineno))->appendChild($1)->appendChild($3);
+ }
+| call_expression_no_statement t_XML_DESCENDENT property_identifier {
+ require_support(PARSE_E4X, "E4X not supported");
+ $$ = (new NodeDescendantExpression(yylineno))->appendChild($1)->appendChild($3);
+ }
+;
+
%%
const char* yytokname(int tok) {
View
18 walker.cpp
@@ -64,5 +64,23 @@ NODE_WALKER_ACCEPT_IMPL(NodeDefaultClause, NodeCaseClause);
NODE_WALKER_ACCEPT_IMPL(NodeObjectLiteralProperty, Node);
NODE_WALKER_ACCEPT_IMPL(NodeForLoop, Node);
NODE_WALKER_ACCEPT_IMPL(NodeForIn, Node);
+NODE_WALKER_ACCEPT_IMPL(NodeForEachIn, Node);
NODE_WALKER_ACCEPT_IMPL(NodeWhile, Node);
NODE_WALKER_ACCEPT_IMPL(NodeDoWhile, NodeStatement);
+NODE_WALKER_ACCEPT_IMPL(NodeXMLDefaultNamespace, NodeStatement);
+NODE_WALKER_ACCEPT_IMPL(NodeXMLName, Node);
+NODE_WALKER_ACCEPT_IMPL(NodeXMLElement, NodeExpression);
+NODE_WALKER_ACCEPT_IMPL(NodeXMLComment, Node);
+NODE_WALKER_ACCEPT_IMPL(NodeXMLPI, Node);
+NODE_WALKER_ACCEPT_IMPL(NodeXMLContentList, Node);
+NODE_WALKER_ACCEPT_IMPL(NodeXMLTextData, Node);
+NODE_WALKER_ACCEPT_IMPL(NodeXMLEmbeddedExpression, Node);
+NODE_WALKER_ACCEPT_IMPL(NodeXMLAttributeList, Node);
+NODE_WALKER_ACCEPT_IMPL(NodeXMLAttribute, Node);
+NODE_WALKER_ACCEPT_IMPL(NodeWildcardIdentifier, NodeExpression);
+NODE_WALKER_ACCEPT_IMPL(NodeStaticAttributeIdentifier, NodeExpression);
+NODE_WALKER_ACCEPT_IMPL(NodeDynamicAttributeIdentifier, NodeExpression);
+NODE_WALKER_ACCEPT_IMPL(NodeStaticQualifiedIdentifier, NodeExpression);
+NODE_WALKER_ACCEPT_IMPL(NodeDynamicQualifiedIdentifier, NodeExpression);
+NODE_WALKER_ACCEPT_IMPL(NodeFilteringPredicate, NodeExpression);
+NODE_WALKER_ACCEPT_IMPL(NodeDescendantExpression, NodeExpression);
View
18 walker.hpp
@@ -148,7 +148,25 @@ namespace fbjs {
NODE_WALKER_VISIT_IMPL(NodeObjectLiteralProperty, Node);
NODE_WALKER_VISIT_IMPL(NodeForLoop, Node);
NODE_WALKER_VISIT_IMPL(NodeForIn, Node);
+ NODE_WALKER_VISIT_IMPL(NodeForEachIn, Node);
NODE_WALKER_VISIT_IMPL(NodeWhile, Node);
NODE_WALKER_VISIT_IMPL(NodeDoWhile, NodeStatement);
+ NODE_WALKER_VISIT_IMPL(NodeXMLDefaultNamespace, NodeStatement);
+ NODE_WALKER_VISIT_IMPL(NodeXMLName, Node);
+ NODE_WALKER_VISIT_IMPL(NodeXMLElement, NodeExpression);
+ NODE_WALKER_VISIT_IMPL(NodeXMLComment, Node);
+ NODE_WALKER_VISIT_IMPL(NodeXMLPI, Node);
+ NODE_WALKER_VISIT_IMPL(NodeXMLContentList, Node);
+ NODE_WALKER_VISIT_IMPL(NodeXMLTextData, Node);
+ NODE_WALKER_VISIT_IMPL(NodeXMLEmbeddedExpression, Node);
+ NODE_WALKER_VISIT_IMPL(NodeXMLAttributeList, Node);
+ NODE_WALKER_VISIT_IMPL(NodeXMLAttribute, Node);
+ NODE_WALKER_VISIT_IMPL(NodeWildcardIdentifier, NodeExpression);
+ NODE_WALKER_VISIT_IMPL(NodeStaticAttributeIdentifier, NodeExpression);
+ NODE_WALKER_VISIT_IMPL(NodeDynamicAttributeIdentifier, NodeExpression);
+ NODE_WALKER_VISIT_IMPL(NodeStaticQualifiedIdentifier, NodeExpression);
+ NODE_WALKER_VISIT_IMPL(NodeDynamicQualifiedIdentifier, NodeExpression);
+ NODE_WALKER_VISIT_IMPL(NodeFilteringPredicate, NodeExpression);
+ NODE_WALKER_VISIT_IMPL(NodeDescendantExpression, NodeExpression);
};
}
Please sign in to comment.
Something went wrong with that request. Please try again.