1 | (function() {
|
2 | var self = this;
|
3 | var createDynamicLexer;
|
4 | exports.createDynamicLexer = createDynamicLexer = function(gen1_options) {
|
5 | var nextLexer, source;
|
6 | nextLexer = gen1_options !== void 0 && Object.prototype.hasOwnProperty.call(gen1_options, "nextLexer") && gen1_options.nextLexer !== void 0 ? gen1_options.nextLexer : void 0;
|
7 | source = gen1_options !== void 0 && Object.prototype.hasOwnProperty.call(gen1_options, "source") && gen1_options.source !== void 0 ? gen1_options.source : void 0;
|
8 | var lexer;
|
9 | lexer = {
|
10 | tokens: [],
|
11 | nextLexer: nextLexer,
|
12 | lex: function() {
|
13 | var self = this;
|
14 | var token;
|
15 | token = self.tokens.shift();
|
16 | if (token) {
|
17 | self.yytext = token;
|
18 | return token;
|
19 | } else {
|
20 | token = self.nextLexer.lex();
|
21 | self.yytext = self.nextLexer.yytext;
|
22 | self.yylloc = self.nextLexer.yylloc;
|
23 | self.yyleng = self.nextLexer.yyleng;
|
24 | self.yylineno = self.nextLexer.yylineno;
|
25 | self.match = self.nextLexer.match;
|
26 | return token;
|
27 | }
|
28 | },
|
29 | showPosition: function() {
|
30 | var self = this;
|
31 | return self.nextLexer.showPosition();
|
32 | },
|
33 | setInput: function(input) {
|
34 | var self = this;
|
35 | return self.nextLexer.setInput(input);
|
36 | }
|
37 | };
|
38 | if (source) {
|
39 | lexer.setInput(source);
|
40 | }
|
41 | return lexer;
|
42 | };
|
43 | }).call(this); |
\ | No newline at end of file |