drafts.jl 1.5 KB
include("ASPLang.jl")

using .ASPLang

function test_parse(source, grammar=asp_grammar)
    expr = parse_asp(source, grammar)
    println("$source\n$(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")
#         ])
#     ])
# ])