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

Experiment: make GAP scanner/reader accessible from GAP #4130

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fingolfin
Copy link
Member

@fingolfin fingolfin commented Oct 9, 2020

This experimental PR is something I've been telling people for a long time now; since I never seem to find time to clean it up and finish it, I thought I should post it here as-is; perhaps it motivates someone to join forces or to do their own thing.

This patch adds a way to take any input and run it through the parser, but without executing it, or printing any syntax errors etc. Instead the tokens as found by the scanner are recorded in a plain list, as is information about syntax errors.

To try it out, compile it, then ReadLib("tokenizer.g");

This has numerous potential application

  • implement "perfect" GAP syntax highlighting
  • implement a new REPL which allows for true multi line editing, context aware tab completion, syntax highlighting of the input while you type etc.
  • the REPL could also detect syntax errors as you type and show them (e.g. by marking the offending bits in red or underlining them etc.)
  • all the same could of course be used in alternative GAP frontends like Jupyter
  • a better demo mode could be implemented
  • yet another alternative implementation for Test could be written, in pure GAP (I don't see any reason to do that right now, I just mention it)
  • could be used in alternative code testing frameworks
  • AutoDoc could perhaps use it for more accurate parsing of GAP files
  • ...

Of course to get there, more work should be done. For one, this proof of concept should be polished and turned into something nicer:

  • instead of returning a dumb list of lists, one could return a list of records, or even objects (whether this transformation is done in the kernel or in a higher level GAP wrapper is up to the imagination of the implementor(s))
  • actually try to implement something from the list above (or something not yet in there) to see if the code can do all that's necessary for it
  • add tests
  • documentation... :-)
  • ...

@fingolfin fingolfin added the do not merge PRs which are not yet ready to be merged (e.g. submitted for discussion, or test results) label Oct 9, 2020
@coveralls
Copy link

coveralls commented Oct 9, 2020

Coverage Status

Coverage decreased (-0.003%) to 93.726% when pulling 0a0137e on fingolfin:mh/scanner-tokenizer-accessible-from-gap into e62d395 on gap-system:master.

@fingolfin fingolfin force-pushed the mh/scanner-tokenizer-accessible-from-gap branch from ef349b0 to 0a0137e Compare October 16, 2020 10:33
@fingolfin fingolfin added the kind: discussion discussions, questions, requests for comments, and so on label Oct 16, 2020
@fingolfin fingolfin force-pushed the mh/scanner-tokenizer-accessible-from-gap branch from 0a0137e to 8bca6c6 Compare January 28, 2021 00:04
@fingolfin fingolfin force-pushed the mh/scanner-tokenizer-accessible-from-gap branch from 8bca6c6 to b8d83a7 Compare July 1, 2021 09:14
@codecov
Copy link

codecov bot commented Jul 1, 2021

Codecov Report

Merging #4130 (8bca6c6) into master (b080f45) will increase coverage by 11.04%.
The diff coverage is 73.07%.

❗ Current head 8bca6c6 differs from pull request most recent head b8d83a7. Consider uploading reports for the commit b8d83a7 to get more accurate results

@@             Coverage Diff             @@
##           master    #4130       +/-   ##
===========================================
+ Coverage   82.32%   93.36%   +11.04%     
===========================================
  Files         679      716       +37     
  Lines      288109   812570   +524461     
===========================================
+ Hits       237184   758659   +521475     
- Misses      50925    53911     +2986     
Impacted Files Coverage Δ
src/scanner.h 50.00% <ø> (+25.00%) ⬆️
src/read.c 95.54% <36.36%> (-2.12%) ⬇️
src/scanner.c 97.34% <59.25%> (-2.66%) ⬇️
src/streams.c 81.62% <81.52%> (+0.85%) ⬆️
src/baltree.h 0.00% <0.00%> (-97.53%) ⬇️
src/dynarray.h 0.00% <0.00%> (-94.12%) ⬇️
src/libgap-api.c 4.50% <0.00%> (-51.29%) ⬇️
lib/memory.gi 43.12% <0.00%> (-39.92%) ⬇️
src/sysjmp.c 52.17% <0.00%> (-30.44%) ⬇️
src/io.c 59.29% <0.00%> (-28.64%) ⬇️
... and 289 more

@fingolfin fingolfin force-pushed the mh/scanner-tokenizer-accessible-from-gap branch from b8d83a7 to 26116ed Compare January 10, 2022 22:03
@fingolfin fingolfin force-pushed the mh/scanner-tokenizer-accessible-from-gap branch from 26116ed to 29e98f6 Compare October 21, 2022 00:51
@fingolfin fingolfin force-pushed the mh/scanner-tokenizer-accessible-from-gap branch from 29e98f6 to 0d27895 Compare March 7, 2023 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge PRs which are not yet ready to be merged (e.g. submitted for discussion, or test results) kind: discussion discussions, questions, requests for comments, and so on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants