bexp

package
v1.2.23 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const ADD uint = 16

ADD represents integer addition

View Source
const AND uint = 15

AND represents logical conjunction

View Source
const BOTTOM uint = 12

BOTTOM represents logical falsehood

View Source
const END_OF uint = 0

END_OF signals "end of file"

View Source
const EQUALS uint = 6

EQUALS signals an equality

View Source
const GREATERTHAN uint = 10

GREATERTHAN signals a (strict) inequality X > Y

View Source
const GREATERTHAN_EQUALS uint = 11

GREATERTHAN_EQUALS signals a (non-strict) inequality X >= Y

View Source
const IDENTIFIER uint = 5

IDENTIFIER signals a column variable.

View Source
const LBRACE uint = 2

LBRACE signals "left brace"

View Source
const LESSTHAN uint = 8

LESSTHAN signals a (strict) inequality X < Y

View Source
const LESSTHAN_EQUALS uint = 9

LESSTHAN_EQUALS signals a (non-strict) inequality X <= Y

View Source
const MUL uint = 18

MUL represents integer multiplication

View Source
const NOT_EQUALS uint = 7

NOT_EQUALS signals a non-equality

View Source
const NUMBER uint = 4

NUMBER signals an integer number

View Source
const OR uint = 14

OR represents logical disjunction

View Source
const RBRACE uint = 3

RBRACE signals "right brace"

View Source
const SUB uint = 17

SUB represents integer subtraction

View Source
const TOP uint = 13

TOP represents logical truth

View Source
const WHITESPACE uint = 1

WHITESPACE signals whitespace

Variables

View Source
var BINOPS = []uint{SUB, MUL, ADD}

BINOPS captures the set of binary operations

CONDITIONS captures the set of conditions.

View Source
var CONNECTIVES = []uint{AND, OR}

CONNECTIVES captures the set of logical connectives.

Functions

func Parse

func Parse[T Term[T]](input string, environment func(string) bool) (T, []source.SyntaxError)

Parse a given input string into logical proposition. The environment determines the set of permitted variable names.

Types

type Parser

type Parser[T Term[T]] struct {
	// contains filtered or unexported fields
}

Parser provides a general-purpose parser for propositions and arithmetic expressions.

func (*Parser[T]) Done

func (p *Parser[T]) Done() bool

Done determines whether or not the parser has parsed all the available tokens.

type Term

type Term[T any] interface {
	// Create new variable.
	Variable(string) T
	// Create new constant.
	Number(big.Int) T
	// Logical
	Or(...T) T
	And(...T) T
	Truth(bool) T
	// Relational
	Equals(T) T
	NotEquals(T) T
	LessThan(T) T
	LessThanEquals(T) T
	// Arithmetic
	Add(...T) T
	Mul(...T) T
	Sub(...T) T
}

Term represents an abstraction over boolean expressions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL