Skip to content

Commit

Permalink
Add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
bachish committed Apr 19, 2024
1 parent fcd444f commit f041859
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,6 @@ bin/

### Mac OS ###
.DS_Store

### Generated files ###
/gen/
26 changes: 26 additions & 0 deletions generator/src/main/kotlin/org/ucfs/examples/AstGeneratorExample.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.ucfs.examples

import org.ucfs.ast.NodeClassesGenerator
import org.ucfs.grammar.combinator.Grammar
import org.ucfs.grammar.combinator.extension.StringExtension.times
import org.ucfs.grammar.combinator.regexp.Epsilon
import org.ucfs.grammar.combinator.regexp.Nt
import org.ucfs.grammar.combinator.regexp.or
import java.nio.file.Path

class DyckGrammar: Grammar(){
var S by Nt()
var Round by Nt()
var Quadrat by Nt()
var Curly by Nt()
init{
setStart(S)
S = Round or Quadrat or Epsilon
Round = "(" * S * ")"
Quadrat = "[" * S * "]"
Curly = "{" * S * "}"
}
}
fun main(){
NodeClassesGenerator(DyckGrammar::class.java).generate(Path.of("gen"), "")
}

0 comments on commit f041859

Please sign in to comment.