Skip to content

A LR(0) (and hopefully also a LALR(1) in the future) parser created in Python.

Notifications You must be signed in to change notification settings

SSoup64/Cologne

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

COLOGNE

What Cologne is:

Cologne is a LR(0) parser created in Python.

How to use cologne:

  1. import Cologne.
import Cologne
  1. create a parser.
parser = Cologne.parser
  1. create your terminals.
# Terminals.
NUMBER = parser.add_terminal(Cologne.Terminal("NUMBER"))
PLUS = parser.add_terminal(Cologne.Terminal("PLUS"))
MINUS = parser.add_terminal(Cologne.Terminal("MINUS"))
TIMES = parser.add_terminal(Cologne.Terminal("TIMES"))
DIVIDE = parser.add_terminal(Cologne.Terminal("DIVIDE"))
  1. create your non terminals.
expr = parser.add_non_terminal(Cologne.NonTerminal("expr"))
  1. create your productions.
parser.add_productions(
	Cologne.Production( expr, (expr, PLUS, expr) ),
	Cologne.Production( expr, (expr, MINUS, expr) ),
	Cologne.Production( expr, (expr, TIMES, expr) ),
	Cologne.Production( expr, (expr, DIVIDE, expr) ),
	Cologne.Production( expr, (NUMBER, ) )
)
  1. Generate the closures and the parse table.
parser.generate_closures()
parse_table = Cologne.ParseTable(parser)

About

A LR(0) (and hopefully also a LALR(1) in the future) parser created in Python.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages