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

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

Update SBI to rev. 244.

  • Property mode set to 100644
File size: 3.6 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_and,
46 lc_as,
47 lc_break,
48 lc_bool,
49 lc_builtin,
50 lc_char,
51 lc_class,
52 lc_deleg,
53 lc_do,
54 lc_elif,
55 lc_else,
56 lc_end,
57 lc_enum,
58 lc_except,
59 lc_false,
60 lc_finally,
61 lc_for,
62 lc_fun,
63 lc_new,
64 lc_get,
65 lc_if,
66 lc_in,
67 lc_int,
68 lc_interface,
69 lc_is,
70 lc_nil,
71 lc_not,
72 lc_or,
73 lc_override,
74 lc_packed,
75 lc_private,
76 lc_prop,
77 lc_protected,
78 lc_public,
79 lc_raise,
80 lc_resource,
81 lc_return,
82 lc_self,
83 lc_set,
84 lc_static,
85 lc_string,
86 lc_struct,
87 lc_then,
88 lc_this,
89 lc_true,
90 lc_var,
91 lc_with,
92 lc_while,
93 lc_yield,
94
95 /* Operators */
96 lc_period,
97 lc_slash,
98 lc_lparen,
99 lc_rparen,
100 lc_lsbr,
101 lc_rsbr,
102 lc_equal,
103 lc_notequal,
104 lc_lt,
105 lc_gt,
106 lc_lt_equal,
107 lc_gt_equal,
108 lc_assign,
109 lc_plus,
110 lc_minus,
111 lc_mult,
112 lc_increase,
113
114 /* Punctuators */
115 lc_comma,
116 lc_colon,
117 lc_scolon,
118
119 lc__limit
120} lclass_t;
121
122typedef struct {
123 /* String ID */
124 int sid;
125} lem_ident_t;
126
127typedef struct {
128 /* Character value */
129 bigint_t value;
130} lem_lit_char_t;
131
132typedef struct {
133 /* Integer value */
134 bigint_t value;
135} lem_lit_int_t;
136
137typedef struct {
138 /* String value */
139 char *value;
140} lem_lit_string_t;
141
142/** Lexical element */
143typedef struct {
144 /* Lexical element class */
145 lclass_t lclass;
146
147 union {
148 lem_ident_t ident;
149 lem_lit_char_t lit_char;
150 lem_lit_int_t lit_int;
151 lem_lit_string_t lit_string;
152 } u;
153
154 /** Coordinates of this lexical element */
155 struct cspan *cspan;
156} lem_t;
157
158/** Lexer state object */
159typedef struct lex {
160 /** Input object */
161 struct input *input;
162
163 /** Lexing buffer */
164 char *inbuf;
165
166 /** Pointer to current position in lexing buffer */
167 char *ibp;
168
169 /** Number of the line currently in inbuf */
170 int ib_line;
171
172 /** Column number adjustment (due to tabs) */
173 int col_adj;
174
175 /** @c b_true if we have the previous lem in @c prev */
176 bool_t prev_valid;
177
178 /** Previous lem (only valid if @c current_valid is true) */
179 lem_t prev;
180
181 /** @c b_true if we have the current lem in @c current */
182 bool_t current_valid;
183
184 /** Curent lem (only valid if @c current_valid is true) */
185 lem_t current;
186} lex_t;
187
188#endif
Note: See TracBrowser for help on using the repository browser.