minor cleanup, bugfixes, worked on golike parser
This commit is contained in:
@@ -1,11 +1,20 @@
|
||||
import gll
|
||||
|
||||
ws = gll.many(gll.whitespace)
|
||||
ws = gll.skipmany(gll.whitespace())
|
||||
skipped = lambda pat: gll.skip(gll.string(pat))
|
||||
|
||||
function = function
|
||||
body = gll.seq(skipped("{"), skipped("}"))
|
||||
|
||||
package_name = gll.seq(gll.skip(gll.string("package")), gl.skip(ws),
|
||||
gll.regex(".*$"), tag="package_name")
|
||||
argument = gll.seq(gll.regex("\w+", tag="argument"), ws,
|
||||
gll.regex("\w+", tag="type"), gll.skip(gll.regex("[\s,]*")))
|
||||
arguments_list = gll.seq(skipped("("), gll.many(argument), skipped(")"), tag="arguments")
|
||||
|
||||
function = gll.seq(skipped("func"), ws, gll.regex("\w+", tag="function_name"),
|
||||
ws, arguments_list, ws, body, ws, tag="function")
|
||||
|
||||
package_name = gll.seq(skipped("package"), ws, gll.regex("\w+", tag="name"),
|
||||
gll.skipmany(gll.string(" ")), skipped("\n"),
|
||||
tag="package_name")
|
||||
|
||||
package = gll.seq(package_name, gll.many(function, tag="package_body"),
|
||||
tag="package")
|
||||
|
Reference in New Issue
Block a user