Skip to content

Commit

Permalink
add parse index to parse elements
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrsh committed Apr 26, 2018
1 parent a8a52fc commit 5c06921
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/compiler/parser.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { error } from "../util/util";

const WHITESPACE_RE = /\s/;
let parseIndex;

const pushChild = (child, stack) => {
stack[stack.length - 1].children.push(child);
Expand All @@ -14,6 +15,7 @@ const parseOpeningTag = (index, input, length, stack) => {

if (char === ">") {
const element = {
index: parseIndex++,
type: type,
children: []
};
Expand All @@ -25,6 +27,7 @@ const parseOpeningTag = (index, input, length, stack) => {
break;
} else if (char === "/" && input[index + 1] === ">") {
pushChild({
index: parseIndex++,
type: type,
children: []
}, stack);
Expand Down Expand Up @@ -75,6 +78,7 @@ const parseText = (index, input, length, stack) => {
}

pushChild({
index: parseIndex++,
type: "m-text",
content: content
}, stack);
Expand All @@ -84,8 +88,10 @@ const parseText = (index, input, length, stack) => {

export const parse = (input) => {
const length = input.length;
parseIndex = 0;

const root = {
index: parseIndex++,
type: "m-fragment",
children: []
};
Expand Down

0 comments on commit 5c06921

Please sign in to comment.