package expr

  1. Overview
  2. Docs
Simple library to parse expressions

Install

dune-project
 Dependency

Authors

Maintainers

Sources

0.6.0.zip
sha256=24c681c4da72e59853da89c31052b2110e056eb54df501d391bfcc99c01ffaea
md5=80a29f1c1dd24ea23b3fa63f8a1f4d8a

doc/src/expr/ast.ml.html

Source file ast.ml

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
(* SPDX-FileCopyrightText: 2025 Christian Lindig <lindig@gmail.com>
 * SPDX-License-Identifier: Unlicense
 *)
(* Type definition for the Abstract Syntax Tree (AST).
   This defines the structure of the recognized expressions.
   Expressions can evaluate to either a float (A) or a boolean (B).
*)

type expr =
  | FloatLiteral of float
  | BoolLiteral of bool
  | StringLiteral of string
  | ID of string
  | Plus of expr * expr
  | Minus of expr * expr
  | Times of expr * expr
  | Divide of expr * expr
  | Not of expr
  | And of expr * expr
  | Or of expr * expr
  | Equal of expr * expr (* a == b *)
  | Less of expr * expr (* a < b *)
  | Greater of expr * expr (* a > b *)
  | LessEqual of expr * expr
  | GreaterEqual of expr * expr
  | NotEqual of expr * expr
  | Inside of expr * expr * expr (* v in [x, y] *)
  | Outside of expr * expr * expr (* v in [x, y] *)

type expression = expr