Skip to content

2.12 Syntax Objects

2.12.1 AST::t

(def AST::t)

Base class for syntax objects. It is a struct type with two fields, content and location.

2.12.2 make-AST

(make-AST e src) -> syntax-object

  e   := any
  src := location or #f

Creates a new syntax object.

2.12.3 AST?

(AST? obj) -> boolean

  obj := any object

Returns true if the object obj is a syntax object.

2.12.4 AST-e

(AST-e ast) -> any

  ast := syntax object

Returns the content of a syntax object ast.

2.12.5 AST-source

(AST-source ast) -> location | #f

  ast := syntax object

Returns the source location of a syntax object ast.

2.12.6 read-syntax

(read-syntax [port = (current-input-port)]) -> syntax object | eof

  port := input port

Reads the next syntax object from port.

2.12.7 read-syntax-from-file

(read-syntax-from-file path) -> list of syntax objects

  path := string

Reads the contents of a file pointed by path as syntax objects.

2.12.8 source-location?

(source-location? obj) -> boolean

  obj := any object

Returns true if the object obj is a source location.

2.12.9 source-location-path?

(source-location-path? obj) -> boolean

  obj := any object

Returns true if the object obj is a source location with a file path.

2.12.10 source-location-path

(source-location-path loc) -> string

  loc := source location with a path

Returns the source location path.