On this page:
@
top
up

3Abstract SyntaxπŸ”— i

This library provides an extensible hierarchy of structure types representing abstract JavaScript syntax. It can be required via:

struct

(struct Term(location)
#:extra-constructor-namemake-Term)
location:(maybe/c region?)
The base structure type of all abstract syntax.

3.1DeclarationsπŸ”— i

struct

(struct Declaration Term(location)
#:extra-constructor-namemake-Declaration )
location:(maybe/c region?)

struct

(struct FunctionDeclaration Declaration (locationnameargsbody)
#:extra-constructor-namemake-FunctionDeclaration )
location:(maybe/c region?)

struct

(struct ImportDeclaration Declaration (locationspecifiers)
#:extra-constructor-namemake-ImportDeclaration )
location:(maybe/c region?)
specifiers:(listof ImportSpecifier? )

struct

(struct ExportDeclaration Declaration (locationspecifiers)
#:extra-constructor-namemake-ExportDeclaration )
location:(maybe/c region?)

struct

#:extra-constructor-namemake-VariableDeclaration )
location:(maybe/c region?)
bindings:(nelistof/cVariableInitializer? )

struct

(struct LetDeclaration Declaration (locationbindings)
#:extra-constructor-namemake-LetDeclaration )
location:(maybe/c region?)
bindings :
(or/c (nelistof/cVariableInitializer? )
(nelistof/cFunctionDeclaration? ))

3.2ExpressionsπŸ”— i

struct

(struct Expression Term(location)
#:extra-constructor-namemake-Expression )
location:(maybe/c region?)

struct

(struct StringLiteral Expression (locationvalue)
#:extra-constructor-namemake-StringLiteral )
location:(maybe/c region?)
value:string?

struct

pattern
global?
case-insensitive?)
#:extra-constructor-namemake-RegexpLiteral )
location:(maybe/c region?)
pattern:string?
global?:boolean?
case-insensitive?:boolean?

struct

(struct NumericLiteral Expression (locationvalue)
#:extra-constructor-namemake-NumericLiteral )
location:(maybe/c region?)
value:number?

struct

(struct BooleanLiteral Expression (locationvalue)
#:extra-constructor-namemake-BooleanLiteral )
location:(maybe/c region?)
value:boolean?

struct

#:extra-constructor-namemake-NullLiteral )
location:(maybe/c region?)

struct

(struct ArrayLiteral Expression (locationelements)
#:extra-constructor-namemake-ArrayLiteral )
location:(maybe/c region?)

struct

(struct ObjectLiteral Expression (locationproperties)
#:extra-constructor-namemake-ObjectLiteral )
location:(maybe/c region?)

struct

#:extra-constructor-namemake-ThisReference )
location:(maybe/c region?)

struct

#:extra-constructor-namemake-VarReference )
location:(maybe/c region?)

struct

(struct BracketReference Expression (locationcontainerkey)
#:extra-constructor-namemake-BracketReference )
location:(maybe/c region?)
container:Expression/X?

struct

(struct DotReference Expression (locationcontainerid)
#:extra-constructor-namemake-DotReference )
location:(maybe/c region?)
container:Expression/X?

struct

(struct NewExpression Expression (locationconstructorarguments)
#:extra-constructor-namemake-NewExpression )
location:(maybe/c region?)
constructor:Expression/X?
arguments:ExpressionList/X?

struct

(struct PostfixExpression Expression (locationexpressionoperator)
#:extra-constructor-namemake-PostfixExpression )
location:(maybe/c region?)
expression:Expression/X?

struct

(struct PrefixExpression Expression (locationoperatorexpression)
#:extra-constructor-namemake-PrefixExpression )
location:(maybe/c region?)
operator:PrefixOperator/c
expression:Expression/X?

struct

(struct InfixExpression Expression (locationleftoperatorright)
#:extra-constructor-namemake-InfixExpression )
location:(maybe/c region?)
operator:InfixOperator/c

struct

test
consequent
alternate)
#:extra-constructor-namemake-ConditionalExpression )
location:(maybe/c region?)
consequent:Expression/X?
alternate:Expression/X?

struct

(struct AssignmentExpression Expression (locationlhsoperatorrhs)
#:extra-constructor-namemake-AssignmentExpression )
location:(maybe/c region?)

struct

(struct FunctionExpression Expression (locationnameargsbody)
#:extra-constructor-namemake-FunctionExpression )
location:(maybe/c region?)

struct

(struct LetExpression Expression (locationbindingsbody)
#:extra-constructor-namemake-LetExpression )
location:(maybe/c region?)

struct

(struct CallExpression Expression (locationmethodargs)
#:extra-constructor-namemake-CallExpression )
location:(maybe/c region?)
method:Expression/X?

struct

(struct ParenExpression Expression (locationexpression)
#:extra-constructor-namemake-ParenExpression )
location:(maybe/c region?)
expression:Expression/X?

struct

(struct ListExpression Expression (locationexpressions)
#:extra-constructor-namemake-ListExpression )
location:(maybe/c region?)
expressions:ExpressionList/X?

3.3StatementsπŸ”— i

struct

(struct Statement Term(location)
#:extra-constructor-namemake-Statement )
location:(maybe/c region?)

struct

(struct BlockStatement Statement (locationstatements)
#:extra-constructor-namemake-BlockStatement )
location:(maybe/c region?)
statements:SubStatementList/X?

struct

#:extra-constructor-namemake-EmptyStatement )
location:(maybe/c region?)

struct

(struct ExpressionStatement Statement (locationexpression)
#:extra-constructor-namemake-ExpressionStatement )
location:(maybe/c region?)
expression:Expression/X?

struct

(struct IfStatement Statement (locationtestconsequentalternate)
#:extra-constructor-namemake-IfStatement )
location:(maybe/c region?)
consequent:SubStatement/X?
alternate:(maybe/c SubStatement/X? )

struct

(struct DoWhileStatement Statement (locationbodytest)
#:extra-constructor-namemake-DoWhileStatement )
location:(maybe/c region?)

struct

(struct WhileStatement Statement (locationtestbody)
#:extra-constructor-namemake-WhileStatement )
location:(maybe/c region?)

struct

(struct ForStatement Statement (locationinittestincrbody)
#:extra-constructor-namemake-ForStatement )
location:(maybe/c region?)

struct

(struct ForInStatement Statement (locationlhscontainerbody)
#:extra-constructor-namemake-ForInStatement )
location:(maybe/c region?)
container:Expression/X?

struct

#:extra-constructor-namemake-ContinueStatement )
location:(maybe/c region?)

struct

(struct BreakStatement Statement (locationlabel)
#:extra-constructor-namemake-BreakStatement )
location:(maybe/c region?)

struct

(struct ReturnStatement Statement (locationvalue)
#:extra-constructor-namemake-ReturnStatement )
location:(maybe/c region?)

struct

(struct LetStatement Statement (locationbindingsbody)
#:extra-constructor-namemake-LetStatement )
location:(maybe/c region?)

struct

(struct WithStatement Statement (locationcontextbody)
#:extra-constructor-namemake-WithStatement )
location:(maybe/c region?)
context:Expression/X?

struct

(struct SwitchStatement Statement (locationexpressioncases)
#:extra-constructor-namemake-SwitchStatement )
location:(maybe/c region?)
expression:Expression/X?

struct

(struct LabelledStatement Statement (locationlabelstatement)
#:extra-constructor-namemake-LabelledStatement )
location:(maybe/c region?)
label:Identifier?
statement:SubStatement/X?

struct

(struct ThrowStatement Statement (locationvalue)
#:extra-constructor-namemake-ThrowStatement )
location:(maybe/c region?)

struct

(struct TryStatement Statement (locationbodycatchfinally)
#:extra-constructor-namemake-TryStatement )
location:(maybe/c region?)
finally:(maybe/c Statement/X? )

3.4Miscellaneous TermsπŸ”— i

struct

(struct Identifier Term(locationname)
#:extra-constructor-namemake-Identifier )
location:(maybe/c region?)
name:symbol?

struct

(struct CaseClause Term(locationquestionanswer)
#:extra-constructor-namemake-CaseClause )
location:(maybe/c region?)
question:(maybe/c Expression/X? )

struct

(struct CatchClause Term(locationidbody)
#:extra-constructor-namemake-CatchClause )
location:(maybe/c region?)

struct

(struct VariableInitializer Term(locationidinit)
#:extra-constructor-namemake-VariableInitializer )
location:(maybe/c region?)

struct

(struct ImportSpecifier Term(locationmodulebindings)
#:extra-constructor-namemake-ImportSpecifier )
location:(maybe/c region?)

struct

(struct ImportBinding Term(locationlabelbinding)
#:extra-constructor-namemake-ImportBinding )
location:(maybe/c region?)
label:Identifier?
binding:(maybe/c Identifier? )

struct

(struct ExclusionList Term(locationids)
#:extra-constructor-namemake-ExclusionList )
location:(maybe/c region?)

struct

(struct ModuleSpecifier Term(locationprotocolelements)
#:extra-constructor-namemake-ModuleSpecifier )
location:(maybe/c region?)
protocol:(or/c 'file'planet'collect)

struct

(struct ReexportSpecifier Term(locationmoduleexclusions)
#:extra-constructor-namemake-ReexportSpecifier )
location:(maybe/c region?)
exclusions:ExclusionList?

struct

(struct ExportBindings Term(locationbindings)
#:extra-constructor-namemake-ExportBindings )
location:(maybe/c region?)

3.5Utility FunctionsπŸ”— i

procedure

( has-location? x)boolean?

x:Term?
Determines whether x has source location information.

procedure

( ast-location x)region?

procedure

( ast-source x)any

procedure

( ast-start x)position?

procedure

( ast-end x)position?

procedure

( @ start-termend-term)region?

start-term:Term?
end-term:Term?

procedure

( with-location locx)Term?

loc:(maybe/c region?)
x:Term?

procedure

( Property? x)boolean?

x:Term?
Determines whether x can be used as a property name in an object literal.

procedure

( SubStatement? x)boolean?

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.

procedure

( SourceElement? x)boolean?

x:any
Determines whether x is a source element, i.e., a statement or declaration.
Compares x and y for name equality.

procedure

( Term=? xy)boolean?

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.
Produces the binary infix operator corresponding to op.

procedure

( postfix-operator? x)boolean?

x:any
Determines whether x is a JavaScript postfix operator.

procedure

( prefix-operator? x)boolean?

x:any
Determines whether x is a JavaScript prefix operator.

procedure

( infix-operator? x)boolean?

x:any
Determines whether x is a JavaScript infix operator.

procedure

( assignment-operator? x)boolean?

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.6Extending the LanguageπŸ”— i

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:

procedure

( Expression/X? x)boolean?

x:any

procedure

( Statement/X? x)boolean?

x:any

procedure

( SubStatement/X? x)boolean?

x:any

procedure

( ExpressionList/X? x)boolean?

x:any

procedure

( StatementList/X? x)boolean?

x:any

procedure

( SubStatementList/X? x)boolean?

x:any

procedure

( Term/X? x)boolean?

x:any
top
up

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /