3 Abstract Syntax
This library provides an extensible hierarchy of structure types representing abstract JavaScript syntax. It can be required via:
(require (planet dherman/javascript:6/ast)) |
| |||||
location : (optional region?) |
The base structure type of all abstract syntax.
3.1 Declarations
| |||||
location : (optional region?) |
| |||||
location : (optional/c region?) | |||||
name : Identifier? | |||||
args : (listof Identifier?) | |||||
body : (listof SourceElement?) |
| |||||
location : (optional/c region?) | |||||
bindings : (nelistof/c VariableInitializer?) |
| ||||||||
location : (optional/c region?) | ||||||||
|
3.2 Expressions
| |||||
location : (optional region?) |
| |||||
location : (optional/c region?) | |||||
value : string? |
| ||||||||||||||||||||
location : (optional/c region?) | ||||||||||||||||||||
pattern : string? | ||||||||||||||||||||
global? : boolean? | ||||||||||||||||||||
case-insensitive? : boolean? |
| |||||
location : (optional/c region?) | |||||
value : number? |
| |||||
location : (optional/c region?) | |||||
value : boolean? |
| |||||
location : (optional/c region?) |
| |||||
location : (optional/c region?) | |||||
elements : (listof (optional/c Expression/X?)) |
| |||||
location : (optional/c region?) | |||||
properties : (listof (cons/c Property? Expression/X?)) |
| |||||
location : (optional/c region?) |
| |||||
location : (optional/c region?) | |||||
id : Identifier? |
| |||||
location : (optional/c region?) | |||||
container : Expression/X? | |||||
key : Expression/X? |
| |||||
location : (optional/c region?) | |||||
container : Expression/X? | |||||
id : Identifier? |
| |||||
location : (optional/c region?) | |||||
constructor : Expression/X? | |||||
arguments : ExpressionList/X? |
| |||||
location : (optional/c region?) | |||||
expression : Expression/X? | |||||
operator : PostfixOperator/c |
| |||||
location : (optional/c region?) | |||||
operator : PrefixOperator/c | |||||
expression : Expression/X? |
| |||||
location : (optional/c region?) | |||||
left : Expression/X? | |||||
operator : InfixOperator/c | |||||
right : Expression/X? |
| ||||||||||||||||||||
location : (optional/c region?) | ||||||||||||||||||||
test : Expression/X? | ||||||||||||||||||||
consequent : Expression/X? | ||||||||||||||||||||
alternate : Expression/X? |
| |||||
location : (optional/c region?) | |||||
lhs : Expression/X? | |||||
operator : AssignmentOperator/c | |||||
rhs : Expression/X? |
| |||||
location : (optional/c region?) | |||||
name : (optional/c Identifier?) | |||||
args : (listof Identifier?) | |||||
body : (listof SourceElement?) |
| |||||
location : (optional/c region?) | |||||
bindings : (listof VariableInitializer?) | |||||
body : Expression/X? |
| |||||
location : (optional/c region?) | |||||
method : Expression/X? | |||||
args : ExpressionList/X? |
| |||||
location : (optional/c region?) | |||||
expression : Expression/X? |
| |||||
location : (optional/c region?) | |||||
expressions : ExpressionList/X? |
3.3 Statements
| |||||
location : (optional region?) |
| |||||
location : (optional/c region?) | |||||
statements : SubStatementList/X? |
| |||||
location : (optional/c region?) |
| |||||
location : (optional/c region?) | |||||
expression : Expression/X? |
| |||||
location : (optional/c region?) | |||||
test : Expression/X? | |||||
consequent : SubStatement/X? | |||||
alternate : (optional/c SubStatement/X?) |
| |||||
location : (optional/c region?) | |||||
body : SubStatement/X? | |||||
test : Expression/X? |
| |||||
location : (optional/c region?) | |||||
test : Expression/X? | |||||
body : SubStatement/X? |
| |||||
location : (optional/c region?) | |||||
init : (or/c (optional/c Expression/X?) VariableDeclaration? LetDeclaration?) | |||||
test : (optional/c Expression/X?) | |||||
incr : (optional/c Expression/X?) | |||||
body : SubStatement/X? |
| |||||
location : (optional/c region?) | |||||
lhs : (or/c Expression/X? VariableDeclaration? LetDeclaration?) | |||||
container : Expression/X? | |||||
body : SubStatement/X? |
| |||||
location : (optional/c region?) | |||||
label : (optional/c Identifier?) |
| |||||
location : (optional/c region?) | |||||
label : (optional/c Identifier?) |
| |||||
location : (optional/c region?) | |||||
value : (optional/c Expression/X?) |
| |||||
location : (optional/c region?) | |||||
bindings : (listof VariableInitializer?) | |||||
body : SubStatement/X? |
| |||||
location : (optional/c region?) | |||||
context : Expression/X? | |||||
body : SubStatement/X? |
| |||||
location : (optional/c region?) | |||||
expression : Expression/X? | |||||
cases : (listof CaseClause?) |
| |||||
location : (optional/c region?) | |||||
label : Identifier? | |||||
statement : SubStatement/X? |
| |||||
location : (optional/c region?) | |||||
value : Expression/X? |
| |||||
location : (optional/c region?) | |||||
body : Statement/X? | |||||
catch : (listof CatchClause?) | |||||
finally : (optional/c Statement/X?) |
3.4 Miscellaneous Terms
| |||||
location : (optional region?) | |||||
name : symbol? |
| |||||
location : (optional region?) | |||||
question : (optional Expression/X?) | |||||
answer : SubStatementList/X? |
| |||||
location : (optional region?) | |||||
id : Identifier? | |||||
body : Statement/X? |
| |||||
location : (optional region?) | |||||
id : Identifier? | |||||
init : (optional Expression/X?) |
3.5 Utility Functions
x : Term? |
Determines whether x has source location information.
x : (and/c Term? has-location?) |
x : (and/c Term? has-location?) |
x : (and/c Term? has-location?) |
x : (and/c Term? has-location?) |
start-term : Term? |
end-term : Term? |
loc : (optional region?) |
x : Term? |
x : Term? |
Determines whether x can be used as a property name in an object literal.
x : any |
Determines whether x is a valid sub-statement, i.e., a statement not in the top-level position of a function or program.
x : any |
Determines whether x is a source element, i.e., a statement or declaration.
x : Identifier? |
y : Identifier? |
Compares x and y for name equality.
x : Term? |
y : Term? |
Recursively compares two terms, ignoring all source location information and comparing all non-Term components with equal?.
The postfix operators of JavaScript.
The prefix operators of JavaScript.
The infix operators of JavaScript.
The assignment operators of JavaScript.
→ (optional infix-operator?) |
op : assignment-operator? |
Produces the binary infix operator corresponding to op.
x : any |
Determines whether x is a JavaScript postfix operator.
x : any |
Determines whether x is a JavaScript prefix operator.
x : any |
Determines whether x is a JavaScript infix operator.
x : any |
Determines whether x is a JavaScript assignment operator.
Contract form of postfix-operator?.
Contract form of prefix-operator?.
Contract form of infix-operator?.
Contract form of assignment-operator?.
3.6 Extending the Language
Some libraries in this package support extending the language. The notions of expression, statement, expression list, and statement list can be extended by adding custom predicates to the following parameters:
The following predicates represent extensible terms by checking an argument against the standard predicates followed by the corresponding custom predicates:
| ||
| ||
| ||
| ||
| ||
| ||
|