csv_plus_plus 0.1.1 → 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 +8 -0
- data/README.md +18 -62
- data/lib/csv_plus_plus/benchmarked_compiler.rb +62 -0
- data/lib/csv_plus_plus/{code_section.rb → can_define_references.rb} +22 -35
- 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 +3 -5
- 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 +13 -6
- data/lib/csv_plus_plus/modifier/conditional_formatting.rb +17 -0
- data/lib/csv_plus_plus/modifier.rb +73 -65
- data/lib/csv_plus_plus/{language → parser}/cell_value.tab.rb +20 -20
- data/lib/csv_plus_plus/{language → parser}/code_section.tab.rb +83 -87
- 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 +10 -10
- 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 +19 -10
- metadata +34 -24
- data/lib/csv_plus_plus/language/benchmarked_compiler.rb +0 -65
- data/lib/csv_plus_plus/language/compiler.rb +0 -152
- 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 -37
- 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 -192
- data/lib/csv_plus_plus/modifier.tab.rb +0 -907
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './syntax_error'
|
4
|
+
|
5
|
+
module CSVPlusPlus
|
6
|
+
module Error
|
7
|
+
# An error that can be thrown when a modifier doesn't pass our validation.
|
8
|
+
#
|
9
|
+
# @attr_reader modifier [Symbol] The modifier being parsed when the bad input was encountered
|
10
|
+
# @attr_reader bad_input [String] The offending input that caused the error to be thrown
|
11
|
+
# @attr_reader choices [Array<Symbol>, nil] The choices that +value+ must be one of (but violated)
|
12
|
+
# @attr_reader message [String, nil] A relevant message to show
|
13
|
+
class ModifierValidationError < ::CSVPlusPlus::Error::Error
|
14
|
+
attr_reader :bad_input, :choices, :message, :modifier
|
15
|
+
|
16
|
+
# You must supply either a +choices+ or +message+
|
17
|
+
#
|
18
|
+
# @param modifier [Symbol] The modifier being parsed when the bad input was encountered
|
19
|
+
# @param bad_input [String] The offending input that caused the error to be thrown
|
20
|
+
# @param choices [Array<Symbol>, nil] The choices that +value+ must be one of (but violated)
|
21
|
+
# @param message [String, nil] A relevant message to show
|
22
|
+
def initialize(modifier, bad_input, choices: nil, message: nil)
|
23
|
+
@bad_input = bad_input
|
24
|
+
@choices = choices
|
25
|
+
@modifier = modifier
|
26
|
+
|
27
|
+
@message =
|
28
|
+
if @choices
|
29
|
+
"must be one of (#{@choices.map(&:to_s).join(', ')})"
|
30
|
+
else
|
31
|
+
message
|
32
|
+
end
|
33
|
+
|
34
|
+
super(@message)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Create a relevant error message given +@choices+ or +@message+ (one of them must be supplied).
|
38
|
+
#
|
39
|
+
# @return [::String]
|
40
|
+
def error_message
|
41
|
+
<<~ERROR_MESSAGE
|
42
|
+
Error parsing modifier: [[#{@modifier}=...]]
|
43
|
+
Bad input: #{@bad_input}
|
44
|
+
Reason: #{@message}
|
45
|
+
ERROR_MESSAGE
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -1,21 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module CSVPlusPlus
|
4
|
-
module
|
4
|
+
module Error
|
5
5
|
# An error that can be thrown for various syntax errors
|
6
|
-
class SyntaxError < ::CSVPlusPlus::Error
|
7
|
-
# @param message [String] The primary message to be shown to the user
|
8
|
-
# @param bad_input [String] The offending input that caused the error to be thrown
|
6
|
+
class SyntaxError < ::CSVPlusPlus::Error::Error
|
9
7
|
# @param runtime [Runtime] The current runtime
|
10
8
|
# @param wrapped_error [StandardError] The underlying error that caused the syntax error. For example a
|
11
9
|
# Racc::ParseError that was thrown
|
12
|
-
def initialize(
|
13
|
-
@bad_input = bad_input.to_s
|
10
|
+
def initialize(runtime, wrapped_error: nil)
|
14
11
|
@runtime = runtime
|
15
12
|
@wrapped_error = wrapped_error
|
16
|
-
@message = message
|
17
13
|
|
18
|
-
super(
|
14
|
+
super()
|
19
15
|
end
|
20
16
|
|
21
17
|
# @return [String]
|
@@ -34,7 +30,7 @@ module CSVPlusPlus
|
|
34
30
|
#
|
35
31
|
# @return [String]
|
36
32
|
def to_trace
|
37
|
-
"#{message_prefix}#{cell_index} #{
|
33
|
+
"#{message_prefix}#{cell_index} #{error_message}"
|
38
34
|
end
|
39
35
|
|
40
36
|
private
|
@@ -55,11 +51,7 @@ module CSVPlusPlus
|
|
55
51
|
filename = @runtime.filename
|
56
52
|
|
57
53
|
line_str = line_number ? ":#{line_number}" : ''
|
58
|
-
"
|
59
|
-
end
|
60
|
-
|
61
|
-
def message_postfix
|
62
|
-
"#{@message}: \"#{@bad_input}\""
|
54
|
+
"#{filename}#{line_str}"
|
63
55
|
end
|
64
56
|
end
|
65
57
|
end
|
data/lib/csv_plus_plus/error.rb
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative './error/error'
|
4
|
+
require_relative './error/formula_syntax_error'
|
5
|
+
require_relative './error/modifier_syntax_error'
|
6
|
+
require_relative './error/modifier_validation_error'
|
7
|
+
require_relative './error/syntax_error'
|
8
|
+
require_relative './error/writer_error'
|
9
|
+
|
3
10
|
module CSVPlusPlus
|
4
|
-
#
|
5
|
-
|
11
|
+
# A module containing errors to be raised
|
12
|
+
module Error
|
6
13
|
end
|
7
14
|
end
|
data/lib/csv_plus_plus/expand.rb
CHANGED
@@ -4,11 +4,13 @@ module CSVPlusPlus
|
|
4
4
|
Expand =
|
5
5
|
::Struct.new(:repetitions) do
|
6
6
|
# Does this infinitely expand?
|
7
|
+
#
|
8
|
+
# @return [boolean]
|
7
9
|
def infinite?
|
8
10
|
repetitions.nil?
|
9
11
|
end
|
10
12
|
|
11
|
-
#
|
13
|
+
# @return [::String]
|
12
14
|
def to_s
|
13
15
|
"Expand #{repetitions || 'infinity'}"
|
14
16
|
end
|
@@ -4,6 +4,8 @@ module CSVPlusPlus
|
|
4
4
|
# A convenience wrapper around Google's REST API client
|
5
5
|
module GoogleApiClient
|
6
6
|
# Get a +::Google::Apis::SheetsV4::SheetsService+ instance connected to the sheets API
|
7
|
+
#
|
8
|
+
# @return [Google::Apis::SheetsV4::SheetsService]
|
7
9
|
def self.sheets_client
|
8
10
|
::Google::Apis::SheetsV4::SheetsService.new.tap do |s|
|
9
11
|
s.authorization = ::Google::Auth.get_application_default(['https://www.googleapis.com/auth/spreadsheets'].freeze)
|
@@ -11,6 +13,8 @@ module CSVPlusPlus
|
|
11
13
|
end
|
12
14
|
|
13
15
|
# Get a +::Google::Apis::DriveV3::DriveService+ instance connected to the drive API
|
16
|
+
#
|
17
|
+
# @return [Google::Apis::DriveV3::DriveService]
|
14
18
|
def self.drive_client
|
15
19
|
::Google::Apis::DriveV3::DriveService.new.tap do |d|
|
16
20
|
d.authorization = ::Google::Auth.get_application_default(['https://www.googleapis.com/auth/drive.file'].freeze)
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative '../color'
|
4
|
+
|
3
5
|
module CSVPlusPlus
|
4
6
|
# Common methods to be mixed into the Racc parsers
|
5
7
|
#
|
@@ -32,17 +34,21 @@ module CSVPlusPlus
|
|
32
34
|
do_parse
|
33
35
|
return_value
|
34
36
|
rescue ::Racc::ParseError => e
|
35
|
-
runtime.
|
37
|
+
runtime.raise_formula_syntax_error("Error parsing #{parse_subject}", e.message, wrapped_error: e)
|
38
|
+
rescue ::CSVPlusPlus::Error::ModifierValidationError => e
|
39
|
+
raise(::CSVPlusPlus::Error::ModifierSyntaxError.new(runtime, wrapped_error: e))
|
36
40
|
end
|
37
41
|
|
38
42
|
TOKEN_LIBRARY = {
|
39
|
-
|
43
|
+
A1_NOTATION: [::CSVPlusPlus::Entities::CellReference::A1_NOTATION_REGEXP, :A1_NOTATION],
|
40
44
|
FALSE: [/false/i, :FALSE],
|
45
|
+
HEX_COLOR: [::CSVPlusPlus::Color::HEX_STRING_REGEXP, :HEX_COLOR],
|
46
|
+
ID: [/[$!\w:]+/, :ID],
|
47
|
+
INFIX_OP: [%r{\^|\+|-|\*|/|&|<|>|<=|>=|<>}, :INFIX_OP],
|
41
48
|
NUMBER: [/-?[\d.]+/, :NUMBER],
|
42
49
|
STRING: [%r{"(?:[^"\\]|\\(?:["\\/bfnrt]|u[0-9a-fA-F]{4}))*"}, :STRING],
|
43
|
-
|
44
|
-
VAR_REF: [/\$\$/, :VAR_REF]
|
45
|
-
ID: [/[$!\w:]+/, :ID]
|
50
|
+
TRUE: [/true/i, :TRUE],
|
51
|
+
VAR_REF: [/\$\$/, :VAR_REF]
|
46
52
|
}.freeze
|
47
53
|
public_constant :TOKEN_LIBRARY
|
48
54
|
|
@@ -71,7 +77,8 @@ module CSVPlusPlus
|
|
71
77
|
elsif tokenizer.scan_catchall
|
72
78
|
@tokens << [tokenizer.last_match, tokenizer.last_match]
|
73
79
|
else
|
74
|
-
|
80
|
+
# TODO: this should raise a modifier_syntax_error if we're on the modifier parser
|
81
|
+
runtime.raise_formula_syntax_error("Unable to parse #{parse_subject} starting at", tokenizer.peek)
|
75
82
|
end
|
76
83
|
end
|
77
84
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CSVPlusPlus
|
4
|
+
module Modifier
|
5
|
+
# A class that handles the rules for modifiers to support conditional formatting.
|
6
|
+
class ConditionalFormatting
|
7
|
+
attr_reader :arguments, :condition, :invalid_reason
|
8
|
+
|
9
|
+
# @param value [::String] The unparsed conditional formatting rule
|
10
|
+
def initialize(value)
|
11
|
+
condition, args = value.split(/\si:\s*/)
|
12
|
+
@condition = condition.to_sym
|
13
|
+
@arguments = args.split(/\s+/)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -3,30 +3,54 @@
|
|
3
3
|
module CSVPlusPlus
|
4
4
|
# A container representing the operations that can be applied to a cell or row
|
5
5
|
#
|
6
|
-
# @attr
|
6
|
+
# @attr bordercolor [Color]
|
7
|
+
# @attr borders [Array<Symbol>] The borders that will be set
|
8
|
+
# @attr color [Color] The background color of the cell
|
7
9
|
# @attr expand [Expand] Whether this row expands into multiple rows
|
8
|
-
# @attr
|
9
|
-
# @attr
|
10
|
-
# @attr
|
11
|
-
# @attr
|
12
|
-
# @attr
|
13
|
-
# @attr
|
10
|
+
# @attr fontcolor [Color] The font color of the cell
|
11
|
+
# @attr fontfamily [::String] The font family
|
12
|
+
# @attr fontsize [Integer] The font size
|
13
|
+
# @attr halign [:left, :center, :right] Horizontal alignment
|
14
|
+
# @attr note [::String] A note/comment on the cell
|
15
|
+
# @attr numberformat [Symbol] A number format to apply to the value in the cell
|
16
|
+
# @attr row_level [boolean] Is this a row modifier? If so it's values will apply to all cells in the row
|
14
17
|
# (unless overridden by the cell modifier)
|
15
18
|
# @attr validation [Object]
|
16
|
-
# @attr valign [
|
19
|
+
# @attr valign [:top, :center, :bottom] Vertical alignment
|
20
|
+
# @attr var [Symbol] The variable bound to this cell
|
17
21
|
#
|
18
|
-
# @attr_writer borderstyle [
|
22
|
+
# @attr_writer borderstyle [:hashed, :dotted, :double, :solid, :solid_medium, :solid_thick]
|
19
23
|
# The style of border on the cell
|
20
24
|
#
|
21
|
-
# @attr_reader
|
22
|
-
# @attr_reader
|
23
|
-
# @attr_reader color [Color] The background color of the cell
|
24
|
-
# @attr_reader fontcolor [Color] The font color of the cell
|
25
|
-
# @attr_reader formats [Array<String>] Bold/italics/underline/strikethrough formatting
|
25
|
+
# @attr_reader borders [Array<Symbol>]
|
26
|
+
# @attr_reader formats [Array<Symbol>] Bold/italics/underline/strikethrough formatting
|
26
27
|
class Modifier
|
27
|
-
|
28
|
+
attr_accessor :bordercolor,
|
29
|
+
:color,
|
30
|
+
:expand,
|
31
|
+
:fontcolor,
|
32
|
+
:fontfamily,
|
33
|
+
:fontsize,
|
34
|
+
:halign,
|
35
|
+
:valign,
|
36
|
+
:note,
|
37
|
+
:numberformat,
|
38
|
+
:row_level,
|
39
|
+
:validation,
|
40
|
+
:var
|
41
|
+
attr_reader :borders, :formats
|
28
42
|
attr_writer :borderstyle
|
29
|
-
|
43
|
+
|
44
|
+
# When instantiating a new object, extend it with our validation functionality.
|
45
|
+
#
|
46
|
+
# I'm not sure why I need to do it this way tbh, using +include ValidatedModifier+ at the
|
47
|
+
# class level didn't seem to have access to the parent methods
|
48
|
+
# def self.new(*args, **kwargs, &)
|
49
|
+
# allocate.tap do |i|
|
50
|
+
# i.__send__(:initialize, *args, **kwargs, &)
|
51
|
+
# i.extend(::CSVPlusPlus::ValidatedModifier)
|
52
|
+
# end
|
53
|
+
# end
|
30
54
|
|
31
55
|
# @param row_level [Boolean] Whether or not this modifier applies to the entire row
|
32
56
|
def initialize(row_level: false)
|
@@ -36,70 +60,68 @@ module CSVPlusPlus
|
|
36
60
|
@formats = ::Set.new
|
37
61
|
end
|
38
62
|
|
39
|
-
#
|
63
|
+
# Are there any borders set?
|
40
64
|
#
|
41
|
-
# @
|
65
|
+
# @return [Boolean]
|
66
|
+
def any_border?
|
67
|
+
!@borders.empty?
|
68
|
+
end
|
69
|
+
|
70
|
+
# Style of border
|
71
|
+
#
|
72
|
+
# @return [Symbol]
|
73
|
+
def borderstyle
|
74
|
+
@borderstyle || :solid
|
75
|
+
end
|
76
|
+
|
77
|
+
# Is this a cell-level modifier?
|
42
78
|
#
|
43
|
-
# @return [
|
44
|
-
def
|
45
|
-
|
79
|
+
# @return [Boolean]
|
80
|
+
def cell_level?
|
81
|
+
!@row_level
|
46
82
|
end
|
47
83
|
|
48
84
|
# Assign a border
|
49
85
|
#
|
50
|
-
# @param side [
|
86
|
+
# @param side [:top, :left, :bottom, :right, :all]
|
51
87
|
def border=(side)
|
52
88
|
@borders << side
|
53
89
|
end
|
54
90
|
|
55
91
|
# Does this have a border along +side+?
|
56
92
|
#
|
57
|
-
# @param side [
|
93
|
+
# @param side [:top, :left, :bottom, :right, :all]
|
58
94
|
#
|
59
|
-
# @return [
|
95
|
+
# @return [boolean]
|
60
96
|
def border_along?(side)
|
61
|
-
@borders.include?(
|
97
|
+
@borders.include?(:all) || @borders.include?(side)
|
62
98
|
end
|
63
99
|
|
64
100
|
# Does this have a border along all sides?
|
65
101
|
#
|
66
|
-
# @return [
|
102
|
+
# @return [boolean]
|
67
103
|
def border_all?
|
68
|
-
@borders.include?(
|
69
|
-
|| (border_along?(
|
104
|
+
@borders.include?(:all) \
|
105
|
+
|| (border_along?(:top) && border_along?(:bottom) && border_along?(:left) && border_along?(:right))
|
70
106
|
end
|
71
107
|
|
72
|
-
# Set
|
108
|
+
# Set this modifier to expand infinitely
|
73
109
|
#
|
74
|
-
# @
|
75
|
-
def
|
76
|
-
@
|
77
|
-
end
|
78
|
-
|
79
|
-
# Are there any borders set?
|
80
|
-
#
|
81
|
-
# @return [Boolean]
|
82
|
-
def any_border?
|
83
|
-
!@borders.empty?
|
84
|
-
end
|
85
|
-
|
86
|
-
# Set the fontcolor
|
87
|
-
#
|
88
|
-
# @param hex_value [String] formatted as '#000000', '#000' or '000000'
|
89
|
-
def fontcolor=(hex_value)
|
90
|
-
@fontcolor = ::CSVPlusPlus::Color.new(hex_value)
|
110
|
+
# @return [::Expand]
|
111
|
+
def expand!
|
112
|
+
@expand = ::CSVPlusPlus::Expand.new if row_level?
|
91
113
|
end
|
92
114
|
|
93
115
|
# Set a text format (bolid, italic, underline or strikethrough)
|
94
116
|
#
|
95
|
-
# @param value [
|
117
|
+
# @param value [:bold, :italic, :underline, :strikethrough]
|
96
118
|
def format=(value)
|
97
119
|
@formats << value
|
98
120
|
end
|
99
121
|
|
100
122
|
# Is the given format set?
|
101
123
|
#
|
102
|
-
# @param type [
|
124
|
+
# @param type [:bold, :italic, :underline, :strikethrough]
|
103
125
|
#
|
104
126
|
# @return [Boolean]
|
105
127
|
def formatted?(type)
|
@@ -115,7 +137,7 @@ module CSVPlusPlus
|
|
115
137
|
|
116
138
|
# Is the row frozen?
|
117
139
|
#
|
118
|
-
# @return [
|
140
|
+
# @return [boolean]
|
119
141
|
def frozen?
|
120
142
|
@frozen
|
121
143
|
end
|
@@ -129,26 +151,12 @@ module CSVPlusPlus
|
|
129
151
|
|
130
152
|
# Is this a row-level modifier?
|
131
153
|
#
|
132
|
-
# @return [
|
154
|
+
# @return [boolean]
|
133
155
|
def row_level?
|
134
156
|
@row_level
|
135
157
|
end
|
136
158
|
|
137
|
-
#
|
138
|
-
#
|
139
|
-
# @return [Boolean]
|
140
|
-
def cell_level?
|
141
|
-
!@row_level
|
142
|
-
end
|
143
|
-
|
144
|
-
# Style of border
|
145
|
-
#
|
146
|
-
# @return [String]
|
147
|
-
def borderstyle
|
148
|
-
@borderstyle || 'solid'
|
149
|
-
end
|
150
|
-
|
151
|
-
# @return [String]
|
159
|
+
# @return [::String]
|
152
160
|
def to_s
|
153
161
|
# TODO... I dunno, not sure how to manage this
|
154
162
|
"Modifier(row_level: #{@row_level} halign: #{@halign} valign: #{@valign} format: #{@formats} " \
|
@@ -7,14 +7,14 @@
|
|
7
7
|
require 'racc/parser.rb'
|
8
8
|
|
9
9
|
require_relative '../lexer'
|
10
|
-
require_relative '../
|
10
|
+
require_relative '../entities/ast_builder'
|
11
11
|
|
12
12
|
module CSVPlusPlus
|
13
|
-
module
|
14
|
-
class
|
13
|
+
module Parser
|
14
|
+
class CellValue < Racc::Parser
|
15
15
|
|
16
|
-
module_eval(<<'...end cell_value.y/module_eval...', 'cell_value.y',
|
17
|
-
include ::CSVPlusPlus::
|
16
|
+
module_eval(<<'...end cell_value.y/module_eval...', 'cell_value.y', 49)
|
17
|
+
include ::CSVPlusPlus::Entities::ASTBuilder
|
18
18
|
include ::CSVPlusPlus::Lexer
|
19
19
|
|
20
20
|
protected
|
@@ -201,7 +201,7 @@ Racc_debug_parser = false
|
|
201
201
|
|
202
202
|
# reduce 0 omitted
|
203
203
|
|
204
|
-
module_eval(<<'.,.,', 'cell_value.y',
|
204
|
+
module_eval(<<'.,.,', 'cell_value.y', 21)
|
205
205
|
def _reduce_1(val, _values, result)
|
206
206
|
@ast = val[1]
|
207
207
|
result
|
@@ -212,84 +212,84 @@ module_eval(<<'.,.,', 'cell_value.y', 20)
|
|
212
212
|
|
213
213
|
# reduce 3 omitted
|
214
214
|
|
215
|
-
module_eval(<<'.,.,', 'cell_value.y',
|
215
|
+
module_eval(<<'.,.,', 'cell_value.y', 25)
|
216
216
|
def _reduce_4(val, _values, result)
|
217
217
|
result = val[1]
|
218
218
|
result
|
219
219
|
end
|
220
220
|
.,.,
|
221
221
|
|
222
|
-
module_eval(<<'.,.,', 'cell_value.y',
|
222
|
+
module_eval(<<'.,.,', 'cell_value.y', 26)
|
223
223
|
def _reduce_5(val, _values, result)
|
224
224
|
result = variable(val[1])
|
225
225
|
result
|
226
226
|
end
|
227
227
|
.,.,
|
228
228
|
|
229
|
-
module_eval(<<'.,.,', 'cell_value.y',
|
229
|
+
module_eval(<<'.,.,', 'cell_value.y', 27)
|
230
230
|
def _reduce_6(val, _values, result)
|
231
231
|
result = string(val[0])
|
232
232
|
result
|
233
233
|
end
|
234
234
|
.,.,
|
235
235
|
|
236
|
-
module_eval(<<'.,.,', 'cell_value.y',
|
236
|
+
module_eval(<<'.,.,', 'cell_value.y', 28)
|
237
237
|
def _reduce_7(val, _values, result)
|
238
238
|
result = number(val[0])
|
239
239
|
result
|
240
240
|
end
|
241
241
|
.,.,
|
242
242
|
|
243
|
-
module_eval(<<'.,.,', 'cell_value.y',
|
243
|
+
module_eval(<<'.,.,', 'cell_value.y', 29)
|
244
244
|
def _reduce_8(val, _values, result)
|
245
245
|
result = boolean(true)
|
246
246
|
result
|
247
247
|
end
|
248
248
|
.,.,
|
249
249
|
|
250
|
-
module_eval(<<'.,.,', 'cell_value.y',
|
250
|
+
module_eval(<<'.,.,', 'cell_value.y', 30)
|
251
251
|
def _reduce_9(val, _values, result)
|
252
252
|
result = boolean(false)
|
253
253
|
result
|
254
254
|
end
|
255
255
|
.,.,
|
256
256
|
|
257
|
-
module_eval(<<'.,.,', 'cell_value.y',
|
257
|
+
module_eval(<<'.,.,', 'cell_value.y', 31)
|
258
258
|
def _reduce_10(val, _values, result)
|
259
259
|
result = cell_reference(val[0])
|
260
260
|
result
|
261
261
|
end
|
262
262
|
.,.,
|
263
263
|
|
264
|
-
module_eval(<<'.,.,', 'cell_value.y',
|
264
|
+
module_eval(<<'.,.,', 'cell_value.y', 33)
|
265
265
|
def _reduce_11(val, _values, result)
|
266
266
|
result = function_call(val[0], val[2])
|
267
267
|
result
|
268
268
|
end
|
269
269
|
.,.,
|
270
270
|
|
271
|
-
module_eval(<<'.,.,', 'cell_value.y',
|
271
|
+
module_eval(<<'.,.,', 'cell_value.y', 34)
|
272
272
|
def _reduce_12(val, _values, result)
|
273
273
|
result = function_call(val[0], [])
|
274
274
|
result
|
275
275
|
end
|
276
276
|
.,.,
|
277
277
|
|
278
|
-
module_eval(<<'.,.,', 'cell_value.y',
|
278
|
+
module_eval(<<'.,.,', 'cell_value.y', 36)
|
279
279
|
def _reduce_13(val, _values, result)
|
280
280
|
result = val[0] << val[2]
|
281
281
|
result
|
282
282
|
end
|
283
283
|
.,.,
|
284
284
|
|
285
|
-
module_eval(<<'.,.,', 'cell_value.y',
|
285
|
+
module_eval(<<'.,.,', 'cell_value.y', 37)
|
286
286
|
def _reduce_14(val, _values, result)
|
287
287
|
result = [val[0]]
|
288
288
|
result
|
289
289
|
end
|
290
290
|
.,.,
|
291
291
|
|
292
|
-
module_eval(<<'.,.,', 'cell_value.y',
|
292
|
+
module_eval(<<'.,.,', 'cell_value.y', 39)
|
293
293
|
def _reduce_15(val, _values, result)
|
294
294
|
result = function_call(val[1], [val[0], val[2]], infix: true)
|
295
295
|
result
|
@@ -300,6 +300,6 @@ def _reduce_none(val, _values, result)
|
|
300
300
|
val[0]
|
301
301
|
end
|
302
302
|
|
303
|
-
end # class
|
304
|
-
end # module
|
303
|
+
end # class CellValue
|
304
|
+
end # module Parser
|
305
305
|
end # module CSVPlusPlus
|