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

WIP: Parse Stone through Acorn #22

Open
wants to merge 37 commits into
base: master
from

Conversation

Projects
None yet
1 participant
@shnhrrsn
Member

shnhrrsn commented Nov 26, 2017

Stone currently uses a mix of regex and character scanning to parse it’s code, and awkwardly uses Acorn in places to scope vars and validate syntax.

This PR aims to replace the existing Stone compiler with a new parser built entirely on Acorn. The new Stone class will parse templates via Acorn into and AST and then use astring to generate them into JS.

Goals

  • Better/safer parser
  • Clearer errors
  • Full source maps
  • Compile time optimizations

Progress

Overall

  • Parse directives
  • Parse safe output
  • Parse unsafe output
  • Parse comments
  • Generate templates via astring
  • Caching
  • Extensions
  • All tests passing

Directives

  • Loops
    • @for / @endfor and @foreach / @endforeach
    • @while / @endwhile
    • @continue / @continue(condition)
    • @break / @break(condition)
    • Magic loop var
  • Conditionals
    • @if / @endif
    • @elseif
    • @else
    • @unless / @endunless
  • Includes
    • @include
    • @each
  • Layouts
    • @extends
    • @section / @endsection
    • @yield
    • @show
    • @super / @parent
    • @hassection
  • Components
    • @component / @endcomponent
    • @slot / @endslot
    • Tagged components
  • Output
    • @spaceless / @endspaceless
    • @dump
    • @{{ raw output }}
    • Correct spacing
  • Assignments
    • @set
    • @unset
  • Macros
    • @macro / @endmacro

shnhrrsn added some commits Nov 25, 2017

shnhrrsn added some commits Dec 5, 2017

Updated whitespace to match pre-acorn outputs
* All view tests should now pass except for tags, as tagged components have not yet been implemented
* The only test case that was updated is `nested` because pre-acorn stone was incorrectly trimming the last line of a template if it came after a directive
* Moved `set-destructuring` to `set-destructuring-array` and added `set-destructuring-object`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment