You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.1 KiB
44 lines
1.1 KiB
3 years ago
|
var TYPE = require('../../tokenizer').TYPE;
|
||
|
|
||
|
var PLUSSIGN = TYPE.PlusSign;
|
||
|
var SOLIDUS = TYPE.Solidus;
|
||
|
var GREATERTHANSIGN = TYPE.GreaterThanSign;
|
||
|
var TILDE = TYPE.Tilde;
|
||
|
|
||
|
// + | > | ~ | /deep/
|
||
|
module.exports = {
|
||
|
name: 'Combinator',
|
||
|
structure: {
|
||
|
name: String
|
||
|
},
|
||
|
parse: function() {
|
||
|
var start = this.scanner.tokenStart;
|
||
|
|
||
|
switch (this.scanner.tokenType) {
|
||
|
case GREATERTHANSIGN:
|
||
|
case PLUSSIGN:
|
||
|
case TILDE:
|
||
|
this.scanner.next();
|
||
|
break;
|
||
|
|
||
|
case SOLIDUS:
|
||
|
this.scanner.next();
|
||
|
this.scanner.expectIdentifier('deep');
|
||
|
this.scanner.eat(SOLIDUS);
|
||
|
break;
|
||
|
|
||
|
default:
|
||
|
this.scanner.error('Combinator is expected');
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
type: 'Combinator',
|
||
|
loc: this.getLocation(start, this.scanner.tokenStart),
|
||
|
name: this.scanner.substrToCursor(start)
|
||
|
};
|
||
|
},
|
||
|
generate: function(node) {
|
||
|
this.chunk(node.name);
|
||
|
}
|
||
|
};
|