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

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

Update SBI to rev. 174.

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