All files / parser/nodes ternary.js

0% Statements 0/5
100% Branches 0/0
0% Functions 0/2
0% Lines 0/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                                                                 
import Node from './node';
 
/*
 * M atches a ternary.
 * 
 * This matches a ternary.
 */
export default class Ternary extends Node {
    
    /**
     * Creates a wrapper ExperssionStatement
     * 
     * @param {Expression} condition condition
     * @param {Expression} ifTrue code to execute if true
     * @param {Expression} ifFalse code to execute if false
     * @param {Object} position a position from nearley
     */
    constructor (condition: Expression, ifTrue: Expression, ifFalse: Expression, position: Object) {
        super(position);
        
        /** @type {Expression} */
        this.condition = condition;
        /** @type {Expression} */
        this.ifTrue = ifTrue;
        /** @type {Expression} */
        this.ifFalse = ifFalse;
    }
    
    /** @override */
    get children() {
        return ['condition', 'ifTrue', 'ifFalse'];
    }
}