6
/* Structure to store lexer state. */
9
gchar* stream; /* Pointer to the local copy of input string. */
10
guint length; /* Length of input string; stored to reduce calls to strlen(). */
11
guint next_index; /* Index of next (to be read) character from input. */
12
guint mark_index; /* Location, last marked. Useful for getting substrings as part of highlighting */
15
/* Enum for tokens generated by pre-lexer and lexer. */
18
T_UNKNOWN=0, //Unknown
20
/* These are all Pre-Lexer tokens, returned by pre-lexer */
21
PL_DECIMAL, //Decimal saperator
22
PL_DIGIT, //Decimal digit
23
PL_HEX, //A-F of Hex digits
24
PL_SUPER_DIGIT, //Super digits
25
PL_SUPER_MINUS, //Super minus
26
PL_SUB_DIGIT, //Sub digits
27
PL_FRACTION, //Fractions
30
PL_SECOND, //10 //Seconds
31
PL_LETTER, //Alphabets
32
PL_EOS, //End of stream. Yay!!
33
PL_SKIP, //Skip this symbol (whitespace or newline).
35
/* These are all tokens, returned by Lexer. */
38
T_MULTIPLY, //Multiply
39
T_DIV, //Divide (note can't use T_DIVIDE as it is defined in *BSD as an "integer divide fault" trap type value)
41
T_L_FLOOR, //Floor ( Left )
42
T_R_FLOOR, //20 //Floor ( Right )
43
T_L_CEILING, //Ceiling ( Left )
44
T_R_CEILING, //Ceiling ( Right )
47
T_ROOT_4, //Fourth root
52
T_IN, //30 //IN ( for converter )
54
T_SUP_NUMBER, //Super Number
55
T_NSUP_NUMBER, //Negative Super Number
56
T_SUB_NUMBER, //Sub Number
57
T_FUNCTION, //Function
58
T_VARIABLE, //Variable name
60
T_L_R_BRACKET, //40 //(
72
/* Creates a scanner state. Useful when multiple scanners are in action. */
73
PreLexerState* pl_create_scanner(const gchar*);
75
/* Destroy and free memory used by LexerState object. */
76
void pl_destroy_scanner(PreLexerState*);
78
/* Roll back last scanned unichar. */
79
void pl_roll_back(PreLexerState*);
81
/* Get validated gunichar from input stream. */
82
gunichar pl_get_next_gunichar(PreLexerState*);
84
/* Set marker index. To be used for highlighting and error reporting. */
85
void pl_set_marker(PreLexerState*);
87
/* Get marked substring. To be used for error reporting. */
88
gchar* pl_get_marked_substring(const PreLexerState*);
90
/* Get next Pre-Lexer token from stream. */
91
LexerTokenType pl_get_next_token(PreLexerState*);
93
#endif /* PRE_LEXER_H */