No matching definitions.

tur/lexer

src/scscm/lexer.tur
defn

nil-value

(nil-value)
defn

list-nil?

(list-nil? [lst :int])
defn

cons

(cons [value :int next :int])
defn

tail

(tail [lst :int])
defn

lex-ok

(lex-ok [x :int])
defn

lex-err

(lex-err [e :int])
defn

lex-ok?

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

lex-err?

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

lex-ok-val

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

lex-err-val

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

scscm-tokenize-raw

(scscm-tokenize-raw [source :cstr])

scan all tokens from source into a heap array.

defn

scscm-rtl-error?

(scscm-rtl-error? [tl :int])

true if the raw token list contains a scan error.

defn

scscm-rtl-error

(scscm-rtl-error [tl :int])

return the error message from the raw token list.

defn

scscm-rtl-count

(scscm-rtl-count [tl :int])

return the number of tokens in the raw token list.

defn

scscm-rtl-get

(scscm-rtl-get [tl :int i :int])

return the i-th token handle from the raw token list.

defn

scscm-rtl-free

(scscm-rtl-free [tl :int])

free the raw token list struct and all token structs.

defn

scscm-rtl-free-shallow

(scscm-rtl-free-shallow [tl :int])

free the STL wrapper only, not the STok structs.

defn

token-type

(token-type [tok :int])

return the type keyword string for a token handle.

toktoken handle returned by tokenize

One of ":atom" ":symbol" ":keyword" ":number" ":string" ":lparen" ":rparen" ":lbracket" ":rbracket" ":lbrace" ":rbrace" ":quote" ":quasiquote" ":unquote" ":unquote-splice" ":hash-paren" ":eof"

(token-type (head (lex-ok-val (tokenize "(+ 1 2)"))))  ; => ":lparen"

Since: SC0

defn

token-value

(token-value [tok :int])

return the raw text value of a token.

toktoken handle returned by tokenize

The raw scanned text as :cstr (e.g. "foo-bar", ":freq", "440", "hello").

(token-value tok)  ; => "foo-bar"

Since: SC0

defn

token-line

(token-line [tok :int])

return the 1-based source line of a token.

toktoken handle

Line number as :int (1-based).

(token-line tok)  ; => 1

Since: SC0

defn

token-col

(token-col [tok :int])

return the 1-based source column of a token.

toktoken handle

Column number as :int (1-based).

(token-col tok)  ; => 1

Since: SC0

defn

scscm-tokens-build

(scscm-tokens-build [tl :int i :int acc :int])
defn

scscm-list-rev

(scscm-list-rev [lst :int acc :int])
defn

scscm-cstr-as-int

(scscm-cstr-as-int [s :cstr])
defn

scscm-cstr-eq?

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

tokenize

(tokenize [source :cstr])

scan scscm source text and return a cons list of token handles.

sourceNUL-terminated scscm source string

lex-ok(tokens :int) on success, where tokens is a cons list of token handles. lex-err(message :cstr) on scan error.

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

Since: SC0

defn

scscm-token-free-one

(scscm-token-free-one [tok :int])

free one STok struct (value string + struct itself).

defn

tokens-free

(tokens-free [ts :int])

free all token STok structs in a cons list.

tscons list of token handles returned by tokenize
(tokens-free my-tokens)

Since: SC0