ygg-lang / yggdrasil.rs

yggdrasil compiler with rust runtime

Home Page:https://docs.rs/yggdrasil-rt/latest/yggdrasil_rt/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Yggdrasil Generative Grammar

Features

Language Tutorial

  • basic syntax
Name Description
a? Optional element
a* Zero or more elements
a+ One or more elements
a b Sequence of elements
a | b Alternative of branch
name:e Mark element with given name
#Name Mark branch with given name
^rule Remark element
@macro() Macro call
ANY Any unicode characters
IGNORED All rules marked as ignored
  • class vs union

The same syntax A | B performs differently in class and union context.

// expand `A | B` as class
class TestA {
    | tag_a:A 
    | tag_b:B
}
// expand `A | B` as union
union TestB {
    | A #BranchA
    | B #BranchB
}
struct TestA {
    tag_a: A,
    tag_b: B,
}

enum TestB {
    BranchA(A),
    BranchB(B),
}
  • examples

You can learn more from project-yggdrasil.

Tools

About

yggdrasil compiler with rust runtime

https://docs.rs/yggdrasil-rt/latest/yggdrasil_rt/

License:Mozilla Public License 2.0


Languages

Language:Rust 98.1%Language:Jinja 1.7%Language:CSS 0.2%Language:TypeScript 0.0%