source: mainline/uspace/app/sbi/src/lex_t.h@ 883fedc

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

Update SBI to rev. 207.

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