Overview
| Comment: | [build][core] rules graph: definitions and multiple tokens | 
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive | 
| Timelines: | family | ancestors | descendants | both | core | build | rg | 
| Files: | files | file ages | folders | 
| SHA3-256: | da8c5de7dfa98ccb745eb92a8e910af8 | 
| User & Date: | olr on 2018-05-24 11:14:16 | 
| Other Links: | branch diff | manifest | tags | 
Context
| 2018-05-25 | ||
| 10:07 | [build][core] multiple tokens and groups check-in: e83552ea6d user: olr tags: core, build, rg | |
| 2018-05-24 | ||
| 11:14 | [build][core] rules graph: definitions and multiple tokens check-in: da8c5de7df user: olr tags: core, build, rg | |
| 11:13 | [build][bug] darg: wrong statement check-in: c4ce706a6b user: olr tags: build, rg | |
Changes
Modified compile_rules_graph.py from [a8ad098a64] to [b56c5bc314].
| ︙ | ︙ | |||
| 42 43 44 45 46 47 48 49 50 51 | 
def changeReferenceToken (s, dPos):
    for i in range(len(dPos), 0, -1):
        s = s.replace("\\"+str(i), "\\"+dPos[i])
    return s
def createRule (iLine, sRuleName, sTokenLine, sActions, nPriority):
    # print(iLine, "//", sRuleName, "//", sTokenLine, "//", sActions, "//", nPriority)
 | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > < | | | | | | | | | | | | | | | | | | | | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | 
def changeReferenceToken (s, dPos):
    for i in range(len(dPos), 0, -1):
        s = s.replace("\\"+str(i), "\\"+dPos[i])
    return s
def genTokenRules (sTokenLine):
    lToken = sTokenLine.split()
    lTokenRules = None
    for i, sToken in enumerate(lToken):
        if sToken.startswith("{") and sToken.endswith("}") and sToken in dDEF:
            lToken[i] = dDEF[sToken]
        if sToken.startswith("[") and sToken.endswith("]"):
            # multiple token
            if not lTokenRules:
                lTokenRules = [ sToken[1:-1].split("|") ]
            else:
                lNewTemp = []
                for aRule in lTokenRules:
                    lElem = sToken[1:-1].split("|")
                    sElem1 = lElem.pop(0)
                    for sElem in lElem:
                        aNew = list(aRule)
                        aNew.append(sElem)
                        lNewTemp.append(aNew)
                    aRule.append(sElem1)
                lTokenRules.extend(lNewTemp)
        else:
            # simple token
            if not lTokenRules:
                lTokenRules = [[sToken]]
            else:
                for aRule in lTokenRules:
                    aRule.append(sToken)
    for aRule in lTokenRules:
        print("Rule\n", aRule)
        yield aRule
def createRule (iLine, sRuleName, sTokenLine, sActions, nPriority):
    # print(iLine, "//", sRuleName, "//", sTokenLine, "//", sActions, "//", nPriority)
    for lToken in genTokenRules(sTokenLine):
        # Calculate positions
        dPos = {}
        nGroup = 0
        for i, sToken in enumerate(lToken):
            if sToken.startswith("(") and sToken.endswith(")"):
                lToken[i] = sToken[1:-1]
                nGroup += 1
                dPos[nGroup] = i
        # Parse actions
        for nAction, sAction in enumerate(sActions.split(" <<- ")):
            if sAction.strip():
                sActionId = sRuleName + "_a" + str(nAction)
                aAction = createAction(sActionId, sAction, nGroup, nPriority, dPos)
                if aAction:
                    dACTIONS[sActionId] = aAction
                    lResult = list(lToken)
                    lResult.extend(["##"+str(iLine), sActionId])
                    yield lResult
def createAction (sIdAction, sAction, nGroup, nPriority, dPos):
    m = re.search("([-~=])(\\d+|)(:\\d+|)>> ", sAction)
    if not m:
        print(" # Error. No action found at: ", sIdAction)
        print("   ==", sAction, "==")
 | 
| ︙ | ︙ | 
Modified gc_lang/fr/rules_graph.grx from [afffaf61f2] to [25632727ec].
| ︙ | ︙ | |||
| 48 49 50 51 52 53 54 | 
__rule2__
    ci important que soi
    ci vraiment il y a
    ci pour ça
        <<- morph(\2, ":[WAR]", False) -1>> si   # Message1|http://test.grammalecte.net
__rule3__
 | | < < | 48 49 50 51 52 53 54 55 56 57 58 | 
__rule2__
    ci important que soi
    ci vraiment il y a
    ci pour ça
        <<- morph(\2, ":[WAR]", False) -1>> si   # Message1|http://test.grammalecte.net
__rule3__
    contre [nature|pétrie|action]
        <<- morph(\1, "xxxx") -1:2>> =\1+\2     # Message2|http://test.grammalecte.org
        <<-  ~>> hyper|fonction
 |