#vm #instructions #rigz #ast-parser #converting #handles #syntax-highlighting

rigz_runtime

Handles parsing and converting rigz to its VM instructions (for syntax highlighting use tree-sitter-rigz instead)

10 releases (4 breaking)

0.4.0 Nov 4, 2024
0.3.0 Oct 30, 2024
0.2.3 Sep 6, 2024
0.2.2 Aug 14, 2024
0.0.1 May 11, 2024

#197 in Text editors

Download history 538/week @ 2024-08-10 54/week @ 2024-08-17 4/week @ 2024-08-24 117/week @ 2024-08-31 35/week @ 2024-09-07 30/week @ 2024-09-14 7/week @ 2024-09-21 27/week @ 2024-09-28 1/week @ 2024-10-05 1/week @ 2024-10-12 125/week @ 2024-10-26 136/week @ 2024-11-02 17/week @ 2024-11-09

278 downloads per month
Used in rigz

MIT license

86KB
2K SLoC

rigz_runtime

Handles parsing and converting rigz to its VM instructions.

Parser

This is an AST parser, but as soon as it has an element that would be in the AST that element is converted into VM instructions. Tokens and expressions are read from left to right, there is no operator precedence. This means that 1 + 2 * 3 is not equal to 3 * 2 + 1; the first is 9, (1 + 2) * 3, while the second is 7, (3 * 2) + 1.

TODO

  • update parser to support repl, may require VM updates as well
  • Better error messages

lifecycles

@on("event")
fn new_event(e) 
end

dispatch('event', {
    something: 32
})

@plan
fn foo
end

@apply
fn foo
end

[parse, run]
@plan = @after(@run)
@apply = @after(@plan, @confirm)
[parse, run, @plan, @confirm, @apply]

@plan
fn s3_bucket(name: string) 
end

@apply
fn s3_bucket(name: string) 
end

s3_bucket foo

polc

allow data.external {
    bin = "foo"
}

database migration

create_table foo, do |t|
    t.string bar 
    t.column baz, :number
    t.timestamps 
end

let a = $('cat file')

$```ruby


## todo
- support multiple parsers
    - default ignore precedence; 1 + 2 * 3 = 9
    - right recursive precedence; 1 + 2 * 3 = 7
    - pratt parser; 1 + 2 * 3 / 4 = 2.5

Dependencies

~5MB
~76K SLoC