agent_logic.parsing

Logic parsing module.

This module provides parsers for converting logical formulas from string representations to logical expression objects.

class agent_logic.parsing.ASTParser[source]

Bases: object

Parses structured data (JSON/dict) into logical expressions.

static parse_dict(data)[source]

Recursively parses a JSON/dict representation into an expression.

Return type:

LogicalExpression

Parameters:

data (Dict)

class agent_logic.parsing.Tokenizer[source]

Bases: object

Lexical analyzer for tokenizing logical expressions.

TOKEN_MAP = {'AND': '\\∧|\\bAND\\b', 'EXISTS': '∃|\\bEXISTS\\b', 'FORALL': '∀|\\bFORALL\\b', 'IFF': '↔|\\bIFF\\b', 'IMPLIES': '→|\\bIMPLIES\\b', 'LPAREN': '\\(', 'NOT': '¬|\\bNOT\\b', 'OR': '\\∨|\\bOR\\b', 'RPAREN': '\\)', 'VAR': '[a-zA-Z][a-zA-Z0-9_]*'}
static tokenize(expression)[source]

Tokenizes a logical expression into components.

Return type:

List[str]

Parameters:

expression (str)

static validate_syntax(tokens)[source]

Performs basic syntax validation.

Return type:

bool

Parameters:

tokens (List[str])

Modules