| 1 | # -*- tcl -*- |
|---|
| 2 | # Transform - Minimize the grammar, through the removal of the |
|---|
| 3 | # unreachable and not useful nonterminals (and expressions). |
|---|
| 4 | |
|---|
| 5 | # This package assumes to be used from within a PAGE plugin. It uses |
|---|
| 6 | # the API commands listed below. These are identical across the major |
|---|
| 7 | # types of PAGE plugins, allowing this package to be used in reader, |
|---|
| 8 | # transform, and writer plugins. It cannot be used in a configuration |
|---|
| 9 | # plugin, and this makes no sense either. |
|---|
| 10 | # |
|---|
| 11 | # To ensure that our assumption is ok we require the relevant pseudo |
|---|
| 12 | # package setup by the PAGE plugin management code. |
|---|
| 13 | # |
|---|
| 14 | # -----------------+-- |
|---|
| 15 | # page_info | Reporting to the user. |
|---|
| 16 | # page_warning | |
|---|
| 17 | # page_error | |
|---|
| 18 | # -----------------+-- |
|---|
| 19 | # page_log_error | Reporting of internals. |
|---|
| 20 | # page_log_warning | |
|---|
| 21 | # page_log_info | |
|---|
| 22 | # -----------------+-- |
|---|
| 23 | |
|---|
| 24 | # ### ### ### ######### ######### ######### |
|---|
| 25 | ## Requisites |
|---|
| 26 | |
|---|
| 27 | # @mdgen NODEP: page::plugin |
|---|
| 28 | |
|---|
| 29 | package require page::plugin ; # S.a. pseudo-package. |
|---|
| 30 | package require page::analysis::peg::reachable |
|---|
| 31 | package require page::analysis::peg::realizable |
|---|
| 32 | |
|---|
| 33 | namespace eval ::page::analysis::peg {} |
|---|
| 34 | |
|---|
| 35 | # ### ### ### ######### ######### ######### |
|---|
| 36 | ## API |
|---|
| 37 | |
|---|
| 38 | proc ::page::analysis::peg::minimize {t} { |
|---|
| 39 | page_info {[PEG Minimization]} |
|---|
| 40 | page_log_info ..Reachability ; ::page::analysis::peg::reachable::remove! |
|---|
| 41 | page_log_info ..Realizability ; ::page::analysis::peg::realizable::remove! |
|---|
| 42 | |
|---|
| 43 | page_log_info Ok |
|---|
| 44 | return |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | # ### ### ### ######### ######### ######### |
|---|
| 48 | ## Ready |
|---|
| 49 | |
|---|
| 50 | package provide page::analysis::peg::minimize 0.1 |
|---|
| 51 | |
|---|