src/tokens.h

Sat, 11 Jan 2014 22:36:31 +0200

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Sat, 11 Jan 2014 22:36:31 +0200
changeset 73
1ee9b312dc18
child 75
bf8c57437231
permissions
-rw-r--r--

- *hot stuff coming through*

73
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 Copyright (c) 2013-2014, Santeri Piippo
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 All rights reserved.
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 Redistribution and use in source and binary forms, with or without
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 modification, are permitted provided that the following conditions are met:
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * Redistributions of source code must retain the above copyright
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 notice, this list of conditions and the following disclaimer.
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * Redistributions in binary form must reproduce the above copyright
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 notice, this list of conditions and the following disclaimer in the
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 documentation and/or other materials provided with the distribution.
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * Neither the name of the <organization> nor the
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 names of its contributors may be used to endorse or promote products
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 derived from this software without specific prior written permission.
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 */
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31 #ifndef TOKENS_H
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 #define TOKENS_H
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 // =======================================================
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 enum e_token
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 {
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37 // Non-word tokens
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 tk_equals, // ----- 0
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 tk_brackets, // - 1
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40 tk_add_assign, // - 2
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41 tk_sub_assign, // - 3
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42 tk_multiply_assign, // - 4
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43 tk_divide_assign, // ----- 5
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 tk_modulus_assign, // - 6
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45 tk_single_quote, // - 7
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46 tk_dollar_sign, // - 8
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
47 tk_paren_start, // - 9
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48 tk_paren_end, // ----- 10
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49 tk_bracket_start, // - 11
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50 tk_bracket_end, // - 12
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51 tk_brace_start, // - 13
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52 tk_brace_end, // - 14
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53 tk_assign, // ----- 15
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54 tk_plus, // - 16
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55 tk_minus, // - 17
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56 tk_multiply, // - 18
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57 tk_divide, // - 19
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58 tk_modulus, // ----- 20
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59 tk_comma, // - 21
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60 tk_lesser, // - 22
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
61 tk_greater, // - 23
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
62 tk_dot, // - 24
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
63 tk_colon, // ----- 25
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
64 tk_semicolon, // - 26
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65 tk_hash, // - 27
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66 tk_exclamation_mark, // - 28
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67 tk_arrow, // - 29
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
69 // --------------
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
70 // Named tokens
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
71 tk_bool, // ----- 30
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
72 tk_break, // - 31
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
73 tk_case, // - 32
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
74 tk_continue, // - 33
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
75 tk_const, // - 34
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
76 tk_default, // ----- 35
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
77 tk_do, // - 36
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
78 tk_else, // - 37
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
79 tk_event, // - 38
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
80 tk_for, // - 39
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
81 tk_goto, // ----- 40
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
82 tk_if, // - 41
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
83 tk_int, // - 42
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
84 tk_mainloop, // - 43
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
85 tk_onenter, // - 44
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
86 tk_onexit, // ----- 45
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
87 tk_state, // - 46
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
88 tk_switch, // - 47
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
89 tk_str, // - 48
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
90 tk_void, // - 49
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
91 tk_while, // ----- 50
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
92
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
93 // These ones aren't implemented yet but I plan to do so, thus they are
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
94 // reserved. Also serves as a to-do list of sorts for me. >:F
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
95 tk_enum, // - 51
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
96 tk_func, // - 52
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
97 tk_return, // - 53
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
98
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
99 // --------------
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
100 // Generic tokens
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
101 tk_symbol, // - 54
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
102 tk_number, // ----- 55
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
103 tk_string, // - 56
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
104
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
105 last_named_token = (int) tk_symbol - 1,
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
106 tk_any = INT_MAX
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
107 };
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
108
1ee9b312dc18 - *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
109 #endif

mercurial