Javascript Node Types¶
JavaScript language node type mappings for AST semantic extraction
Language Characteristics¶
- Dynamic typing: No static type annotations (see TypeScript for typed variant)
- First-class functions: Functions are values, can be passed and returned
- Prototypal inheritance: Objects inherit directly from other objects
- ES6+ classes: Syntactic sugar over prototype-based inheritance
- Arrow functions: Concise syntax with lexical
thisbinding - Async/await: Promise-based asynchronous programming
- Destructuring: Pattern matching for arrays and objects
- Template literals: String interpolation with backticks
- Modules: ES6 import/export system
- Spread/rest operators:
...for expansion and collection
Semantic Type Encoding¶
Semantic types use 8-bit encoding:
- Bits 7-2: Base category (e.g., DEFINITION_FUNCTION = 0x04)
- Bits 1-0: Refinement within category
Example: DEFINITION_FUNCTION | SemanticRefinements::Function::LAMBDA
- Base: 0x04 (function definition)
- Refinement: 0x01 (lambda/arrow)
- Combined: 0x05
Node Categories¶
- Function Definitions
- Class Definitions
- Variable Declarations
- Function Calls and Expressions
- Member Access
- Identifiers and References
- Literals
- Control Flow
- Async/Sync Constructs
- Error Handling
- Structure and Organization
- Module System
- Destructuring Patterns
- Function Parameters
- Comments
- Keywords
- Punctuation
- Arithmetic Operators
- Logical Operators
- Comparison Operators
- Assignment Operators
- Modern Operators
- Type Constructs
- Parser Errors
Function Definitions¶
JavaScript function declaration forms
JavaScript has multiple function syntaxes, each with different this binding and hoisting behavior. All JavaScript functions have bodies (IS_EMBODIED).
| Node Type | Semantic Type | Name Extraction | Description |
|---|---|---|---|
function_declaration |
DEFINITION_FUNCTION | Function::REGULAR | FIND_IDENTIFIER |
arrow_function |
DEFINITION_FUNCTION | Function::LAMBDA | FIND_ASSIGNMENT_TARGET |
function_expression |
DEFINITION_FUNCTION | Function::LAMBDA | FIND_ASSIGNMENT_TARGET |
method_definition |
DEFINITION_FUNCTION | Function::REGULAR | FIND_IDENTIFIER |
async_function_declaration |
DEFINITION_FUNCTION | Function::ASYNC | FIND_IDENTIFIER |
generator_function |
DEFINITION_FUNCTION | Function::ASYNC | FIND_ASSIGNMENT_TARGET |
generator_function_declaration |
DEFINITION_FUNCTION | Function::ASYNC | FIND_IDENTIFIER |
async_generator_function |
DEFINITION_FUNCTION | Function::ASYNC | FIND_ASSIGNMENT_TARGET |
Class Definitions¶
ES6 class syntax (syntactic sugar over prototypes)
JavaScript classes provide cleaner syntax for constructor functions and prototype-based inheritance.
| Node Type | Semantic Type | Name Extraction | Description |
|---|---|---|---|
class_declaration |
DEFINITION_CLASS | FIND_IDENTIFIER | Class declaration: class Name { ... } |
class_expression |
DEFINITION_CLASS | FIND_IDENTIFIER | Class expression: const C = class { ... } |
class_body |
ORGANIZATION_BLOCK | Organization::MAPPING | NONE |
field_definition |
DEFINITION_VARIABLE | Variable::FIELD | FIND_IDENTIFIER |
Variable Declarations¶
Variable declaration forms with different scoping rules
JavaScript has three variable declaration keywords with different scoping and hoisting behaviors.
| Node Type | Semantic Type | Name Extraction | Description |
|---|---|---|---|
variable_declaration |
DEFINITION_VARIABLE | FIND_IDENTIFIER | Variable declaration: var name = value; |
lexical_declaration |
DEFINITION_VARIABLE | FIND_IDENTIFIER | Lexical declaration: let or const |
variable_declarator |
DEFINITION_VARIABLE | FIND_IDENTIFIER | Variable declarator: name = value within declaration |
Function Calls and Expressions¶
Call expressions and operators
| Node Type | Semantic Type | Name Extraction | Description |
|---|---|---|---|
call_expression |
COMPUTATION_CALL | Call::FUNCTION | FIND_CALL_TARGET |
new_expression |
COMPUTATION_CALL | Call::CONSTRUCTOR | FIND_CALL_TARGET |
binary_expression |
OPERATOR_ARITHMETIC | Arithmetic::BINARY | NONE |
unary_expression |
OPERATOR_ARITHMETIC | Arithmetic::UNARY | NONE |
assignment_expression |
OPERATOR_ASSIGNMENT | NONE | Assignment expression: a = b |
augmented_assignment_expression |
OPERATOR_ASSIGNMENT | NONE | Augmented assignment: a += b, a *= b, etc. |
update_expression |
OPERATOR_ARITHMETIC | Arithmetic::UNARY | NONE |
ternary_expression |
FLOW_CONDITIONAL | Conditional::TERNARY | NONE |
sequence_expression |
COMPUTATION_EXPRESSION | NONE | Sequence expression: a, b, c (evaluates all, returns last) |
parenthesized_expression |
COMPUTATION_EXPRESSION | NONE | Parenthesized expression: (expr) |
expression_statement |
EXECUTION_STATEMENT | NONE | Expression statement: expression used as statement |
empty_statement |
EXECUTION_STATEMENT | NONE | Empty statement: standalone ; |
Member Access¶
Property and element access expressions
| Node Type | Semantic Type | Name Extraction | Description |
|---|---|---|---|
member_expression |
COMPUTATION_ACCESS | CUSTOM | Member access: obj.property |
subscript_expression |
COMPUTATION_ACCESS | NONE | Subscript access: obj[key] |
optional_chain |
COMPUTATION_ACCESS | NONE | Optional chaining: obj?.property |
Identifiers and References¶
Names and special references
| Node Type | Semantic Type | Name Extraction | Description |
|---|---|---|---|
identifier |
NAME_IDENTIFIER | NODE_TEXT | Identifier: variable, function, or parameter name |
property_identifier |
NAME_IDENTIFIER | NODE_TEXT | Property identifier in member access |
statement_identifier |
NAME_IDENTIFIER | NODE_TEXT | Statement identifier (label name) |
shorthand_property_identifier |
NAME_IDENTIFIER | NODE_TEXT | Shorthand property: { x } equivalent to { x: x } |
this |
NAME_SCOPED | NODE_TEXT | this keyword: current execution context |
super |
NAME_SCOPED | NODE_TEXT | super keyword: parent class reference |
meta_property |
NAME_SCOPED | NODE_TEXT | Meta property: import.meta, new.target |
Literals¶
Literal values: strings, numbers, booleans, structures
| Node Type | Semantic Type | Name Extraction | Description |
|---|---|---|---|
string |
LITERAL_STRING | NODE_TEXT | String literal: "string" or 'string' |
template_string |
LITERAL_STRING | NODE_TEXT | Template string: `template ${expr}` |
template_substitution |
LITERAL_STRING | NONE | Template substitution: ${expr} inside template |
string_fragment |
LITERAL_STRING | NONE | String fragment inside template |
escape_sequence |
LITERAL_STRING | NONE | Escape sequence in string: \n, \t, etc. |
number |
LITERAL_NUMBER | Number::INTEGER | NODE_TEXT |
true |
LITERAL_ATOMIC | NODE_TEXT | Boolean true |
false |
LITERAL_ATOMIC | NODE_TEXT | Boolean false |
null |
LITERAL_ATOMIC | NODE_TEXT | Null value |
undefined |
LITERAL_ATOMIC | NODE_TEXT | Undefined value |
array |
LITERAL_STRUCTURED | Structured::SEQUENCE | NONE |
object |
LITERAL_STRUCTURED | Structured::MAPPING | NONE |
pair |
LITERAL_STRUCTURED | Structured::MAPPING | NONE |
property_assignment |
LITERAL_STRUCTURED | Structured::MAPPING | FIND_IDENTIFIER |
computed_property_name |
COMPUTATION_EXPRESSION | NONE | Computed property name: [expr]: value |
regex |
LITERAL_STRING | NODE_TEXT | Regular expression literal: /pattern/flags |
regex_pattern |
LITERAL_STRING | NODE_TEXT | Regex pattern content |
regex_flags |
LITERAL_STRING | NODE_TEXT | Regex flags: g, i, m, etc. |
Control Flow¶
Conditionals, loops, and jumps
| Node Type | Semantic Type | Name Extraction | Description |
|---|---|---|---|
if_statement |
FLOW_CONDITIONAL | Conditional::BINARY | NONE |
else_clause |
FLOW_CONDITIONAL | NONE | Else clause: else { ... } |
switch_statement |
FLOW_CONDITIONAL | Conditional::MULTIWAY | NONE |
switch_body |
ORGANIZATION_BLOCK | Organization::SEQUENTIAL | NONE |
switch_case |
FLOW_CONDITIONAL | NONE | Switch case: case value: |
case_clause |
FLOW_CONDITIONAL | NONE | Case clause in switch |
switch_default |
FLOW_CONDITIONAL | NONE | Switch default: default: |
default_clause |
FLOW_CONDITIONAL | NONE | Default clause in switch |
conditional_expression |
FLOW_CONDITIONAL | Conditional::TERNARY | NONE |
for_statement |
FLOW_LOOP | Loop::COUNTER | NONE |
for_in_statement |
FLOW_LOOP | Loop::ITERATOR | NONE |
for_of_statement |
FLOW_LOOP | Loop::ITERATOR | NONE |
while_statement |
FLOW_LOOP | Loop::CONDITIONAL | NONE |
do_statement |
FLOW_LOOP | Loop::CONDITIONAL | NONE |
return_statement |
FLOW_JUMP | NONE | Return statement: return value; |
break_statement |
FLOW_JUMP | NONE | Break statement: break; or break label; |
continue_statement |
FLOW_JUMP | NONE | Continue statement: continue; or continue label; |
labeled_statement |
EXECUTION_STATEMENT | FIND_IDENTIFIER | Labeled statement: label: statement |
Async/Sync Constructs¶
Asynchronous programming primitives
| Node Type | Semantic Type | Name Extraction | Description |
|---|---|---|---|
await_expression |
FLOW_SYNC | NONE | Await expression: await promise |
yield_expression |
FLOW_SYNC | NONE | Yield expression: yield value in generators |
Error Handling¶
Try/catch/finally and throw statements
| Node Type | Semantic Type | Name Extraction | Description |
|---|---|---|---|
try_statement |
ERROR_TRY | NONE | Try statement: try { ... } |
catch_clause |
ERROR_CATCH | NONE | Catch clause: catch (e) { ... } |
throw_statement |
ERROR_THROW | NONE | Throw statement: throw error; |
finally_clause |
ERROR_FINALLY | NONE | Finally clause: finally { ... } |
Structure and Organization¶
Blocks, modules, and organizational nodes
| Node Type | Semantic Type | Name Extraction | Description |
|---|---|---|---|
statement_block |
ORGANIZATION_BLOCK | Organization::SEQUENTIAL | NONE |
program |
DEFINITION_MODULE | NONE | Program root node |
arguments |
ORGANIZATION_LIST | Organization::COLLECTION | NONE |
formal_parameters |
ORGANIZATION_LIST | Organization::COLLECTION | NONE |
Module System¶
ES6 import/export declarations
| Node Type | Semantic Type | Name Extraction | Description |
|---|---|---|---|
import_statement |
EXTERNAL_IMPORT | Import::MODULE | NONE |
export_statement |
EXTERNAL_EXPORT | NONE | Export statement: export ... |
import_specifier |
EXTERNAL_IMPORT | Import::SELECTIVE | FIND_IDENTIFIER |
export_specifier |
EXTERNAL_EXPORT | FIND_IDENTIFIER | Export specifier: { name } in export |
import_clause |
EXTERNAL_IMPORT | NONE | Import clause in import statement |
export_clause |
EXTERNAL_EXPORT | NONE | Export clause in export statement |
import_default_specifier |
EXTERNAL_IMPORT | Import::MODULE | FIND_IDENTIFIER |
export_default_declaration |
EXTERNAL_EXPORT | NONE | Default export: export default ... |
namespace_import |
EXTERNAL_IMPORT | Import::WILDCARD | FIND_IDENTIFIER |
named_imports |
EXTERNAL_IMPORT | Import::SELECTIVE | NONE |
import_attribute |
EXTERNAL_IMPORT | NONE | Import attribute (import assertions) |
Destructuring Patterns¶
Pattern matching for arrays and objects
| Node Type | Semantic Type | Name Extraction | Description |
|---|---|---|---|
assignment_pattern |
PATTERN_DESTRUCTURE | FIND_IDENTIFIER | Assignment pattern: a = default in destructuring |
object_pattern |
PATTERN_DESTRUCTURE | NONE | Object pattern: { a, b } in destructuring |
array_pattern |
PATTERN_DESTRUCTURE | NONE | Array pattern: [a, b] in destructuring |
rest_pattern |
PATTERN_COLLECT | NONE | Rest pattern: ...rest in destructuring |
spread_element |
PATTERN_COLLECT | NONE | Spread element: ...items in array/call |
shorthand_property_identifier_pattern |
PATTERN_DESTRUCTURE | NODE_TEXT | Shorthand property identifier in pattern |
pair_pattern |
PATTERN_DESTRUCTURE | NONE | Pair pattern in object destructuring |
object_assignment_pattern |
PATTERN_DESTRUCTURE | NONE | Object assignment pattern |
Function Parameters¶
Parameter types in function definitions
| Node Type | Semantic Type | Name Extraction | Description |
|---|---|---|---|
optional_parameter |
DEFINITION_VARIABLE | Variable::PARAMETER | FIND_IDENTIFIER |
rest_parameter |
PATTERN_COLLECT | FIND_IDENTIFIER | Rest parameter: ...params |
required_parameter |
DEFINITION_VARIABLE | Variable::PARAMETER | FIND_IDENTIFIER |
method_signature |
DEFINITION_FUNCTION | FIND_IDENTIFIER | Method signature (declaration only) |
property_signature |
DEFINITION_VARIABLE | FIND_IDENTIFIER | Property signature (declaration only) |
Comments¶
Documentation and comments
| Node Type | Semantic Type | Name Extraction | Description |
|---|---|---|---|
comment |
METADATA_COMMENT | NONE | Comment: line or block style |
hash_bang_line |
METADATA_COMMENT | NODE_TEXT | Hash-bang line: #!/usr/bin/env node |
Keywords¶
Reserved words and language keywords
| Node Type | Semantic Type | Name Extraction | Description |
|---|---|---|---|
function |
DEFINITION_FUNCTION | NONE | Reserved words and language keywords |
class |
DEFINITION_CLASS | NONE | |
const |
DEFINITION_VARIABLE | Variable::IMMUTABLE | NONE |
let |
DEFINITION_VARIABLE | Variable::MUTABLE | NONE |
var |
DEFINITION_VARIABLE | Variable::MUTABLE | NONE |
if |
FLOW_CONDITIONAL | NONE | |
else |
FLOW_CONDITIONAL | NONE | |
for |
FLOW_LOOP | NONE | |
while |
FLOW_LOOP | NONE | |
do |
FLOW_LOOP | NONE | |
switch |
FLOW_CONDITIONAL | NONE | |
case |
FLOW_CONDITIONAL | NONE | |
default |
FLOW_CONDITIONAL | NONE | |
return |
FLOW_JUMP | NONE | |
break |
FLOW_JUMP | NONE | |
continue |
FLOW_JUMP | NONE | |
async |
FLOW_SYNC | NONE | |
await |
FLOW_SYNC | NONE | |
yield |
FLOW_SYNC | NONE | |
import |
EXTERNAL_IMPORT | NONE | |
export |
EXTERNAL_EXPORT | NONE | |
from |
EXTERNAL_IMPORT | NONE | |
throw |
ERROR_THROW | NONE | |
try |
ERROR_TRY | NONE | |
catch |
ERROR_CATCH | NONE | |
finally |
ERROR_FINALLY | NONE | |
typeof |
OPERATOR_LOGICAL | NONE | |
delete |
EXECUTION_STATEMENT | NONE | |
with |
EXECUTION_STATEMENT | NONE | |
new |
COMPUTATION_CALL | NONE | |
extends |
TYPE_REFERENCE | NONE | |
static |
METADATA_ANNOTATION | NONE | |
get |
METADATA_ANNOTATION | NONE | |
set |
METADATA_ANNOTATION | NONE | |
constructor |
DEFINITION_FUNCTION | Function::CONSTRUCTOR | FIND_IDENTIFIER |
of |
OPERATOR_COMPARISON | NONE |
Punctuation¶
Syntactic punctuation tokens
| Node Type | Semantic Type | Name Extraction | Description |
|---|---|---|---|
( |
PARSER_DELIMITER | NONE | Syntactic punctuation tokens |
) |
PARSER_DELIMITER | NONE | |
[ |
PARSER_DELIMITER | NONE | |
] |
PARSER_DELIMITER | NONE | |
{ |
PARSER_DELIMITER | NONE | |
} |
PARSER_DELIMITER | NONE | |
: |
PARSER_PUNCTUATION | NONE | |
' |
PARSER_DELIMITER | NONE | |
, |
PARSER_PUNCTUATION | NONE | |
; |
PARSER_PUNCTUATION | NONE | |
. |
PARSER_PUNCTUATION | NONE | |
| ``` | PARSER_DELIMITER | NONE | |
${ |
PARSER_DELIMITER | NONE |
Arithmetic Operators¶
Mathematical and bitwise operators
| Node Type | Semantic Type | Name Extraction | Description |
|---|---|---|---|
+ |
OPERATOR_ARITHMETIC | Arithmetic::BINARY | NONE |
- |
OPERATOR_ARITHMETIC | Arithmetic::BINARY | NONE |
* |
OPERATOR_ARITHMETIC | Arithmetic::BINARY | NONE |
/ |
OPERATOR_ARITHMETIC | Arithmetic::BINARY | NONE |
% |
OPERATOR_ARITHMETIC | Arithmetic::BINARY | NONE |
** |
OPERATOR_ARITHMETIC | Arithmetic::BINARY | NONE |
& |
OPERATOR_ARITHMETIC | Arithmetic::BITWISE | NONE |
| |
OPERATOR_ARITHMETIC | Arithmetic::BITWISE | NONE |
^ |
OPERATOR_ARITHMETIC | Arithmetic::BITWISE | NONE |
~ |
OPERATOR_ARITHMETIC | Arithmetic::BITWISE | NONE |
<< |
OPERATOR_ARITHMETIC | Arithmetic::BITWISE | NONE |
>> |
OPERATOR_ARITHMETIC | Arithmetic::BITWISE | NONE |
>>> |
OPERATOR_ARITHMETIC | Arithmetic::BITWISE | NONE |
++ |
OPERATOR_ARITHMETIC | Arithmetic::UNARY | NONE |
-- |
OPERATOR_ARITHMETIC | Arithmetic::UNARY | NONE |
Logical Operators¶
Boolean and nullish operators
| Node Type | Semantic Type | Name Extraction | Description |
|---|---|---|---|
&& |
OPERATOR_LOGICAL | NONE | Boolean and nullish operators |
|| |
OPERATOR_LOGICAL | NONE | |
! |
OPERATOR_LOGICAL | NONE | |
?\? |
OPERATOR_LOGICAL | NONE | |
? |
OPERATOR_LOGICAL | NONE | |
?? |
OPERATOR_LOGICAL | NONE |
Comparison Operators¶
Equality and relational operators
| Node Type | Semantic Type | Name Extraction | Description |
|---|---|---|---|
== |
OPERATOR_COMPARISON | NONE | Equality and relational operators |
=== |
OPERATOR_COMPARISON | NONE | |
!= |
OPERATOR_COMPARISON | NONE | |
!== |
OPERATOR_COMPARISON | NONE | |
< |
OPERATOR_COMPARISON | NONE | |
> |
OPERATOR_COMPARISON | NONE | |
<= |
OPERATOR_COMPARISON | NONE | |
>= |
OPERATOR_COMPARISON | NONE | |
instanceof |
OPERATOR_COMPARISON | NONE | |
in |
OPERATOR_COMPARISON | NONE |
Assignment Operators¶
Simple and compound assignment
| Node Type | Semantic Type | Name Extraction | Description |
|---|---|---|---|
= |
OPERATOR_ASSIGNMENT | NONE | Simple and compound assignment |
=> |
OPERATOR_ASSIGNMENT | NONE | |
+= |
OPERATOR_ASSIGNMENT | NONE | |
-= |
OPERATOR_ASSIGNMENT | NONE | |
*= |
OPERATOR_ASSIGNMENT | NONE | |
/= |
OPERATOR_ASSIGNMENT | NONE | |
%= |
OPERATOR_ASSIGNMENT | NONE | |
**= |
OPERATOR_ASSIGNMENT | NONE | |
&= |
OPERATOR_ASSIGNMENT | NONE | |
|= |
OPERATOR_ASSIGNMENT | NONE | |
^= |
OPERATOR_ASSIGNMENT | NONE | |
<<= |
OPERATOR_ASSIGNMENT | NONE | |
>>= |
OPERATOR_ASSIGNMENT | NONE | |
>>>= |
OPERATOR_ASSIGNMENT | NONE | |
&&= |
OPERATOR_ASSIGNMENT | NONE | |
||= |
OPERATOR_ASSIGNMENT | NONE | |
?\?= |
OPERATOR_ASSIGNMENT | NONE |
Modern Operators¶
ES6+ operators
| Node Type | Semantic Type | Name Extraction | Description |
|---|---|---|---|
?. |
COMPUTATION_ACCESS | NONE | ES6+ operators |
... |
PATTERN_COLLECT | NODE_TEXT |
Type Constructs¶
TypeScript-style types that appear in JavaScript parsing
These are included for compatibility when parsing TypeScript-like constructs or JSDoc annotations.
| Node Type | Semantic Type | Name Extraction | Description |
|---|---|---|---|
type_annotation |
TYPE_REFERENCE | NONE | TypeScript-style types that appear in JavaScript parsing |
type_identifier |
TYPE_REFERENCE | NODE_TEXT | |
predefined_type |
TYPE_PRIMITIVE | NODE_TEXT | |
non_null_expression |
TYPE_REFERENCE | NONE | |
type_arguments |
TYPE_GENERIC | NONE | |
type_assertion |
TYPE_REFERENCE | NONE |
Parser Errors¶
Error nodes from parsing
| Node Type | Semantic Type | Name Extraction | Description |
|---|---|---|---|
ERROR |
PARSER_SYNTAX | NODE_TEXT | Error nodes from parsing |
Generated from javascript_types.def