csv_plus_plus 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/CHANGELOG.md +16 -1
 - data/README.md +18 -62
 - data/lib/csv_plus_plus/benchmarked_compiler.rb +62 -0
 - data/lib/csv_plus_plus/can_define_references.rb +88 -0
 - data/lib/csv_plus_plus/can_resolve_references.rb +8 -0
 - data/lib/csv_plus_plus/cell.rb +3 -3
 - data/lib/csv_plus_plus/cli.rb +24 -7
 - data/lib/csv_plus_plus/color.rb +12 -6
 - data/lib/csv_plus_plus/compiler.rb +156 -0
 - data/lib/csv_plus_plus/data_validation.rb +138 -0
 - data/lib/csv_plus_plus/{language → entities}/ast_builder.rb +5 -7
 - data/lib/csv_plus_plus/entities/boolean.rb +31 -0
 - data/lib/csv_plus_plus/{language → entities}/builtins.rb +2 -4
 - data/lib/csv_plus_plus/entities/cell_reference.rb +60 -0
 - data/lib/csv_plus_plus/entities/date.rb +30 -0
 - data/lib/csv_plus_plus/entities/entity.rb +84 -0
 - data/lib/csv_plus_plus/entities/function.rb +33 -0
 - data/lib/csv_plus_plus/entities/function_call.rb +35 -0
 - data/lib/csv_plus_plus/entities/number.rb +34 -0
 - data/lib/csv_plus_plus/entities/runtime_value.rb +26 -0
 - data/lib/csv_plus_plus/entities/string.rb +29 -0
 - data/lib/csv_plus_plus/entities/variable.rb +25 -0
 - data/lib/csv_plus_plus/entities.rb +33 -0
 - data/lib/csv_plus_plus/error/error.rb +10 -0
 - data/lib/csv_plus_plus/error/formula_syntax_error.rb +36 -0
 - data/lib/csv_plus_plus/error/modifier_syntax_error.rb +27 -0
 - data/lib/csv_plus_plus/error/modifier_validation_error.rb +49 -0
 - data/lib/csv_plus_plus/{language → error}/syntax_error.rb +6 -14
 - data/lib/csv_plus_plus/error/writer_error.rb +9 -0
 - data/lib/csv_plus_plus/error.rb +9 -2
 - data/lib/csv_plus_plus/expand.rb +3 -1
 - data/lib/csv_plus_plus/google_api_client.rb +4 -0
 - data/lib/csv_plus_plus/lexer/lexer.rb +19 -11
 - data/lib/csv_plus_plus/modifier/conditional_formatting.rb +17 -0
 - data/lib/csv_plus_plus/modifier.rb +73 -70
 - data/lib/csv_plus_plus/options.rb +3 -0
 - data/lib/csv_plus_plus/parser/cell_value.tab.rb +305 -0
 - data/lib/csv_plus_plus/parser/code_section.tab.rb +410 -0
 - data/lib/csv_plus_plus/parser/modifier.tab.rb +484 -0
 - data/lib/csv_plus_plus/references.rb +68 -0
 - data/lib/csv_plus_plus/row.rb +0 -3
 - data/lib/csv_plus_plus/runtime.rb +199 -0
 - data/lib/csv_plus_plus/scope.rb +196 -0
 - data/lib/csv_plus_plus/template.rb +21 -5
 - data/lib/csv_plus_plus/validated_modifier.rb +164 -0
 - data/lib/csv_plus_plus/version.rb +1 -1
 - data/lib/csv_plus_plus/writer/file_backer_upper.rb +6 -4
 - data/lib/csv_plus_plus/writer/google_sheet_builder.rb +24 -29
 - data/lib/csv_plus_plus/writer/google_sheet_modifier.rb +33 -12
 - data/lib/csv_plus_plus/writer/rubyxl_builder.rb +3 -6
 - data/lib/csv_plus_plus.rb +41 -16
 - metadata +34 -24
 - data/lib/csv_plus_plus/code_section.rb +0 -68
 - data/lib/csv_plus_plus/language/benchmarked_compiler.rb +0 -65
 - data/lib/csv_plus_plus/language/cell_value.tab.rb +0 -332
 - data/lib/csv_plus_plus/language/code_section.tab.rb +0 -442
 - data/lib/csv_plus_plus/language/compiler.rb +0 -157
 - data/lib/csv_plus_plus/language/entities/boolean.rb +0 -33
 - data/lib/csv_plus_plus/language/entities/cell_reference.rb +0 -33
 - data/lib/csv_plus_plus/language/entities/entity.rb +0 -86
 - data/lib/csv_plus_plus/language/entities/function.rb +0 -35
 - data/lib/csv_plus_plus/language/entities/function_call.rb +0 -26
 - data/lib/csv_plus_plus/language/entities/number.rb +0 -36
 - data/lib/csv_plus_plus/language/entities/runtime_value.rb +0 -28
 - data/lib/csv_plus_plus/language/entities/string.rb +0 -31
 - data/lib/csv_plus_plus/language/entities/variable.rb +0 -25
 - data/lib/csv_plus_plus/language/entities.rb +0 -28
 - data/lib/csv_plus_plus/language/references.rb +0 -70
 - data/lib/csv_plus_plus/language/runtime.rb +0 -205
 - data/lib/csv_plus_plus/language/scope.rb +0 -188
 - data/lib/csv_plus_plus/modifier.tab.rb +0 -907
 
| 
         @@ -1,442 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            #
         
     | 
| 
       2 
     | 
    
         
            -
            # DO NOT MODIFY!!!!
         
     | 
| 
       3 
     | 
    
         
            -
            # This file is automatically generated by Racc 1.6.2
         
     | 
| 
       4 
     | 
    
         
            -
            # from Racc grammar file "".
         
     | 
| 
       5 
     | 
    
         
            -
            #
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
            require 'racc/parser.rb'
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
            require_relative '../lexer'
         
     | 
| 
       10 
     | 
    
         
            -
            require_relative '../code_section'
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
            module CSVPlusPlus
         
     | 
| 
       13 
     | 
    
         
            -
              module Language
         
     | 
| 
       14 
     | 
    
         
            -
                class CodeSectionParser < Racc::Parser
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
            module_eval(<<'...end code_section.y/module_eval...', 'code_section.y', 67)
         
     | 
| 
       17 
     | 
    
         
            -
              include ::CSVPlusPlus::Lexer
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
              def initialize
         
     | 
| 
       20 
     | 
    
         
            -
                super
         
     | 
| 
       21 
     | 
    
         
            -
                @code_section = CodeSection.new
         
     | 
| 
       22 
     | 
    
         
            -
              end
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
              protected
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
              def anything_to_parse?(input)
         
     | 
| 
       27 
     | 
    
         
            -
                @rest = input.strip
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
                return !@rest.index(::CSVPlusPlus::Lexer::END_OF_CODE_SECTION).nil?
         
     | 
| 
       30 
     | 
    
         
            -
              end
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
              def parse_subject
         
     | 
| 
       33 
     | 
    
         
            -
                'code section'
         
     | 
| 
       34 
     | 
    
         
            -
              end
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
              def tokenizer
         
     | 
| 
       37 
     | 
    
         
            -
                ::CSVPlusPlus::Lexer::Tokenizer.new(
         
     | 
| 
       38 
     | 
    
         
            -
                  catchall: /[\(\)\{\}\/\*\+\-,=&]/,
         
     | 
| 
       39 
     | 
    
         
            -
                  ignore: /\s+|\#[^\n]+\n/,
         
     | 
| 
       40 
     | 
    
         
            -
                  stop_fn: lambda do |scanner|
         
     | 
| 
       41 
     | 
    
         
            -
                    return false unless scanner.scan(/#{::CSVPlusPlus::Lexer::END_OF_CODE_SECTION}/)
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
                    @tokens << [:END_OF_CODE, scanner.matched]
         
     | 
| 
       44 
     | 
    
         
            -
                    @rest = scanner.rest.strip
         
     | 
| 
       45 
     | 
    
         
            -
                    true
         
     | 
| 
       46 
     | 
    
         
            -
                  end,
         
     | 
| 
       47 
     | 
    
         
            -
                  tokens: [
         
     | 
| 
       48 
     | 
    
         
            -
                    [/\n/, :EOL],
         
     | 
| 
       49 
     | 
    
         
            -
                    [/:=/, :ASSIGN],
         
     | 
| 
       50 
     | 
    
         
            -
                    [/\bdef\b/, :FN_DEF],
         
     | 
| 
       51 
     | 
    
         
            -
                    [/\bTRUE\b/i, :TRUE],
         
     | 
| 
       52 
     | 
    
         
            -
                    [/\bFALSE\b/i, :FALSE],
         
     | 
| 
       53 
     | 
    
         
            -
                    [/"(?:[^"\\]|\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4}))*"/, :STRING],
         
     | 
| 
       54 
     | 
    
         
            -
                    [/-?[\d.]+/, :NUMBER],
         
     | 
| 
       55 
     | 
    
         
            -
                    [/\$\$/, :VAR_REF],
         
     | 
| 
       56 
     | 
    
         
            -
                    [/[!:\w_]+/, :ID],
         
     | 
| 
       57 
     | 
    
         
            -
                  ],
         
     | 
| 
       58 
     | 
    
         
            -
                )
         
     | 
| 
       59 
     | 
    
         
            -
              end
         
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
              def return_value
         
     | 
| 
       62 
     | 
    
         
            -
                [@code_section, @rest]
         
     | 
| 
       63 
     | 
    
         
            -
              end
         
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
              private
         
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
              def e(type, *entity_args)
         
     | 
| 
       68 
     | 
    
         
            -
                ::CSVPlusPlus::Language::TYPES[type].new(*entity_args)
         
     | 
| 
       69 
     | 
    
         
            -
              end
         
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
              def def_function(id, arguments, body)
         
     | 
| 
       72 
     | 
    
         
            -
                fn_def = e(:function, id, arguments, body)
         
     | 
| 
       73 
     | 
    
         
            -
                @code_section.def_function(fn_def.id, fn_def)
         
     | 
| 
       74 
     | 
    
         
            -
              end
         
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
              def def_variable(id, ast)
         
     | 
| 
       77 
     | 
    
         
            -
                @code_section.def_variable(id, ast)
         
     | 
| 
       78 
     | 
    
         
            -
              end
         
     | 
| 
       79 
     | 
    
         
            -
            ...end code_section.y/module_eval...
         
     | 
| 
       80 
     | 
    
         
            -
            ##### State transition tables begin ###
         
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
     | 
    
         
            -
            racc_action_table = [
         
     | 
| 
       83 
     | 
    
         
            -
                45,    27,     3,    37,    51,     7,    38,    52,    28,     9,
         
     | 
| 
       84 
     | 
    
         
            -
                19,     8,    29,    30,    31,    32,    33,    24,    25,    22,
         
     | 
| 
       85 
     | 
    
         
            -
                21,    23,    20,    19,    29,    30,    31,    32,    33,    19,
         
     | 
| 
       86 
     | 
    
         
            -
                24,    25,    22,    21,    23,    20,    24,    25,    22,    21,
         
     | 
| 
       87 
     | 
    
         
            -
                23,    20,    19,    29,    30,    31,    32,    33,    19,    24,
         
     | 
| 
       88 
     | 
    
         
            -
                25,    22,    21,    23,    20,    24,    25,    22,    21,    23,
         
     | 
| 
       89 
     | 
    
         
            -
                20,    19,    29,    30,    31,    32,    33,    19,    24,    25,
         
     | 
| 
       90 
     | 
    
         
            -
                22,    21,    23,    20,    24,    25,    22,    21,    23,    20,
         
     | 
| 
       91 
     | 
    
         
            -
                19,    29,    30,    31,    32,    33,    12,    24,    25,    22,
         
     | 
| 
       92 
     | 
    
         
            -
                21,    23,    20,    19,    48,    13,    14,    15,    35,    19,
         
     | 
| 
       93 
     | 
    
         
            -
                24,    25,    22,    21,    23,    20,    24,    25,    22,    21,
         
     | 
| 
       94 
     | 
    
         
            -
                23,    20,    19,    29,    30,    31,    32,    33,    36,    24,
         
     | 
| 
       95 
     | 
    
         
            -
                25,    22,    21,    23,    20,    10,    50,   nil,     7,    29,
         
     | 
| 
       96 
     | 
    
         
            -
                30,    31,    32,    33,     8,    29,    30,    31,    32,    33,
         
     | 
| 
       97 
     | 
    
         
            -
                29,    30,    31,    32,    33,    29,    30,    31,    32,    33,
         
     | 
| 
       98 
     | 
    
         
            -
                29,    30,    31,    32,    33 ]
         
     | 
| 
       99 
     | 
    
         
            -
             
     | 
| 
       100 
     | 
    
         
            -
            racc_action_check = [
         
     | 
| 
       101 
     | 
    
         
            -
                34,    15,     0,    26,    47,     0,    26,    47,    15,     1,
         
     | 
| 
       102 
     | 
    
         
            -
                13,     0,    34,    34,    34,    34,    34,    13,    13,    13,
         
     | 
| 
       103 
     | 
    
         
            -
                13,    13,    13,    19,    16,    16,    16,    16,    16,    27,
         
     | 
| 
       104 
     | 
    
         
            -
                19,    19,    19,    19,    19,    19,    27,    27,    27,    27,
         
     | 
| 
       105 
     | 
    
         
            -
                27,    27,    29,    39,    39,    39,    39,    39,    30,    29,
         
     | 
| 
       106 
     | 
    
         
            -
                29,    29,    29,    29,    29,    30,    30,    30,    30,    30,
         
     | 
| 
       107 
     | 
    
         
            -
                30,    31,    40,    40,    40,    40,    40,    32,    31,    31,
         
     | 
| 
       108 
     | 
    
         
            -
                31,    31,    31,    31,    32,    32,    32,    32,    32,    32,
         
     | 
| 
       109 
     | 
    
         
            -
                33,    41,    41,    41,    41,    41,     7,    33,    33,    33,
         
     | 
| 
       110 
     | 
    
         
            -
                33,    33,    33,    36,    36,     8,     9,    12,    20,    37,
         
     | 
| 
       111 
     | 
    
         
            -
                36,    36,    36,    36,    36,    36,    37,    37,    37,    37,
         
     | 
| 
       112 
     | 
    
         
            -
                37,    37,    52,    42,    42,    42,    42,    42,    25,    52,
         
     | 
| 
       113 
     | 
    
         
            -
                52,    52,    52,    52,    52,     2,    38,   nil,     2,    43,
         
     | 
| 
       114 
     | 
    
         
            -
                43,    43,    43,    43,     2,    44,    44,    44,    44,    44,
         
     | 
| 
       115 
     | 
    
         
            -
                46,    46,    46,    46,    46,    49,    49,    49,    49,    49,
         
     | 
| 
       116 
     | 
    
         
            -
                53,    53,    53,    53,    53 ]
         
     | 
| 
       117 
     | 
    
         
            -
             
     | 
| 
       118 
     | 
    
         
            -
            racc_action_pointer = [
         
     | 
| 
       119 
     | 
    
         
            -
                 0,     9,   123,   nil,   nil,   nil,   nil,    75,    89,    96,
         
     | 
| 
       120 
     | 
    
         
            -
               nil,   nil,    94,     7,   nil,    -3,     8,   nil,   nil,    20,
         
     | 
| 
       121 
     | 
    
         
            -
                87,   nil,   nil,   nil,   nil,   115,    -1,    26,   nil,    39,
         
     | 
| 
       122 
     | 
    
         
            -
                45,    58,    64,    77,    -4,   nil,    90,    96,   115,    27,
         
     | 
| 
       123 
     | 
    
         
            -
                46,    65,    97,   113,   119,   nil,   124,     0,   nil,   129,
         
     | 
| 
       124 
     | 
    
         
            -
               nil,   nil,   109,   134 ]
         
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
       126 
     | 
    
         
            -
            racc_action_default = [
         
     | 
| 
       127 
     | 
    
         
            -
               -30,   -30,   -30,    -2,    -4,    -5,    -6,   -30,   -30,   -30,
         
     | 
| 
       128 
     | 
    
         
            -
                -1,    -3,   -30,   -30,    54,   -30,   -11,   -12,   -13,   -30,
         
     | 
| 
       129 
     | 
    
         
            -
               -30,   -16,   -17,   -18,   -19,   -20,   -30,   -30,   -10,   -30,
         
     | 
| 
       130 
     | 
    
         
            -
               -30,   -30,   -30,   -30,   -30,   -15,   -30,   -30,   -30,    -8,
         
     | 
| 
       131 
     | 
    
         
            -
               -21,   -22,   -23,   -24,   -25,   -14,   -29,   -30,   -27,    -7,
         
     | 
| 
       132 
     | 
    
         
            -
                -9,   -26,   -30,   -28 ]
         
     | 
| 
       133 
     | 
    
         
            -
             
     | 
| 
       134 
     | 
    
         
            -
            racc_goto_table = [
         
     | 
| 
       135 
     | 
    
         
            -
                16,     4,     1,    11,     2,    26,    34,    47,   nil,   nil,
         
     | 
| 
       136 
     | 
    
         
            -
               nil,   nil,   nil,   nil,    39,   nil,    40,    41,    42,    43,
         
     | 
| 
       137 
     | 
    
         
            -
                44,   nil,   nil,    46,    49,   nil,   nil,   nil,   nil,   nil,
         
     | 
| 
       138 
     | 
    
         
            -
               nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,    53 ]
         
     | 
| 
       139 
     | 
    
         
            -
             
     | 
| 
       140 
     | 
    
         
            -
            racc_goto_check = [
         
     | 
| 
       141 
     | 
    
         
            -
                 7,     3,     1,     3,     2,     6,     7,    10,   nil,   nil,
         
     | 
| 
       142 
     | 
    
         
            -
               nil,   nil,   nil,   nil,     7,   nil,     7,     7,     7,     7,
         
     | 
| 
       143 
     | 
    
         
            -
                 7,   nil,   nil,     7,     7,   nil,   nil,   nil,   nil,   nil,
         
     | 
| 
       144 
     | 
    
         
            -
               nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,     7 ]
         
     | 
| 
       145 
     | 
    
         
            -
             
     | 
| 
       146 
     | 
    
         
            -
            racc_goto_pointer = [
         
     | 
| 
       147 
     | 
    
         
            -
               nil,     2,     4,     1,   nil,   nil,   -10,   -13,   nil,   nil,
         
     | 
| 
       148 
     | 
    
         
            -
               -29 ]
         
     | 
| 
       149 
     | 
    
         
            -
             
     | 
| 
       150 
     | 
    
         
            -
            racc_goto_default = [
         
     | 
| 
       151 
     | 
    
         
            -
               nil,   nil,   nil,   nil,     5,     6,   nil,   nil,    17,    18,
         
     | 
| 
       152 
     | 
    
         
            -
               nil ]
         
     | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
       154 
     | 
    
         
            -
            racc_reduce_table = [
         
     | 
| 
       155 
     | 
    
         
            -
              0, 0, :racc_error,
         
     | 
| 
       156 
     | 
    
         
            -
              2, 22, :_reduce_none,
         
     | 
| 
       157 
     | 
    
         
            -
              1, 22, :_reduce_none,
         
     | 
| 
       158 
     | 
    
         
            -
              2, 23, :_reduce_none,
         
     | 
| 
       159 
     | 
    
         
            -
              1, 23, :_reduce_none,
         
     | 
| 
       160 
     | 
    
         
            -
              1, 24, :_reduce_none,
         
     | 
| 
       161 
     | 
    
         
            -
              1, 24, :_reduce_none,
         
     | 
| 
       162 
     | 
    
         
            -
              6, 25, :_reduce_7,
         
     | 
| 
       163 
     | 
    
         
            -
              5, 25, :_reduce_8,
         
     | 
| 
       164 
     | 
    
         
            -
              3, 27, :_reduce_9,
         
     | 
| 
       165 
     | 
    
         
            -
              1, 27, :_reduce_10,
         
     | 
| 
       166 
     | 
    
         
            -
              3, 26, :_reduce_11,
         
     | 
| 
       167 
     | 
    
         
            -
              1, 28, :_reduce_none,
         
     | 
| 
       168 
     | 
    
         
            -
              1, 28, :_reduce_none,
         
     | 
| 
       169 
     | 
    
         
            -
              3, 28, :_reduce_14,
         
     | 
| 
       170 
     | 
    
         
            -
              2, 28, :_reduce_15,
         
     | 
| 
       171 
     | 
    
         
            -
              1, 28, :_reduce_16,
         
     | 
| 
       172 
     | 
    
         
            -
              1, 28, :_reduce_17,
         
     | 
| 
       173 
     | 
    
         
            -
              1, 28, :_reduce_18,
         
     | 
| 
       174 
     | 
    
         
            -
              1, 28, :_reduce_19,
         
     | 
| 
       175 
     | 
    
         
            -
              1, 28, :_reduce_20,
         
     | 
| 
       176 
     | 
    
         
            -
              3, 30, :_reduce_21,
         
     | 
| 
       177 
     | 
    
         
            -
              3, 30, :_reduce_22,
         
     | 
| 
       178 
     | 
    
         
            -
              3, 30, :_reduce_23,
         
     | 
| 
       179 
     | 
    
         
            -
              3, 30, :_reduce_24,
         
     | 
| 
       180 
     | 
    
         
            -
              3, 30, :_reduce_25,
         
     | 
| 
       181 
     | 
    
         
            -
              4, 29, :_reduce_26,
         
     | 
| 
       182 
     | 
    
         
            -
              3, 29, :_reduce_27,
         
     | 
| 
       183 
     | 
    
         
            -
              3, 31, :_reduce_28,
         
     | 
| 
       184 
     | 
    
         
            -
              1, 31, :_reduce_29 ]
         
     | 
| 
       185 
     | 
    
         
            -
             
     | 
| 
       186 
     | 
    
         
            -
            racc_reduce_n = 30
         
     | 
| 
       187 
     | 
    
         
            -
             
     | 
| 
       188 
     | 
    
         
            -
            racc_shift_n = 54
         
     | 
| 
       189 
     | 
    
         
            -
             
     | 
| 
       190 
     | 
    
         
            -
            racc_token_table = {
         
     | 
| 
       191 
     | 
    
         
            -
              false => 0,
         
     | 
| 
       192 
     | 
    
         
            -
              :error => 1,
         
     | 
| 
       193 
     | 
    
         
            -
              :END_OF_CODE => 2,
         
     | 
| 
       194 
     | 
    
         
            -
              "(" => 3,
         
     | 
| 
       195 
     | 
    
         
            -
              ")" => 4,
         
     | 
| 
       196 
     | 
    
         
            -
              :FN_DEF => 5,
         
     | 
| 
       197 
     | 
    
         
            -
              :ASSIGN => 6,
         
     | 
| 
       198 
     | 
    
         
            -
              "," => 7,
         
     | 
| 
       199 
     | 
    
         
            -
              :CELL_REF => 8,
         
     | 
| 
       200 
     | 
    
         
            -
              :EOL => 9,
         
     | 
| 
       201 
     | 
    
         
            -
              :FALSE => 10,
         
     | 
| 
       202 
     | 
    
         
            -
              :ID => 11,
         
     | 
| 
       203 
     | 
    
         
            -
              :NUMBER => 12,
         
     | 
| 
       204 
     | 
    
         
            -
              :STRING => 13,
         
     | 
| 
       205 
     | 
    
         
            -
              :TRUE => 14,
         
     | 
| 
       206 
     | 
    
         
            -
              :VAR_REF => 15,
         
     | 
| 
       207 
     | 
    
         
            -
              "&" => 16,
         
     | 
| 
       208 
     | 
    
         
            -
              "*" => 17,
         
     | 
| 
       209 
     | 
    
         
            -
              "+" => 18,
         
     | 
| 
       210 
     | 
    
         
            -
              "-" => 19,
         
     | 
| 
       211 
     | 
    
         
            -
              "/" => 20 }
         
     | 
| 
       212 
     | 
    
         
            -
             
     | 
| 
       213 
     | 
    
         
            -
            racc_nt_base = 21
         
     | 
| 
       214 
     | 
    
         
            -
             
     | 
| 
       215 
     | 
    
         
            -
            racc_use_result_var = true
         
     | 
| 
       216 
     | 
    
         
            -
             
     | 
| 
       217 
     | 
    
         
            -
            Racc_arg = [
         
     | 
| 
       218 
     | 
    
         
            -
              racc_action_table,
         
     | 
| 
       219 
     | 
    
         
            -
              racc_action_check,
         
     | 
| 
       220 
     | 
    
         
            -
              racc_action_default,
         
     | 
| 
       221 
     | 
    
         
            -
              racc_action_pointer,
         
     | 
| 
       222 
     | 
    
         
            -
              racc_goto_table,
         
     | 
| 
       223 
     | 
    
         
            -
              racc_goto_check,
         
     | 
| 
       224 
     | 
    
         
            -
              racc_goto_default,
         
     | 
| 
       225 
     | 
    
         
            -
              racc_goto_pointer,
         
     | 
| 
       226 
     | 
    
         
            -
              racc_nt_base,
         
     | 
| 
       227 
     | 
    
         
            -
              racc_reduce_table,
         
     | 
| 
       228 
     | 
    
         
            -
              racc_token_table,
         
     | 
| 
       229 
     | 
    
         
            -
              racc_shift_n,
         
     | 
| 
       230 
     | 
    
         
            -
              racc_reduce_n,
         
     | 
| 
       231 
     | 
    
         
            -
              racc_use_result_var ]
         
     | 
| 
       232 
     | 
    
         
            -
             
     | 
| 
       233 
     | 
    
         
            -
            Racc_token_to_s_table = [
         
     | 
| 
       234 
     | 
    
         
            -
              "$end",
         
     | 
| 
       235 
     | 
    
         
            -
              "error",
         
     | 
| 
       236 
     | 
    
         
            -
              "END_OF_CODE",
         
     | 
| 
       237 
     | 
    
         
            -
              "\"(\"",
         
     | 
| 
       238 
     | 
    
         
            -
              "\")\"",
         
     | 
| 
       239 
     | 
    
         
            -
              "FN_DEF",
         
     | 
| 
       240 
     | 
    
         
            -
              "ASSIGN",
         
     | 
| 
       241 
     | 
    
         
            -
              "\",\"",
         
     | 
| 
       242 
     | 
    
         
            -
              "CELL_REF",
         
     | 
| 
       243 
     | 
    
         
            -
              "EOL",
         
     | 
| 
       244 
     | 
    
         
            -
              "FALSE",
         
     | 
| 
       245 
     | 
    
         
            -
              "ID",
         
     | 
| 
       246 
     | 
    
         
            -
              "NUMBER",
         
     | 
| 
       247 
     | 
    
         
            -
              "STRING",
         
     | 
| 
       248 
     | 
    
         
            -
              "TRUE",
         
     | 
| 
       249 
     | 
    
         
            -
              "VAR_REF",
         
     | 
| 
       250 
     | 
    
         
            -
              "\"&\"",
         
     | 
| 
       251 
     | 
    
         
            -
              "\"*\"",
         
     | 
| 
       252 
     | 
    
         
            -
              "\"+\"",
         
     | 
| 
       253 
     | 
    
         
            -
              "\"-\"",
         
     | 
| 
       254 
     | 
    
         
            -
              "\"/\"",
         
     | 
| 
       255 
     | 
    
         
            -
              "$start",
         
     | 
| 
       256 
     | 
    
         
            -
              "code_section",
         
     | 
| 
       257 
     | 
    
         
            -
              "code",
         
     | 
| 
       258 
     | 
    
         
            -
              "def",
         
     | 
| 
       259 
     | 
    
         
            -
              "fn_def",
         
     | 
| 
       260 
     | 
    
         
            -
              "var_def",
         
     | 
| 
       261 
     | 
    
         
            -
              "fn_def_args",
         
     | 
| 
       262 
     | 
    
         
            -
              "exp",
         
     | 
| 
       263 
     | 
    
         
            -
              "fn_call",
         
     | 
| 
       264 
     | 
    
         
            -
              "infix_fn_call",
         
     | 
| 
       265 
     | 
    
         
            -
              "fn_call_args" ]
         
     | 
| 
       266 
     | 
    
         
            -
             
     | 
| 
       267 
     | 
    
         
            -
            Racc_debug_parser = false
         
     | 
| 
       268 
     | 
    
         
            -
             
     | 
| 
       269 
     | 
    
         
            -
            ##### State transition tables end #####
         
     | 
| 
       270 
     | 
    
         
            -
             
     | 
| 
       271 
     | 
    
         
            -
            # reduce 0 omitted
         
     | 
| 
       272 
     | 
    
         
            -
             
     | 
| 
       273 
     | 
    
         
            -
            # reduce 1 omitted
         
     | 
| 
       274 
     | 
    
         
            -
             
     | 
| 
       275 
     | 
    
         
            -
            # reduce 2 omitted
         
     | 
| 
       276 
     | 
    
         
            -
             
     | 
| 
       277 
     | 
    
         
            -
            # reduce 3 omitted
         
     | 
| 
       278 
     | 
    
         
            -
             
     | 
| 
       279 
     | 
    
         
            -
            # reduce 4 omitted
         
     | 
| 
       280 
     | 
    
         
            -
             
     | 
| 
       281 
     | 
    
         
            -
            # reduce 5 omitted
         
     | 
| 
       282 
     | 
    
         
            -
             
     | 
| 
       283 
     | 
    
         
            -
            # reduce 6 omitted
         
     | 
| 
       284 
     | 
    
         
            -
             
     | 
| 
       285 
     | 
    
         
            -
            module_eval(<<'.,.,', 'code_section.y', 29)
         
     | 
| 
       286 
     | 
    
         
            -
              def _reduce_7(val, _values, result)
         
     | 
| 
       287 
     | 
    
         
            -
                 def_function(val[1], val[3], val[5])
         
     | 
| 
       288 
     | 
    
         
            -
                result
         
     | 
| 
       289 
     | 
    
         
            -
              end
         
     | 
| 
       290 
     | 
    
         
            -
            .,.,
         
     | 
| 
       291 
     | 
    
         
            -
             
     | 
| 
       292 
     | 
    
         
            -
            module_eval(<<'.,.,', 'code_section.y', 30)
         
     | 
| 
       293 
     | 
    
         
            -
              def _reduce_8(val, _values, result)
         
     | 
| 
       294 
     | 
    
         
            -
                 def_function(val[1], [], val[4])
         
     | 
| 
       295 
     | 
    
         
            -
                result
         
     | 
| 
       296 
     | 
    
         
            -
              end
         
     | 
| 
       297 
     | 
    
         
            -
            .,.,
         
     | 
| 
       298 
     | 
    
         
            -
             
     | 
| 
       299 
     | 
    
         
            -
            module_eval(<<'.,.,', 'code_section.y', 32)
         
     | 
| 
       300 
     | 
    
         
            -
              def _reduce_9(val, _values, result)
         
     | 
| 
       301 
     | 
    
         
            -
                 result = val[0] << val[2]
         
     | 
| 
       302 
     | 
    
         
            -
                result
         
     | 
| 
       303 
     | 
    
         
            -
              end
         
     | 
| 
       304 
     | 
    
         
            -
            .,.,
         
     | 
| 
       305 
     | 
    
         
            -
             
     | 
| 
       306 
     | 
    
         
            -
            module_eval(<<'.,.,', 'code_section.y', 33)
         
     | 
| 
       307 
     | 
    
         
            -
              def _reduce_10(val, _values, result)
         
     | 
| 
       308 
     | 
    
         
            -
                 result = [val[0]]
         
     | 
| 
       309 
     | 
    
         
            -
                result
         
     | 
| 
       310 
     | 
    
         
            -
              end
         
     | 
| 
       311 
     | 
    
         
            -
            .,.,
         
     | 
| 
       312 
     | 
    
         
            -
             
     | 
| 
       313 
     | 
    
         
            -
            module_eval(<<'.,.,', 'code_section.y', 35)
         
     | 
| 
       314 
     | 
    
         
            -
              def _reduce_11(val, _values, result)
         
     | 
| 
       315 
     | 
    
         
            -
                 def_variable(val[0], val[2])
         
     | 
| 
       316 
     | 
    
         
            -
                result
         
     | 
| 
       317 
     | 
    
         
            -
              end
         
     | 
| 
       318 
     | 
    
         
            -
            .,.,
         
     | 
| 
       319 
     | 
    
         
            -
             
     | 
| 
       320 
     | 
    
         
            -
            # reduce 12 omitted
         
     | 
| 
       321 
     | 
    
         
            -
             
     | 
| 
       322 
     | 
    
         
            -
            # reduce 13 omitted
         
     | 
| 
       323 
     | 
    
         
            -
             
     | 
| 
       324 
     | 
    
         
            -
            module_eval(<<'.,.,', 'code_section.y', 39)
         
     | 
| 
       325 
     | 
    
         
            -
              def _reduce_14(val, _values, result)
         
     | 
| 
       326 
     | 
    
         
            -
                 result = val[1]
         
     | 
| 
       327 
     | 
    
         
            -
                result
         
     | 
| 
       328 
     | 
    
         
            -
              end
         
     | 
| 
       329 
     | 
    
         
            -
            .,.,
         
     | 
| 
       330 
     | 
    
         
            -
             
     | 
| 
       331 
     | 
    
         
            -
            module_eval(<<'.,.,', 'code_section.y', 40)
         
     | 
| 
       332 
     | 
    
         
            -
              def _reduce_15(val, _values, result)
         
     | 
| 
       333 
     | 
    
         
            -
                 result = e(:variable, val[1])
         
     | 
| 
       334 
     | 
    
         
            -
                result
         
     | 
| 
       335 
     | 
    
         
            -
              end
         
     | 
| 
       336 
     | 
    
         
            -
            .,.,
         
     | 
| 
       337 
     | 
    
         
            -
             
     | 
| 
       338 
     | 
    
         
            -
            module_eval(<<'.,.,', 'code_section.y', 41)
         
     | 
| 
       339 
     | 
    
         
            -
              def _reduce_16(val, _values, result)
         
     | 
| 
       340 
     | 
    
         
            -
                 result = e(:string, val[0])
         
     | 
| 
       341 
     | 
    
         
            -
                result
         
     | 
| 
       342 
     | 
    
         
            -
              end
         
     | 
| 
       343 
     | 
    
         
            -
            .,.,
         
     | 
| 
       344 
     | 
    
         
            -
             
     | 
| 
       345 
     | 
    
         
            -
            module_eval(<<'.,.,', 'code_section.y', 42)
         
     | 
| 
       346 
     | 
    
         
            -
              def _reduce_17(val, _values, result)
         
     | 
| 
       347 
     | 
    
         
            -
                 result = e(:number, val[0])
         
     | 
| 
       348 
     | 
    
         
            -
                result
         
     | 
| 
       349 
     | 
    
         
            -
              end
         
     | 
| 
       350 
     | 
    
         
            -
            .,.,
         
     | 
| 
       351 
     | 
    
         
            -
             
     | 
| 
       352 
     | 
    
         
            -
            module_eval(<<'.,.,', 'code_section.y', 43)
         
     | 
| 
       353 
     | 
    
         
            -
              def _reduce_18(val, _values, result)
         
     | 
| 
       354 
     | 
    
         
            -
                 result = e(:boolean, true)
         
     | 
| 
       355 
     | 
    
         
            -
                result
         
     | 
| 
       356 
     | 
    
         
            -
              end
         
     | 
| 
       357 
     | 
    
         
            -
            .,.,
         
     | 
| 
       358 
     | 
    
         
            -
             
     | 
| 
       359 
     | 
    
         
            -
            module_eval(<<'.,.,', 'code_section.y', 44)
         
     | 
| 
       360 
     | 
    
         
            -
              def _reduce_19(val, _values, result)
         
     | 
| 
       361 
     | 
    
         
            -
                 result = e(:boolean, false)
         
     | 
| 
       362 
     | 
    
         
            -
                result
         
     | 
| 
       363 
     | 
    
         
            -
              end
         
     | 
| 
       364 
     | 
    
         
            -
            .,.,
         
     | 
| 
       365 
     | 
    
         
            -
             
     | 
| 
       366 
     | 
    
         
            -
            module_eval(<<'.,.,', 'code_section.y', 45)
         
     | 
| 
       367 
     | 
    
         
            -
              def _reduce_20(val, _values, result)
         
     | 
| 
       368 
     | 
    
         
            -
                 result = e(:cell_reference, val[0])
         
     | 
| 
       369 
     | 
    
         
            -
                result
         
     | 
| 
       370 
     | 
    
         
            -
              end
         
     | 
| 
       371 
     | 
    
         
            -
            .,.,
         
     | 
| 
       372 
     | 
    
         
            -
             
     | 
| 
       373 
     | 
    
         
            -
            module_eval(<<'.,.,', 'code_section.y', 47)
         
     | 
| 
       374 
     | 
    
         
            -
              def _reduce_21(val, _values, result)
         
     | 
| 
       375 
     | 
    
         
            -
                 result = e(:function_call, :concat, [val[0], val[2]])
         
     | 
| 
       376 
     | 
    
         
            -
                result
         
     | 
| 
       377 
     | 
    
         
            -
              end
         
     | 
| 
       378 
     | 
    
         
            -
            .,.,
         
     | 
| 
       379 
     | 
    
         
            -
             
     | 
| 
       380 
     | 
    
         
            -
            module_eval(<<'.,.,', 'code_section.y', 48)
         
     | 
| 
       381 
     | 
    
         
            -
              def _reduce_22(val, _values, result)
         
     | 
| 
       382 
     | 
    
         
            -
                 result = e(:function_call, :multiply, [val[0], val[2]])
         
     | 
| 
       383 
     | 
    
         
            -
                result
         
     | 
| 
       384 
     | 
    
         
            -
              end
         
     | 
| 
       385 
     | 
    
         
            -
            .,.,
         
     | 
| 
       386 
     | 
    
         
            -
             
     | 
| 
       387 
     | 
    
         
            -
            module_eval(<<'.,.,', 'code_section.y', 49)
         
     | 
| 
       388 
     | 
    
         
            -
              def _reduce_23(val, _values, result)
         
     | 
| 
       389 
     | 
    
         
            -
                 result = e(:function_call, :add, [val[0], val[2]])
         
     | 
| 
       390 
     | 
    
         
            -
                result
         
     | 
| 
       391 
     | 
    
         
            -
              end
         
     | 
| 
       392 
     | 
    
         
            -
            .,.,
         
     | 
| 
       393 
     | 
    
         
            -
             
     | 
| 
       394 
     | 
    
         
            -
            module_eval(<<'.,.,', 'code_section.y', 50)
         
     | 
| 
       395 
     | 
    
         
            -
              def _reduce_24(val, _values, result)
         
     | 
| 
       396 
     | 
    
         
            -
                 result = e(:function_call, :minus, [val[0], val[2]])
         
     | 
| 
       397 
     | 
    
         
            -
                result
         
     | 
| 
       398 
     | 
    
         
            -
              end
         
     | 
| 
       399 
     | 
    
         
            -
            .,.,
         
     | 
| 
       400 
     | 
    
         
            -
             
     | 
| 
       401 
     | 
    
         
            -
            module_eval(<<'.,.,', 'code_section.y', 51)
         
     | 
| 
       402 
     | 
    
         
            -
              def _reduce_25(val, _values, result)
         
     | 
| 
       403 
     | 
    
         
            -
                 result = e(:function_call, :divide, [val[0], val[2]])
         
     | 
| 
       404 
     | 
    
         
            -
                result
         
     | 
| 
       405 
     | 
    
         
            -
              end
         
     | 
| 
       406 
     | 
    
         
            -
            .,.,
         
     | 
| 
       407 
     | 
    
         
            -
             
     | 
| 
       408 
     | 
    
         
            -
            module_eval(<<'.,.,', 'code_section.y', 53)
         
     | 
| 
       409 
     | 
    
         
            -
              def _reduce_26(val, _values, result)
         
     | 
| 
       410 
     | 
    
         
            -
                 result = e(:function_call, val[0], val[2])
         
     | 
| 
       411 
     | 
    
         
            -
                result
         
     | 
| 
       412 
     | 
    
         
            -
              end
         
     | 
| 
       413 
     | 
    
         
            -
            .,.,
         
     | 
| 
       414 
     | 
    
         
            -
             
     | 
| 
       415 
     | 
    
         
            -
            module_eval(<<'.,.,', 'code_section.y', 54)
         
     | 
| 
       416 
     | 
    
         
            -
              def _reduce_27(val, _values, result)
         
     | 
| 
       417 
     | 
    
         
            -
                 result = e(:function_call, val[0], [])
         
     | 
| 
       418 
     | 
    
         
            -
                result
         
     | 
| 
       419 
     | 
    
         
            -
              end
         
     | 
| 
       420 
     | 
    
         
            -
            .,.,
         
     | 
| 
       421 
     | 
    
         
            -
             
     | 
| 
       422 
     | 
    
         
            -
            module_eval(<<'.,.,', 'code_section.y', 56)
         
     | 
| 
       423 
     | 
    
         
            -
              def _reduce_28(val, _values, result)
         
     | 
| 
       424 
     | 
    
         
            -
                 result = val[0] << val[2]
         
     | 
| 
       425 
     | 
    
         
            -
                result
         
     | 
| 
       426 
     | 
    
         
            -
              end
         
     | 
| 
       427 
     | 
    
         
            -
            .,.,
         
     | 
| 
       428 
     | 
    
         
            -
             
     | 
| 
       429 
     | 
    
         
            -
            module_eval(<<'.,.,', 'code_section.y', 57)
         
     | 
| 
       430 
     | 
    
         
            -
              def _reduce_29(val, _values, result)
         
     | 
| 
       431 
     | 
    
         
            -
                 result = [val[0]]
         
     | 
| 
       432 
     | 
    
         
            -
                result
         
     | 
| 
       433 
     | 
    
         
            -
              end
         
     | 
| 
       434 
     | 
    
         
            -
            .,.,
         
     | 
| 
       435 
     | 
    
         
            -
             
     | 
| 
       436 
     | 
    
         
            -
            def _reduce_none(val, _values, result)
         
     | 
| 
       437 
     | 
    
         
            -
              val[0]
         
     | 
| 
       438 
     | 
    
         
            -
            end
         
     | 
| 
       439 
     | 
    
         
            -
             
     | 
| 
       440 
     | 
    
         
            -
                end   # class CodeSectionParser
         
     | 
| 
       441 
     | 
    
         
            -
              end   # module Language
         
     | 
| 
       442 
     | 
    
         
            -
            end   # module CSVPlusPlus
         
     | 
| 
         @@ -1,157 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # frozen_string_literal: true
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            require 'csv'
         
     | 
| 
       4 
     | 
    
         
            -
            # TODO: move some of these out to csv_plus_plus.rb
         
     | 
| 
       5 
     | 
    
         
            -
            require_relative '../cell'
         
     | 
| 
       6 
     | 
    
         
            -
            require_relative '../modifier'
         
     | 
| 
       7 
     | 
    
         
            -
            require_relative '../modifier.tab'
         
     | 
| 
       8 
     | 
    
         
            -
            require_relative '../row'
         
     | 
| 
       9 
     | 
    
         
            -
            require_relative '../template'
         
     | 
| 
       10 
     | 
    
         
            -
            require_relative 'benchmarked_compiler'
         
     | 
| 
       11 
     | 
    
         
            -
            require_relative 'code_section.tab'
         
     | 
| 
       12 
     | 
    
         
            -
            require_relative 'entities'
         
     | 
| 
       13 
     | 
    
         
            -
            require_relative 'runtime'
         
     | 
| 
       14 
     | 
    
         
            -
            require_relative 'scope'
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
            module CSVPlusPlus
         
     | 
| 
       17 
     | 
    
         
            -
              module Language
         
     | 
| 
       18 
     | 
    
         
            -
                # Encapsulates the parsing and building of objects (+Template+ -> +Row+ -> +Cell+). Variable resolution is delegated
         
     | 
| 
       19 
     | 
    
         
            -
                # to the +Scope+
         
     | 
| 
       20 
     | 
    
         
            -
                #
         
     | 
| 
       21 
     | 
    
         
            -
                # @attr_reader options [Options] The +Options+ to compile with
         
     | 
| 
       22 
     | 
    
         
            -
                # @attr_reader runtime [Runtime] The runtime execution
         
     | 
| 
       23 
     | 
    
         
            -
                # @attr_reader scope [Scope] +Scope+ for variable resolution
         
     | 
| 
       24 
     | 
    
         
            -
                class Compiler
         
     | 
| 
       25 
     | 
    
         
            -
                  attr_reader :timings, :benchmark, :options, :runtime, :scope
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
                  # Create a compiler and make sure it gets cleaned up
         
     | 
| 
       28 
     | 
    
         
            -
                  #
         
     | 
| 
       29 
     | 
    
         
            -
                  # @param runtime [Runtime] The initial +Runtime+ for the compiler
         
     | 
| 
       30 
     | 
    
         
            -
                  # @param options [Options]
         
     | 
| 
       31 
     | 
    
         
            -
                  def self.with_compiler(runtime:, options:, &block)
         
     | 
| 
       32 
     | 
    
         
            -
                    compiler = new(options:, runtime:)
         
     | 
| 
       33 
     | 
    
         
            -
                    if options.verbose
         
     | 
| 
       34 
     | 
    
         
            -
                      ::CSVPlusPlus::Language::BenchmarkedCompiler.with_benchmarks(compiler) do |c|
         
     | 
| 
       35 
     | 
    
         
            -
                        block.call(c)
         
     | 
| 
       36 
     | 
    
         
            -
                      end
         
     | 
| 
       37 
     | 
    
         
            -
                    else
         
     | 
| 
       38 
     | 
    
         
            -
                      yield(compiler)
         
     | 
| 
       39 
     | 
    
         
            -
                    end
         
     | 
| 
       40 
     | 
    
         
            -
                  ensure
         
     | 
| 
       41 
     | 
    
         
            -
                    runtime.cleanup!
         
     | 
| 
       42 
     | 
    
         
            -
                  end
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
                  # @param runtime [Runtime]
         
     | 
| 
       45 
     | 
    
         
            -
                  # @param options [Options]
         
     | 
| 
       46 
     | 
    
         
            -
                  # @param scope [Scope, nil]
         
     | 
| 
       47 
     | 
    
         
            -
                  def initialize(runtime:, options:, scope: nil)
         
     | 
| 
       48 
     | 
    
         
            -
                    @options = options
         
     | 
| 
       49 
     | 
    
         
            -
                    @runtime = runtime
         
     | 
| 
       50 
     | 
    
         
            -
                    @scope = scope || ::CSVPlusPlus::Language::Scope.new(runtime:)
         
     | 
| 
       51 
     | 
    
         
            -
                  end
         
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
                  # Write the compiled results
         
     | 
| 
       54 
     | 
    
         
            -
                  def outputting!
         
     | 
| 
       55 
     | 
    
         
            -
                    @runtime.start_at_csv!
         
     | 
| 
       56 
     | 
    
         
            -
                    yield
         
     | 
| 
       57 
     | 
    
         
            -
                  end
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
                  # Compile a template and return a +::CSVPlusPlus::Template+ instance ready to be written with a +Writer+
         
     | 
| 
       60 
     | 
    
         
            -
                  #
         
     | 
| 
       61 
     | 
    
         
            -
                  # @return [Template]
         
     | 
| 
       62 
     | 
    
         
            -
                  def compile_template
         
     | 
| 
       63 
     | 
    
         
            -
                    parse_code_section!
         
     | 
| 
       64 
     | 
    
         
            -
                    rows = parse_csv_section!
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
                    ::CSVPlusPlus::Template.new(rows:).tap do |t|
         
     | 
| 
       67 
     | 
    
         
            -
                      t.validate_infinite_expands(@runtime)
         
     | 
| 
       68 
     | 
    
         
            -
                      expanding { t.expand_rows! }
         
     | 
| 
       69 
     | 
    
         
            -
                      resolve_all_cells!(t)
         
     | 
| 
       70 
     | 
    
         
            -
                    end
         
     | 
| 
       71 
     | 
    
         
            -
                  end
         
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
                  # @return [String]
         
     | 
| 
       74 
     | 
    
         
            -
                  def to_s
         
     | 
| 
       75 
     | 
    
         
            -
                    "Compiler(options: #{@options}, runtime: #{@runtime}, scope: #{@scope})"
         
     | 
| 
       76 
     | 
    
         
            -
                  end
         
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
                  protected
         
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
       80 
     | 
    
         
            -
                  # Parses the input file and returns a +CodeSection+
         
     | 
| 
       81 
     | 
    
         
            -
                  #
         
     | 
| 
       82 
     | 
    
         
            -
                  # @return [CodeSection]
         
     | 
| 
       83 
     | 
    
         
            -
                  def parse_code_section!
         
     | 
| 
       84 
     | 
    
         
            -
                    @runtime.start!
         
     | 
| 
       85 
     | 
    
         
            -
                    parsing_code_section do |input|
         
     | 
| 
       86 
     | 
    
         
            -
                      code_section, csv_section = ::CSVPlusPlus::Language::CodeSectionParser.new.parse(input, self)
         
     | 
| 
       87 
     | 
    
         
            -
                      # TODO: infer a type
         
     | 
| 
       88 
     | 
    
         
            -
                      # allow user-supplied key/values to override anything global or from the code section
         
     | 
| 
       89 
     | 
    
         
            -
                      code_section.def_variables(
         
     | 
| 
       90 
     | 
    
         
            -
                        options.key_values.transform_values { |v| ::CSVPlusPlus::Language::Entities::String.new(v.to_s) }
         
     | 
| 
       91 
     | 
    
         
            -
                      )
         
     | 
| 
       92 
     | 
    
         
            -
                      @scope.code_section = code_section
         
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
                      # return the csv_section to the caller because they're gonna re-write input with it
         
     | 
| 
       95 
     | 
    
         
            -
                      next csv_section
         
     | 
| 
       96 
     | 
    
         
            -
                    end
         
     | 
| 
       97 
     | 
    
         
            -
                    @scope.code_section
         
     | 
| 
       98 
     | 
    
         
            -
                  end
         
     | 
| 
       99 
     | 
    
         
            -
             
     | 
| 
       100 
     | 
    
         
            -
                  # Parse the CSV section and return an array of +Row+s
         
     | 
| 
       101 
     | 
    
         
            -
                  #
         
     | 
| 
       102 
     | 
    
         
            -
                  # @return [Array<Row>]
         
     | 
| 
       103 
     | 
    
         
            -
                  def parse_csv_section!
         
     | 
| 
       104 
     | 
    
         
            -
                    @runtime.start_at_csv!
         
     | 
| 
       105 
     | 
    
         
            -
                    @runtime.map_rows(::CSV.new(runtime.input)) do |csv_row|
         
     | 
| 
       106 
     | 
    
         
            -
                      parse_row(csv_row)
         
     | 
| 
       107 
     | 
    
         
            -
                    end
         
     | 
| 
       108 
     | 
    
         
            -
                  ensure
         
     | 
| 
       109 
     | 
    
         
            -
                    # we're done with the file and everything is in memory
         
     | 
| 
       110 
     | 
    
         
            -
                    @runtime.cleanup!
         
     | 
| 
       111 
     | 
    
         
            -
                  end
         
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
       113 
     | 
    
         
            -
                  # Iterates through each cell of each row and resolves it's variable and function references.
         
     | 
| 
       114 
     | 
    
         
            -
                  #
         
     | 
| 
       115 
     | 
    
         
            -
                  # @param template [Template]
         
     | 
| 
       116 
     | 
    
         
            -
                  # @return [Array<Entity>]
         
     | 
| 
       117 
     | 
    
         
            -
                  def resolve_all_cells!(template)
         
     | 
| 
       118 
     | 
    
         
            -
                    @runtime.start_at_csv!
         
     | 
| 
       119 
     | 
    
         
            -
                    @runtime.map_rows(template.rows, cells_too: true) do |cell|
         
     | 
| 
       120 
     | 
    
         
            -
                      cell.ast = @scope.resolve_cell_value if cell.ast
         
     | 
| 
       121 
     | 
    
         
            -
                    end
         
     | 
| 
       122 
     | 
    
         
            -
                  end
         
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
       124 
     | 
    
         
            -
                  # Expanding rows
         
     | 
| 
       125 
     | 
    
         
            -
                  def expanding
         
     | 
| 
       126 
     | 
    
         
            -
                    @runtime.start_at_csv!
         
     | 
| 
       127 
     | 
    
         
            -
                    yield
         
     | 
| 
       128 
     | 
    
         
            -
                  end
         
     | 
| 
       129 
     | 
    
         
            -
             
     | 
| 
       130 
     | 
    
         
            -
                  private
         
     | 
| 
       131 
     | 
    
         
            -
             
     | 
| 
       132 
     | 
    
         
            -
                  def parsing_code_section
         
     | 
| 
       133 
     | 
    
         
            -
                    csv_section = yield(@runtime.input.read)
         
     | 
| 
       134 
     | 
    
         
            -
                    @runtime.rewrite_input!(csv_section)
         
     | 
| 
       135 
     | 
    
         
            -
                  end
         
     | 
| 
       136 
     | 
    
         
            -
             
     | 
| 
       137 
     | 
    
         
            -
                  # Using the current +@runtime+ and the given +csv_row+ parse it into a +Row+ of +Cell+s
         
     | 
| 
       138 
     | 
    
         
            -
                  # +csv_row+ should have already been run through a CSV parser and is an array of strings
         
     | 
| 
       139 
     | 
    
         
            -
                  #
         
     | 
| 
       140 
     | 
    
         
            -
                  # @param csv_row [Array<Array<String>>]
         
     | 
| 
       141 
     | 
    
         
            -
                  # @return [Row]
         
     | 
| 
       142 
     | 
    
         
            -
                  def parse_row(csv_row)
         
     | 
| 
       143 
     | 
    
         
            -
                    row_modifier = ::CSVPlusPlus::Modifier.new(row_level: true)
         
     | 
| 
       144 
     | 
    
         
            -
             
     | 
| 
       145 
     | 
    
         
            -
                    cells =
         
     | 
| 
       146 
     | 
    
         
            -
                      @runtime.map_row(csv_row) do |value, _cell_index|
         
     | 
| 
       147 
     | 
    
         
            -
                        cell_modifier = ::CSVPlusPlus::Modifier.new
         
     | 
| 
       148 
     | 
    
         
            -
                        parsed_value = ::CSVPlusPlus::ModifierParser.new(row_modifier:, cell_modifier:).parse(value, @runtime)
         
     | 
| 
       149 
     | 
    
         
            -
             
     | 
| 
       150 
     | 
    
         
            -
                        ::CSVPlusPlus::Cell.parse(parsed_value, runtime:, modifier: cell_modifier)
         
     | 
| 
       151 
     | 
    
         
            -
                      end
         
     | 
| 
       152 
     | 
    
         
            -
             
     | 
| 
       153 
     | 
    
         
            -
                    ::CSVPlusPlus::Row.new(@runtime.row_index, cells, row_modifier)
         
     | 
| 
       154 
     | 
    
         
            -
                  end
         
     | 
| 
       155 
     | 
    
         
            -
                end
         
     | 
| 
       156 
     | 
    
         
            -
              end
         
     | 
| 
       157 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,33 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # frozen_string_literal: true
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            require_relative './entity'
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            module CSVPlusPlus
         
     | 
| 
       6 
     | 
    
         
            -
              module Language
         
     | 
| 
       7 
     | 
    
         
            -
                module Entities
         
     | 
| 
       8 
     | 
    
         
            -
                  # A boolean value
         
     | 
| 
       9 
     | 
    
         
            -
                  #
         
     | 
| 
       10 
     | 
    
         
            -
                  # @attr_reader value [true, false]
         
     | 
| 
       11 
     | 
    
         
            -
                  class Boolean < Entity
         
     | 
| 
       12 
     | 
    
         
            -
                    attr_reader :value
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
                    # @param value [String, Boolean]
         
     | 
| 
       15 
     | 
    
         
            -
                    def initialize(value)
         
     | 
| 
       16 
     | 
    
         
            -
                      super(:boolean)
         
     | 
| 
       17 
     | 
    
         
            -
                      # TODO: probably can do a lot better in general on type validation
         
     | 
| 
       18 
     | 
    
         
            -
                      @value = value.is_a?(::String) ? (value.downcase == 'true') : value
         
     | 
| 
       19 
     | 
    
         
            -
                    end
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
                    # @return [String]
         
     | 
| 
       22 
     | 
    
         
            -
                    def to_s
         
     | 
| 
       23 
     | 
    
         
            -
                      @value.to_s.upcase
         
     | 
| 
       24 
     | 
    
         
            -
                    end
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
                    # @return [boolean]
         
     | 
| 
       27 
     | 
    
         
            -
                    def ==(other)
         
     | 
| 
       28 
     | 
    
         
            -
                      super && value == other.value
         
     | 
| 
       29 
     | 
    
         
            -
                    end
         
     | 
| 
       30 
     | 
    
         
            -
                  end
         
     | 
| 
       31 
     | 
    
         
            -
                end
         
     | 
| 
       32 
     | 
    
         
            -
              end
         
     | 
| 
       33 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,33 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # frozen_string_literal: true
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            require_relative './entity'
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            module CSVPlusPlus
         
     | 
| 
       6 
     | 
    
         
            -
              module Language
         
     | 
| 
       7 
     | 
    
         
            -
                module Entities
         
     | 
| 
       8 
     | 
    
         
            -
                  # A reference to a cell
         
     | 
| 
       9 
     | 
    
         
            -
                  #
         
     | 
| 
       10 
     | 
    
         
            -
                  # @attr_reader cell_reference [String] The cell reference in A1 format
         
     | 
| 
       11 
     | 
    
         
            -
                  class CellReference < Entity
         
     | 
| 
       12 
     | 
    
         
            -
                    attr_reader :cell_reference
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
                    # @param cell_reference [String] The cell reference in A1 format
         
     | 
| 
       15 
     | 
    
         
            -
                    def initialize(cell_reference)
         
     | 
| 
       16 
     | 
    
         
            -
                      super(:cell_reference)
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
                      @cell_reference = cell_reference
         
     | 
| 
       19 
     | 
    
         
            -
                    end
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
                    # @return [String]
         
     | 
| 
       22 
     | 
    
         
            -
                    def to_s
         
     | 
| 
       23 
     | 
    
         
            -
                      @cell_reference
         
     | 
| 
       24 
     | 
    
         
            -
                    end
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
                    # @return [Boolean]
         
     | 
| 
       27 
     | 
    
         
            -
                    def ==(other)
         
     | 
| 
       28 
     | 
    
         
            -
                      super && @cell_reference == other.cell_reference
         
     | 
| 
       29 
     | 
    
         
            -
                    end
         
     | 
| 
       30 
     | 
    
         
            -
                  end
         
     | 
| 
       31 
     | 
    
         
            -
                end
         
     | 
| 
       32 
     | 
    
         
            -
              end
         
     | 
| 
       33 
     | 
    
         
            -
            end
         
     |