【文件属性】:
文件名称:abstract:使用Go生成抽象语法树
文件大小:17KB
文件格式:ZIP
更新时间:2021-05-21 06:40:08
Go
抽象的
在Go中轻松生成抽象语法树。
没有代码生成
没有其他语言
只是Go中一个可靠的解析库
示例第一个?
让我们开始吧,这是解析算术表达式的方式:
plus := Lex ( "+" )
minus := Lex ( "-" )
times := Lex ( "*" )
over := Lex ( "/" )
spaces := Maybe ( Munch ( Space )). Garbage ()
operator := OneOf ( plus , minus , times , over )
number := And ( spaces , Many ( Digit ), spaces ). Alias ( "number" )
mainlexer := And ( Many ( And ( number , operator )), number )
result :=
【文件预览】:
abstract-master
----abstract.go(13KB)
----coverage.sh(115B)
----LICENSE(1KB)
----examples()
--------arithmetic.go(1KB)
--------recordings.txt(150B)
--------presentation.go(581B)
--------example_presentation.go(575B)
--------lisp.go(1KB)
----README.md(7KB)
----abstract_test.go(7KB)
----coverage.html(19KB)