# All files / src/generators generator.js

100% Statements 20/20
100% Branches 18/18
100% Functions 1/1
100% Lines 20/20

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    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
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64

    12x
    1629x

    662x

    101x

    48x

    53x

    151x

    62x

    34x

    32x

    66x

    36x

    16x

    54x

    52x

    187x

    48x

    20x

    6x

    1x

     // @flow

    import primitive from './primitive'
    import tuple from './tuple'
    import inputProp from './inputProp'
    import valueProp from './valueProp'
    import list from './list'
    import parentheses from './parentheses'
    import object from './object'
    import projection from './projection'
    import objectProjection from './objectProjection'
    import pipe from './pipe'
    import functionCall from './functionCall'
    import binaryOperator from './binaryOperator'
    import unaryOperator from './unaryOperator'
    import ternary from './ternary'
    import assignment from './assignment'
    import lambda from './lambda'
    import variable from './variable'
    import type { NodeType, GeneratedCodeType } from '../types'

    const Generator = (node: NodeType): GeneratedCodeType => {
      switch (node.name) {
        case 'primitive':
          return primitive(node)
        case 'variable':
          return variable(node)
        case 'tuple':
          return tuple(node)
        case 'inputProp':
          return inputProp(node)
        case 'list':
          return list(node)
        case 'pipe':
          return pipe(node)
        case 'valueProp':
          return valueProp(Generator)(node)
        case 'object':
          return object(node)
        case 'parentheses':
          return parentheses(node)
        case 'projection':
          return projection(Generator)(node)
        case 'objectProjection':
          return objectProjection(Generator)(node)
        case 'functionCall':
          return functionCall(Generator)(node)
        case 'lambda':
          return lambda(node)
        case 'binaryOperation':
          return binaryOperator(node)
        case 'unaryOperation':
          return unaryOperator(node)
        case 'assignment':
          return assignment(Generator)(node)
        case 'ternary':
          return ternary(node)
        default:
          throw new Error(`Unknown node name '${node.name}'`)
      }
    }

    export default Generator