Skip to content
/ RE Public

A work-in-progress python implementation for syntactic and semantic analysis (Finite State Machine, Regular Expression and Shift-Reduce Parser).

Notifications You must be signed in to change notification settings

000alen/RE

Repository files navigation

RE

A work-in-progress python implementation for syntactic and semantic analysis (Finite State Machine, Regular Expression and Shift-Reduce Parser).

To-do list

  • Refactor Re.Lexer.Lexer.lex.
  • Implement RE.Parser.Parser.parse.

Usage

"""A very basic definition of BaseTypes using RE."""

from RE.RegularExpression.Literal import Literal
from RE.RegularExpression.One import One
from RE.RegularExpression.Optional import Optional
from RE.RegularExpression.Wildcard import Wildcard
from RE.RegularExpression.Zero import Zero

_sign = Literal("+") | Literal("-")
_digit = Literal("0") >> Literal("9")

base_types = {
    "integer": Optional(_sign) + One(_digit),
    "decimal": Optional(_sign) + Zero(_digit) + Literal(".") + One(_digit),
    "boolean": Literal("True") | Literal("False"),
    "undefined": Literal("Undefined"),
    "string": Literal("\"") + Zero(Wildcard()) + Literal("\""),
}

string = input("> ")
for name, expression in base_types.items():
    if expression.match(string):
        print(name)

About

A work-in-progress python implementation for syntactic and semantic analysis (Finite State Machine, Regular Expression and Shift-Reduce Parser).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages