Crate cirru_parser

Source
Expand description

§Cirru Parser

This tiny parser parses indentation based syntax into nested a vector, then it could used as S-Expressions for evaluation or codegen.

defn fib (x)
  if (<= x 2) 1
    +
      fib $ dec x
      fib $ - x 2

parses to:

[ ["defn" "fib" [ "x" ]
    [ "if" [ "<=" "x" "2" ] "1"
      [ "+" [ "fib" ["dec" "x"] ] [ "fib" ["-" "x" "2"] ] ]
    ]
] ]

find more on http://text.cirru.org/ .

Structs§

CirruWriterOptions
options for writer, use_inline for more compact format.

Enums§

Cirru
Cirru uses nested Vecters and Strings as data structure
CirruLexItem
internal control item during lexing

Functions§

cirru_to_lisp
Converts a string of Cirru code directly to a Lisp-like string.
escape_cirru_leaf
common API for turning Cirru leaf with strings escaped
format
format Cirru code, use options to control use_inline option
format_to_lisp
format to Cirru to WAT
lex
The lexer for Cirru syntax. It scans the code and returns a flat list of tokens. It uses a state machine to handle different parts of the syntax, such as strings, tokens, and indentation.
parse
Parses a string of Cirru code into a tree of Cirru expressions.
resolve_indentations
This function transforms a flat list of tokens into a tree structure by handling indentation. It inserts Open and Close tokens based on changes in indentation levels.

Type Aliases§

CirruLexItemList
a list to lex nodes