All files / parser/nodes unaryExpression.js

60% Statements 3/5
100% Branches 0/0
33.33% Functions 1/3
60% Lines 3/5
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 36 37 38                                      6x     6x     6x                        
import Node from './node';
 
/**
 * Matches a unary expression
 * 
 * See Also: `BinaryExpression`
 * 
 * This matches any generic unary expression
 */
export default class UnaryExpression extends Node {
    
    /**
     * Creates a wrapper ExperssionStatement
     * 
     * @param {Expression} expression the expression
     * @param {string} operator the operator for the expression
     * @param {Object} position a position from nearley
     */
    constructor (expression: any, operator: string, position: Object) {
        super(position);
        
        /** @type {Expression} */
        this.expression = expression;
        
        /** @type {string} */
        this.op = operator;
    }
    
    /** @override */
    get children () {
        return ['expression'];
    }
    
    /** @override */
    toString() {
        return this.op + `(${this.expression})`
    }
}