lib-script · crate
kinogaki-script-syntax
lib-script's syntax: an indentation-aware lexer, a recovering parser and a syntax tree whose every node keeps the exact span of its text.
- Repository
- lib-script (kinogaki/lib-script)
- Folder
libs/lib-script/crates/syntax- Source
- 10 files, 2,147 lines
- Tests
- 1 file, 98 lines
What it is
lib-script's syntax: an indentation-aware lexer, a recovering parser and a syntax tree whose every node keeps the exact span of its text.
The language is Python-like (blocks by indentation, # comments, def, if/elif/else, for x in ..., while, param), with static types checked by kinogaki-script-types. See docs/LANGUAGE.md.
Depends on
None.
Third-party
None.
Used by
| Crate | Repository | As | What it is |
|---|---|---|---|
kinogaki-script-bench | lib-script | normal | Benchmarks on the test host, 1M elements: cargo run --release -p kinogaki-script-bench. |
kinogaki-script-exec | lib-script | normal | lib-script's engine: a column (batch) interpreter in safe Rust. |
kinogaki-script-ir | lib-script | normal | lib-script's column IR: typed SSA values (vectors as groups of scalar values) in structured regions; lowering from the checked program; uniform/varying analysis; optimisation; a verifier; and the fault table that maps instructions back to source spans. |
kinogaki-script-types | lib-script | normal | lib-script's front end after parsing: types, the host schema a context offers, the library catalog's signatures, the checker that builds the typed program, and completion and hover for the editor. |
kinogaki-scripting | Core and the app | normal | Scripts over the standard values: lib-script's engine behind the SDK's ScriptEngine, and what a script sees of each value. |
Modules
astThe syntax tree.280 linesdiagDiagnostics: errors and warnings at spans of the source.84 lineshighlightToken classes for an editor's syntax colors.50 lineslexerThe indentation-aware lexer.432 linesparserThe recursive-descent parser.183 linesparser::expr(private)Expressions, by Python's precedence: conditional,or,and,not, comparisons,+ -,* / // %, unary-,**, then calls, indexing and members.430 linesparser::stmt(private)Statements and blocks.398 linesspanByte spans into the source and their line/column positions.92 linestokenTokens: what the lexer produces and the parser reads.188 lines
Public types and traits
At the crate root
Structs DiagnosticLineIndexLocatedParsedSpan
Enums Severity
By module: 26 public types and traits in 7 modules
ast ArgBinOpBlockCmpOpDefDefParamExprExprKindIdentModuleStmtStmtKindTypeExprUnOp
diag DiagnosticLocatedSeverity
highlight Class
lexer Lexed
parser Parsed
span LineIndexSpan
token KeywordPunctTokenTokenKind
Besides these, 3 public functions at module level.
