You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
4. Possible User defined operator cast : `parse_operator_cast`
173
182
5. Possible Constructor : `parse_constructor`
174
183
6. Something that has the following: (identifier, const, unsigned, signed, short, long, bool, char, int, double)
175
184
1. Possible Constructor `parse_constructor`
176
185
2. Possible Operator, Function, or varaible : `parse_operator_function_or_variable`
177
-
24. Something completely unknown (will just make untyped...) : `parse_untyped`
186
+
25. Something completely unknown (will just make untyped...) : `parse_untyped`
178
187
179
188
## `parse_comment`
180
189
@@ -197,15 +206,17 @@ A portion of the code in `parse_typedef` is very similar to this as both have to
197
206
2. If the token has a closing brace its an inplace definition
198
207
3. If the `token[-2]` is an identifier & `token[-3]` is the declaration type, its a variable using a namespaced type.
199
208
4. If the `token[-2]` is an indirection, then its a variable using a namespaced/forwarded type.
200
-
5. If any of the above is the case, `parse_operator_function_or_variable`
201
-
4. If the previous token was a closing curly brace, its a definition : `parse_forward_or_definition`
202
-
5. If the previous token was a closing square brace, its an array definition : `parse_operator_function_or_variable`
209
+
5. If the `token[-2]` is an assign classifier, and the starting tokens were the which type with possible `class` token after, its an enum forward declaration.
210
+
6. If any of the above is the case, `parse_operator_function_or_variable`
211
+
4. If the `token[2]` is a vendor fundamental type (builtin) then it is an enum forward declaration.
212
+
5. If the previous token was a closing curly brace, its a definition : `parse_forward_or_definition`
213
+
6. If the previous token was a closing square brace, its an array definition : `parse_operator_function_or_variable`
203
214
204
215
## `parse_define`
205
216
206
217
1. Define directive
207
218
2. Get identifier
208
-
3. Get Content
219
+
3. Get Content (Optional)
209
220
210
221
## `parse_forward_or_definition`
211
222
@@ -243,36 +254,47 @@ In the future statements and expressions will be parsed.
243
254
1. Make sure this is being called for a valid type (namespace, global body, export body, linkage body)
244
255
2. If its not a global body, consume the opening curly brace
3. Is either ( identifier, const specifier, long, short, signed, unsigned, bool, char, double, int)
272
-
1. If its an operator cast (definition outside class) : `parse_operator_cast`
273
-
2. Its an operator, function, or varaible : `parse_operator_function_or_varaible`
284
+
1. Attempt to parse as constrcutor or destructor : `parse_global_nspace_constructor_destructor`
285
+
2. If its an operator cast (definition outside class) : `parse_operator_cast`
286
+
3. Its an operator, function, or varaible : `parse_operator_function_or_varaible`
274
287
4. If its not a global body, consume the closing curly brace
275
288
289
+
## `parse_global_nspace_constructor_destructor`
290
+
291
+
1. Look ahead for the start of the arguments for a possible constructor/destructor
292
+
2. Go back past the identifier
293
+
3. Check to see if its a destructor by checking for the `~`
294
+
4. Continue the next token should be a `::`
295
+
5. Determine if the next valid identifier (ignoring possible template parameters) is the same as the first identifier of the function.
296
+
6. If it is we have either a constructor or destructor so parse using their respective functions (`parse_constructor`, `parse_destructor`).
297
+
276
298
## `parse_identifier`
277
299
278
300
This is going to get heavily changed down the line to have a more broken down "identifier expression" so that the qualifier, template args, etc, can be distinguished between the targeted identifier.
@@ -284,6 +306,7 @@ The function can parse all of them, however the AST node compresses them all int
284
306
1. Consume `::`
285
307
2. Consume member identifier
286
308
3.`parse_template args` (for member identifier)
309
+
4. If a `~` is encounted and the scope is for a destructor's identifier, do not consume it and return with what parsed.
287
310
288
311
## `parse_include`
289
312
@@ -329,15 +352,17 @@ When this function is called, attribute and specifiers may have been resolved, h
329
352
2. If the we immdiately find a closing token, consume it and finish.
330
353
3. If we encounter a varadic argument, consume it and return a `param_varadic` ast constant
331
354
4.`parse_type`
332
-
5. If we have an identifier
355
+
5. If we have a macro, parse it (Unreal has macros as tags to parameters and or as entire arguments).
356
+
6. So long as next token isn't a comma
357
+
a. If we have an identifier
333
358
1. Consume it
334
359
2. Check for assignment:
335
-
1. Consume assign operator
336
-
2. Parse the expression
337
-
6. While we continue to encounter commas
338
-
1. Consume them
339
-
2. Repeat steps 3 to 5.2.2
340
-
7. Consume the closing token
360
+
a. Consume assign operator
361
+
b. Parse the expression
362
+
7. While we continue to encounter commas
363
+
a. Consume them
364
+
b. Repeat steps 3 to 6.2.b
365
+
8. Consume the closing token
341
366
342
367
## `parse_preprocess_cond`
343
368
@@ -456,6 +481,7 @@ This currently doesn't support postfix specifiers (planning to in the future)
456
481
2. If there is an assignment operator:
457
482
1. Consume operator
458
483
2. Consume the expression (assigned to untyped string for now)
484
+
3. If a macro is encountered consume it (Unreal UMETA macro support)
459
485
3. If there is a comma, consume it
460
486
461
487
## `parse_export_body`
@@ -476,10 +502,9 @@ This currently doesn't support postfix specifiers (planning to in the future)
476
502
477
503
1. Consume `friend`
478
504
2.`parse_type`
479
-
3. If the currok is an identifier its a function declaration (there is no support for inline definitions yet)
480
-
1.`parse_identifier`
481
-
2.`parse_params`
482
-
4. Consume end statement
505
+
3. If the currok is an identifier its a function declaration or definition
506
+
1.`parse_function_after_name`
507
+
4. Consume end statement so long as its not a function definion
483
508
5. Check for inline comment, `parse_comment` if exists
484
509
485
510
## `parse_function`
@@ -540,7 +565,8 @@ Note: This currently doesn't support templated operator casts (going to need to
540
565
5. The following compound into a resolved definition or declaration:
541
566
1.`parse_attributes`
542
567
2. Parse specifiers
543
-
3.`parse_operator_function_or_variable`
568
+
3. Attempt to parse as constructor or destructor: `parse_global_nspace_constructor_destructor`
Copy file name to clipboardExpand all lines: docs/Parsing.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
The library features a naive parser tailored for only what the library needs to construct the supported syntax of C++ into its AST.
4
4
5
-
This parser does not, and should not do the compiler's job. By only supporting this minimal set of features, the parser is kept (so far) around 5500 loc. I hope to keep it under 10k loc worst case.
5
+
This parser does not, and should not do the compiler's job. By only supporting this minimal set of features, the parser is kept (so far) around ~5600 loc. I hope to keep it under 10k loc worst case.
6
6
7
7
You can think of this parser of a frontend parser vs a semantic parser. Its intuitively similar to WYSIWYG. What you precerive as the syntax from the user-side before the compiler gets a hold of it, is what you get.
8
8
@@ -73,7 +73,7 @@ The lexing and parsing takes shortcuts from whats expected in the standard.
73
73
* The parse API treats any execution scope definitions with no validation and are turned into untyped Code ASTs.
Copy file name to clipboardExpand all lines: project/Readme.md
+2-3Lines changed: 2 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,8 +10,7 @@ Just like the `gen.<hpp/cpp>` they include their components: `dependencies/<depe
10
10
11
11
Code not making up the core library is located in `auxiliary/<auxiliary_name>.<hpp/cpp>`. These are optional extensions or tools for the library.
12
12
13
-
**TODO : Right now the library is not finished, as such the first self-hosting iteration is still WIP**
14
-
Both libraries use *pre-generated* (self-hosting I guess) version of the library to then generate the latest version of itself.
13
+
Both libraries use *pre-generated* (self-hosting I guess) version of the library to then generate the latest version of itself.
15
14
16
15
The default `gen.bootstrap.cpp` located in the project folder is meant to be produce a standard segmented library, where the components of the library
17
16
have relatively dedicated header and source files. Dependencies included at the top of the file and each header starting with a pragma once.
@@ -52,7 +51,7 @@ Names or Content fields are interned strings and thus showed be cached using `ge
52
51
53
52
The library has its code segmented into component files, use it to help create a derived version without needing to have to rewrite a generated file directly or build on top of the header via composition or inheritance.
54
53
55
-
The parser is documented under `docs/Parsing.md` and `docs/Parser_Algo.md`.
54
+
The parser is documented under `docs/Parsing.md` and `docs/Parser_Algo.md`.
56
55
57
56
## A note on compilation and runtime generation speed
0 commit comments