Rework javascript fixture grammar
This commit is contained in:
parent
8134b64d00
commit
91cf35b72c
7 changed files with 55530 additions and 90492 deletions
|
|
@ -27,7 +27,7 @@ if (isReady()) {
|
|||
---
|
||||
|
||||
(if_statement (function_call (identifier))
|
||||
(statement_block (expression_statement (function_call (property_access (identifier) (identifier)) (identifier)))))
|
||||
(statement_block (expression_statement (function_call (member_access (identifier) (identifier)) (identifier)))))
|
||||
|
||||
==========================================
|
||||
if-else statements
|
||||
|
|
@ -78,7 +78,7 @@ for (var i = 1; someCondition(i); i = next()) {
|
|||
|
||||
(for_statement
|
||||
(var_declaration (var_assignment (identifier) (number)))
|
||||
(expression_statement (function_call (identifier) (identifier)))
|
||||
(function_call (identifier) (identifier))
|
||||
(assignment (identifier) (function_call (identifier)))
|
||||
(statement_block (expression_statement (function_call (identifier)))))
|
||||
|
||||
|
|
@ -135,11 +135,11 @@ try {
|
|||
(program
|
||||
(try_statement
|
||||
(statement_block (expression_statement (function_call (identifier))))
|
||||
(catch_clause (identifier)
|
||||
(catch (identifier)
|
||||
(statement_block (expression_statement (function_call (identifier) (identifier))))))
|
||||
(try_statement
|
||||
(statement_block (expression_statement (function_call (identifier))))
|
||||
(finally_clause
|
||||
(finally
|
||||
(statement_block (expression_statement (function_call (identifier)))))))
|
||||
|
||||
===========================================
|
||||
|
|
@ -150,7 +150,7 @@ throw new Error("wtf");
|
|||
|
||||
---
|
||||
|
||||
(throw_statement (constructor_call (function_call (identifier) (string))))
|
||||
(throw_statement (constructor_call (identifier) (string)))
|
||||
|
||||
===========================================
|
||||
indented code after blocks
|
||||
|
|
@ -163,7 +163,7 @@ indented code after blocks
|
|||
|
||||
(program
|
||||
(expression_statement
|
||||
(function_expression (identifier) (formal_parameters) (statement_block)))
|
||||
(function_expression (identifier) (statement_block)))
|
||||
(return_statement (identifier)))
|
||||
|
||||
===========================================
|
||||
|
|
@ -184,13 +184,13 @@ switch(x) {
|
|||
---
|
||||
|
||||
(switch_statement (identifier)
|
||||
(switch_case
|
||||
(case
|
||||
(string)
|
||||
(expression_statement (function_call (identifier) (string)))
|
||||
(break_statement))
|
||||
(switch_case
|
||||
(case
|
||||
(function_call (identifier))
|
||||
(expression_statement (function_call (identifier) (string)))
|
||||
(break_statement))
|
||||
(switch_case
|
||||
(default
|
||||
(expression_statement (function_call (identifier) (string)))))
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ theFunction(/regex1/, /regex2/g);
|
|||
---
|
||||
|
||||
(expression_statement (function_call (identifier)
|
||||
(regex) (regex)))
|
||||
(arguments (regex) (regex))))
|
||||
|
||||
==========================================
|
||||
numbers
|
||||
|
|
@ -18,7 +18,7 @@ theFunction(100.0, 200);
|
|||
---
|
||||
|
||||
(expression_statement (function_call (identifier)
|
||||
(number) (number)))
|
||||
(arguments (number) (number))))
|
||||
|
||||
==========================================
|
||||
strings
|
||||
|
|
@ -29,7 +29,7 @@ theFunction('', "", 'single-quoted-string', "double-quoted-string");
|
|||
---
|
||||
|
||||
(expression_statement (function_call (identifier)
|
||||
(string) (string) (string) (string)))
|
||||
(arguments (string) (string) (string) (string))))
|
||||
|
||||
==========================================
|
||||
function expressions
|
||||
|
|
@ -45,10 +45,10 @@ var x = {
|
|||
|
||||
(var_declaration (var_assignment
|
||||
(identifier)
|
||||
(object (identifier) (function_expression
|
||||
(object (pair (identifier) (function_expression
|
||||
(formal_parameters (identifier) (identifier))
|
||||
(statement_block
|
||||
(var_declaration (var_assignment (identifier) (identifier))))))))
|
||||
(var_declaration (var_assignment (identifier) (identifier)))))))))
|
||||
|
||||
==========================================
|
||||
comments
|
||||
|
|
@ -75,11 +75,11 @@ var thing = {
|
|||
(object
|
||||
(comment)
|
||||
(comment)
|
||||
(identifier) (function_expression
|
||||
(pair (identifier) (function_expression
|
||||
(formal_parameters (identifier) (comment))
|
||||
(statement_block
|
||||
(comment)
|
||||
(expression_statement (function_call (identifier))))))))
|
||||
(expression_statement (function_call (identifier)))))))))
|
||||
|
||||
==========================================
|
||||
comments within expressions
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ x.theMethod(5, 6);
|
|||
---
|
||||
|
||||
(expression_statement (function_call
|
||||
(property_access (identifier) (identifier))
|
||||
(number) (number)))
|
||||
(member_access (identifier) (identifier))
|
||||
(arguments (number) (number))))
|
||||
|
||||
==========================================
|
||||
constructor calls
|
||||
|
|
@ -20,9 +20,9 @@ var x = new Node(5, new Node(3, null));
|
|||
|
||||
(var_declaration (var_assignment
|
||||
(identifier)
|
||||
(constructor_call (function_call (identifier)
|
||||
(constructor_call (identifier) (arguments
|
||||
(number)
|
||||
(constructor_call (function_call (identifier)
|
||||
(constructor_call (identifier) (arguments
|
||||
(number)
|
||||
(null)))))))
|
||||
|
||||
|
|
@ -37,11 +37,11 @@ print(object.property);
|
|||
|
||||
(program
|
||||
(expression_statement (assignment
|
||||
(property_access (identifier) (identifier))
|
||||
(member_access (identifier) (identifier))
|
||||
(string)))
|
||||
(expression_statement (function_call
|
||||
(identifier)
|
||||
(property_access (identifier) (identifier)))))
|
||||
(member_access (identifier) (identifier)))))
|
||||
|
||||
==========================================
|
||||
property access across lines
|
||||
|
|
@ -54,8 +54,8 @@ object
|
|||
---
|
||||
|
||||
(expression_statement
|
||||
(property_access
|
||||
(property_access (identifier) (identifier))
|
||||
(member_access
|
||||
(member_access (identifier) (identifier))
|
||||
(identifier)))
|
||||
|
||||
===========================================
|
||||
|
|
@ -68,11 +68,11 @@ print(object[propertyName()]);
|
|||
---
|
||||
(program
|
||||
(expression_statement (assignment
|
||||
(property_access (identifier) (function_call (identifier)))
|
||||
(subscript_access (identifier) (function_call (identifier)))
|
||||
(function_call (identifier))))
|
||||
(expression_statement (function_call
|
||||
(identifier)
|
||||
(property_access (identifier) (function_call (identifier))))))
|
||||
(subscript_access (identifier) (function_call (identifier))))))
|
||||
|
||||
==========================================
|
||||
ternary expressions
|
||||
|
|
@ -91,7 +91,7 @@ print(isDone() ? stuff : otherStuff);
|
|||
mathematical operators
|
||||
==========================================
|
||||
|
||||
-a + b * c - d / +e
|
||||
a++ + b * c - d / e--
|
||||
|
||||
---
|
||||
(expression_statement
|
||||
|
|
@ -119,14 +119,14 @@ boolean operators
|
|||
type operators
|
||||
===========================================
|
||||
|
||||
print((x instanceof Array) || (typeof x == "string"))
|
||||
print((x instanceof Array) || (typeof x === "string"))
|
||||
|
||||
---
|
||||
|
||||
(expression_statement (function_call (identifier)
|
||||
(bool_op
|
||||
(expression (instanceof_expression (identifier) (identifier)))
|
||||
(expression (typeof_expression (bool_op (identifier) (string)))))))
|
||||
(expression (type_op (identifier) (identifier)))
|
||||
(expression (rel_op (type_op (identifier)) (string))))))
|
||||
|
||||
============================================
|
||||
the 'in' operator
|
||||
|
|
@ -137,7 +137,7 @@ print(x in y)
|
|||
---
|
||||
(expression_statement (function_call
|
||||
(identifier)
|
||||
(in_expression (identifier) (identifier))))
|
||||
(type_op (identifier) (identifier))))
|
||||
|
||||
============================================
|
||||
assignment operators
|
||||
|
|
@ -151,10 +151,10 @@ x /= 2;
|
|||
---
|
||||
|
||||
(program
|
||||
(expression_statement (assignment (identifier) (number)))
|
||||
(expression_statement (assignment (identifier) (number)))
|
||||
(expression_statement (assignment (identifier) (number)))
|
||||
(expression_statement (assignment (identifier) (number))))
|
||||
(expression_statement (math_assignment (identifier) (number)))
|
||||
(expression_statement (math_assignment (identifier) (number)))
|
||||
(expression_statement (math_assignment (identifier) (number)))
|
||||
(expression_statement (math_assignment (identifier) (number))))
|
||||
|
||||
============================================
|
||||
property access and operators
|
||||
|
|
@ -166,5 +166,5 @@ print(x.y.z && a.b.c)
|
|||
|
||||
(expression_statement (function_call (identifier)
|
||||
(bool_op
|
||||
(property_access (property_access (identifier) (identifier)) (identifier))
|
||||
(property_access (property_access (identifier) (identifier)) (identifier)))))
|
||||
(member_access (member_access (identifier) (identifier)) (identifier))
|
||||
(member_access (member_access (identifier) (identifier)) (identifier)))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue