Fixed a lazySlot bug where lazy slots in different objects end up pointing to the...
[io/quag.git] / libs / iovm / source / IoLexer.h
blob3e86cefab6a9d35c5792d329f3f1c809bb1ae6dc
1 /* Copyright (c) 2003, Steve Dekorte
2 docLicense("BSD revised")
4 * The lexer takes source code and produces a token stream.
5 */
7 #ifndef IOLEXER_DEFINED
8 #define IOLEXER_DEFINED 1
10 #include "List.h"
11 #include "Stack.h"
12 #include "IoToken.h"
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
18 typedef int uchar_t;
20 typedef struct
22 char *s;
23 char *current;
24 List *charLineIndex;
25 size_t lineHint;
26 size_t maxChar;
27 Stack *posStack;
28 Stack *tokenStack;
29 List *tokenStream;
30 size_t resultIndex;
31 IoToken *errorToken;
32 char *errorDescription;
33 } IoLexer;
35 IoLexer *IoLexer_new(void);
36 void IoLexer_free(IoLexer *self);
37 void IoLexer_clear(IoLexer *self);
39 IoToken *IoLexer_errorToken(IoLexer *self);
41 /* --- lexing --------------- */
42 void IoLexer_string_(IoLexer *self, const char *string);
43 int IoLexer_lex(IoLexer *self);
44 void IoLexer_print(IoLexer *self);
45 void IoLexer_printTokens(IoLexer *self);
46 char *IoLexer_errorDescription(IoLexer *self);
48 /* --- getting results ------ */
49 IoToken *IoLexer_top(IoLexer *self);
50 IoTokenType IoLexer_topType(IoLexer *self);
51 IoToken *IoLexer_pop(IoLexer *self);
53 /* --- stack management ----- */
54 char *IoLexer_lastPos(IoLexer *self);
55 void IoLexer_pushPos(IoLexer *self);
56 void IoLexer_popPos(IoLexer *self);
57 void IoLexer_popPosBack(IoLexer *self);
59 /* --- next/prev character --- */
60 uchar_t IoLexer_nextChar(IoLexer *self);
61 uchar_t IoLexer_prevChar(IoLexer *self);
63 char *IoLexer_current(IoLexer *self);
64 int IoLexer_onNULL(IoLexer *self);
66 // grabbing
68 int IoToken_grabLength(IoLexer *self);
69 void IoToken_grabTokenType_(IoLexer *self, IoTokenType type);
70 IoToken *IoLexer_addTokenString_length_type_(IoLexer *self, const char *s1, size_t len, IoTokenType type);
72 // reading
74 int IoLexer_read(IoLexer *self);
75 void IoLexer_messageChain(IoLexer *self);
77 // message
79 int IoLexer_readMessage(IoLexer *self);
80 int IoLexer_readPadding(IoLexer *self);
81 int IoLexer_readOpenParen(IoLexer *self);
82 int IoLexer_readCloseParen(IoLexer *self);
84 // symbols
86 int IoLexer_readSymbol(IoLexer *self);
87 int IoLexer_readIdentifier(IoLexer *self);
88 int IoLexer_readOperator(IoLexer *self);
90 // comments
92 int IoLexer_readComment(IoLexer *self);
93 int IoLexer_readSlashStarComment(IoLexer *self);
94 int IoLexer_readSlashSlashComment(IoLexer *self);
95 int IoLexer_readPoundComment(IoLexer *self);
97 // quotes
99 int IoLexer_readQuote(IoLexer *self);
100 int IoLexer_readMonoQuote(IoLexer *self);
101 int IoLexer_readTriQuote(IoLexer *self);
103 // helpers
105 int IoLexer_readTokenChar_type_(IoLexer *self, char c, IoTokenType type);
106 int IoLexer_readTokenString_(IoLexer *self, const char *s);
108 int IoLexer_readString_(IoLexer *self, const char *s);
109 int IoLexer_readChar_(IoLexer *self, char c);
110 int IoLexer_readCharIn_(IoLexer *self, const char *s);
112 int IoLexer_readNonReturn(IoLexer *self);
113 int IoLexer_readNonQuote(IoLexer *self);
115 // character definitions
117 int IoLexer_readCharacter(IoLexer *self);
119 int IoLexer_readOpChar(IoLexer *self);
120 int IoLexer_readSpecialChar(IoLexer *self);
121 int IoLexer_readNonColonSpecialChar(IoLexer *self);
122 int IoLexer_readDigit(IoLexer *self);
123 int IoLexer_readLetter(IoLexer *self);
124 int IoLexer_readDigit(IoLexer *self);
126 int IoLexer_readTerminator(IoLexer *self);
127 int IoLexer_readTerminatorChar(IoLexer *self);
129 int IoLexer_readSeparator(IoLexer *self);
130 int IoLexer_readSeparatorChar(IoLexer *self);
132 int IoLexer_readWhitespace(IoLexer *self);
133 int IoLexer_readWhitespaceChar(IoLexer *self);
135 int IoLexer_readNumber(IoLexer *self);
136 int IoLexer_readDecimal(IoLexer *self);
137 int IoLexer_readHexNumber(IoLexer *self);
139 // parsing
141 IoToken *IoLexer_rootMessageToken(IoLexer *self, IoToken **error);
143 #ifdef __cplusplus
145 #endif
146 #endif