#grammar #command #config-file #abstract-syntax-tree #b #sub

nightly app ycc

Yggdrasil Command-line Compiler

1 unstable release

0.0.0 Nov 10, 2022

MPL-2.0 license

415KB
9K SLoC

Yggdrasil Generative Grammar

Build/test

Yggdrasil grammar DSL for tree-sitter

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
^rule Unmark element
#Name Mark branch name
@macro() Macro call
IGNORED All rules marked as ignored
ANY All unicode characters
  • 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 examples.

Dependencies

~6–43MB
~688K SLoC