package p4spectec
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
P4-SpecTec: A mechanization toolchain for the P4 Programming Language
Install
dune-project
Dependency
Authors
Maintainers
Sources
v0.1.2.tar.gz
md5=1a3bc0a385fe1ecf403c019f49aa6de6
sha512=5d20b5821f33e2a3a5419b208606f27c01511994c2b3b1e1cdf4c077056dfd0aa81682af0720e1060ee2bfb0341918fcc4c53159820205a2bc32b725e5c1a714
doc/src/p4spectec.domain/atom.ml.html
Source file atom.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 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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164type upid = string [@@deriving yojson] type optext = string [@@deriving yojson] [@@@ocamlformat "disable"] type t = | Keyword of upid (* concrete object word: INT *) | Tag of upid (* silent meta case label: _NUM *) | Operator of optext (* concrete operator: '+', '->', '#' *) | Sub (* <: *) | Sup (* :> *) | Turnstile (* |- *) | Tilesturn (* -| *) | Arrow (* -> *) | ArrowSub (* ->_ *) | DoubleArrowSub (* =>_ *) | DoubleArrowLong (* ==> *) | SqArrow (* ~> *) | SqArrowStar (* ~>* *) | Dot (* . *) | Dot2 (* .. *) | Dot3 (* ... *) | Semicolon (* ; *) | Colon (* : *) | ColonEq (* := *) | Tilde2 (* ~~ *) | Backslash (* \ *) | LAngle (* `< *) | RAngle (* `> *) | LParen (* `( *) | RParen (* `) *) | LBrack (* `[ *) | RBrack (* `] *) | LBrace (* `{ *) | RBrace (* `} *) [@@deriving yojson] [@@@ocamlformat "enable"] let compare (atom_a : t) (atom_b : t) = Stdlib.compare atom_a atom_b let eq (atom_a : t) (atom_b : t) : bool = compare atom_a atom_b = 0 (* Parse-faithful: round-trips through atom_of_string *) let string_of_atom = function | Keyword id -> id | Tag id -> "_" ^ id | Operator s -> "'" ^ s ^ "'" | Sub -> "<:" | Sup -> ":>" | Turnstile -> "|-" | Tilesturn -> "-|" | Arrow -> "->" | ArrowSub -> "->_" | DoubleArrowSub -> "=>_" | DoubleArrowLong -> "==>" | SqArrow -> "~>" | SqArrowStar -> "~>*" | Dot -> "." | Dot2 -> ".." | Dot3 -> "..." | Semicolon -> ";" | Colon -> ":" | ColonEq -> ":=" | Tilde2 -> "~~" | Backslash -> "\\" | LAngle -> "`<" | RAngle -> "`>" | LParen -> "`(" | RParen -> "`)" | LBrack -> "`[" | RBrack -> "`]" | LBrace -> "`{" | RBrace -> "`}" let atom_of_string = function | "<:" -> Sub | ":>" -> Sup | "|-" -> Turnstile | "-|" -> Tilesturn | "->" -> Arrow | "->_" -> ArrowSub | "=>_" -> DoubleArrowSub | "==>" -> DoubleArrowLong | "~>" -> SqArrow | "~>*" -> SqArrowStar | "." -> Dot | ".." -> Dot2 | "..." -> Dot3 | ";" -> Semicolon | ":" -> Colon | ":=" -> ColonEq | "~~" -> Tilde2 | "\\" -> Backslash | "`<" -> LAngle | "`>" -> RAngle | "`(" -> LParen | "`)" -> RParen | "`[" -> LBrack | "`]" -> RBrack | "`{" -> LBrace | "`}" -> RBrace | s when String.length s >= 2 && s.[0] = '\'' && s.[String.length s - 1] = '\'' -> Operator (String.sub s 1 (String.length s - 2)) | s when String.length s >= 2 && s.[0] = '_' -> Tag (String.sub s 1 (String.length s - 1)) | id -> Keyword id (* Lossy display glyph *) let render_atom = function | Keyword id -> id | Tag "EMPTY" -> "/* empty */" | Tag id -> "_" ^ id | Operator s -> s | Sub -> "<:" | Sup -> ":>" | Turnstile -> "|-" | Tilesturn -> "-|" | Arrow -> "->" | ArrowSub -> "->_" | DoubleArrowSub -> "=>_" | DoubleArrowLong -> "==>" | SqArrow -> "~>" | SqArrowStar -> "~>*" | Dot -> "." | Dot2 -> ".." | Dot3 -> "..." | Semicolon -> ";" | Colon -> ":" | ColonEq -> ":=" | Tilde2 -> "~~" | Backslash -> "\\" | LAngle -> "<" | RAngle -> ">" | LParen -> "(" | RParen -> ")" | LBrack -> "[" | RBrack -> "]" | LBrace -> "{" | RBrace -> "}" let is_upid (s : string) : bool = String.length s > 0 && (match s.[0] with 'A' .. 'Z' -> true | _ -> false) && String.for_all (function | 'A' .. 'Z' | 'a' .. 'z' | '0' .. '9' | '_' | '\'' -> true | _ -> false) s let is_operator atom s = match atom with Operator o -> String.equal o s | _ -> false (* Constructors *) let keyword (s : string) : t = Keyword s let tag (s : string) : t = if is_upid s then Tag s else invalid_arg ("Atom.tag: expected upid: " ^ s) let operator (s : string) : t = if String.contains s '\'' || String.contains s '\n' then invalid_arg ("Atom.operator: unquotable operator: " ^ s) else Operator s
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>