Skip to content
This repository was archived by the owner on Sep 22, 2020. It is now read-only.

Conversation

shnhrrsn
Copy link
Member

@shnhrrsn 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

* 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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant