Grammalecte  Diff

Differences From Artifact [9a2e2f9a01]:

To Artifact [f859281899]:


259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
        dFUNCTIONS["_g_d_"+sActionId] = sAction
        sAction = "_g_d_"+sActionId
        return [sOption, sCondition, cAction, sAction]
    else:
        print("# Unknown action at line " + sActionId)
        return None


def checkRegexes (dAllGraph):
    "check validity of regexes"
    print("  checking regexes...")
    aRegex = set()
    for sGraphName, dGraph in dAllGraph.items():
        for nKey, dVal in dGraph.items():
            if "<re_value>" in dVal:
                for sRegex in dVal["<re_value>"]:
                    if sRegex not in aRegex:
                        _checkRegex(sRegex)
                        aRegex.add(sRegex)
            if "<re_morph>" in dVal:
                for sRegex in dVal["<re_morph>"]:
                    if sRegex not in aRegex:
                        _checkRegex(sRegex)
                        aRegex.add(sRegex)
    aRegex.clear()

def _checkRegex (sRegex):
    #print(sRegex)
    if "¬" in sRegex:
        sPattern, sNegPattern = sRegex.split("¬")
        try:
            if not sNegPattern:
                print("# Warning! Empty negpattern:", sRegex)
            re.compile(sPattern)
            re.compile(sNegPattern)
        except:
            print("# Error. Wrong regex:", sRegex)
            traceback.print_exc()
            exit()
    else:
        try:
            if not sRegex:
                print("# Warning! Empty pattern:", sRegex)
            re.compile(sRegex)
        except:
            print("# Error. Wrong regex:", sRegex)
            traceback.print_exc()
            exit()


def make (lRule, dDef, sLang, bJavaScript):
    "compile rules, returns a dictionary of values"
    # for clarity purpose, don’t create any file here

    # removing comments, zeroing empty lines, creating definitions, storing tests, merging rule lines
    print("  parsing rules...")







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







259
260
261
262
263
264
265










































266
267
268
269
270
271
272
        dFUNCTIONS["_g_d_"+sActionId] = sAction
        sAction = "_g_d_"+sActionId
        return [sOption, sCondition, cAction, sAction]
    else:
        print("# Unknown action at line " + sActionId)
        return None












































def make (lRule, dDef, sLang, bJavaScript):
    "compile rules, returns a dictionary of values"
    # for clarity purpose, don’t create any file here

    # removing comments, zeroing empty lines, creating definitions, storing tests, merging rule lines
    print("  parsing rules...")