Moving parser setup code into a separate file

This commit is contained in:
Jeff Avallone 2014-12-19 20:41:02 -05:00
parent 43eaf493e6
commit 69ae3f0fe1
2 changed files with 42 additions and 39 deletions

View File

@ -1,42 +1,6 @@
import Q from 'q';
import parser from './javascript/grammar.peg';
import Node from './javascript/node.js';
import Root from './javascript/root.js';
import Regexp from './javascript/regexp.js';
import Match from './javascript/match.js';
import MatchFragment from './javascript/match_fragment.js';
import Subexp from './javascript/subexp.js';
import Charset from './javascript/charset.js';
import CharsetEscape from './javascript/charset_escape.js';
import CharsetRange from './javascript/charset_range.js';
import Literal from './javascript/literal.js';
import Escape from './javascript/escape.js';
import AnyCharacter from './javascript/any_character.js';
import Repeat from './javascript/repeat.js';
import RepeatAny from './javascript/repeat_any.js';
import RepeatOptional from './javascript/repeat_optional.js';
import RepeatRequired from './javascript/repeat_required.js';
import RepeatSpec from './javascript/repeat_spec.js';
parser.Parser.SyntaxNode = Node;
parser.Parser.Root = { module: Root };
parser.Parser.Regexp = { module: Regexp };
parser.Parser.Match = { module: Match };
parser.Parser.MatchFragment = { module: MatchFragment };
parser.Parser.Subexp = { module: Subexp };
parser.Parser.Charset = { module: Charset };
parser.Parser.CharsetEscape = { module: CharsetEscape };
parser.Parser.CharsetRange = { module: CharsetRange };
parser.Parser.Literal = { module: Literal };
parser.Parser.Escape = { module: Escape };
parser.Parser.AnyCharacter = { module: AnyCharacter };
parser.Parser.Repeat = { module: Repeat };
parser.Parser.RepeatAny = { module: RepeatAny };
parser.Parser.RepeatOptional = { module: RepeatOptional };
parser.Parser.RepeatRequired = { module: RepeatRequired };
parser.Parser.RepeatSpec = { module: RepeatSpec };
import javascript from './javascript/parser.js';
export default class Parser {
constructor() {
@ -52,9 +16,9 @@ export default class Parser {
var deferred = Q.defer();
setTimeout(() => {
Node.state = this.state;
javascript.Parser.SyntaxNode.state = this.state;
this.parsed = parser.parse(expression.replace(/\n/g, '\\n'));
this.parsed = javascript.parse(expression.replace(/\n/g, '\\n'));
deferred.resolve(this);
});

View File

@ -0,0 +1,39 @@
import parser from './grammar.peg';
import Node from './node.js';
import Root from './root.js';
import Regexp from './regexp.js';
import Match from './match.js';
import MatchFragment from './match_fragment.js';
import Subexp from './subexp.js';
import Charset from './charset.js';
import CharsetEscape from './charset_escape.js';
import CharsetRange from './charset_range.js';
import Literal from './literal.js';
import Escape from './escape.js';
import AnyCharacter from './any_character.js';
import Repeat from './repeat.js';
import RepeatAny from './repeat_any.js';
import RepeatOptional from './repeat_optional.js';
import RepeatRequired from './repeat_required.js';
import RepeatSpec from './repeat_spec.js';
parser.Parser.SyntaxNode = Node;
parser.Parser.Root = { module: Root };
parser.Parser.Regexp = { module: Regexp };
parser.Parser.Match = { module: Match };
parser.Parser.MatchFragment = { module: MatchFragment };
parser.Parser.Subexp = { module: Subexp };
parser.Parser.Charset = { module: Charset };
parser.Parser.CharsetEscape = { module: CharsetEscape };
parser.Parser.CharsetRange = { module: CharsetRange };
parser.Parser.Literal = { module: Literal };
parser.Parser.Escape = { module: Escape };
parser.Parser.AnyCharacter = { module: AnyCharacter };
parser.Parser.Repeat = { module: Repeat };
parser.Parser.RepeatAny = { module: RepeatAny };
parser.Parser.RepeatOptional = { module: RepeatOptional };
parser.Parser.RepeatRequired = { module: RepeatRequired };
parser.Parser.RepeatSpec = { module: RepeatSpec };
export default parser;