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

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

Update SBI to rev. 144.

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