コード例 #1
0
ファイル: Declaration.py プロジェクト: hiker/stan
class Implicit(BasicStatement):

    # Stores a parameter declaration
    def __init__(self, sImplicit="IMPLICIT", loc=None, nIndent=0):
        BasicStatement.__init__(self, None, loc, nIndent)
        self.sImplicit = sImplicit
        self.sNone     = None
        self.type      = None
        self.l         = DoubleList()
        self.sParOpen  = None
        self.sParClose = None
    # --------------------------------------------------------------------------
    def SetParOpen(self, sParOpen): self.sParOpen = sParOpen
    # --------------------------------------------------------------------------
    def SetParClose(self, sParClose): self.sParClose = sParClose
    # --------------------------------------------------------------------------
    def SetImplicitNone(self, sNone="NONE"): self.sNone=sNone
    # --------------------------------------------------------------------------
    def isNone(self): return self.sNone!=None
    # --------------------------------------------------------------------------
    def SetType(self, type): self.type=type
    # --------------------------------------------------------------------------
    def AddLetter(self, sFrom, sDash=None, sTo=None, sComma=None):
        self.l.append(FromTo(sFrom, sDash, sTo), sComma)
    # --------------------------------------------------------------------------
    def ToList(self, stylesheet, l):
        BasicStatement.ToList(self, stylesheet, l)
        l.append(stylesheet.sKeyword(self.sImplicit),nIndentNext=1)
        if self.sNone:
            l.append(stylesheet.sKeyword(self.sNone))
            return
        stylesheet.ToList(self.type, l)
        l.append(self.sParOpen)
        self.l.ToList(stylesheet, l)
        l.append(self.sParClose)
コード例 #2
0
ファイル: IO.py プロジェクト: hiker/stan
class BasicIOList(BasicStatement):
    def __init__(self, sLabel=None, loc=None, nIndent=0, sKeyword="",
                 sParOpen=None, opt=None):
        BasicStatement.__init__(self, sLabel, loc, nIndent, isDeclaration=0)
        self.sKeyword  = sKeyword
        self.sParOpen  = sParOpen
        self.sParClose = ')'
        self.lParams   = DoubleList()
        if opt: self.AddIOOpt(opt)
    # --------------------------------------------------------------------------
    def SetParOpen(self, sParOpen='('): self.sParOpen = sParOpen
    # --------------------------------------------------------------------------
    def SetParClose(self, sParClose=')'): self.sParClose = sParClose
    # --------------------------------------------------------------------------
    def AddIOOpt(self, exp, sComma=None):
        if type(exp)==type(1): exp=`exp`
        self.lParams.append(exp, sComma)
    # --------------------------------------------------------------------------
    def sGetParClose(self): return self.sParClose
    # --------------------------------------------------------------------------
    def GetVarUsage(self, varUsage, sType="read", obj=None, loc=None):
        for i in self.lParams.GetMainList():
            varUsage.AddVariable(i, "unknown", obj, loc)
    # --------------------------------------------------------------------------
    def ToList(self, stylesheet, l):
        BasicStatement.ToList(self, stylesheet, l)
        l.append(stylesheet.sKeyword(self.sKeyword))
        if self.sParOpen:
            l.append(self.sParOpen)
            self.lParams.ToList(stylesheet, l),
            l.append(self.sParClose)
コード例 #3
0
ファイル: Statements.py プロジェクト: hiker/stan
 def __init__(self, sLabel=None, loc=None, sOp='ALLOCATE',sParOpen='(',
              nIndent=0):
     BasicStatement.__init__(self, sLabel, loc, nIndent, isDeclaration=0)
     self.sOp             = sOp
     self.sParOpen        = sParOpen
     self.lVars           = DoubleList()
     self.lOptions        = DoubleList()
     self.sParClose       = ")"
コード例 #4
0
ファイル: Declaration.py プロジェクト: hiker/stan
 def __init__(self, loc, sUse="USE", nIndent=0):
     BasicStatement.__init__(self, None, loc, nIndent)
     self.sUse        = sUse
     self.lNature     = []
     self.lColons     = []
     self.lOnly       = DoubleList()
     self.lOnlyString = ''
     self.lRename     = DoubleList()
     self.sComma      = None
     self.sName       = None
コード例 #5
0
ファイル: Declaration.py プロジェクト: hiker/stan
 def __init__(self, sType, sComma=None, loc=None, nIndent=0, var=None,
              attribute=None):
     BasicStatement.__init__(self, None, loc, nIndent)
     self.sType        = sType
     self.sComma       = sComma
     self.lAttributes  = DoubleList()
     self.lColons      = []
     self.lVars        = DoubleList()
     if var:
         self.AppendVariable(var)
     if attribute:
         self.AddAttribute(attribute)
コード例 #6
0
ファイル: Declaration.py プロジェクト: hiker/stan
class CrayPointer(BasicStatement):
    def __init__(self, loc, sPointer='POINTER', nIndent=0):
        BasicStatement.__init__(self, None, loc, nIndent)
        self.sPointer = sPointer
        self.lPointer = DoubleList()
    # --------------------------------------------------------------------------
    def AddPointer(self, pointer, sComma=None):
        self.lPointer.append(pointer, sComma)
    # --------------------------------------------------------------------------
    def ToList(self, stylesheet, l):
        BasicStatement.ToList(self, stylesheet, l)
        l.append(self.sPointer, nIndentNext=1)
        self.lPointer.ToList(stylesheet, l)
コード例 #7
0
ファイル: Declaration.py プロジェクト: hiker/stan
class DataValueList(BasicRepr):
    def __init__(self, sSlash1='/'):
        self.sSlash1   = sSlash1
        self.sSlash2   = None
        self.ValueList = DoubleList()
    # --------------------------------------------------------------------------
    def AddValue(self, obj, sComma=None): self.ValueList.append(obj, sComma)
    # --------------------------------------------------------------------------
    def AddSlash(self, sSlash): self.sSlash2 = sSlash
    # --------------------------------------------------------------------------
    def ToList(self, stylesheet, l):
        l.append(self.sSlash1)
        self.ValueList.ToList(stylesheet, l)
        l.append(self.sSlash2)
コード例 #8
0
ファイル: Function.py プロジェクト: hiker/stan
class FunctionStatement(BasicStatement):
    def __init__(self, loc=None, nIndent=0, lType=None, sFunc="FUNCTION", sName="",
                 oFunc = None):
        BasicStatement.__init__(self, None, loc, nIndent, isDeclaration=0)
        self.sFunc       = sFunc
        self.sName       = sName
        self.lArgs       = DoubleList()
        self.sParOpen    = None
        self.sParClose   = None
        self.lType       = lType
        self.oFunc       = oFunc
        self.lResult     = []
    # --------------------------------------------------------------------------
    def SetParOpen(self, sParOpen  ): self.sParOpen  = sParOpen
    # --------------------------------------------------------------------------
    def SetParClose(self, sParClose): self.sParClose = sParClose
    # --------------------------------------------------------------------------
    def GetName(self): return self.sName
    # --------------------------------------------------------------------------
    def GetType(self): return self.lType
    # --------------------------------------------------------------------------
    def GetArguments(self): return self.lArgs.GetMainList()
    # --------------------------------------------------------------------------
    def AddArgument(self, sName, sComma=None, d=None):
        self.lArgs.append(sName, sComma)
        if self.oFunc:
            self.oFunc.AddArgument(sName, sComma=sComma, d=d)
    # --------------------------------------------------------------------------
    def SetResult(self, sResult, sParOpen, sName, sParClose):
        self.lResult = [sResult, sParOpen, sName, sParClose]
    # --------------------------------------------------------------------------
    def ToList(self, stylesheet, l):
        BasicStatement.ToList(self, stylesheet, l)
        for i in self.lType:
            if i.__class__==Type:
                i.ToList(stylesheet, l)
            else:
                l.append(stylesheet.sKeyword(i))
            l.indent(1)
        l.append(stylesheet.sKeyword(self.sFunc), nIndentNext=1)
        l.append(self.sName)
        if not self.sParOpen:
            return
        l.append(self.sParOpen)
        self.lArgs.ToList(stylesheet, l)
        l.append(self.sParClose)
        if self.lResult:
            l.indent(1)
            l.extend(self.lResult)
コード例 #9
0
ファイル: Statements.py プロジェクト: hiker/stan
 def __init__(self, sLabel=None, loc=None, sNullify="NULLIFY",
              sParOpen='(', nIndent=0):
     BasicStatement.__init__(self, sLabel, loc, nIndent, isDeclaration=0)
     self.sNullify  = sNullify
     self.sParOpen  = sParOpen
     self.sParClose = None
     self.lPointers = DoubleList()
コード例 #10
0
ファイル: Subroutine.py プロジェクト: hiker/stan
class SubroutineStatement(BasicStatement):
    def __init__(self, loc=None, lPrefix=[], sSub="SUBROUTINE", sName="",
                 nIndent=0, oSub = None):
        BasicStatement.__init__(self, None, loc, nIndent)
        self.lPrefix     = lPrefix
        self.sSub        = sSub
        self.sName       = sName
        self.lArgs       = DoubleList()
        self.sParOpen    = None
        self.sParClose   = None
        self.oSub        = oSub
    # --------------------------------------------------------------------------
    def SetParOpen(self, sParOpen): self.sParOpen = sParOpen
    # --------------------------------------------------------------------------
    def SetParClose(self, sParClose): self.sParClose = sParClose
    # --------------------------------------------------------------------------
    def GetName(self): return self.sName
    # --------------------------------------------------------------------------
    def GetPrefix(self): return self.lPrefix
    # --------------------------------------------------------------------------
    def GetArguments(self): return self.lArgs.GetMainList()
    # --------------------------------------------------------------------------
    def AddArgument(self, sName, sComma=None, d=None):
        if self.sParOpen==None: self.sParOpen="("
        self.sParClose = ")"
        if sComma==None and \
               len(self.lArgs.lGetSecondaryList())==len(self.lArgs)-1:
            self.lArgs.append(",", sName)
        else:
            self.lArgs.append(sName, sComma)
            
        if self.oSub:
            self.oSub.AddArgument(sName, sComma=sComma, d=d)
            
    # --------------------------------------------------------------------------
    def ToList(self, stylesheet, l):
        BasicStatement.ToList(self, stylesheet, l)
        for i in self.lPrefix:
            l.append(stylesheet.sKeyword(i), nIndentNext=1)
        l.append(stylesheet.sKeyword(self.sSub), nIndentNext=1)
        l.append(self.sName)
        if not self.sParOpen:
            return 
        l.append(self.sParOpen)
        self.lArgs.ToList(stylesheet, l)
        l.append(self.sParClose)
コード例 #11
0
ファイル: Select.py プロジェクト: hiker/stan
 def __init__(self, sLabel=None, loc=None, sCase='CASE',  nIndent=0):
     BasicStatement.__init__(self, sLabel, loc, nIndent, isDeclaration=0)
     self.sCase     = sCase
     self.sName     = None
     self.sDefault  = None           # for DEFAULT
     self.sParOpen  = None
     self.sParClose = None
     self.lSelector = DoubleList()
コード例 #12
0
ファイル: IO.py プロジェクト: hiker/stan
 def __init__(self, sLabel=None, loc=None, nIndent=0, sKeyword="",
              sParOpen=None, opt=None):
     BasicStatement.__init__(self, sLabel, loc, nIndent, isDeclaration=0)
     self.sKeyword  = sKeyword
     self.sParOpen  = sParOpen
     self.sParClose = ')'
     self.lParams   = DoubleList()
     if opt: self.AddIOOpt(opt)
コード例 #13
0
ファイル: Declaration.py プロジェクト: hiker/stan
class DataStatementSet(BasicRepr):
    def __init__(self, sComma=None):
        self.sComma     = sComma
        self.ObjectList = DoubleList()
        self.DataValue  = None
    # --------------------------------------------------------------------------
    def AddObject(self, obj, sComma=None): self.ObjectList.append(obj, sComma)
    # --------------------------------------------------------------------------
    def AddValueList(self, vl): self.DataValue = vl
    # --------------------------------------------------------------------------
    def AddSecondSlash(self, sSlash): self.sSlash2 = sSlash
    # --------------------------------------------------------------------------
    def ToList(self, stylesheet, l):
        if self.sComma:
            l.append(self.sComma, nIndentNext=1)
        self.ObjectList.ToList(stylesheet, l)
        self.DataValue.ToList(stylesheet,  l)
コード例 #14
0
ファイル: If.py プロジェクト: hiker/stan
 def __init__(self, sLabel=None, loc=None, sIf="IF", sParOpen='(',
              ifCond=None, sParClose=')', nIndent=0):
     BasicStatement.__init__(self, sLabel, loc, nIndent, isDeclaration=0)
     self.sIf       = sIf
     self.sParOpen  = sParOpen
     self.ifCond    = ifCond
     self.sParClose = sParClose
     self.lLabels   = DoubleList()
コード例 #15
0
ファイル: Declaration.py プロジェクト: hiker/stan
 def __init__(self, sImplicit="IMPLICIT", loc=None, nIndent=0):
     BasicStatement.__init__(self, None, loc, nIndent)
     self.sImplicit = sImplicit
     self.sNone     = None
     self.type      = None
     self.l         = DoubleList()
     self.sParOpen  = None
     self.sParClose = None
コード例 #16
0
ファイル: Declaration.py プロジェクト: hiker/stan
class ModuleProcedure(BasicStatement):
    def __init__(self, loc, sModule=None, sProcedure="PROCEDURE", nIndent=0):
        BasicStatement.__init__(self, None, loc, nIndent)
        self.sModule    = sModule
        self.sProcedure = sProcedure
        self.l          = DoubleList()
    # --------------------------------------------------------------------------
    def AddProcedure(self, obj, sComma=None): self.l.append(obj, sComma)
    # --------------------------------------------------------------------------
    def ToList(self, stylesheet, l):
        BasicStatement.ToList(self, stylesheet, l)
        if self.sModule:
            l.append(self.sModule,    nIndentNext=1)
            l.append(self.sProcedure, nIndentNext=1)
        else:
            l.append(self.sProcedure, nIndentNext=1)
        self.l.ToList(stylesheet, l)
コード例 #17
0
ファイル: Statements.py プロジェクト: hiker/stan
class Allocate(BasicStatement):

    # Stores a return statement.
    def __init__(self, sLabel=None, loc=None, sOp='ALLOCATE',sParOpen='(',
                 nIndent=0):
        BasicStatement.__init__(self, sLabel, loc, nIndent, isDeclaration=0)
        self.sOp             = sOp
        self.sParOpen        = sParOpen
        self.lVars           = DoubleList()
        self.lOptions        = DoubleList()
        self.sParClose       = ")"
    # --------------------------------------------------------------------------
    def SetParClose(self, sParClose): self.sParClose = sParClose
    # --------------------------------------------------------------------------
    # Adds a variable to allocate to the allocate statement. Parameters:
    #
    # var -- Variable to add
    #
    # sSeparator -- String which separates a variable from the next. Usual a
    #               comma, but the ')' is stored here as well.
    def AddVariable(self, var, sSeparator=None):
        self.lVars.append(var, sSeparator)
    # --------------------------------------------------------------------------
    # Appends an option (stat, errmsg, or source) to the statement. Parameters:
    #
    # sName -- Name of the option
    #
    # sEqual -- The '=' character
    #
    # obj -- A scalar int variable
    #
    # sSeparator -- String which separates an option from the next. Usual a
    #               comma, but the ')' can be stored here as well.
    def AddOption(self, sName, sEqual, obj, sSeparator=None):
        self.lOptions.append( OptionString(sName, sEqual, obj), sSeparator )
    # --------------------------------------------------------------------------
    # Creates a list of strings which represents this statement. Parameters:
    #
    # stylesheet -- The stylesheet to use during layout
    def ToList(self, stylesheet=None,l=[]):
        BasicStatement.ToList(self, stylesheet, l)
        l.extend([stylesheet.sKeyword(self.sOp), self.sParOpen]) # 'allocate', '('
        self.lVars.ToList(stylesheet, l)
        self.lOptions.ToList(stylesheet, l)
        l.append(self.sParClose)
コード例 #18
0
ファイル: Declaration.py プロジェクト: hiker/stan
class Declaration(BasicStatement):
    def __init__(self, sType, sComma=None, loc=None, nIndent=0, var=None,
                 attribute=None):
        BasicStatement.__init__(self, None, loc, nIndent)
        self.sType        = sType
        self.sComma       = sComma
        self.lAttributes  = DoubleList()
        self.lColons      = []
        self.lVars        = DoubleList()
        if var:
            self.AppendVariable(var)
        if attribute:
            self.AddAttribute(attribute)
    # --------------------------------------------------------------------------
    # Add a variable or an array specification to the list of declaration
    def AddDeclaredVariable(self, var, sComma=None):
        self.lVars.append(var, sComma)
    # --------------------------------------------------------------------------
    # Add an attribute, like 'allocateable', ...
    def AddAttribute(self, sAtt, sComma=None):
        if len(self.lAttributes)==0 and not self.sComma:
            self.sComma=","
        self.lAttributes.append(sAtt, sComma)
    # --------------------------------------------------------------------------
    # Adds the optional double colon of a declaration. Parameters:
    # 
    # c1/c2 -- Each of the two colons (the scanner returns two colons for a ::)
    def AddDoubleColons(self, c1, c2): self.lColons=[c1,c2]
    # --------------------------------------------------------------------------
    # This function is used to construct new declaration statements:
    def AppendVariable(self, v):
        if len(self.lVars)==0:
            self.lColons=[":",":"]
            self.lVars.append(v)
        else:
            self.lVars.append(",", v)
    # --------------------------------------------------------------------------
    def GetAttributes(self):
        return self.lAttributes.GetMainList()
    # --------------------------------------------------------------------------
    def ToList(self, stylesheet, l):
        BasicStatement.ToList(self, stylesheet, l)
        stylesheet.ToList(self.sType, l)
        if self.sComma:
            l.append(self.sComma)
        l.indent(1)
        # The if is not really necessary, but without it two spaces
        # would be added in case of an empy attribute list
        if len(self.lAttributes.GetMainList())>0:
            self.lAttributes.ToList(stylesheet, l, bAddSpace=1)
            l.indent(1)
        if self.lColons:
            l.extend(self.lColons)
            l.indent(1)
        self.lVars.ToList(stylesheet, l, bAddSpace=1)
コード例 #19
0
ファイル: Declaration.py プロジェクト: hiker/stan
class Public(BasicStatement):
    # Stores a public statement declaration
    def __init__(self, loc, sPublic="PUBLIC", nIndent=0):
        BasicStatement.__init__(self, None, loc, nIndent)
        self.sPublic = sPublic
        self.lColons = None
        self.l       = DoubleList()
    # --------------------------------------------------------------------------
    def AddDoubleColons(self, c1, c2): self.lColons=[c1,c2]
    # --------------------------------------------------------------------------
    def AddObject(self, obj, sComma=None): self.l.append(obj, sComma)
    # --------------------------------------------------------------------------
    def ToList(self, stylesheet, l):
        BasicStatement.ToList(self, stylesheet, l)
        l.append(stylesheet.sKeyword(self.sPublic), nIndentNext=1)
        if self.lColons:
            l.extend(self.lColons)
        self.l.ToList(stylesheet, l)
コード例 #20
0
ファイル: Declaration.py プロジェクト: hiker/stan
class Intrinsic(BasicStatement):
    # Stores an intrinsic declaration
    def __init__(self, loc, sIntri="INTRINSIC", nIndent=0):
        BasicStatement.__init__(self, None, loc, nIndent)
        self.sIntri  = sIntri
        self.lColons = None
        self.l       = DoubleList()
    # --------------------------------------------------------------------------
    def AddDoubleColons(self, c1, c2): self.lColons=[c1,c2]
    # --------------------------------------------------------------------------
    def AddIntrinsic(self, obj, sComma=None): self.l.append(obj, sComma)
    # --------------------------------------------------------------------------
    def ToList(self, stylesheet, l):
        BasicStatement.ToList(self, stylesheet, l)
        l.append(stylesheet.sKeyword(self.sIntri),nIndentNext=1)
        if self.lColons:
            l.extend(self.lColons)
        self.l.ToList(stylesheet, l)
コード例 #21
0
ファイル: Statements.py プロジェクト: hiker/stan
 def __init__(self, sName=None, sArg=None):
     self.sName     = sName
     self.lArgs     = DoubleList()
     self.sParOpen  = None
     self.sParClose = None
     if sArg:
         self.sParOpen="("
         self.AddArgument(sArg)
         self.sParClose=")"
コード例 #22
0
ファイル: IO.py プロジェクト: hiker/stan
class Read(BasicIOList):
    # Stores a read statement
    def __init__(self, sLabel=None, loc=None, nIndent=0,
                 sRead="READ", sParOpen=None,
                 nUnit=None, var=None):
        BasicIOList.__init__(self, sLabel, loc, nIndent, sRead, sParOpen)
        self.lIOExp    = DoubleList()
        self.sFormat   = None
        self.sComma    = None
        if nUnit:
            if not sParOpen: self.SetParOpen()
            self.AddIOOpt("%s"%nUnit)
            self.SetParClose()
        if var:
            self.AddIOExpression(var)
    # --------------------------------------------------------------------------
    def SetFormat(self, sFormat, sComma=None):
        self.sFormat = sFormat
        self.sComma  = sComma
    # --------------------------------------------------------------------------
    def AddIOExpression(self, exp, sComma=None):
        # To simplify manually creating statements, a comma is automatically
        # added, if only expressions are specified here (except for the first
        # call).
        if type(exp)==type(1): exp=`exp`
        if sComma==None and \
               len(self.lIOExp.lGetSecondaryList())==len(self.lIOExp)-1:
            self.lIOExp.append(",", exp)
        else:
            self.lIOExp.append(exp, sComma)
    # --------------------------------------------------------------------------
    def GetVarUsage(self, varUsage, sType="read", obj=None, loc=None):
        for i in self.lIOExp.GetMainList():
            varUsage.AddVariable(i, "write", obj, loc)
        BasicIOList.GetVarUsage(self, varUsage, sType, obj, loc)
    # --------------------------------------------------------------------------
    def ToList(self, stylesheet, l):
        BasicIOList.ToList(self, stylesheet, l)
        l.append(' ')
        if self.sFormat:
            l.append(self.sFormat, nIndent=1)
            if self.sComma:
                l.append(self.sComma)
        self.lIOExp.ToList(stylesheet, l)
コード例 #23
0
ファイル: Statements.py プロジェクト: hiker/stan
class Nullify(BasicStatement):
    def __init__(self, sLabel=None, loc=None, sNullify="NULLIFY",
                 sParOpen='(', nIndent=0):
        BasicStatement.__init__(self, sLabel, loc, nIndent, isDeclaration=0)
        self.sNullify  = sNullify
        self.sParOpen  = sParOpen
        self.sParClose = None
        self.lPointers = DoubleList()
    # --------------------------------------------------------------------------
    def SetParClose(self, sParClose=')'): self.sParClose=')'
    # --------------------------------------------------------------------------
    def AddExpression(self, exp, sComma=None):
        self.lPointers.append(exp, sComma)
    # --------------------------------------------------------------------------
    def ToList(self, stylesheet, l):
        BasicStatement.ToList(self, stylesheet, l)
        l.extend([stylesheet.sKeyword(self.sNullify), self.sParOpen])
        self.lPointers.ToList(stylesheet, l)
        l.append(self.sParClose)
コード例 #24
0
ファイル: Statements.py プロジェクト: hiker/stan
 def __init__(self, sLabel=None, loc=None, sGo="GO", sTo="TO",
              sParOpen="(", nIndent=0):
     BasicStatement.__init__(self, sLabel, loc, nIndent, isDeclaration=0)
     self.sGo        = sGo
     self.sTo        = sTo
     self.sParOpen   = sParOpen
     self.sParClose  = ""
     self.sComma     = ""
     self.lLabels    = DoubleList()
     self.oExp       = None
コード例 #25
0
ファイル: IO.py プロジェクト: hiker/stan
 def __init__(self, sLabel=None, loc=None, sPrint="PRINT", nIndent=0,
              format=None):
     BasicStatement.__init__(self, sLabel, loc, nIndent, isDeclaration=0)
     self.sPrint  = sPrint
     self.format  = format
     if format:
         self.sComma  = ","              # First comma after format
     else:
         self.sComma  = None             # First comma after format
     self.lIO     = DoubleList()
コード例 #26
0
ファイル: Declaration.py プロジェクト: hiker/stan
class External(BasicStatement):
   # Stores an external declaration
    def __init__(self, loc, sExternal="EXTERNAL", nIndent=0):
        BasicStatement.__init__(self, None, loc, nIndent)
        self.sExternal = sExternal
        self.lColon    = []
        self.l         = DoubleList()
    # --------------------------------------------------------------------------
    def AddDoubleColon(self, sCol1, sCol2): self.lColon=[sCol1,sCol2]
    # --------------------------------------------------------------------------
    def AddExternal(self, ext, sComma=None):
        self.l.append(ext, sComma)
    # --------------------------------------------------------------------------
    def ToList(self, stylesheet, l):
        BasicStatement.ToList(self, stylesheet, l)
        l.append(stylesheet.sKeyword(self.sExternal), nIndentNext=1)
        if self.lColon:
            l.extend(self.lColon)
        self.l.ToList(stylesheet, l)
コード例 #27
0
ファイル: Declaration.py プロジェクト: hiker/stan
class Equivalence(BasicStatement):
    def __init__(self, loc, sEq="EQUIVALENCE", nIndent=0):
        BasicStatement.__init__(self, None, loc, nIndent)
        self.sEq       = sEq
        self.lObjects  = DoubleList()
    # --------------------------------------------------------------------------
    def AddObject(self, obj, sComma=None):
        self.lObjects.append(obj, sComma)
    # --------------------------------------------------------------------------    
    def GetAllUsedVariables(self):
        l=[]
        for i in self.lObjects.GetMainList():
            l.extend(i.GetAllUsedVariables())
        return l
    # --------------------------------------------------------------------------
    def ToList(self, stylesheet, l):
        BasicStatement.ToList(self, stylesheet, l)
        l.append(stylesheet.sKeyword(self.sEq))
        self.lObjects.ToList(stylesheet, l)
コード例 #28
0
ファイル: Subroutine.py プロジェクト: hiker/stan
 def __init__(self, loc=None, lPrefix=[], sSub="SUBROUTINE", sName="",
              nIndent=0, oSub = None):
     BasicStatement.__init__(self, None, loc, nIndent)
     self.lPrefix     = lPrefix
     self.sSub        = sSub
     self.sName       = sName
     self.lArgs       = DoubleList()
     self.sParOpen    = None
     self.sParClose   = None
     self.oSub        = oSub
コード例 #29
0
ファイル: IO.py プロジェクト: hiker/stan
class IODoList(BasicRepr):
    # Stores '(obj1, obj2, ..., objn, i=1, n)
    def __init__(self,sParOpen, obj1, sComma1):
        self.sParOpen    = sParOpen
        self.sParClose   = None
        self.lObj        = DoubleList(l1=[obj1], l2=[sComma1])
        self.lLoopData =  []             # stores: [var,'=',from',',to]
                                          # and maybe [',',stride]
    # --------------------------------------------------------------------------
    # Sets the implied do variable and the equal sign
    def SetVar(self, v, sEqual): self.lLoopData.extend([v, sEqual])
    # --------------------------------------------------------------------------
    def SetFrom(self,f,sComma): self.lLoopData.extend([f,sComma])
    # --------------------------------------------------------------------------
    def SetTo(self,t): self.lLoopData.append(t)
    # --------------------------------------------------------------------------
    def SetStep(self,sComma, s): self.lLoopData.extend([sComma,s])
    # --------------------------------------------------------------------------
    def AddExpr(self, e, sComma): self.lObj.append(e, sComma)
    # --------------------------------------------------------------------------
    def SetParClose(self, sParClose): self.sParClose = sParClose
    # --------------------------------------------------------------------------
    def GetVarUsage(self, varUsage, sType="read", obj=None, loc=None):
        for i in self.lObj.GetMainList():
            varUsage.AddVariable(i, sType, obj, loc)
        varUsage.AddVariable(self.lLoopData[0], "write", obj, loc)
        varUsage.AddVariable(self.lLoopData[2], "read",  obj, loc)
        varUsage.AddVariable(self.lLoopData[4], "read",  obj, loc)
        if len(self.lLoopData)>5:
            varUsage.AddVariable(self.lLoopData[6], "read", obj, loc)
    # --------------------------------------------------------------------------
    def ToList(self, stylesheet, l):
        l.append(self.sParOpen)
        self.lObj.ToList(stylesheet, l)
        stylesheet.ToList(self.lLoopData[0], l)      # var
        l.append(self.lLoopData[1])                  # =
        stylesheet.ToList(self.lLoopData[2], l)      # from
        l.append(self.lLoopData[3])                  # ,
        stylesheet.ToList(self.lLoopData[4], l)      # to
        if len(self.lLoopData)>5:
            l.append(self.lLoopData[5])              # ,
            stylesheet.ToList(self.lLoopData[6], l)  # step
        l.append(self.sParClose)
コード例 #30
0
ファイル: Function.py プロジェクト: hiker/stan
 def __init__(self, loc=None, nIndent=0, lType=None, sFunc="FUNCTION", sName="",
              oFunc = None):
     BasicStatement.__init__(self, None, loc, nIndent, isDeclaration=0)
     self.sFunc       = sFunc
     self.sName       = sName
     self.lArgs       = DoubleList()
     self.sParOpen    = None
     self.sParClose   = None
     self.lType       = lType
     self.oFunc       = oFunc
     self.lResult     = []