BlockContext's caller is now stored in sender field
[panda.git] / src / st-lexer.h
blob6af15b47ed968303e75cb92410bf0087dc9aca2f
1 /*
2 * st-lexer.h
4 * Copyright (C) 2008 Vincent Geddes
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
25 #ifndef __ST_LEXER_H__
26 #define __ST_LEXER_H__
28 #include <stdbool.h>
29 #include <st-types.h>
31 typedef struct st_lexer st_lexer;
32 typedef struct st_token st_token;
34 typedef enum
36 ST_TOKEN_INVALID,
37 ST_TOKEN_LPAREN,
38 ST_TOKEN_RPAREN,
39 ST_TOKEN_BLOCK_BEGIN,
40 ST_TOKEN_BLOCK_END,
41 ST_TOKEN_COMMA,
42 ST_TOKEN_SEMICOLON,
43 ST_TOKEN_PERIOD,
44 ST_TOKEN_RETURN,
45 ST_TOKEN_COLON,
46 ST_TOKEN_ASSIGN,
47 ST_TOKEN_TUPLE_BEGIN,
48 ST_TOKEN_IDENTIFIER,
49 ST_TOKEN_CHARACTER_CONST,
50 ST_TOKEN_STRING_CONST,
51 ST_TOKEN_NUMBER_CONST,
52 ST_TOKEN_SYMBOL_CONST,
53 ST_TOKEN_COMMENT,
54 ST_TOKEN_BINARY_SELECTOR,
55 ST_TOKEN_KEYWORD_SELECTOR,
56 ST_TOKEN_EOF
58 } st_token_type;
61 st_lexer *st_lexer_new (const char *string);
62 st_token *st_lexer_next_token (st_lexer *lexer);
63 st_token *st_lexer_current_token (st_lexer *lexer);
64 void st_lexer_destroy (st_lexer *lexer);
65 char st_lexer_error_char (st_lexer *lexer);
66 st_uint st_lexer_error_line (st_lexer *lexer);
67 st_uint st_lexer_error_column (st_lexer *lexer);
68 char *st_lexer_error_message (st_lexer *lexer);
69 void st_lexer_filter_comments (st_lexer *lexer, bool filter);
72 st_token_type st_token_get_type (st_token *token);
73 char *st_token_get_text (st_token *token);
74 st_uint st_token_get_line (st_token *token);
75 st_uint st_token_get_column (st_token *token);
77 bool st_number_token_negative (st_token *token);
78 char *st_number_token_number (st_token *token);
79 st_uint st_number_token_radix (st_token *token);
80 int st_number_token_exponent (st_token *token);
82 #endif /* __ST_LEXER_H__ */