class Formula

Public Instance Methods

any_internal_reference() click to toggle source
# File src/excel/formula_peg.rb, line 90
def any_internal_reference
  table_reference || local_table_reference || sheet_reference || sheetless_reference
end
any_reference() click to toggle source
# File src/excel/formula_peg.rb, line 86
def any_reference
  external_reference || any_internal_reference
end
area() click to toggle source
# File src/excel/formula_peg.rb, line 186
def area
  node :area do
    reference && ignore { terminal(":") } && reference
  end
end
argument() click to toggle source
# File src/excel/formula_peg.rb, line 24
def argument
  expression || null
end
arithmetic() click to toggle source
# File src/excel/formula_peg.rb, line 62
def arithmetic
  node :arithmetic do
    thing && one_or_more { (space && operator && space && thing) }
  end
end
array() click to toggle source
# File src/excel/formula_peg.rb, line 40
def array
  node :array do
    ignore { terminal("{") } && space && row && any_number_of { (space && ignore { terminal(";") } && space && row) } && space && ignore { terminal("}") }
  end
end
basic_type() click to toggle source
# File src/excel/formula_peg.rb, line 52
def basic_type
  string || percentage || number || boolean
end
boolean() click to toggle source
# File src/excel/formula_peg.rb, line 210
def boolean
  boolean_true || boolean_false
end
boolean_false() click to toggle source
# File src/excel/formula_peg.rb, line 220
def boolean_false
  node :boolean_false do
    ignore { terminal("FALSE") }
  end
end
boolean_true() click to toggle source
# File src/excel/formula_peg.rb, line 214
def boolean_true
  node :boolean_true do
    ignore { terminal("TRUE") }
  end
end
brackets() click to toggle source
# File src/excel/formula_peg.rb, line 34
def brackets
  node :brackets do
    ignore { terminal("(") } && space && one_or_more { expression } && space && ignore { terminal(")") }
  end
end
cell() click to toggle source
# File src/excel/formula_peg.rb, line 192
def cell
  node :cell do
    reference
  end
end
column() click to toggle source
# File src/excel/formula_peg.rb, line 202
def column
  terminal(/\$?[A-Za-z]{1,3}/)
end
column_range() click to toggle source
# File src/excel/formula_peg.rb, line 174
def column_range
  node :column_range do
    column && ignore { terminal(":") } && column
  end
end
comparator() click to toggle source
# File src/excel/formula_peg.rb, line 74
def comparator
  node :comparator do
    terminal(">=") || terminal("<=") || terminal("<>") || terminal(">") || terminal("<") || terminal("=")
  end
end
comparison() click to toggle source
# File src/excel/formula_peg.rb, line 68
def comparison
  node :comparison do
    (arithmetic || string_join || thing) && space && comparator && space && (arithmetic || string_join || thing)
  end
end
complex_structured_reference() click to toggle source
# File src/excel/formula_peg.rb, line 142
def complex_structured_reference
  terminal(/\[[^\u005d]*\],\[[^\u005d]*\]/)
end
error() click to toggle source
# File src/excel/formula_peg.rb, line 242
def error
  node :error do
    terminal("#REF!") || terminal("#NAME?") || terminal("#VALUE!") || terminal("#DIV/0!") || terminal("#N/A") || terminal("#NUM!")
  end
end
expression() click to toggle source
# File src/excel/formula_peg.rb, line 16
def expression
  string_join || comparison || arithmetic || thing
end
external_reference() click to toggle source
# File src/excel/formula_peg.rb, line 112
def external_reference
  node :external_reference do
    terminal(/\[\d+\]!?/) && (any_internal_reference || named_reference)
  end
end
formula() click to toggle source
# File src/excel/formula_peg.rb, line 10
def formula
  node :formula do
    optional { space } && one_or_more { expression }
  end
end
function() click to toggle source
# File src/excel/formula_peg.rb, line 28
def function
  node :function do
    terminal(/[a-zA-Z_][a-zA-Z0-9.]+/) && ignore { terminal("(") } && space && optional { argument } && any_number_of { (space && ignore { terminal(",") } && space && argument) } && space && ignore { terminal(")") }
  end
end
local_table_reference() click to toggle source
# File src/excel/formula_peg.rb, line 124
def local_table_reference
  node :local_table_reference do
    ignore { terminal("[") } && (range_structured_reference || short_range_structured_reference || complex_structured_reference || overly_structured_reference || simple_structured_reference) && ignore { terminal("]") }
  end
end
named_reference() click to toggle source
# File src/excel/formula_peg.rb, line 154
def named_reference
  node :named_reference do
    terminal(/[#\p{word}][\p{word}_.!]+/)
  end
end
null() click to toggle source
# File src/excel/formula_peg.rb, line 236
def null
  node :null do
    followed_by { terminal(",") }
  end
end
number() click to toggle source
# File src/excel/formula_peg.rb, line 100
def number
  node :number do
    terminal(/[-+]?[0-9]+\.?[0-9]*([eE][-+]?[0-9]+)?/)
  end
end
operator() click to toggle source
# File src/excel/formula_peg.rb, line 106
def operator
  node :operator do
    terminal("+") || terminal("-") || terminal("/") || terminal("*") || terminal("^")
  end
end
overly_structured_reference() click to toggle source
# File src/excel/formula_peg.rb, line 146
def overly_structured_reference
  ignore { terminal("[") } && simple_structured_reference && ignore { terminal("]") }
end
percentage() click to toggle source
# File src/excel/formula_peg.rb, line 94
def percentage
  node :percentage do
    (terminal(/[-+]?[0-9]+\.?[0-9]*/) || function) && ignore { terminal("%") }
  end
end
prefix() click to toggle source
# File src/excel/formula_peg.rb, line 226
def prefix
  node :prefix do
    terminal(/[-+]/) && thing
  end
end
range_structured_reference() click to toggle source
# File src/excel/formula_peg.rb, line 134
def range_structured_reference
  terminal(/\[[^\u005d]*\],\[[^\u005d]*\]:\[[^\u005d]*\]/)
end
reference() click to toggle source
# File src/excel/formula_peg.rb, line 206
def reference
  terminal(/\$?[A-Za-z]{1,3}\$?[0-9]+(?![0-9A-Za-z_.])/)
end
root() click to toggle source
# File src/excel/formula_peg.rb, line 6
def root
  formula
end
row() click to toggle source
# File src/excel/formula_peg.rb, line 46
def row
  node :row do
    basic_type && any_number_of { (space && ignore { terminal(",") } && space && basic_type) }
  end
end
row_number() click to toggle source
# File src/excel/formula_peg.rb, line 198
def row_number
  terminal(/\$?\d+/)
end
row_range() click to toggle source
# File src/excel/formula_peg.rb, line 180
def row_range
  node :row_range do
    row_number && ignore { terminal(":") } && row_number
  end
end
sheet_reference() click to toggle source
# File src/excel/formula_peg.rb, line 160
def sheet_reference
  node :sheet_reference do
    (single_quoted_string || terminal(/[\p{word}][\p{word}_.]+/)) && ignore { terminal("!") } && (sheetless_reference || error || named_reference)
  end
end
sheetless_reference() click to toggle source
# File src/excel/formula_peg.rb, line 170
def sheetless_reference
  column_range || row_range || area || cell
end
short_range_structured_reference() click to toggle source
# File src/excel/formula_peg.rb, line 138
def short_range_structured_reference
  terminal(/\[[^\u005d]*\]:\[[^\u005d]*\]/)
end
simple_structured_reference() click to toggle source
# File src/excel/formula_peg.rb, line 150
def simple_structured_reference
  terminal(/[^\u005d]*/)
end
single_quoted_string() click to toggle source
# File src/excel/formula_peg.rb, line 166
def single_quoted_string
  ignore { terminal("'") } && terminal(/[^']*/) && ignore { terminal("'") }
end
space() click to toggle source
# File src/excel/formula_peg.rb, line 232
def space
  ignore { terminal(/[ \n\r]*/) }
end
string() click to toggle source
# File src/excel/formula_peg.rb, line 80
def string
  node :string do
    ignore { terminal("\"") } && terminal(/(""|[^"])*/) && ignore { terminal("\"") }
  end
end
string_join() click to toggle source
# File src/excel/formula_peg.rb, line 56
def string_join
  node :string_join do
    (arithmetic || thing) && one_or_more { (space && ignore { terminal("&") } && space && (arithmetic || thing)) }
  end
end
table_name() click to toggle source
# File src/excel/formula_peg.rb, line 130
def table_name
  terminal(/[.\p{Word}_]+/)
end
table_reference() click to toggle source
# File src/excel/formula_peg.rb, line 118
def table_reference
  node :table_reference do
    table_name && ignore { terminal("[") } && (range_structured_reference || short_range_structured_reference || complex_structured_reference || overly_structured_reference || simple_structured_reference) && ignore { terminal("]") }
  end
end
thing() click to toggle source
# File src/excel/formula_peg.rb, line 20
def thing
  percentage || function || array || brackets || any_reference || string || number || boolean || prefix || error || named_reference
end