Last change
on this file since 6a80231 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Rev | Line | |
---|
[6a3a178] | 1 | var TYPE = require('../../tokenizer').TYPE;
|
---|
| 2 |
|
---|
| 3 | var IDENT = TYPE.Ident;
|
---|
| 4 | var ASTERISK = 0x002A; // U+002A ASTERISK (*)
|
---|
| 5 | var VERTICALLINE = 0x007C; // U+007C VERTICAL LINE (|)
|
---|
| 6 |
|
---|
| 7 | function eatIdentifierOrAsterisk() {
|
---|
| 8 | if (this.scanner.tokenType !== IDENT &&
|
---|
| 9 | this.scanner.isDelim(ASTERISK) === false) {
|
---|
| 10 | this.error('Identifier or asterisk is expected');
|
---|
| 11 | }
|
---|
| 12 |
|
---|
| 13 | this.scanner.next();
|
---|
| 14 | }
|
---|
| 15 |
|
---|
| 16 | // ident
|
---|
| 17 | // ident|ident
|
---|
| 18 | // ident|*
|
---|
| 19 | // *
|
---|
| 20 | // *|ident
|
---|
| 21 | // *|*
|
---|
| 22 | // |ident
|
---|
| 23 | // |*
|
---|
| 24 | module.exports = {
|
---|
| 25 | name: 'TypeSelector',
|
---|
| 26 | structure: {
|
---|
| 27 | name: String
|
---|
| 28 | },
|
---|
| 29 | parse: function() {
|
---|
| 30 | var start = this.scanner.tokenStart;
|
---|
| 31 |
|
---|
| 32 | if (this.scanner.isDelim(VERTICALLINE)) {
|
---|
| 33 | this.scanner.next();
|
---|
| 34 | eatIdentifierOrAsterisk.call(this);
|
---|
| 35 | } else {
|
---|
| 36 | eatIdentifierOrAsterisk.call(this);
|
---|
| 37 |
|
---|
| 38 | if (this.scanner.isDelim(VERTICALLINE)) {
|
---|
| 39 | this.scanner.next();
|
---|
| 40 | eatIdentifierOrAsterisk.call(this);
|
---|
| 41 | }
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | return {
|
---|
| 45 | type: 'TypeSelector',
|
---|
| 46 | loc: this.getLocation(start, this.scanner.tokenStart),
|
---|
| 47 | name: this.scanner.substrToCursor(start)
|
---|
| 48 | };
|
---|
| 49 | },
|
---|
| 50 | generate: function(node) {
|
---|
| 51 | this.chunk(node.name);
|
---|
| 52 | }
|
---|
| 53 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.