-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
*/+ fix comments & test messages, *add CompilerDevelopment.md* #50
Conversation
… (atm only for the parsing stage)
looks good, there's a lot of good ideas in that document. I haven't studied it thoroughly yet that will have to wait |
Thanks & sure, take your time. I will, however, start integrating now, because I'm beginning to forget what I've done, and why. I'll branch off of |
… testability this is something that needs to be done
Update: new step in between the former 1) and 2), regarding Even though I didn't really forget it, I now realized (as I'm integrating) that it's worth mentioning and discussing. It is a prerequisite for the following steps. To be precise: for testing them properly. And to have the successive commits be reasonable and comprehensible. |
CompilerDevelopment.md
Outdated
- plus, optionally, method's for registering/unregistering a listener with the parser | ||
- anything related to the lexer, error strategies, character/token streams is hidden from the outside | ||
- to make a clear distinction between the *generated* parser (and lexer) vs. `Prog8Parser`, and to discourage directly using the generated stuff, we'll rename the existing `prog8Parser`/`prog8Lexer` to `Prog8ANTLRParser` and `Prog8ANTLRLexer` and move them to package `prog8.parser.generated` | ||
3. introduce AST node `CharLiteral` and keep them until after identifier resolution and type checking; insert there an AST transformation step that turns them in UBYTE constants (literals) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would this give us? A char literal is equivalent to the (encoded) byte value of that character.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So that we don't need IStringEncoding
for parsing, i.e. separation of concerns. One may ask the reverse: why would you not have it?
Note that I do NOT introduce Datatype.CHAR, I'm only moving this step into Compiler.processAst, thereby making it explicit and saving a lot of parameters (lowering the mental burden, not for perfomance), and, not least, removing this dependency.
It is in fact the single most effective step, and it took me a week or more to come up with (I did attempt to introduce DataType.CHAR, but that's something else and I'm glad to have found a way of not having to do this yet).
CompilerDevelopment.md
Outdated
4. remove uses of `IStringEncoding` from module `compilerAst` - none should be necessary anymore | ||
5. move `IStringEncoding` to module `compiler` | ||
6. same with `ModuleImporter`, then rewrite that (addressing #46) | ||
7. refactor AST nodes and grammar: less generated parse tree nodes (`XyzContext`), less intermediary stuff (private classes in `Antr2Kotlin.kt` [sic]), more compact code. Also: nicer names such as simply `StringLiteral` instead of `StringLiteralValue` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've corrected the name of that misspelled file Antr->Antlr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. But keep in mind that we should be very careful with renamings (particularly of files), as it complicates integration. The more so as long as there aren't enough tests.
The one exception in the plan, renaming the generated parser, also serves to definitely find all outside usages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize this, so please take the opportunity to rename this file in your branch as well. It was just the file rename, there were no other dependencies on the particular file name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
@irmen, I am realizing that I am unable to synthesize a chain of commits that reflects the order of steps in the plan. I really tried, but the very task at hand is to disentangle things. So at first they are entangled, and I kind of need everything at once to "cut through" (mostly steps 1, 2 and 3). So, what to do?
|
I've packaged together It's 15 commits (incl. 1 trivial file rename and 2 pure additions of TODOs), and ready either to be added here or for a new PR draft, whichever you prefer. Btw.: I've checked now: this would indeed resolve #46 (but ModuleImporter of course still needs to be moved and re-thought). |
As a result of scrutinizing due to your questions about it, a7736d8 has now removed Module.IsLibraryModule variable and moved it to a function that is smart enough to figure it out by itself from the source path. I hope to have more time next weekend to actually look into your commits, in |
Great, thanks for that and also for kindly + comprehensively answering my questions in #51! You see, I deemed the point where
My main question to you at this point would have been whether you would leave it as such and continue with step 4, or rather have it fixed - even with temporary hacks (be prepared) - and have tests added for it before moving on. I think it is best if I open another PR for the actual stuff, so we have this one here for the more general discussion. It'll take some time, I need to try out a few strategies of merging locally before putting it onto github. |
Okay, I've done it again (rebasing, not fun at all), and opened the PR draft. That's now the reference, not my fork. Quite some problems - if not all - that I mentioned above aren't there anymore, and it's now 14 commits (net). |
@meisl is this PR still relevant or is everything in here also already in testing123 in your clone? If so we can close this one and just concentrate on getting that other one reviewed and merged :) |
Hi @irmen,
big thumbs up for 9bd3a67 ! This makes #49 actually useful :D
This PR is mostly a test for working on the new branch (I, for one, had some "fights" with git...).
But it also contains the plan that I promised, which outlines what I've done so far in my fork basically, only thought-over and reordered.
It is explicitly meant for discussion, even though written in a style that might not sound like that. Please don't be offended, it's just so to make it more concise. So again, I consider it work in progress, I'm totally open for discussion on every point.