Created
April 4, 2020 16:34
-
-
Save reverendpaco/eb4ba2d70721bd07f586a1ccb0b3c715 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let dqlParser2 = peg("top_level", stack: ParseStack): | |
top_level <- goal * end_marker | |
S <- *Space | |
end_marker <- "." | |
goal <- S * predicate * S * *( separator * S * goal) * *(unary_op) | |
unary_op <- S * "|>" * S * "UN" * S | |
separator <- "," | |
predicate <- named_predicate | selection_stuff | group | |
selection_stuff <- "SEL" | |
group <- "GROUP" | |
named_predicate <- >?alias * ?ns_wrapper * >functor * "(" * functorArgs * ")": | |
var np = new(NamedPredicate) | |
for idx,i in pairs(capture): | |
echo "Hi --- ",$i.s | |
np.alias = $1 | |
np.functor_name = $2 | |
var matching = get_items_matching("namespace", stack)[0] | |
let n = Namespace(matching) | |
np.ns = n.parts | |
stack[].add ("named_predicate",np,) | |
alias <- +Alpha * "@" | |
ns_part <- +Alpha | |
ns_wrapper <- ns: | |
var ns = new(Namespace) | |
var matching = get_items_matching("ns_part", stack) | |
for i in matching.items: | |
ns.parts.add i.data | |
stack[].add (("namespace",ns,)) | |
ns <- >ns_part * "." * ?ns: | |
var bs = new(BoxedString) | |
bs.data = $1 | |
stack[].add( ("ns_part",bs )) | |
functor <- +( {'a'..'z','A'..'Z','0'..'9','_'}) | |
# functorArgs <- >column * *("," * >column): | |
# for idx,i in pairs(capture): | |
# if idx!=0: | |
# np.args.add(i.s) | |
# | |
functorArgs <- "A" | |
column <- +Alpha |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment