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

fix: return parser errors monadically #468

Merged
merged 3 commits into from
Feb 5, 2021
Merged

fix: return parser errors monadically #468

merged 3 commits into from
Feb 5, 2021

Conversation

wodeni
Copy link
Member

@wodeni wodeni commented Feb 5, 2021

Description

Related issue/PR: #158

Add ParserError type to Substance, Domain, and Style. The errors are just strings from nearley for now. Depending on the demand, I can try to access the parse table to customize our own errors.

Implementation strategy and design decisions

  • Add ParserError to all three languages
  • Minor cleaning of the repo

Examples with steps to reproduce them

Checklist

  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • New and existing tests pass locally using npm test
  • I ran npm run docs and there were no errors when generating the HTML site
  • My code follows the style guidelines of this project (e.g.: no ESLint warnings)

Open questions

  • How often do we need to surface parser errors? They are the least informative error, so should we try our best to avoid them in, say, the IDE by streaming to the parser and parse partial programs greedily instead?

@codecov-io
Copy link

Codecov Report

Merging #468 (c378197) into master (76ada1f) will decrease coverage by 1.24%.
The diff coverage is 69.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #468      +/-   ##
==========================================
- Coverage   25.82%   24.58%   -1.25%     
==========================================
  Files          74       74              
  Lines        5587     5601      +14     
  Branches     1125     1130       +5     
==========================================
- Hits         1443     1377      -66     
- Misses       4144     4224      +80     
Impacted Files Coverage Δ
packages/penrose-core/src/utils/Error.ts 33.00% <25.00%> (-1.05%) ⬇️
packages/penrose-core/src/compiler/Style.ts 35.63% <47.05%> (-0.68%) ⬇️
packages/penrose-core/src/compiler/Substance.ts 89.95% <91.30%> (+0.28%) ⬆️
packages/penrose-core/src/compiler/Domain.ts 91.54% <100.00%> (+0.30%) ⬆️
packages/penrose-core/src/ui/styles.ts 0.00% <0.00%> (-100.00%) ⬇️
packages/penrose-core/src/packets.tsx 0.00% <0.00%> (-64.71%) ⬇️
packages/penrose-core/src/utils/Log.ts 0.00% <0.00%> (-29.42%) ⬇️
packages/penrose-core/src/API.tsx 0.00% <0.00%> (-19.24%) ⬇️
packages/penrose-core/src/ui/Embed.tsx 0.00% <0.00%> (-10.00%) ⬇️
packages/penrose-core/src/engine/Optimizer.ts 0.00% <0.00%> (-8.03%) ⬇️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 76ada1f...c378197. Read the comment docs.

@wodeni wodeni changed the title Categorize and codify errors in Style Return parser errors monadically Feb 5, 2021
@wodeni wodeni self-assigned this Feb 5, 2021
@wodeni wodeni changed the title Return parser errors monadically fix: return parser errors monadically Feb 5, 2021
@wodeni wodeni merged commit 6305301 into master Feb 5, 2021
@wodeni wodeni deleted the style-errors branch February 5, 2021 03:05
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.

2 participants