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
Porting the compilation pipeline #419
Conversation
[sty] add Style AST types and create compiler module [sty] simplify substance types and export them as TS types fix: bypass ts checking by temporarily disabling return type
Summarizing the plan for this branch: @hypotext and I will separately branch off from |
* [sty-parse] nearley setup * [sty-parse] selector grammar; sepBy combinator * [sty-parser] complete selector grammar * [sty-parser] parse multiple blocks & whitespace/range cleanup * [sty-parser] start jest test suite * [sty-parser] compile grammar before running test; more test cases * [sty-arse] resolve all ambiguities on selector grammar * [sty-parse] stmt sequencing grammar; better testing for comments * [sty-parse] start working on expression grammar * [sty-parse] parse path assign fix ws issue at the beginning of programs bump ts to 3.9.5 for fromEntries * [sty-parse] layering expression * [sty-parse] computations * [sty-parse] gpi decl, constr/obj fns * [sty-parse] floating point number * [sty-parse] tag but not reject style types replace all raw string types with identifier in ASTNode rework some node props to be descriptive add test for keywords * [sty-parse] first working arith expr parser * [sty-parse] list-like exprs; unary minus * [sty-parse] access path and test cases * [sty-parse] multiline comments; remaining stmt types * [sty-parse] systematically parse all example programs in the wiki * [sty-parser] integrate the parser with build pipeline add test to main test module * [sty-parse] remove obsolete optimizer and evaluator tests * fix: increase resource size to avoid bundling errors
Just merged the new parser. I expect some experimentation when porting the Style compiler early on. I'd suggest staying on your branch until it's stable (e.g. compiles 1+ programs in our wiki) @hypotext |
Ok, thanks, will do! @wodeni |
Ported the domain parser (#441). I'll merge this branch soon and start porting the semantic checker. Once I get there, we'll have a (potentially revised) |
* [domain] start empty domain parser; abstract out parser util functions; improve build script * [domain] domain AST * [domain] parse type and predicate decls * [domain] parse functions * [domain] simplify domain grammar by removing dependent types; add constr and prelude * [domain] parse notations; add epsilon rules for arg and type param lists * [domain] only allow typevars as type params; clean up prop type * [domain] scaffloding for domain checker; working example of Either pattern and error types * [domain] new foldM function; start checking types; fix Var type * [domain] check types and constructors; util all combinator; fix output type in AST * [domain] first pass of domain checker; subtypes/notations not handled; lightly tested * [domain] separate out error module; reexport either monad * [domain] add subtype graph building and cycle detection * [domain] add isSubType function using dijkstra \(!\)
* [sub-parse] substance parser setup; move common tokens to ParserUtil * [sub-parse] parse decls and label stmts * [sub-parse] parse decls and label stmts * [sub-parse] resolve cons, func, and pred ambiguity via a generic type; parse preds * [sub-parse] parse equiv. exprs and preds * [sub-parse] parse existing examples; fix newline at EOF * [domain] fix newline at EOF * [sub-check] setup Substance checker * [domain] add real domain programs to the test suite * [sub-parse] only parse vars or preds in pred arg * [sub-check] check decls; generalize misc error util functions * [sub-check] check type list via unification; lightly tested with known problems in checkTypeconstructor * chore: add command for reporting test coverage * [sub-check] add more sophisticated type eq check; fix the logic of substitution error checking * [sub-check] rename subtype checker; return bottom for unbounded vars in expressions; add subtype tests * [sub-check] check functions * [sub-check] check deconstructors * [sub-check] check predicates * [sub-check] check labeling stmts and type eq stmts * [parser] add node information such as children and node type to all parsed nodes; include tree integrity tests in all parser tests * [sub-check] add label postprocessing; mark errors with error types after typechecking * [sub-check] add real programs to Substance checker test suite
Substance parser and typechecker are both ported and tested with 102 test cases (#447) 🎉 . Next step: finish Style compiler and the port should be done! |
5de118a
to
9907599
Compare
* [scp] add style program JSON conversion in backend, and add example JSON file (for orthogonal vectors) in frontend tests. also add orthogonal vectors to registry * [scp] add input types + implementation stub for style compiler * [scp] fix indentation * [scp] fix indentation, add some work on selector checking * [scp] finish selector environment-building code (with selector in env for debugging); all error-checking omitted * [scp] implement some of the substitution finding code * [parser] fix off-by-one-error in selector parsing * [scp] get (ported part of) style compiler compatible with ASTs, no crash but haven't checked correctness of SelEnvs yet * [scm] confirm + improve SelEnv schema * [scm] add some misc sel checking functions * [scp] add test compiler data for linear-algebra-simple.sty, as well as tests for substitution-finding helper functions * [scp] add some function stubs for style matching * [scp] add rel-substitution code (unrun/untested) and documentation of compiler so far * [scp] add rel pretty-printing code and informally verify that all substitution code works (with a minor parser/AST incompatibility in RelPred name). TODO write tests for substitution code * [scp] update compiler and parsed ASTs to deal with minor changes in parser/grammar fixing #436 #437 * [scp] test substitutions (and regenerate style test data WRT parser change) * [scp] add code for testing that a substituted relational line matches a substance program line + code for converting style exprs/predicates to substance ones. add (passing) test that the compiler finds right substitutions on the LA style program * [scp] add code for replacing anon statements with local vars, as well as (passing) test * [scp] add some boilerplate for writing style program translation code * [scp] add some boilerplate for style translation and substitution-applying code * [scp] finish substitution-applying code (not fully tested, but runs); add hacks for issues #443 #444 * [scp] add some translation code (currently not working on GPIs and w/ a hack for local vars); update for #443 #444 * [scp] integrate LocalVar with Path grammar (since parser parses into that form, not IInternalLocalVar) and remove hacks related to it * [scp] add GPI insertion; compiler generates first translation before genOptProblem (untested) * [scp] add boilerplate genOptProblem + initial state * [scp] add some genOptProblem code for finding various kinds of paths in the translation * [scp] add most of the rest of genOptProblem code for generating translation (except initShape and initProperty) * [scp] fix circular import of canvasSize * [scp] fix bug in finding varying val in vector * [scp] add shape initialization code (untested) * [scp] fix varying property finding bug; add `insertNames` * [scp] fix `findExpr` bug on vectors; seems like there might be a VarAD (vector) conversion error? runs and generates translation, and crashes on (old) evaluator. [untested] * [scp] convert `penrose-web` to use new AST types throughout; remove `ts-nocheck`; system runs (and crashes at runtime) * [scp] implement `insertLabels` and AccessPath lookup; still crashes on runtime * [scp] get first figure on screen (though with NaNs, number/object errors, etc). fix boolean literal in style program, label Substance objects by default, skip shape layering for now, and add hack for accesspath index parsing (#448) * [scp] fix compiler bug with initializing shape properties; fix Canvas bug with making translation differentiable again (only needed for state w/ old compiler and decodeJSON, now removed); currently crashes on labels * [scp] fix bugs with pending properties and vector sampling; don't use sorted shapes w/ layering; fix bug with updated shape dimensions in translation but not in shapes (not sure why this broke?); initial output looks reasonable, but optimization and resampling are not tested * [scp] render strokeOpacity in Square shape * [scp] comment out old console logs; replace Optimizer logs with console.log for now; fix opt init param + fn name bugs * [scp] first working compiler with optimization and resample (initialize opt weight in compiler; fix shape find bug) * [scp] gather partial layerings in compiler; improve path printing * [scp] load dsl/sub/sty programs using the new toolchain; compiler still needs to be tested * [scp] implement substance equality check and address #448, now LA image appears onscreen (with funky labels) * [scp] implement some selector checking using domain/substance checkers [untested] * [scp] fix bug with Env (`clone` doesn't work; using Map's immutability is better) * [scp] implement more selector checking using Sub/Domain function (for decls) and valcons subtype checking * [scp] implement path aliasing for GPI properties in deleteProperty and insertExpr (for properties only) * [scp] add more test programs for whole thing; works with the set tree example; set circles mostly works except for a selector match bug possibly w/ nested predicates (?) * [scp] hook up new style compiler to CLI and program toolchain, and remove `processData`! working example: `roger watch linear-algebra-domain/twoVectorsPerp_unsugared.sub linear-algebra-domain/linear-algebra-paper-simple.sty linear-algebra-domain/linear-algebra.dsl` * [scp] preprocess Substance program to disambiguate `Func` #453; now the big set circle example works [the functional version of substance preprocessing is just for testing, not final, needs to mutate ast] * [scp] fix Sub prog Func disambiguation to be imperative #453; should now be more general * [scp] get all old examples working (adding unsugared Substance programs, temp string hacks #458, and Style SEFuncOrValCons disambiguation based on the Substance ones). found some label bugs #459 #460 * [scp] revert hacks for #458 * [scp] some cleanup of logs + putting comments back in * [style-compiler-port] hotfix to allow reconnecting to the socket via button * [scp] return errors in `checkSels` and `insertExpr` (if in `compiling` mode) instead of throwing them; clean up some other internal errors * [scp] add some ad-hoc tests for selector errors and translation errors * [scp] fix JS heap issue after 2501f73 #450 * [scp] implement layering sort function * [scp] port old Style compiler tests to work on loaded LA programs Co-authored-by: katherineye <kye@princeton.edu> Co-authored-by: maxkrieger <themaxaxis@gmail.com> Co-authored-by: wodeni <wn2155@columbia.edu>
* [scp] add style program JSON conversion in backend, and add example JSON file (for orthogonal vectors) in frontend tests. also add orthogonal vectors to registry * [scp] add input types + implementation stub for style compiler * [scp] fix indentation * [scp] fix indentation, add some work on selector checking * [scp] finish selector environment-building code (with selector in env for debugging); all error-checking omitted * [scp] implement some of the substitution finding code * [parser] fix off-by-one-error in selector parsing * [scp] get (ported part of) style compiler compatible with ASTs, no crash but haven't checked correctness of SelEnvs yet * [scm] confirm + improve SelEnv schema * [scm] add some misc sel checking functions * [scp] add test compiler data for linear-algebra-simple.sty, as well as tests for substitution-finding helper functions * [scp] add some function stubs for style matching * [scp] add rel-substitution code (unrun/untested) and documentation of compiler so far * [scp] add rel pretty-printing code and informally verify that all substitution code works (with a minor parser/AST incompatibility in RelPred name). TODO write tests for substitution code * [scp] update compiler and parsed ASTs to deal with minor changes in parser/grammar fixing #436 #437 * [scp] test substitutions (and regenerate style test data WRT parser change) * [scp] add code for testing that a substituted relational line matches a substance program line + code for converting style exprs/predicates to substance ones. add (passing) test that the compiler finds right substitutions on the LA style program * [scp] add code for replacing anon statements with local vars, as well as (passing) test * [scp] add some boilerplate for writing style program translation code * [scp] add some boilerplate for style translation and substitution-applying code * [scp] finish substitution-applying code (not fully tested, but runs); add hacks for issues #443 #444 * [scp] add some translation code (currently not working on GPIs and w/ a hack for local vars); update for #443 #444 * [scp] integrate LocalVar with Path grammar (since parser parses into that form, not IInternalLocalVar) and remove hacks related to it * [scp] add GPI insertion; compiler generates first translation before genOptProblem (untested) * [scp] add boilerplate genOptProblem + initial state * [scp] add some genOptProblem code for finding various kinds of paths in the translation * [scp] add most of the rest of genOptProblem code for generating translation (except initShape and initProperty) * [scp] fix circular import of canvasSize * [scp] fix bug in finding varying val in vector * [scp] add shape initialization code (untested) * [scp] fix varying property finding bug; add `insertNames` * [scp] fix `findExpr` bug on vectors; seems like there might be a VarAD (vector) conversion error? runs and generates translation, and crashes on (old) evaluator. [untested] * [scp] convert `penrose-web` to use new AST types throughout; remove `ts-nocheck`; system runs (and crashes at runtime) * [scp] implement `insertLabels` and AccessPath lookup; still crashes on runtime * [scp] get first figure on screen (though with NaNs, number/object errors, etc). fix boolean literal in style program, label Substance objects by default, skip shape layering for now, and add hack for accesspath index parsing (#448) * [scp] fix compiler bug with initializing shape properties; fix Canvas bug with making translation differentiable again (only needed for state w/ old compiler and decodeJSON, now removed); currently crashes on labels * [scp] fix bugs with pending properties and vector sampling; don't use sorted shapes w/ layering; fix bug with updated shape dimensions in translation but not in shapes (not sure why this broke?); initial output looks reasonable, but optimization and resampling are not tested * [scp] render strokeOpacity in Square shape * [scp] comment out old console logs; replace Optimizer logs with console.log for now; fix opt init param + fn name bugs * [scp] first working compiler with optimization and resample (initialize opt weight in compiler; fix shape find bug) * [scp] gather partial layerings in compiler; improve path printing * [scp] load dsl/sub/sty programs using the new toolchain; compiler still needs to be tested * [lerna] initialize lerna * [lerna] start deprecating all Haskell related code * [lerna] remove haskell precommmit hook * [lerna] add test script for all packages * [lerna] delete top-level haskell configs * [lerna] install husky in monorepo * [lerna] test husky * [lerna] test husky * fix: install script for roger * v1.0.1 * chore: add changelog * [scp] implement substance equality check and address #448, now LA image appears onscreen (with funky labels) * [scp] implement some selector checking using domain/substance checkers [untested] * [scp] fix bug with Env (`clone` doesn't work; using Map's immutability is better) * [lerna] remove haskell lint config and update ci workflow * [lerna] fix build_other_branches workflow * [lerna] updated CI config * [lerna] install lerna in ci * [lerna] sudo lerna install * [lerna] store test results in CI * [lerna] add junit * Updated config.yml * [lerna] full paths for artifacts * [lerna] collect test report in dedicated directory * [scp] implement more selector checking using Sub/Domain function (for decls) and valcons subtype checking * [scp] implement path aliasing for GPI properties in deleteProperty and insertExpr (for properties only) * [scp] add more test programs for whole thing; works with the set tree example; set circles mostly works except for a selector match bug possibly w/ nested predicates (?) * [lerna] add bootstrap command and test with automator * [lerna] add codecov detector * [scp] hook up new style compiler to CLI and program toolchain, and remove `processData`! working example: `roger watch linear-algebra-domain/twoVectorsPerp_unsugared.sub linear-algebra-domain/linear-algebra-paper-simple.sty linear-algebra-domain/linear-algebra.dsl` * [scp] preprocess Substance program to disambiguate `Func` #453; now the big set circle example works [the functional version of substance preprocessing is just for testing, not final, needs to mutate ast] * [scp] fix Sub prog Func disambiguation to be imperative #453; should now be more general * [scp] get all old examples working (adding unsugared Substance programs, temp string hacks #458, and Style SEFuncOrValCons disambiguation based on the Substance ones). found some label bugs #459 #460 * [scp] revert hacks for #458 * [scp] some cleanup of logs + putting comments back in * [style-compiler-port] hotfix to allow reconnecting to the socket via button * [lerna-merge] fix JS heap issue * [lerna-merge] fix CI JSON issue * [scp] return errors in `checkSels` and `insertExpr` (if in `compiling` mode) instead of throwing them; clean up some other internal errors * [scp] add some ad-hoc tests for selector errors and translation errors * [scp] fix JS heap issue after 2501f73 #450 * [scp] implement layering sort function * [scp] port old Style compiler tests to work on loaded LA programs * [lerna] fix style test case path * [lerna] fix import issue in Style Co-authored-by: katherineye <katherine.ye@gmail.com> Co-authored-by: katherineye <kye@princeton.edu> Co-authored-by: maxkrieger <themaxaxis@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #419 +/- ##
=========================================
Coverage ? 25.68%
=========================================
Files ? 74
Lines ? 5607
Branches ? 1127
=========================================
Hits ? 1440
Misses ? 4167
Partials ? 0 Continue to review full report at Codecov.
|
Description
Related issues: #336 #428
We will port the Domain, Substance Style parsers/checkers and compiler into TypeScript.
Implementation strategy and design decisions
penrose-web/src/compiler/Style.ts
for a possible place to put the Style compiler code. The top-level function should becompileStyle
, and its signature looks like something like this:Examples with steps to reproduce them
TODO
Checklist
TODO: update checklist for TS
npm test
npm run docs
and there were no errors when generating the HTML siteOpen questions
Questions that require more discussion or to be addressed in future development: