Sha256: 2583b1402618744862e3ff6f58c64163749f52dd225cc23fc3ad9944bb1c88c5

Contents?: true

Size: 856 Bytes

Versions: 1

Compression:

Stored size: 856 Bytes

Contents

#
# Context free grammar of tokens (terminal
# nodes) for the Emerald language.
#
grammar Scopes
  include Variables

  rule scope_fn
    (given / unless / each / with) "\n"
    <ScopeFn>
  end

  rule given
    "given" space* boolean_expr <Given>
  end

  rule unless
    "unless" space* boolean_expr <Unless>
  end

  rule with
    "with" space* variable_name <With>
  end

  rule each
    "each" space* collection:variable_name
    space* "as" space* val_name:variable_name
    indexed:(',' space* key_name:variable_name)?
    <Each>
  end

  rule boolean_expr
    binary_expr / unary_expr
  end

  rule binary_expr
    lhs:unary_expr
    space+ op:("and" / "or") space*
    rhs:boolean_expr
    <BinaryExpr>
  end

  rule unary_expr
    negated:("not" space+)?
    (val:variable_name / '(' space* val:boolean_expr space* ')')
    <UnaryExpr>
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
emerald-lang-1.0.0 lib/emerald/grammar/scopes.tt