main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1.9 KB
|
Line | |
---|
1 | var TYPE = require('../../tokenizer').TYPE;
|
---|
2 |
|
---|
3 | var WHITESPACE = TYPE.WhiteSpace;
|
---|
4 | var COMMENT = TYPE.Comment;
|
---|
5 | var IDENT = TYPE.Ident;
|
---|
6 | var FUNCTION = TYPE.Function;
|
---|
7 | var COLON = TYPE.Colon;
|
---|
8 | var LEFTPARENTHESIS = TYPE.LeftParenthesis;
|
---|
9 |
|
---|
10 | function consumeRaw() {
|
---|
11 | return this.createSingleNodeList(
|
---|
12 | this.Raw(this.scanner.tokenIndex, null, false)
|
---|
13 | );
|
---|
14 | }
|
---|
15 |
|
---|
16 | function parentheses() {
|
---|
17 | this.scanner.skipSC();
|
---|
18 |
|
---|
19 | if (this.scanner.tokenType === IDENT &&
|
---|
20 | this.lookupNonWSType(1) === COLON) {
|
---|
21 | return this.createSingleNodeList(
|
---|
22 | this.Declaration()
|
---|
23 | );
|
---|
24 | }
|
---|
25 |
|
---|
26 | return readSequence.call(this);
|
---|
27 | }
|
---|
28 |
|
---|
29 | function readSequence() {
|
---|
30 | var children = this.createList();
|
---|
31 | var space = null;
|
---|
32 | var child;
|
---|
33 |
|
---|
34 | this.scanner.skipSC();
|
---|
35 |
|
---|
36 | scan:
|
---|
37 | while (!this.scanner.eof) {
|
---|
38 | switch (this.scanner.tokenType) {
|
---|
39 | case WHITESPACE:
|
---|
40 | space = this.WhiteSpace();
|
---|
41 | continue;
|
---|
42 |
|
---|
43 | case COMMENT:
|
---|
44 | this.scanner.next();
|
---|
45 | continue;
|
---|
46 |
|
---|
47 | case FUNCTION:
|
---|
48 | child = this.Function(consumeRaw, this.scope.AtrulePrelude);
|
---|
49 | break;
|
---|
50 |
|
---|
51 | case IDENT:
|
---|
52 | child = this.Identifier();
|
---|
53 | break;
|
---|
54 |
|
---|
55 | case LEFTPARENTHESIS:
|
---|
56 | child = this.Parentheses(parentheses, this.scope.AtrulePrelude);
|
---|
57 | break;
|
---|
58 |
|
---|
59 | default:
|
---|
60 | break scan;
|
---|
61 | }
|
---|
62 |
|
---|
63 | if (space !== null) {
|
---|
64 | children.push(space);
|
---|
65 | space = null;
|
---|
66 | }
|
---|
67 |
|
---|
68 | children.push(child);
|
---|
69 | }
|
---|
70 |
|
---|
71 | return children;
|
---|
72 | }
|
---|
73 |
|
---|
74 | module.exports = {
|
---|
75 | parse: {
|
---|
76 | prelude: function() {
|
---|
77 | var children = readSequence.call(this);
|
---|
78 |
|
---|
79 | if (this.getFirstListNode(children) === null) {
|
---|
80 | this.error('Condition is expected');
|
---|
81 | }
|
---|
82 |
|
---|
83 | return children;
|
---|
84 | },
|
---|
85 | block: function() {
|
---|
86 | return this.Block(false);
|
---|
87 | }
|
---|
88 | }
|
---|
89 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.