No matching definitions.

tur/parser

src/scscm/parser.tur
defn

scscm-cstr-eq?

(scscm-cstr-eq? [a :cstr b :cstr])
defn

lex-err?

(lex-err? [r :ptr<void>])
defn

lex-ok-val

(lex-ok-val [r :ptr<void>])
defn

lex-err

(lex-err [e :int])
defn

lex-ok

(lex-ok [x :int])
defn

token-type

(token-type [tok :int])
defn

token-value

(token-value [tok :int])
defn

scscm-ast-leaf

(scscm-ast-leaf [kind :int value :cstr])

allocate a leaf AST node with a value string.

defn

scscm-ast-list-node

(scscm-ast-list-node [kind :int])

allocate a composite AST node (list or vector).

defn

scscm-ast-add-child

(scscm-ast-add-child [node :int child :int])

append a child handle to a composite node.

defn

ast-kind

(ast-kind [node :int])

return the kind keyword string of an AST node.

nodeAST node handle

One of ":atom" ":symbol" ":keyword" ":number" ":string" ":list" ":vector" ":quote" ":quasiquote" ":unquote" ":unquote-splice" ":hash-paren"

(ast-kind node)  ; => ":symbol"

Since: SC1

defn

ast-symbol-name

(ast-symbol-name [node :int])

return the raw symbol text of a symbol node.

nodea ":symbol" AST node

Symbol name as :cstr (e.g. "foo-bar").

(ast-symbol-name node)  ; => "foo-bar"

Since: SC1

defn

ast-number-value

(ast-number-value [node :int])

return the text representation of a number node.

nodea ":number" AST node

Number text as :cstr (e.g. "440", "0.5").

(ast-number-value node)  ; => "440"

Since: SC1

defn

ast-string-value

(ast-string-value [node :int])

return the contents of a string node (without quotes).

nodea ":string" AST node

String contents as :cstr (escape sequences preserved as-is from source).

(ast-string-value node)  ; => "hello"

Since: SC1

defn

ast-list-len

(ast-list-len [node :int])

return the number of children of a composite node.

nodea ":list", ":vector", or wrapper node

Child count as :int.

(ast-list-len node)  ; => 3

Since: SC1

defn

ast-list-get

(ast-list-get [node :int i :int])

return the i-th child (0-indexed) of a composite node.

nodea ":list", ":vector", or wrapper node
i0-based child index

Child node handle as :int.

(ast-list-get node 0)  ; => first child handle

Since: SC1

defn

scscm-ast-value

(scscm-ast-value [node :int])
defn

ast-free

(ast-free [node :int])

free one AST node and all its children recursively.

nodeAST node handle (may be 0/nil)
(ast-free node)

Since: SC1

defn

ast-free-all

(ast-free-all [nodes :int])

free every AST node in a cons list plus the list cells.

nodescons list of AST node handles
(ast-free-all top-level-forms)

Since: SC1

defn

scscm-parse-list-body

(scscm-parse-list-body [tokens :int node :int close-ttyp :cstr])
defn

scscm-parse-wrapper

(scscm-parse-wrapper [kind :int tokens :int])
defn

scscm-parse-all

(scscm-parse-all [tokens :int acc :int])
defn

scscm-parse-form

(scscm-parse-form [tokens :int])
defn

parse

(parse [tokens :int])

parse a token cons list into a cons list of top-level AST nodes.

tokenscons list of token handles returned by tokenize

lex-ok(nodes :int) where nodes is a cons list of AST node handles. lex-err(msg-int :int) on parse error (msg-int is a :cstr cast to :int).

(let [r (tokenize "(+ 1 2)")]
    (if (lex-ok? r) (parse (lex-ok-val r)) (lex-err-val r)))

Since: SC1