drafts.jl
1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
include("ASPLang.jl")
using .ASPLang
function test_parse(source, grammar=asp_grammar)
expr = parse_asp(source, grammar)
println("$source => $(expr).\n")
print(pstring(expr))
end
# test_parse("\"a\"", term_grammar)
# test_parse(" - - 2", term_grammar)
# test_parse("f(0) + (A - 1) * a / 3 + f( 1, B, 2 + 3, g(0) )", term_grammar)
# test_parse("a", literal_grammar)
# test_parse("-a(3)", literal_grammar)
# test_parse("not a(3)", literal_grammar)
# test_parse("not -a(3)", literal_grammar)
# test_parse("- a(3)", literal_grammar)
# test_parse(" - - a(3)", literal_grammar)
#test_parse("1 - f(e) < #count { a, b : c, -d ; e, f : not e, f } < 2", aggregate_grammar)
# test_parse("a | b :: p(3) :- c, d, e(1).")
# test_parse(":~ a. [ 3@0, b, -1 ]")
# test_parse("a :: 3 / 10.
# b | c :- a.
# b?")
src = read("sbf.plp", String)
test_parse(src)
# test_parse("(2 + A) * a", term_grammar)
# test_parse(" 1 < { a : not a ; b ; c } <= 3 :- c.")
# Program(Any[
# Rule(Any[
# Choice(Any[
# LeftBound(Any[
# NumberConstant("1"), LT()
# ]),
# Choices(Any[
# RestrictedChoice(Any[
# SymbolicConstant("a"), NafLiteral(SymbolicConstant("a"))
# ]),
# SymbolicConstant("b"),
# SymbolicConstant("c")
# ]),
# RightBound(Any[
# LE(), NumberConstant("3")
# ])
# ]),
# Body(Any[
# SymbolicConstant("c")
# ])
# ])
# ])