Skip to content

Conversation

@IsaacOscar
Copy link

I've made some changes to the kernancompiler module and associated kernan features.
Firstly I reduced boilerplate and duplicate code, this required me to change ParseNodeMeta to actually provide a GraceObject and not a .NET Dictionary.

Secondly I added two extra methods to the kernancompiler module:

  1. parse(n, c), this is like parse(c), but it tells kernan that the code came from the module called n, this will make parse errors more usefull (by telling the user which file has said error).
  2. readGraceModule(m) this returns the contents of the grace module identifier by m, this performs roughly the same logic as kernan internally does for import "m" as foo; except that it won't treat resource files and .dll files specially. Thus you can say have:
foo.dll
foo.grace

And readGraceModule("foo") will return the contents of the .grace file, whereas an import "foo" will actually try and load the .dll file; the intention is that the .grace file will contain meta-data (like method specifications) for the .dll file.

In order to not duplicate code, I have modified kernan's import logic slightly to expose a TryReadModuleFile method that tries to read a module file, and instead of actually loading it (like the previous tryLoadModuleFile method did), it now just returns the contents of the module file as a string.

In order to minimise the number of changes made by this pull request, I have not used my cool Callback.cs library, but I still think it's a good idea.

@IsaacOscar
Copy link
Author

I've added threw new commits that make 3 independent changes:

  1. I fixed a bug where calling & on a pattern actually does the same as |.
  2. I've added an identity based hash method to existing objects that complements the existing identity based == method.
  3. I've added support for BooleanExtension, TypeExtension, and SequenceExtension that work like the existing ObjectExtension, NumberExtension, and StringExtension. (Note that SequenceExtension applies to [...] sequences as well as those created by calling ++ on such objects)

@IsaacOscar
Copy link
Author

I fixed a couple of bugs and made TypeExtension apply to NativeTypePatterns as well as GraceTypes.

@IsaacOscar
Copy link
Author

IsaacOscar commented Feb 2, 2020

I've now made it so you can catch parse faillures as normal grace exceptions when calling kernancompiler.parse.

This required that I modify the kernancompiler.parse methods to actually call the Parse method and not just return a new Parser object.

I also modified GraceObjectProxy so that if a call to a proxied C# object throws a grace exception you can catch it (although I don't actually need this now, it could prove useful later) EDIT: actually I do need this change to catch exceptions thrown by readGraceModule, in particular when the module can't be found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant