aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ast.ml
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-07-11 03:07:56 -0300
committerMarcos Magueta <maguetamarcos@gmail.com>2026-07-11 03:07:56 -0300
commitc530682030e80ee2de2c263471e5eda7a3392e84 (patch)
tree43099c96f71f01ad1ebd04724fbf7f39852b30b9 /lib/ast.ml
parent5d5a6e68032f263bfd524794f75174dafd04bf3f (diff)
downloadSOL-c530682030e80ee2de2c263471e5eda7a3392e84.tar.gz
SOL-c530682030e80ee2de2c263471e5eda7a3392e84.zip
working vm: parser, admission with totality checks, solver and repl
Diffstat (limited to '')
-rw-r--r--lib/ast.ml25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/ast.ml b/lib/ast.ml
new file mode 100644
index 0000000..9674664
--- /dev/null
+++ b/lib/ast.ml
@@ -0,0 +1,25 @@
+(** Surface syntax tree.
+
+ The parser produces one uniform node category. Atoms and
+ variables share a spelling in Sol and are distinguished by
+ context, so classification (proposition or term, relation or
+ variable) belongs to the loader, not the grammar. *)
+
+type node =
+ | Name of string (** identifier; variable or relation, by context *)
+ | Int of Z.t
+ | Rat of Z.t * Z.t (** one token, [1/4]; normalized at loading *)
+ | Str of string
+ | Record of (string * node) list (** [{l: n ...}], source order *)
+ | Seq of node list * node option (** [#(a b)], optional [| tail] *)
+ | Block of string * (string * node) list (** [[Rel l: n ...]] *)
+ | And of node * node
+ | Or of node * node
+
+(** A program is a list of statements. A bare block asserts a fact;
+ a directive is a top-level message send such as
+ [Relation named: ... schema: ...], [Rule name: ... head: ...
+ body: ...], or [Query expression: ...]. *)
+type statement =
+ | Directive of string * (string * node) list
+ | Assert of node