view src/cbcTranslator.py @ 5:11fba907c0af

add Translater(object), that can translate C/CbC source code from NFA or DFA(CbC can translate from DFA). and refactoring, refactoring, refactoring... not implimented translation-DotFile.
author ryoma <e075725@ie.u-ryukyu.ac.jp>
date Thu, 01 Jul 2010 00:40:51 +0900
parents
children 168d60b03e2c
line wrap: on
line source

#!/usr/bin/env python

import sys
from dfareg import Regexp, CallGraph
from cTranslator import CTranslator

class CbCTranslateExeption(Exception):
    pass

class CbCTranslator(CTranslator):
    def __init__(self, regexp, cg, stream=sys):
        if cg.type is "NFA": raise CbCTranslateExeption("can't translate CbC from NFA")
        self.regexp = regexp
        self.cg = cg
        self.stream = stream
        self.funType = '__code '
        self.callType = 'goto '
        self.breakStatement = ''
        self.debug = False

def main():
    reg = Regexp("(A|B)*C")
    cbct = CbCTranslator(reg.regexp, CallGraph(reg.dfa))
    cbct.translate()

if __name__ == '__main__' : main()