source: mainline/uspace/app/sbi/src/lex_t.h@ 1ef0fc3

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 1ef0fc3 was 074444f, checked in by Jiri Svoboda <jiri@…>, 16 years ago

Update SBI to rev. 184.

  • Property mode set to 100644
File size: 3.4 KB
Line 
1/*
2 * Copyright (c) 2010 Jiri Svoboda
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef LEX_T_H_
30#define LEX_T_H_
31
32#include "bigint_t.h"
33
34/** Lexical element class */
35typedef enum {
36 lc_invalid,
37 lc_eof,
38
39 lc_ident,
40 lc_lit_char,
41 lc_lit_int,
42 lc_lit_string,
43
44 /* Keywords */
45 lc_as,
46 lc_bool,
47 lc_builtin,
48 lc_char,
49 lc_class,
50 lc_constructor,
51 lc_do,
52 lc_else,
53 lc_end,
54 lc_except,
55 lc_false,
56 lc_finally,
57 lc_for,
58 lc_fun,
59 lc_new,
60 lc_get,
61 lc_if,
62 lc_in,
63 lc_int,
64 lc_interface,
65 lc_is,
66 lc_nil,
67 lc_override,
68 lc_packed,
69 lc_private,
70 lc_prop,
71 lc_protected,
72 lc_public,
73 lc_raise,
74 lc_resource,
75 lc_return,
76 lc_self,
77 lc_set,
78 lc_static,
79 lc_string,
80 lc_struct,
81 lc_then,
82 lc_this,
83 lc_true,
84 lc_var,
85 lc_with,
86 lc_while,
87 lc_yield,
88
89 /* Operators */
90 lc_period,
91 lc_slash,
92 lc_lparen,
93 lc_rparen,
94 lc_lsbr,
95 lc_rsbr,
96 lc_equal,
97 lc_notequal,
98 lc_lt,
99 lc_gt,
100 lc_lt_equal,
101 lc_gt_equal,
102 lc_assign,
103 lc_plus,
104 lc_minus,
105 lc_mult,
106 lc_increase,
107
108 /* Punctuators */
109 lc_comma,
110 lc_colon,
111 lc_scolon,
112
113 lc__limit
114} lclass_t;
115
116typedef struct {
117 /* String ID */
118 int sid;
119} lem_ident_t;
120
121typedef struct {
122 /* Character value */
123 bigint_t value;
124} lem_lit_char_t;
125
126typedef struct {
127 /* Integer value */
128 bigint_t value;
129} lem_lit_int_t;
130
131typedef struct {
132 /* String value */
133 char *value;
134} lem_lit_string_t;
135
136/** Lexical element */
137typedef struct {
138 /* Lexical element class */
139 lclass_t lclass;
140
141 union {
142 lem_ident_t ident;
143 lem_lit_char_t lit_char;
144 lem_lit_int_t lit_int;
145 lem_lit_string_t lit_string;
146 } u;
147
148 /** Coordinates of this lexical element */
149 int line_no, col_0;
150} lem_t;
151
152/** Lexer state object */
153typedef struct lex {
154 /** Input object */
155 struct input *input;
156
157 /** Lexing buffer */
158 char *inbuf;
159
160 /** Pointer to current position in lexing buffer */
161 char *ibp;
162
163 /** Number of the line currently in inbuf */
164 int ib_line;
165
166 /** Column number adjustment (due to tabs) */
167 int col_adj;
168
169 /** @c b_true if we have the next lem in @c current */
170 bool_t current_valid;
171
172 /** Curent lem (only valid if @c current_valid is true) */
173 lem_t current;
174} lex_t;
175
176#endif
Note: See TracBrowser for help on using the repository browser.