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

HTML syntax part 3 #323

Closed
wants to merge 4 commits into from
Closed

Conversation

jakub-g
Copy link
Collaborator

@jakub-g jakub-g commented Oct 9, 2014

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 and syntaxTree.js

  • lots of changes to support HTMLish definition of args, controller, export, newly-added export-module and id + lot of validation code
  • removed assertions concerning modifiers at the beginning of the statement (<export template) since it's no longer supported (now it's always <template maybe-export-here>
  • changed mod to modifier in the syntax tree, and now it's an object or null instead of string or empty string (to support export="foo")
  • errtests.js: added a few lines to aid debugging in case of template parse errors
  • added suberrors array to syntax tree in case of <template>-statement parsing errors to be more detailed (see template8.txt for instance)
  • some whitespace changes (my editor somehow replaced tabs with spaces, and removed trailing whitespace, IMO it's fine)

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 template
in 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 from message 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 string
I 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 and ctrl can have only "value" inside double quotes, not inside single quotes unlike other attribs
  • introduced export-module which when parsed sets node.isExportModule = true for now in the syntax tree but nothing more than that (it doesn't perform the exporting functionality)
  • no checking for multiple conflicting exports, export-module etc
  • export can have value <template id=foo export=bar> and then block.modifier.exportName is available (null if not set), but nothing is done with it further, it's just parsed (template is still exported as foo instead of bar)

@jakub-g
Copy link
Collaborator Author

jakub-g commented Oct 9, 2014

Naturally I recommend using GH code review assistant to handle the hugeness of the PR ;)

@divdavem
Copy link
Member

@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

@jakub-g jakub-g force-pushed the htmlsyntax-part3 branch 2 times, most recently from 3ccc97b to 37e9938 Compare October 20, 2014 15:03
@jakub-g
Copy link
Collaborator Author

jakub-g commented Oct 20, 2014

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.

@jakub-g jakub-g force-pushed the htmlsyntax-part3 branch 2 times, most recently from df114f3 to 6e604c7 Compare October 27, 2014 13:39
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
@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) when pulling c974ff8 on jakub-g:htmlsyntax-part3 into 897c7eb on ariatemplates:master.

@marclaval
Copy link
Contributor

LGTM

@jakub-g jakub-g closed this in 9164b50 Oct 31, 2014
@jakub-g jakub-g changed the title WIP HTML syntax part 3 HTML syntax part 3 Oct 31, 2014
@jakub-g
Copy link
Collaborator Author

jakub-g commented Oct 31, 2014

@Mlaval thanks for review @divdavem thanks for rebasing and resolving conflicts :)

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.

None yet

4 participants