nixd
Loading...
Searching...
No Matches
tokens.py
Go to the documentation of this file.
1from dataclasses import dataclass
2from typing import List
3
4
5@dataclass
6class Token:
7 name: str
8 spelling: str
9
10
12 def __init__(self, name):
13 self.name = name
14 self.spelling = name
15
16
17keyword_tokens: List[Token] = [
18 KwToken("if"),
19 KwToken("then"),
20 KwToken("else"),
21 KwToken("assert"),
22 KwToken("with"),
23 KwToken("let"),
24 KwToken("in"),
25 KwToken("rec"),
26 KwToken("inherit"),
27 KwToken("or"),
28]
29
30
32 pass
33
34
35bin_op_tokens: List[Token] = [
36 OpToken("impl", "->"),
37 OpToken("or", "||"),
38 OpToken("and", "&&"),
39 OpToken("eq", "=="),
40 OpToken("neq", "!="),
41 OpToken("lt", "<"),
42 OpToken("gt", ">"),
43 OpToken("le", "<="),
44 OpToken("ge", ">="),
45 OpToken("update", "//"),
46 OpToken("add", "+"),
47 OpToken("negate", "-"),
48 OpToken("mul", "*"),
49 OpToken("div", "/"),
50 OpToken("concat", "++"),
51 OpToken("pipe_into", "|>"),
52 OpToken("pipe_from", "<|"),
53]
54
55tokens: List[Token] = [
56 *keyword_tokens,
57 Token("eof", "eof"),
58 Token("id", "id"),
59 Token("int", "int"),
60 Token("float", "float"),
61 Token("dquote", '"'),
62 Token("string_part", "string_part"),
63 Token("string_escape", "string_escape"),
64 Token("quote2", "''"),
65 Token("path_fragment", "path_fragment"),
66 Token("spath", "<path>"),
67 Token("uri", "uri"),
68 Token("r_curly", "}"),
69 Token("dollar_curly", "${"),
70 Token("ellipsis", "..."),
71 Token("comma", ","),
72 Token("dot", "."),
73 Token("semi_colon", ";"),
74 Token("eq", "="),
75 Token("l_curly", "{"),
76 Token("l_paren", "("),
77 Token("r_paren", ")"),
78 Token("l_bracket", "["),
79 Token("r_bracket", "]"),
80 Token("question", "?"),
81 Token("at", "@"),
82 Token("colon", ":"),
83 Token("unknown", "unknown"),
84 Token("path_end", "path_end"),
85 OpToken("not", "!"), # unary operator
86 *bin_op_tokens,
87]
__init__(self, name)
Definition tokens.py:12