Sha256: 3661fdfbdbf94ad815d6f1134cfdc39ccba8acb388102409b2848d04cffb84ad

Contents?: true

Size: 1.47 KB

Versions: 6

Compression:

Stored size: 1.47 KB

Contents

grammar Soroban
  rule formula
    '=' space? logical <Formula> / string / number / boolean
  end
  rule logical
    and ( space? 'or' space? and )*
  end
  rule and
    truthval ( space? 'and' space? truthval )*
  end
  rule truthval
    comparison / '(' space? logical space? ')' / boolean
  end
  rule boolean
    'true' / 'false' / 'TRUE' / 'FALSE'
  end
  rule comparison
    expression ( space? comparator space? expression )*
  end
  rule comparator
    '=' <Equal> / '<>' <NotEqual> / '>=' / '<=' / '>' / '<'
  end
  rule expression
    multiplicative ( space? additive_operator space? multiplicative )*
  end
  rule additive_operator
    '+' / '-'
  end
  rule multiplicative
    value ( space? multiplicative_operator space? value )*
  end
  rule multiplicative_operator
    '^' <Pow> / '*' / '/'
  end
  rule value
    ( function / '(' space? expression space? ')' / range / number / boolean / identifier / string / '-' value )
  end
  rule function
    [a-zA-Z]+ '(' space? arguments? space? ')' <Function>
  end
  rule arguments
    logical ( space? ',' space? logical )*
  end
  rule number
    float / integer
  end
  rule float
    [0-9]* '.' [0-9]+
  end
  rule integer
    [0-9]+
  end
  rule identifier
    [a-zA-Z] [a-zA-Z0-9]* <Identifier>
  end
  rule label
    [A-Za-z]+ [1-9] [0-9]* <Label> / '$' [A-Za-z]+ '$' [1-9] [0-9]* <Label>
  end
  rule string
    '"' ('\"' / !'"' .)* '"' / "'" [^']* "'"
  end
  rule range
    label ':' label <Range>
  end
  rule space
    [\s]+
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
soroban-0.3.1 lib/soroban/parser/grammar.treetop
soroban-0.3.0 lib/soroban/parser/grammar.treetop
soroban-0.2.0 lib/soroban/parser/grammar.treetop
soroban-0.1.1 lib/soroban/parser/grammar.treetop
soroban-0.1.0 lib/soroban/parser/grammar.treetop
Soroban-0.1.0 lib/soroban/parser/grammar.treetop