opengrammar.parser.meta_syntax

The meta-syntax parser.

Module Contents

Classes

Conjunction

A conjunction.

Disjunction

A disjunction.

LHS

The left-hand side of a rule.

MetaSyntaxAST

The abstract syntax tree of the meta-syntax.

NonTerminal

A non-terminal symbol.

PostfixType

The kind of postfix operators available.

RHS

The right-hand side of a rule.

Rule

A rule.

Terminal

A terminal symbol.

class opengrammar.parser.meta_syntax.Conjunction(antecedent, consequent, postfix=None)[source]

A conjunction.

The conjunction of two operands.

Parameters:
  • antecedent (Operands) – An antecedent.

  • consequent (Operands) – A consequent.

  • postfix (Optional[PostfixType]) – A postfix operator.

class opengrammar.parser.meta_syntax.Disjunction(antecedent, consequent, postfix=None)[source]

A disjunction.

The disjunction of two operands.

Parameters:
  • antecedent (Operands) – An antecedent.

  • consequent (Operands) – A consequent.

  • postfix (Optional[PostfixType]) – The postfix operator.

class opengrammar.parser.meta_syntax.LHS(rule)[source]

The left-hand side of a rule.

Initializes the LHS.

Parameters:

rule (Union[NonTerminal, Conjunction, Disjunction]) – A rule.

class opengrammar.parser.meta_syntax.MetaSyntaxAST(rules)[source]

The abstract syntax tree of the meta-syntax.

Initializes the MetaSyntaxAST.

Parameters:

rules (List[Rule]) – A list of rules.

class opengrammar.parser.meta_syntax.NonTerminal(symbol, postfix=None)[source]

A non-terminal symbol.

Initializes the NonTerminal.

Parameters:
  • symbol (str) – The symbol of the non-terminal.

  • postfix (Optional[PostfixType]) – The postfix operator.

class opengrammar.parser.meta_syntax.PostfixType(*args, **kwds)[source]

Bases: enum.Enum

The kind of postfix operators available.

class opengrammar.parser.meta_syntax.RHS(rule)[source]

The right-hand side of a rule.

Initializes the RHS.

Parameters:

rule (Operands) – A rule.

class opengrammar.parser.meta_syntax.Rule(lhs, rhs, number=None)[source]

A rule.

Initializes the Rule.

Parameters:
  • lhs (LHS) – The left-hand side of the rule.

  • rhs (RHS) – The right-hand side of the rule.

  • number (Optional[int]) – The rule number.

class opengrammar.parser.meta_syntax.Terminal(symbol)[source]

A terminal symbol.

Initializes the Terminal.

Parameters:

symbol (str) – The symbol of the terminal.