Skip to content
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

Establishing generic parselets and functions #105

Merged
merged 111 commits into from
Oct 23, 2023

Conversation

phorward
Copy link
Member

@phorward phorward commented Mar 4, 2023

About

This PR is intended to coordinate generic parselets & functions in Tokay as established in #10.

To- do

  • Syntax changes
  • Handle parselet instances
  • Handle generic values in intermediate structures
    • Repeat<P> min=1, max=void
      • Think about a replacement of Capture by RefValue with a new value type Capture, so that Repeat<Char> returns a capture range and not a list of values turned into Turn Capture into object #116
      • Implement Pos<P>
      • Implement Opt<P>
      • Implement Kle<P>
      • Compile P+ into Pos<P>
      • Compile P? into Opt<P>
      • Compile P* into Kle<P>
    • List<P, Sep: (',' _), empty: true>
    • Peek<P>
      • Replace peek P by Peek<P>
    • Not<P>
      • Replace not P by Not<P>
    • Expect<P> msg=void
      • Replace expect P by Expect<P>
    • Keyword<P> turned into Implement builtin Keyword<P> #121
      • Replace tokay.toks 'kw' _standalone_ by Keyword<'kw'>
  • Tests

Currently without usage. Still have to find a starting point.
The previous implementation did not have any real advantage, except making the code more complex at this point.
Unfinished intermediate commit.
Introduces ImlValue::Generic to describe a generic usage.
Removes constants from ImlParselet and making it part of ImlValue::Parselet.

Yet without functionality. Under further consideration.
This is yet another intermediate commit.
Compiler::get() returns any ImlValue with a name.
ImlOp and ImlValue will merge as well in their meaning.
Intermediate commit with a lot of stuff todo.
ImlProgram is a better name for the linker, to glue intermediate parts together into a program.
phorward added a commit that referenced this pull request Apr 19, 2023
Squashed commit of the following:

commit a5c658f
Author: Jan Max Meyer <jmm@phorward.de>
Date:   Wed Apr 19 20:57:13 2023 +0200

    ImlOp::compile_to_vec()

commit 5946136
Author: Jan Max Meyer <jmm@phorward.de>
Date:   Wed Apr 19 20:10:44 2023 +0200

    ImlValue::compile_load() & ImlValue::compile_call()

commit 6566246
Author: Jan Max Meyer <jmm@phorward.de>
Date:   Tue Apr 18 20:33:41 2023 +0200

    ImlProgram::finalize() improvements

commit de8932e
Author: Jan Max Meyer <jmm@phorward.de>
Date:   Tue Apr 18 18:42:31 2023 +0200

    wip: Separated self-contained ImlProgram::finalize()

commit 19acfce
Author: Jan Max Meyer <jmm@phorward.de>
Date:   Tue Apr 18 00:36:55 2023 +0200

    wip: Move finalization entirely into ImlProgram

commit 45a1570
Author: Jan Max Meyer <jmm@phorward.de>
Date:   Mon Apr 17 23:26:40 2023 +0200

    wip: Change signature of ImlOp::compile

commit 77e247f
Author: Jan Max Meyer <jmm@phorward.de>
Date:   Mon Apr 17 22:58:48 2023 +0200

    wip: Rename Linker into ImlProgram

    ImlProgram is a better name for the linker, to glue intermediate parts together into a program.

commit bef35e8
Author: Jan Max Meyer <jmm@phorward.de>
Date:   Mon Apr 17 00:20:24 2023 +0200

    .

commit c12f1fc
Author: Jan Max Meyer <jmm@phorward.de>
Date:   Sun Apr 16 23:31:34 2023 +0200

    wip: ImlValue::Shared

    Intermediate commit with a lot of stuff todo.

commit d4ee396
Author: Jan Max Meyer <jmm@phorward.de>
Date:   Wed Apr 5 00:43:11 2023 +0200

    wip: get clarification for data model

    This is yet another intermediate commit.
    Compiler::get() returns any ImlValue with a name.
    ImlOp and ImlValue will merge as well in their meaning.

commit 0010a84
Author: Jan Max Meyer <jmm@phorward.de>
Date:   Wed Mar 22 13:33:51 2023 +0100

    ImlValue::Generic & ImlParselet clean-up

    Introduces ImlValue::Generic to describe a generic usage.
    Removes constants from ImlParselet and making it part of ImlValue::Parselet.

    Yet without functionality. Under further consideration.

commit 4eff813
Author: Jan Max Meyer <jmm@phorward.de>
Date:   Mon Mar 20 15:33:21 2023 +0100

    Substitute Option<ImlValue> by ImlValue::Void

commit 50a5df8
Author: Jan Max Meyer <jmm@phorward.de>
Date:   Mon Mar 20 12:31:17 2023 +0100

    First traversal of value_generic/genarg

    Unfinished intermediate commit.

commit 9e4bb42
Author: Jan Max Meyer <jmm@phorward.de>
Date:   Sun Mar 19 16:21:40 2023 +0100

    Rename ImlValue::value() to ImlValue::into_refvalue()

commit 6f0d981
Author: Jan Max Meyer <jmm@phorward.de>
Date:   Sun Mar 19 16:15:36 2023 +0100

    Renaming iml-modules into appropriate filenames

    ...for better distinction.

commit 19c8b1c
Author: Jan Max Meyer <jmm@phorward.de>
Date:   Sun Mar 19 15:09:58 2023 +0100

    Merge ImlTarget into ImlValue

    The previous implementation did not have any real advantage, except making the code more complex at this point.

commit 2b2d89d
Author: Jan Max Meyer <jmm@phorward.de>
Date:   Sun Mar 19 11:33:43 2023 +0100

    Check for invalid parselet instances

commit fe9a1bb
Author: Jan Max Meyer <jmm@phorward.de>
Date:   Mon Mar 13 22:56:18 2023 +0100

    Let's use ImlValue::Parselet for instances as well

    Currently without usage. Still have to find a starting point.

commit 43353b8
Author: Jan Max Meyer <jmm@phorward.de>
Date:   Sat Mar 11 12:29:50 2023 +0100

    ImlValue::ParseletInstance?

commit 3482a3d
Merge: 2483e83 09e376c
Author: Jan Max Meyer <jmm@phorward.de>
Date:   Mon Mar 6 18:49:22 2023 +0100

    Merge branch 'main' into generic-parselets

commit 2483e83
Author: Jan Max Meyer <jmm@phorward.de>
Date:   Sun Mar 5 23:27:31 2023 +0100

    temporarily disabling prelude

commit 06d12fa
Merge: 34e738e 0f1d00c
Author: Jan Max Meyer <jmm@phorward.de>
Date:   Sat Mar 4 11:01:27 2023 +0100

    Merge branch 'main' into generic-parselets

commit 34e738e
Merge: ae9a4b7 d51ee23
Author: Jan Max Meyer <jmm@phorward.de>
Date:   Thu Feb 23 00:29:11 2023 +0100

    Merge branch 'main' into generic-parselets

commit ae9a4b7
Author: Jan Max Meyer <jmm@phorward.de>
Date:   Sun Feb 19 00:16:48 2023 +0100

    Some renamings

commit 6b297f1
Author: Jan Max Meyer <jmm@phorward.de>
Date:   Sat Feb 18 22:26:51 2023 +0100

    Unify naming for constants and signature

commit 53b86f1
Author: Jan Max Meyer <jmm@phorward.de>
Date:   Sat Feb 18 22:23:53 2023 +0100

    Use IndexMap for constants and signature
The `+=`-operator uses `list_extend()`, which generates different results when P returns a list.
... and tested behavior with generated parselets.
Broken, still WIP.
Finally remove deprecated stuff as it is replaced by Tokay internals for now.
This is useful for debugging and error reporting
@phorward phorward removed the tokay label Oct 8, 2023
- Re-enables reporting of unused symbols
- Improves reporting of unresolved values that are registered
- Improves reporting of invalid generic configurations

This commit also showed up that ImlValue::Shared is a bug problem, and was a conceptual mistake, making things heavy and blurry. Therefore, a huger rework of the ImlValue is scheduled, and the Iml*-stuff in general.
- Renamed `ImlParseletConfig` into `ImlParseletInstance`
- Removed `ImlParselet.is_generic()`
- Moved required generic argument checking into `ImlParselet.derive()`
@phorward phorward marked this pull request as ready for review October 22, 2023 18:20
@phorward
Copy link
Member Author

This pull request is now ready to be merged.

I'm a little unhappy with the current ImlValue implementation, but this is the only way to adequately solve the problem at the moment. Anyway, this should be done better or differently, and I'm sure it will.

All that's missing now is some documentation to describe the new features.

By implementing build-ins with the help of Tokay itself, #120 will be another big milestone to significantly reduce the size of the generated code and thus make Tokay much more performant again like the previous solution. However, this step here has to be to raise Tokay to another level.

@phorward phorward merged commit 2b75daf into tokay-lang:main Oct 23, 2023
3 checks passed
@phorward phorward deleted the generic-parselets branch December 25, 2023 20:40
@phorward phorward restored the generic-parselets branch December 25, 2023 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant