Sha256: 09d401506f4db250a8c5f495ef092623451548f63ebb98e7e9d82cb63343c822

Contents?: true

Size: 1.53 KB

Versions: 3

Compression:

Stored size: 1.53 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 / '-' float / '-' integer )
  end
  rule float
    [0-9]* '.' [0-9]+ <FloatValue>
  end
  rule integer
    [0-9]+ <IntegerValue>
  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

3 entries across 3 versions & 1 rubygems

Version Path
soroban-0.7.3 lib/soroban/parser/grammar.treetop
soroban-0.7.2 lib/soroban/parser/grammar.treetop
soroban-0.5.4 lib/soroban/parser/grammar.treetop