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
HTML syntax part 3 #323
HTML syntax part 3 #323
Conversation
Naturally I recommend using GH code review assistant to handle the hugeness of the PR ;) |
@jakub-g For info, I have done a rebase of your branch on the most recent commits from https://github.com/ariatemplates/hashspace, resolving some conflicts. Here is the resulting branch on my fork: https://github.com/divdavem/hashspace/tree/jakub-htmlsyntax-part3 |
3ccc97b
to
37e9938
Compare
I've added a number of tests in the last commit. There are still some missing features to be added (listed them in the first message of this PR) but this PR is big enough already - they can be added later on. Anyone brave enough to review this monster? :) One obvious downside of this PR I can already tell is that TemplateStart in hspblocks got really huge. Probably for debugging sake, it could be better to move this code to the later stage so you could run it with node-inspector and put breakpoints etc. OTOH it turned out it was pretty convenient for me to use http://pegjs.majda.cz/online for real-time evaluation of parse tree. |
df114f3
to
6e604c7
Compare
Conflicts: docs/playground/splitter.hsp docs/samples/logs/logs.hsp test/compiler/errsamples/element6.txt test/compiler/errsamples/element7.txt test/gestures/doubleTap.spec.hsp test/gestures/drag.spec.hsp test/gestures/longPress.spec.hsp test/gestures/pinch.spec.hsp test/gestures/singleTap.spec.hsp test/gestures/swipe.spec.hsp test/gestures/tap.spec.hsp test/rt/cptattelements3.spec.hsp test/rt/cptattelements4.spec.hsp test/rt/evthandler.spec.hsp
moved error handling logic to syntaxtree only basic extraction of attribs is done at hspblocks parse time
6e604c7
to
c974ff8
Compare
LGTM |
This is still WIP but I'm opening a PR already, since it's huge, so that someone can start reviewing
(I'll add new commit with some tests, the src should be untouched or barely touched)
Almost all 200 files changed are just syntax update in HSP files. In some of the test files I had to tweak error messages since the way parser works has changed.
In first commit the two most interesting changes are
hspblocks.pegjs
andsyntaxTree.js
args
,controller
,export
, newly-addedexport-module
andid
+ lot of validation code<export template
) since it's no longer supported (now it's always<template maybe-export-here>
mod
tomodifier
in the syntax tree, and now it's anobject
ornull
instead of string or empty string (to supportexport="foo"
)suberrors
array to syntax tree in case of<template>
-statement parsing errors to be more detailed (see template8.txt for instance)Due to the way how HTML attributes are parsed, I had to change some tests (template8 once again for instance)
In hspblocks, crazily big amount of code is for error handling to have friendly messages instead of terse parse errors.
For that I modified the HTMLAttribute to be more readable and provide
code
which is propagated to the templatein case of template opening statement parse error.
In the last commit I added the suberrors-awareness to the playground, this meant having to modify log to output
messages
array apart frommessage
string, so that I can format them the way I want (i.e.<br>
-separated), because currently in hashspace it's impossible to easily do any kind of pre-display manipulation like e.g. introducing HTML newlines in a multiline stringI kept
message
too (which just joins lines with a space) for backward compat (there were some failing log tests, I didn'qt want to touch it)In the JS generator code I took advantage of the fact that log methods can have varags input.
Notable missing parts:
args
andctrl
can have only"value"
inside double quotes, not inside single quotes unlike other attribsexport-module
which when parsed setsnode.isExportModule = true
for now in the syntax tree but nothing more than that (it doesn't perform the exporting functionality)export
can have value<template id=foo export=bar>
and thenblock.modifier.exportName
is available (null
if not set), but nothing is done with it further, it's just parsed (template is still exported asfoo
instead ofbar
)