Exemplo n.º 1
0
#Scanner created with HexNumber.ATG data
from AFDFixed.AFD import *

adfArray = []
ident = 'ident'
temp = AFD(ident)
tempidentAcceptance = {0: False, 1: True}

temp.setDictAcceptance(tempidentAcceptance)
tempidentTransitions = {
    0: {
        1: [{
            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, 97, 98, 99, 100, 101, 102, 103,
            104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
            117, 118, 119, 120, 121, 122
        }]
    },
    1: {
        1: [{
            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, 97, 98, 99, 100, 101, 102, 103,
            104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
            117, 118, 119, 120, 121, 122
        }, {48, 49, 50, 51, 52, 53, 54, 55, 56, 57}]
    }
}

temp.setTransition(tempidentTransitions)
adfArray.append(temp)
hexnumber = 'hexnumber'
Exemplo n.º 2
0
    return "key doesn't exist"

def isHigher(val1, val2):
    if val1 < val2:
        return True
    else:
        return False
    


exceptions = ['while','do','if','switch']
precedence = {'ident': 0, 'hexnumber': 1, 'number': 2, 'signnumber': 3, 'whitetoken': 4, 'ANY': 5}

adfArray = []
ident= 'ident'
temp = AFD(ident)
tempidentAcceptance = {0: False, 1: True}

temp.setDictAcceptance(tempidentAcceptance)
tempidentTransitions = {0: {1: [{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, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122}]}, 1: {1: {48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 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, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122}}}

temp.setTransition(tempidentTransitions)
adfArray.append(temp)
hexnumber= 'hexnumber'
temp = AFD(hexnumber)
temphexnumberAcceptance = {0: False, 1: False, 2: True}

temp.setDictAcceptance(temphexnumberAcceptance)
temphexnumberTransitions = {0: {1: [{65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57}]}, 1: {1: [{65, 66, 67, 68, 69, 70, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57}], 2: [{72}]}}

temp.setTransition(temphexnumberTransitions)
Exemplo n.º 3
0
    KeywordsDict = createKeywordsDict(charactersDict, keywords)
    print('KeywordsDict', KeywordsDict)
    tokensDict, exceptions = createTokensDict(charactersDict, tokens,
                                              specialCharacters, special)
    print('tokensDict', tokensDict)
    tokensArray = functionsCreator(tokensDict, charactersDict)

    for i in tokensArray:
        print(i.getTransitions())
        i.correctTransitions(charactersDict, specialCharacters, special)
        print(i.getTransitions())

    adfArray = []
    for i in tokensArray:
        name = i.getName()
        temp = AFD(name)
        acceptanceDict = i.getAcceptance()
        temp.setDictAcceptance(acceptanceDict)
        transitionsDict = i.getTransitions()
        temp.setTransition(transitionsDict)
        adfArray.append(temp)

    exceptions = ['while', 'do', 'if', 'switch']

    scanner = fileWritter(nameATG)
    scanner.writeImport('from AFDFixed.AFD import *')
    scanner.writeSentence('')
    scanner.writeSentence("exceptions = ['while','do','if','switch']")
    adfArray = []
    scanner.writeSentence('adfArray = []')
    for i in tokensArray:
Exemplo n.º 4
0
#Scanner created with Double.ATG data
from AFDFixed.AFD import *

exceptions = ['while', 'do', 'if', 'switch']
adfArray = []
number = 'number'
temp = AFD(number)
tempnumberAcceptance = {0: False, 1: True}

temp.setDictAcceptance(tempnumberAcceptance)
tempnumberTransitions = {
    0: {
        1: [{48, 49, 50, 51, 52, 53, 54, 55, 56, 57}]
    },
    1: {
        1: [{48, 49, 50, 51, 52, 53, 54, 55, 56, 57}]
    }
}

temp.setTransition(tempnumberTransitions)
adfArray.append(temp)
decnumber = 'decnumber'
temp = AFD(decnumber)
tempdecnumberAcceptance = {0: False, 1: False, 2: False, 3: True}

temp.setDictAcceptance(tempdecnumberAcceptance)
tempdecnumberTransitions = {
    0: {
        1: [{48, 49, 50, 51, 52, 53, 54, 55, 56, 57}]
    },
    1: {
Exemplo n.º 5
0
    return "key doesn't exist"


def isHigher(val1, val2):
    if val1 < val2:
        return True
    else:
        return False


exceptions = ['while', 'do', 'if', 'switch']
precedence = {'number': 0, 'decnumber': 1, 'white': 2, 'ANY': 3}

adfArray = []
number = 'number'
temp = AFD(number)
tempnumberAcceptance = {0: False, 1: True}

temp.setDictAcceptance(tempnumberAcceptance)
tempnumberTransitions = {
    0: {
        1: [{48, 49, 50, 51, 52, 53, 54, 55, 56, 57}]
    },
    1: {
        1: [{48, 49, 50, 51, 52, 53, 54, 55, 56, 57}]
    }
}

temp.setTransition(tempnumberTransitions)
adfArray.append(temp)
decnumber = 'decnumber'
Exemplo n.º 6
0
#Scanner created with Aritmetica.ATG data
from AFDFixed.AFD import *

exceptions = ['while', 'do', 'if', 'switch']
adfArray = []
ident = 'ident'
temp = AFD(ident)
tempidentAcceptance = {0: False, 1: True}

temp.setDictAcceptance(tempidentAcceptance)
tempidentTransitions = {
    0: {
        1: [{
            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, 97, 98, 99, 100, 101, 102, 103,
            104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
            117, 118, 119, 120, 121, 122
        }]
    },
    1: {
        1: [{
            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, 97, 98, 99, 100, 101, 102, 103,
            104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
            117, 118, 119, 120, 121, 122
        }, {48, 49, 50, 51, 52, 53, 54, 55, 56, 57}]
    }
}

temp.setTransition(tempidentTransitions)
adfArray.append(temp)
Exemplo n.º 7
0
    return "key doesn't exist"


def isHigher(val1, val2):
    if val1 < val2:
        return True
    else:
        return False


exceptions = ['while', 'do', 'if', 'switch']
precedence = {'ident': 0, 'number': 1, 'ANY': 2}

adfArray = []
ident = 'ident'
temp = AFD(ident)
tempidentAcceptance = {0: False, 1: True}

temp.setDictAcceptance(tempidentAcceptance)
tempidentTransitions = {
    0: {
        1: [{
            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, 97, 98, 99, 100, 101, 102, 103,
            104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
            117, 118, 119, 120, 121, 122
        }]
    },
    1: {
        1: {
            48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71,
Exemplo n.º 8
0
#Scanner created with Cocol.ATG data
from AFDFixed.AFD import *

exceptions = ['while', 'do', 'if', 'switch']
adfArray = []
ident = 'ident'
temp = AFD(ident)
tempidentAcceptance = {0: False, 1: True}

temp.setDictAcceptance(tempidentAcceptance)
tempidentTransitions = {
    0: {
        1: [{
            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, 97, 98, 99, 100, 101, 102, 103,
            104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
            117, 118, 119, 120, 121, 122
        }]
    },
    1: {
        1: [{
            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, 97, 98, 99, 100, 101, 102, 103,
            104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
            117, 118, 119, 120, 121, 122
        }, {48, 49, 50, 51, 52, 53, 54, 55, 56, 57}]
    }
}

temp.setTransition(tempidentTransitions)
adfArray.append(temp)