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§
- Cirru
Writer Options - options for writer,
use_inline
for more compact format.
Enums§
- Cirru
- Cirru uses nested Vecters and Strings as data structure
- Cirru
LexItem - 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
andClose
tokens based on changes in indentation levels.
Type Aliases§
- Cirru
LexItem List - a list to lex nodes