Skip to content

Commit

Permalink
new MVL, compiler, and router
Browse files Browse the repository at this point in the history
First, this change involves a refactor of some of the module structure
of the code to be consistent.

Next, there is a new Moon View Language (MVL). It has three types of
nodes:

* Node: A node that is equivalent to the contents of the
expression within it, analogous to a variable reference.
   - `<{node}#>`
* Data Node: A node that is equivalent to a function call that can call
a function with an expression directly or attributes to represent an
object.
   - `<{node} {data}/>`
   - `<{node} foo="bar" bar="baz"/>`
* Data & Children Node: A node that is equivalent to a function call
with attributes representing an object along with support for children,
which can include text, dynamic text blocks, and other nodes.
   - `<{node} foo="bar" bar="baz">Text {dynamic} <node#></>`
   - `<p>Hello Moon!</p>`

This means that all nodes must now be functions, so `Moon.view.m` is now
an object with keys being HTML elements and a special `text` element
which takes a `value` data property. All elements must then usually be
imported or declared at the top of files.

The new parser uses parser combinators and comes with better error
reporting that displays the line of the error, the surrounding lines,
and the exact position where something was expected. It also supports
full JavaScript syntax along with MVL, *without* needing parentheses
around nodes.

The new generator is much simpler and only generates function calls or
variable references as appropriate for the node type in question. It
doesn't do any static function call optimization as the nodes can be
dynamic at any time. This can easily be done by the developer and
included with a reference using a normal variable reference node.

Lastly, work on the router has started. There is a simple file structure
set up, a basic driver that changes the route using the `history` API,
and a basic `Link` component that creates `a` elements with the data
provided. Nothing fancy for now.
  • Loading branch information
kbrsh committed Nov 26, 2019
1 parent b56a09e commit 981c575
Show file tree
Hide file tree
Showing 40 changed files with 1,604 additions and 4,017 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"node": true
},
"rules": {
"arrow-parens": ["error", "as-needed"],
"constructor-super": 2,
"dot-notation": 2,
"eqeqeq": 2,
Expand Down
Loading

0 comments on commit 981c575

Please sign in to comment.