Fri, 17 Jan 2014 22:55:13 +0200
- parser now processes commands.def properly
73
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
75
bf8c57437231
- renamed files to .cxx, restructured parser.cc
Teemu Piippo <crimsondusk64@gmail.com>
parents:
73
diff
changeset
|
2 | Copyright (c) 2012-2014, Santeri Piippo |
73
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 | |
75
bf8c57437231
- renamed files to .cxx, restructured parser.cc
Teemu Piippo <crimsondusk64@gmail.com>
parents:
73
diff
changeset
|
34 | #include <climits> |
bf8c57437231
- renamed files to .cxx, restructured parser.cc
Teemu Piippo <crimsondusk64@gmail.com>
parents:
73
diff
changeset
|
35 | |
73
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 | enum e_token |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | { |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | // Non-word tokens |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | tk_equals, // ----- 0 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | tk_brackets, // - 1 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | tk_add_assign, // - 2 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | tk_sub_assign, // - 3 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | tk_multiply_assign, // - 4 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | tk_divide_assign, // ----- 5 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | tk_modulus_assign, // - 6 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | tk_single_quote, // - 7 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | tk_dollar_sign, // - 8 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | tk_paren_start, // - 9 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | tk_paren_end, // ----- 10 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | tk_bracket_start, // - 11 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | tk_bracket_end, // - 12 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | tk_brace_start, // - 13 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | tk_brace_end, // - 14 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | tk_assign, // ----- 15 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | tk_plus, // - 16 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | tk_minus, // - 17 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | tk_multiply, // - 18 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | tk_divide, // - 19 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | tk_modulus, // ----- 20 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | tk_comma, // - 21 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | tk_lesser, // - 22 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
63 | tk_greater, // - 23 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | tk_dot, // - 24 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
65 | tk_colon, // ----- 25 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | tk_semicolon, // - 26 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
67 | tk_hash, // - 27 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
68 | tk_exclamation_mark, // - 28 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
69 | tk_arrow, // - 29 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
70 | |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
71 | // -------------- |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
72 | // Named tokens |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | tk_bool, // ----- 30 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
74 | tk_break, // - 31 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
75 | tk_case, // - 32 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
76 | tk_continue, // - 33 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
77 | tk_const, // - 34 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
78 | tk_default, // ----- 35 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
79 | tk_do, // - 36 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
80 | tk_else, // - 37 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
81 | tk_event, // - 38 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
82 | tk_for, // - 39 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
83 | tk_goto, // ----- 40 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
84 | tk_if, // - 41 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
85 | tk_int, // - 42 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
86 | tk_mainloop, // - 43 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
87 | tk_onenter, // - 44 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
88 | tk_onexit, // ----- 45 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
89 | tk_state, // - 46 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
90 | tk_switch, // - 47 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
91 | tk_str, // - 48 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | tk_void, // - 49 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
93 | tk_while, // ----- 50 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
94 | |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
95 | // 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
|
96 | // 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
|
97 | tk_enum, // - 51 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
98 | tk_func, // - 52 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
99 | tk_return, // - 53 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
100 | |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
101 | // -------------- |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
102 | // Generic tokens |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
103 | tk_symbol, // - 54 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
104 | tk_number, // ----- 55 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
105 | tk_string, // - 56 |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
106 | |
79
2425fa6a4f21
- parser now processes commands.def properly
Teemu Piippo <crimsondusk64@gmail.com>
parents:
75
diff
changeset
|
107 | tk_first_named_token = tk_bool, |
2425fa6a4f21
- parser now processes commands.def properly
Teemu Piippo <crimsondusk64@gmail.com>
parents:
75
diff
changeset
|
108 | tk_last_named_token = (int) tk_symbol - 1, |
2425fa6a4f21
- parser now processes commands.def properly
Teemu Piippo <crimsondusk64@gmail.com>
parents:
75
diff
changeset
|
109 | tk_any = INT_MAX |
73
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
110 | }; |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
111 | |
1ee9b312dc18
- *hot stuff coming through*
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
112 | #endif |