Sha256: e9e745289ef593542d8d936ee1522da1cfae29e4f25502f8f73237e9b0486d30

Contents?: true

Size: 842 Bytes

Versions: 1

Compression:

Stored size: 842 Bytes

Contents

# Sexpr

A ruby compilation framework around s-expressions.

## Example

    grammar = SexpGrammar.load(<<-YAML)

      # alternative rule
      bool_expr:
        - bool_and
        - bool_or
        - bool_not
        - var_ref
        - literal

      # non-terminal
      bool_and:
        - [ bool_expr, bool_expr ]
      bool_or:
        - [ bool_expr, bool_expr ]
      bool_not:
        - [ bool_expr ]
      literal:
        - [ truth_value ]
      var_ref:
        - [ var_name ]

      # terminals
      var_name:
        !ruby/regexp /^[a-z]+$/
      truth_value:
        - true
        - false

    YAML

    grammar === [:bool_and, [:bool_not, [:var_ref, "x"]], [:literal, true]]
    # => true

    grammar === [:bool_and, [:literal, "true"]]
    # => false (second term is missing)

## Links

https://github.com/blambeau/sexpr

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sexpr-0.2.0 README.md