-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoken.ml
More file actions
107 lines (100 loc) · 2.73 KB
/
Copy pathtoken.ml
File metadata and controls
107 lines (100 loc) · 2.73 KB
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
(* SPDX-License-Identifier: MPL-2.0 *)
(* token.ml — Token type definitions for the TANGLE lexer.
*
* Each constructor corresponds to a terminal symbol in the TANGLE EBNF
* grammar. The lexer (lexer.mll) produces values of type [token] and
* the parser (parser.mly) consumes them via the [%token] declarations
* that mirror this type.
*)
(** Source location for error messages. *)
type pos = {
pos_line : int; (** 1-based line number *)
pos_col : int; (** 0-based column *)
}
(** A located token carries its source position for diagnostics. *)
type located_token = {
tok : token;
pos : pos;
}
(** All token kinds produced by the TANGLE lexer.
*
* Groups:
* - Keywords : language-level reserved words
* - Invariant names : built-in knot/link invariants
* - Operators : symbolic punctuation
* - Literals : values embedded in source text
* - Special : end-of-file sentinel
*)
and token =
(* ---- Keywords ---- *)
| DEF
| WEAVE
| INTO
| YIELD
| STRANDS
| COMPUTE
| ASSERT
| MATCH
| WITH
| END
| LET
| IN
| IDENTITY
| TRUE
| FALSE
| CLOSE
| MIRROR
| REVERSE
| SIMPLIFY
| CAP
| CUP
| BRAID
(* Echo / product forms *)
| ECHOCLOSE
| LOWER
| RESIDUE
| PAIR
| FST
| SND
| ECHOADD
| ECHOEQ
(* ---- Invariant names ---- *)
| JONES
| ALEXANDER
| HOMFLY
| KAUFFMAN
| WRITHE
| LINKING
(* ---- Operators / punctuation ---- *)
| DOT (* . — vertical compose / cons *)
| PIPE (* | — horizontal tensor *)
| PLUS (* + — addition / connect sum *)
| MINUS (* - — subtraction *)
| STAR (* * — multiplication *)
| SLASH (* / — division *)
| EQEQ (* == — structural equality *)
| TILDE (* ~ — isotopy equivalence *)
| GTGT (* >> — pipeline *)
| GT (* > — over-crossing operator *)
| LT (* < — under-crossing operator *)
| LPAREN (* ( *)
| RPAREN (* ) *)
| LBRACKET (* [ *)
| RBRACKET (* ] *)
| LBRACE (* { *)
| RBRACE (* } *)
| COMMA (* , *)
| COLON (* : *)
| EQ (* = — binding / definition *)
| ARROW (* => — match arm arrow *)
| SEMI (* ; *)
| CARET (* ^ — exponentiation *)
| UNDERSCORE (* _ — wildcard pattern *)
(* ---- Literals ---- *)
| INT of int (** Integer literal *)
| FLOAT of float (** Floating-point literal *)
| STRING of string (** String literal (contents, no quotes) *)
| IDENT of string (** Identifier *)
| GENERATOR of int (** Braid generator index: s1 -> 1, s2 -> 2, etc. *)
(* ---- Special ---- *)
| EOF