-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement various modules on which
Spec
depends
- Loading branch information
Jason Evans
committed
Mar 28, 2022
1 parent
f5315ef
commit 3c0401f
Showing
11 changed files
with
207 additions
and
13 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
open Basis | ||
open Basis.Rudiments | ||
|
||
module T = struct | ||
type t = { | ||
index: uns; | ||
name: string; | ||
start: bool; | ||
prec: Prec.t option; | ||
prods: (Prod.t, Prod.cmper_witness) Ordset.t; | ||
} | ||
|
||
let hash_fold {index; _} state = | ||
Uns.hash_fold index state | ||
|
||
let cmp {index=index0; _} {index=index1; _} = | ||
Uns.cmp index0 index1 | ||
|
||
let pp {index; name; start; prec; prods} formatter = | ||
formatter | ||
|> Fmt.fmt "{index=" |> Uns.pp index | ||
|> Fmt.fmt "; name=" |> String.pp name | ||
|> Fmt.fmt "; start=" |> Bool.pp start | ||
|> Fmt.fmt "; prec=" |> (Option.pp Prec.pp) prec | ||
|> Fmt.fmt "; prods=" |> (List.pp Prod.pp) (Ordset.to_list prods) | ||
|> Fmt.fmt "}" | ||
end | ||
include T | ||
include Identifiable.Make(T) | ||
|
||
let init ~index ~name ~start ~prec ~prods = | ||
{index; name; start; prec; prods} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
open Basis | ||
open Basis.Rudiments | ||
|
||
type t = { | ||
index: uns; | ||
name: string; | ||
start: bool; | ||
prec: Prec.t option; | ||
prods: (Prod.t, Prod.cmper_witness) Ordset.t; | ||
} | ||
|
||
include IdentifiableIntf.S with type t := t | ||
|
||
val init: index:uns -> name:string -> start:bool -> prec:Prec.t option | ||
-> prods:(Prod.t, Prod.cmper_witness) Ordset.t -> t |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
open Basis | ||
open Basis.Rudiments | ||
|
||
module T = struct | ||
type t = { | ||
index: uns; | ||
lhs_index: uns; | ||
rhs_indexes: uns array; | ||
prec: Prec.t option; | ||
} | ||
|
||
let hash_fold {index; _} state = | ||
Uns.hash_fold index state | ||
|
||
let cmp {index=index0; _} {index=index1; _} = | ||
Uns.cmp index0 index1 | ||
|
||
let pp {index; lhs_index; rhs_indexes; prec} formatter = | ||
formatter | ||
|> Fmt.fmt "{index=" |> Uns.pp index | ||
|> Fmt.fmt "; lhs_index=" |> Uns.pp lhs_index | ||
|> Fmt.fmt "; rhs_indexes=" |> (Array.pp Uns.pp) rhs_indexes | ||
|> Fmt.fmt "; prec=" |> (Option.pp Prec.pp) prec | ||
|> Fmt.fmt "}" | ||
end | ||
include T | ||
include Identifiable.Make(T) | ||
|
||
let init ~index ~lhs_index ~rhs_indexes ~prec = | ||
{index; lhs_index; rhs_indexes; prec} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
open Basis | ||
open Basis.Rudiments | ||
|
||
type t = { | ||
index: uns; | ||
lhs_index: uns; | ||
rhs_indexes: uns array; | ||
prec: Prec.t option; | ||
} | ||
|
||
include IdentifiableIntf.S with type t := t | ||
|
||
val init: index:uns -> lhs_index:uns -> rhs_indexes:uns array -> prec:Prec.t option -> t |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
open Basis | ||
open! Basis.Rudiments | ||
|
||
module T = struct | ||
type t = | ||
| Token of Token.t | ||
| Nonterm of Nonterm.t | ||
|
||
let hash_fold t state = | ||
match t with | ||
| Token token -> Token.hash_fold token state | ||
| Nonterm nonterm -> Nonterm.hash_fold nonterm state | ||
|
||
let cmp t0 t1 = | ||
match t0, t1 with | ||
| Token token0, Token token1 -> Token.cmp token0 token1 | ||
| Token _, Nonterm _ -> Cmp.Lt | ||
| Nonterm _, Token _ -> Cmp.Gt | ||
| Nonterm nonterm0, Nonterm nonterm1 -> Nonterm.cmp nonterm0 nonterm1 | ||
|
||
let pp t formatter = | ||
match t with | ||
| Token token -> formatter |> Fmt.fmt "Token " |> Token.pp token | ||
| Nonterm nonterm -> formatter |> Fmt.fmt "Nonterm " |> Nonterm.pp nonterm | ||
end | ||
include T | ||
include Identifiable.Make(T) | ||
|
||
let of_token token = | ||
Token token | ||
|
||
let of_nonterm nonterm = | ||
Nonterm nonterm |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
open Basis | ||
open! Basis.Rudiments | ||
|
||
type t = | ||
| Token of Token.t | ||
| Nonterm of Nonterm.t | ||
|
||
include IdentifiableIntf.S with type t := t | ||
|
||
val of_token: Token.t -> t | ||
val of_nonterm: Nonterm.t -> t |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
open Basis | ||
open Basis.Rudiments | ||
|
||
module T = struct | ||
type t = { | ||
index: uns; | ||
name: string; | ||
alias: string option; | ||
prec: Prec.t option; | ||
} | ||
|
||
let hash_fold {index; _} state = | ||
Uns.hash_fold index state | ||
|
||
let cmp {index=index0; _} {index=index1; _} = | ||
Uns.cmp index0 index1 | ||
|
||
let pp {index; name; alias; prec} formatter = | ||
formatter | ||
|> Fmt.fmt "{index=" |> Uns.pp index | ||
|> Fmt.fmt "; name=" |> String.pp name | ||
|> Fmt.fmt "; alias=" |> (Option.pp String.pp) alias | ||
|> Fmt.fmt "; prec=" |> (Option.pp Prec.pp) prec | ||
|> Fmt.fmt "}" | ||
end | ||
include T | ||
include Identifiable.Make(T) | ||
|
||
let init ~index ~name ~alias ~prec = | ||
{index; name; alias; prec} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
open Basis | ||
open Basis.Rudiments | ||
|
||
type t = { | ||
index: uns; | ||
name: string; | ||
alias: string option; | ||
prec: Prec.t option; | ||
} | ||
|
||
include IdentifiableIntf.S with type t := t | ||
|
||
val init: index:uns -> name:string -> alias:string option -> prec:Prec.t option -> t |
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