All files / parser/nodes identifier.js

100% Statements 4/4
100% Branches 0/0
100% Functions 3/3
100% Lines 4/4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35                                      276x     276x         12x         20x    
import Node from './node';
import Id from '../../scope/scopeItem';
 
/**
 * Wraps a identifier.
 * 
 * Identifiers are specified by the tokenizer but this serves just as a class
 *  which is used for the parser
 * 
 */
export default class Identifier extends Node {
    
    /**
     * Creates an identifier
     * 
     * @param {string} identifier the identifier
     * @param {Object} position a position from nearley
     */
    constructor (identifier: string, position: Object) {
        super(position);
        
        /** @type {string} */
        this.identifier = new Id(identifier, null);
    }
    
    /** @override */
    get children() {
        return null;
    }
    
    /** @override */
    toString() {
        return this.identifier.rootId;
    }
}