5 * Implements the interface for LICE's lexer
10 * Type: lexer_token_type_t
11 * Type to describe a tokens type.
14 * Implemented as a typedef of an enumeration, lexer_token_t
15 * is used to describe the current lexer token. The following
16 * tokens exist (as constants).
19 * LEXER_TOKEN_IDENTIFIER - Identifier
20 * LEXER_TOKEN_PUNCT - Language punctuation
21 * LEXER_TOKEN_CHAR - Character literal
22 * LEXER_TOKEN_STRING - String literal
23 * LEXER_TOKEN_NUMBER - Number (of any type)
24 * LEXER_TOKEN_EQUAL - Equal
25 * LEXER_TOKEN_LEQUAL - Lesser-or-equal
26 * LEXER_TOKEN_GEQUAL - Greater-or-equal
27 * LEXER_TOKEN_NEQUAL - Not-equal
28 * LEXER_TOKEN_INCREMENT - Pre/post increment
29 * LEXER_TOKEN_DECREMENT - Pre/post decrement
30 * LEXER_TOKEN_ARROW - Pointer arrow `->`
31 * LEXER_TOKEN_LSHIFT - Left shift
32 * LEXER_TOKEN_RSHIFT - Right shift
33 * LEXER_TOKEN_COMPOUND_ADD - Compound-assignment addition
34 * LEXER_TOKEN_COMPOUND_SUB - Compound-assignment subtraction
35 * LEXER_TOKEN_COMPOUND_MUL - Compound-assignment multiplication
36 * LEXER_TOKEN_COMPOUND_DIV - Compound-assignment division
37 * LEXER_TOKEN_COMPOUND_MOD - Compound-assignment moduluas
38 * LEXER_TOKEN_COMPOUND_OR - Compound-assignment bit-or
39 * LEXER_TOKEN_COMPOUND_XOR - Compound-assignment bit-xor
40 * LEXER_TOKEN_COMPOUND_LSHIFT - Compound-assignment left-shift
41 * LEXER_TOKEN_COMPOUND_RSHIFT - Compound-assignment right-shift
42 * LEXER_TOKEN_AND - Logical and
43 * LEXER_TOKEN_OR - Logical or
46 LEXER_TOKEN_IDENTIFIER,
55 LEXER_TOKEN_INCREMENT,
56 LEXER_TOKEN_DECREMENT,
60 LEXER_TOKEN_COMPOUND_ADD,
61 LEXER_TOKEN_COMPOUND_SUB,
62 LEXER_TOKEN_COMPOUND_MUL,
63 LEXER_TOKEN_COMPOUND_DIV,
64 LEXER_TOKEN_COMPOUND_MOD,
65 LEXER_TOKEN_COMPOUND_AND,
66 LEXER_TOKEN_COMPOUND_OR,
67 LEXER_TOKEN_COMPOUND_XOR,
68 LEXER_TOKEN_COMPOUND_LSHIFT,
69 LEXER_TOKEN_COMPOUND_RSHIFT,
75 * Class: lexer_token_t
76 * Describes a token in the token stream
83 lexer_token_type_t type;
94 * Function: lexer_islong
95 * Checks for a given string if it's a long-integer-literal.
98 * string - The string to check
101 * Returns `true` if the string is a long-literal,
104 bool lexer_islong(char *string);
107 * Function: lexer_isint
108 * Checks for a given string if it's a int-integer-literal.
111 * string - The string to check
114 * Returns `true` if the string is a int-literal,
117 bool lexer_isint (char *string);
120 * Function: lexer_isfloat
121 * Checks for a given string if it's a floating-point-literal.
124 * string - The string to check
127 * Returns `true` if the string is floating-point-literal,
130 bool lexer_isfloat(char *string);
133 * Function: lexer_ispunct
134 * Checks if a given token is language punctuation and matches.
137 * token - The token to test
138 * c - The punction to test if matches
141 * Returns `true` if the given token is language punctuation and
144 bool lexer_ispunct(lexer_token_t *token, int c);
147 * Function: lexer_unget
148 * Undo the given token in the token stream.
151 * token - The token to unget
153 void lexer_unget(lexer_token_t *token);
156 * Function: lexer_next
157 * Get the next token in the token stream.
160 * The next token in the token stream or NULL
163 lexer_token_t *lexer_next(void);
166 * Function: lexer_peek
167 * Look at the next token without advancing the stream.
170 * The next token without advancing the token stream or NULL on failure
174 * The function will peek ahead to see the next token in the stream
175 * without advancing the lexer state.
177 lexer_token_t *lexer_peek(void);
180 * Function: lexer_token_string
181 * Convert a token to a human-readable representation
184 * token - The token to convert
187 * A string representation of the token or NULL on failure.
189 char *lexer_token_string(lexer_token_t *token);
192 * Function: lexer_marker
193 * Get the line marker of where the lexer currently is.
196 * Currently returns file.c:line, will later be extended to also include
197 * column marker. This is used in error reporting.
199 char *lexer_marker(void);