Grammalecte  Check-in [8f59594242]

Overview
Comment:[core] listRules() update
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | core
Files: files | file ages | folders
SHA3-256: 8f5959424221f301ba9ffdb5e842cab614fa001be976c72d89dd073fc3839820
User & Date: olr on 2019-07-27 01:07:04
Other Links: manifest | tags
Context
2019-07-28
23:18
[fr] tests et ajustements check-in: fc9f9195c1 user: olr tags: trunk, fr
2019-07-27
01:07
[core] listRules() update check-in: 8f59594242 user: olr tags: trunk, core
01:06
[fr] tests check-in: 17195aec63 user: olr tags: trunk, fr
Changes

Modified gc_core/py/lang_core/gc_engine.py from [f4d14f00c4] to [7f1ad67968].

134
135
136
137
138
139
140

141
142
143
144
145
146
147
148
149
150





151
152
153
154
155
156
157
134
135
136
137
138
139
140
141
142
143
144
145
146





147
148
149
150
151
152
153
154
155
156
157
158







+





-
-
-
-
-
+
+
+
+
+







    "generator: returns typle (sOption, sLineId, sRuleId)"
    if sFilter:
        try:
            zFilter = re.compile(sFilter)
        except re.error:
            echo("# Error. List rules: wrong regex.")
            sFilter = None
    # regex rules
    for sOption, lRuleGroup in chain(_getRules(True), _getRules(False)):
        if sOption != "@@@@":
            for _, _, sLineId, sRuleId, _, _ in lRuleGroup:
                if not sFilter or zFilter.search(sRuleId):
                    yield ("RegEx", sOption, sLineId, sRuleId)
        else:
            for sRuleName, lActions in _rules_graph.dRule.items():
                sOption, _, cActionType, *_ = lActions
                if cActionType == "-":
                    yield("Tokens", sOption, "", sRuleName)
    # tokens rules
    for sRuleName, lActions in _rules_graph.dRule.items():
        sOption, _, cActionType, *_ = lActions
        if cActionType == "-":
            yield("Tokens", sOption, "", sRuleName)


def displayRules (sFilter=None):
    "display the name of rules, with the filter <sFilter>"
    echo("List of rules. Filter: << " + str(sFilter) + " >>")
    for sOption, sLineId, sRuleId, sType in listRules(sFilter):
        echo("{:<8} {:<10} {:<10} {}".format(sOption, sLineId, sRuleId, sType))