0.0.1 • Published 10 years ago

umpire v0.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
10 years ago

Umpire

A logical framework.

Usage

  var theory = new Umpire()

  theory.defineType('Real'
    // Definitions should return what they matched
  , function (token) {
    var match = token.match(/^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/)

    if(match) {
      return match[0]
    }
    // If no match is possible, return false
    else {
      return false
    }
  })

  // Match on [Real, Real, ...]
  theory.defineType('Vector', ['[', theory.repeat('Real', ','),']'])

  // Match on [Vector, Vector, ...]
  theory.defineType('Matrix', ['[', theory.repeat('Vector', ','),']'])

  /// Assert on types
  t.equal(theory.getType('0'), 'Real')
  t.equal(theory.getType('-10.3e-9'), 'Real')
  t.equal(theory.getType('-10.3ee'), false)
  t.equal(theory.getType('[-1.3e9, 3]'), 'Vector')
  t.equal(theory.getType('[[1, 2],[3, 4]]'), 'Matrix')