Beispiel #1
0
def testRepl3Sub(): # test zur ueberleitung auf ar_codeListParameters
 
 te.checkComplainAndAdjustExpected( 0)
 
 codeList= codeListMake( codeListConfigMake(), codeListParametersMake( nil))

 te.test( codeListCheck( codeList))

 te.test( codeListConfigCheck( codeListGetConfig( codeList)))

 te.test( codeListParametersCheck( codeListGetParameters( codeList)))
 

 codeList= codeListMake( codeListConfigMake(), codeListParametersMake( ConsSimple( true, nil)))

 te.test( codeListCheck( codeList))

 te.test( codeListConfigCheck( codeListGetConfig( codeList)))

 codeListParameters= codeListGetParameters( codeList)

 te.test( codeListParametersCheck( codeListParameters))
 
 te.test( id( true) == id( codeListGetParameterValues( codeList).car()))

 te.test( id( true) == id( codeListGetParameterValuesCdrContainer( codeList).cdr().car()))

 te.test( id( true) == id( codeListParametersGetParameterValues( codeListParameters).car()))

 te.test( id( true) == id( codeListGetParameterValuesCdrContainer2( codeList).cdr().cdr().car()))

 te.checkComplainAndAdjustExpected( 10)
Beispiel #2
0
 def macroBufFeed( self, l, outer= True): 

  ensure( l, [Cons])

  if outer:
   if isinstance( l.cdr(), Cons):
    if isinstance( l.cdr().car(), Cons):
     ensureConsType( l.cdr().car(), ar_codeList) # baustelle: ggf. uebertestet
     ensureConsType( l.cdr().car().cdr().car(), ar_codeListConfig) # baustelle: ggf. uebertestet
     pass

  uNames.next( usRename( ConsSimple, 'cs'))
  uNames.next( usRename( Symbol, 's'))

  c= l
  r= nil # reverse

  while not id( nil) == id( c):
   r= ConsSimple( c.car(), r)
   c= c.cdr()

  self.macroBufAdd( False, Symbol( ')'))

  while not id( nil) == id( r):
   value= r.car()
   if isinstance( value, Cons) and typeSymbolChk( value.car(), ar_codeList): # f69eef8ad76e459da16194dcdd0c73c6
    codeListEnsure( value) # b73fcfe5b4de4df6946ee586d8f79713
    self.macroBufFeed( codeListGetParameterValues( value), outer= False) # 2849da4969b146bc88315f20fd205e06 baustelle0: hier wird das Environment verworfen
   else: 
    self.macroBufAdd( False, value)
   r= r.cdr()

  self.macroBufAdd( outer, Symbol( '(')) # 64005373aae94f3a9314d303d5f4016e

  uNames.undo()
  uNames.undo()
Beispiel #3
0
def testInterpreterGeneral1( ConsClass):

 def testCrCr( ex, ou, d= None):
  htEnvLocals= { id( env_locals1) : "env_locals1"}
  if not None == d:
   htEnvLocals.update( d)
  test( ConsRepr( ex ).repr_wrapped( htEnvLocals, [ CpctReprCodeListConfigMake]),
   ConsRepr( ou ).repr_wrapped( htEnvLocals, [ CpctReprCodeListConfigMake]))

 def codeListFake( rest):
  if InterpreterStructures.alteVariante:
   return cs( ar_codeList, cs( codeListConfigMakeRepr, rest))
  else:
   return cs( ar_codeList, cs( codeListConfigMakeRepr, cs( ar_codeListParameters, rest)))

 def codeListFakeRoot( rest):
  if InterpreterStructures.alteVariante:
   return cs( ar_codeList, cs( codeListConfigMakeRepr, rest))
  else:
   return cs( ar_codeList, cs( codeListConfigMakeRepr, cs( ar_codeListParameters, cs( s( 'progn-root'), rest))))


 te.checkComplainAndAdjustExpected( 0)

 i= Interpreter()
 env_locals1= i.getEnvLocals()
 codeListConfigMakeRepr= 'codeListConfigMake( ...)'

 uNames.next( usRename( ConsAbstractCarAutoHistoryCSCS, 'ConsSimple'))
 testCrCr( codeListFakeRoot( nil), i.codeList)
 test( nil , i.codeListParent2EvalToken )

 if InterpreterStructures.alteVariante:
  testCrCr( cs( cs( ar_codeList, i.codeListCurrentEvalTokenList.cdr()), nil), i.codeCurrentLeafList,
   { id( i.codeListCurrentEvalTokenList.cdr()): 'codeListCurrentEvalTokenList.cdr()'})
 else:
  testCrCr( cs( cs( ar_codeList, cs( codeListConfigMakeRepr, i.codeListCurrentEvalTokenList)), nil), i.codeCurrentLeafList,
   { id( i.codeListCurrentEvalTokenList.cdr()): 'codeListCurrentEvalTokenList.cdr()'})

 uNames.undo()

 codeLeaf= i.codeLeafBackTree.car()
 testCrCr( cs( codeLeaf, nil), i.codeLeafBackTree, { id( codeLeaf): 'codeLeaf'})

 te.checkComplainAndAdjustExpected( 4)

 if False:
  pass
 elif id( ConsClass) == id( ConsAbstractCarAutoHistoryCSCS): # b4dfedc64bf1440b82f109a25c7f8421

  #ConsAbstractCarAutoHistoryCSCS.__name__= 'cs'
  #ConsSimple.__name__= 'cs'

  uNames.next( usRename( ConsAbstractCarAutoHistoryCSCS, 'cs'))
  uNames.next( usRename( ConsSimple, 'cs'))

  i.evalToken( s( 'aa'))

  ht_selfid2Name= { id( env_locals1): 'env_locals1'}
  testCrCr( cs( ar_codeList, cs( env_locals1, cs( s( 'aa'), nil))), i.codeList)

  testCrCr( cs( s( 'aa'), nil), i.codeListCurrentEvalTokenList.cdr())
  currentLeaf= i.codeCurrentLeafList.car()
  testCrCr( cs( ar_codeList, cs( env_locals1, i.codeListCurrentEvalTokenList.cdr())), currentLeaf)
  testCrCr( cs( currentLeaf, nil), i.codeCurrentLeafList)
  codeLeaf= i.codeLeafBackTree.car()
  testCrCr( cs( codeLeaf, nil), i.codeLeafBackTree)
  
  test( 'aa', i.codeList.cdr().cdr().car())

  test( id( consHistory), id( i.codeList.cdr().consWrapped.car().car()))
  testCrCr( cs( consHistory, cs( s( 'aa'), nil)), i.codeList.cdr().cdr().consWrapped.car())

  i.evalToken( s( '('), True)

  testCrCr( cs( env_locals1, nil), i.codeListCurrentEvalTokenList.cdr())
  currentLeaf= i.codeCurrentLeafList.car()
  testCrCr( cs( ar_codeList, i.codeListCurrentEvalTokenList.cdr()), currentLeaf)
  testCrCr( cs( currentLeaf, cs( cs( ar_codeList, cs( env_locals1, cs( currentLeaf, nil))), nil)), i.codeCurrentLeafList)
  codeLeaf= i.codeLeafBackTree.car()
  testCrCr( cs( codeLeaf, nil), i.codeLeafBackTree)

  i.evalToken( s( 'bb'))

  testCrCr( cs( s( 'bb'), nil), i.codeListCurrentEvalTokenList.cdr())
  currentLeaf= i.codeCurrentLeafList.car()
  testCrCr( cs( ar_codeList, cs( env_locals1, i.codeListCurrentEvalTokenList.cdr())), currentLeaf)
  testCrCr( cs( currentLeaf, cs( cs( ar_codeList, cs( env_locals1, cs( currentLeaf, nil))), nil)), i.codeCurrentLeafList)
  codeLeaf= i.codeLeafBackTree.car()
  testCrCr( cs( codeLeaf, nil), i.codeLeafBackTree)

  i.evalToken( s( ')'))

  testCrCr( cs( cs( ar_codeList, cs( env_locals1, cs( s( 'bb'), nil))), nil), i.codeListCurrentEvalTokenList.cdr())
  currentLeaf= i.codeCurrentLeafList.car()
  testCrCr( cs( ar_codeList, cs( env_locals1, i.codeListCurrentEvalTokenList.cdr())), currentLeaf)
  testCrCr( cs( currentLeaf, nil), i.codeCurrentLeafList)
  codeLeafBefore= codeLeaf
  codeLeaf= i.codeLeafBackTree.car()
  testCrCr( cs( codeLeaf, cs( codeLeafBefore, nil)), i.codeLeafBackTree)

  testCrCr( cs( ar_codeList, cs( env_locals1, cs( s( 'bb'), nil))), i.codeList.cdr().cdr().car())

  testCrCr( cs( consHistory, cs( cs( cs( consHistory, cs( ar_codeList, nil)), cs( cs( consHistory, cs( env_locals1, nil)), cs( cs( consHistory, cs( s( 'bb'), nil)), nil))), cs( s( 'aa'), nil))), i.codeList.cdr().cdr().consWrapped.car())

  i.evalToken( s( 'a'), True) # aa => a
  test( 'a', i.codeList.cdr().cdr().car())

  testCrCr( cs( consHistory, cs( s( 'a'), cs( cs( cs( consHistory, cs( ar_codeList, nil)), cs( cs( consHistory, cs( env_locals1, nil)), cs( cs( consHistory, cs( s( 'bb'), nil)), nil))), cs( s( 'aa'), nil)))), i.codeList.cdr().cdr().consWrapped.car())

  test( id( consHistory), id( i.codeList.cdr().consWrapped.car().car()))
  testCrCr( cs( cs( consHistory, cs( ar_codeList, nil)), cs( cs( consHistory, cs( env_locals1, nil)), cs( cs( consHistory, cs( s( 'a'), cs( cs( cs( consHistory, cs( ar_codeList, nil)), cs( cs( consHistory, cs( env_locals1, nil)), cs( cs( consHistory, cs( s( 'bb'), nil)), nil))), cs( s( 'aa'), nil)))), nil))), i.codeList.consWrapped)
  testCrCr( cs( ar_codeList, cs( env_locals1, cs( s( 'a'), nil))), i.codeList)

  uNames.undo()
  uNames.undo()

  te.checkComplainAndAdjustExpected( 27)

 elif id( ConsClass) == id( ConsSimple): # b4dfedc64bf1440b82f109a25c7f8421
  
  i.evalToken( cs( ar_value, s( 'a')))

  test( ar_codeListConfig, i.codeList.cdr().car().car())
  #test( s( 'a'), i.codeList.cdr().cdr().car())
  test( s( 'a'), codeListGetParameterValues( i.codeList).cdr().car())

  te.checkComplainAndAdjustExpected( 2)

 else:
  assert( False)

 test( nil , i.codeListParent2EvalToken )
 i.evalToken( cs( ar_value, s( '(')))
 elem= codeListFake( nil)
 tail= cs( elem, nil)

 uNames.next( usRename( ConsAbstractCarAutoHistoryCSCS, 'ConsSimple'))
 uNames.next( usRename( ConsSimple, 'cs'))
 uNames.next( usRename( Symbol, 's'))

 testCrCr( codeListFakeRoot( cs( s( 'a'), tail)), i.codeList)

 test( ConsTrait( cs( cs( s( 'a'), tail), nil)).repr_wrapped()
 , ConsRepr( i.codeListParent2EvalToken).repr_wrapped( None, [ CpctReprCodeListConfigMake]))
 i.evalToken( cs( ar_value, s( 'b')))
 elem= codeListFake( cs( s( 'b'), nil))
 tail= cs( elem, nil)

 testCrCr( codeListFakeRoot( cs( s( 'a'), tail)), i.codeList)
 testCrCr( cs( cs( s( 'a'), tail), nil), i.codeListParent2EvalToken)

 i.evalToken( cs( ar_value, s( 'c')))
 elem= codeListFake( cs( s( 'b'), cs( s( 'c'), nil)))
 tail= cs( elem, nil)

 testCrCr( codeListFakeRoot( cs( s( 'a'), tail)), i.codeList)
 testCrCr( cs( cs( s( 'a'), tail), nil), i.codeListParent2EvalToken)

 i.evalToken( cs( ar_value, s( ')')))

 testCrCr( codeListFakeRoot( cs( s( 'a'), cs( elem, nil))), i.codeList)
 test( nil , i.codeListParent2EvalToken )

 i.evalToken( cs( ar_value, s( 'd')))

 testCrCr( codeListFakeRoot( cs( s( 'a'), cs( elem, cs( s( 'd'), nil)))), i.codeList)
 test( nil , i.codeListParent2EvalToken )

 uNames.undo()
 uNames.undo()
 uNames.undo()

 te.checkComplainAndAdjustExpected( 11)
Beispiel #4
0
 def evalStep( self, rod):

  if False: # 8337c49584d44686be0bc780cf310dfc
   pass
  elif '(' == rod:
   evol= '('
  elif ')' == rod:
   codeList= self.codeListCurrentEvalTokenList.cdr().car()
   codeListEnsure( codeList)
   codeListTmp= codeListGetParameterValues( codeList)
   executeObject= codeListTmp.car()
   executeParameters= codeListParametersMake( codeListTmp.cdr())

   if id( ar_codeList)== id( executeObject): # baustelle1 : harte fehlerausgabe
    print "self.codeListCurrentEvalTokenList ", ConsRepr( self.codeListCurrentEvalTokenList).repr_wrapped()
    raise Exception( "")

   del codeListTmp

   evol= ')'

   if not self.quotationModeIsActivated():

    codeList= self.codeCurrentLeafList.car()
    assert( id( ar_codeList)== id( codeList.car()))
    codeListConfig= codeList.cdr().car()
    assert( id( ar_codeListConfig)== id( codeListConfig.car()))
    del codeListConfig
    del codeList

    env_locals= self.getEnvLocals()
    if False: # 34c428c5375b49df9b919c610a5a9ce6
     pass
    elif isinstance( executeObject, Macro):
     executeObject.setEnvironment( env_locals)
     executeObject.setParameters( executeParameters)
     execote= executeObject.execute()

     cs= ConsSimple
    
     def tmp0( rest): # c3ee5239baaf4484a61bd525f589ef76
      return codeListMake( codeListConfigMake( env_locals), codeListParametersMake( rest))

     assert( id( ar_retValueFromMacro) == id( execote.car())) # baustelle: ggf. auch ar_retListFromMacro, loesung von 8357c3268e594c2f92afaa3a3af12afb

     execote= execote.cdr()

     self.macroBufFeed_v2( tmp0( consesMake( Symbol( 'eval1'), execote)))

    elif isinstance( executeObject, Quotation):
     executeObject.setEnvironment( env_locals)
     executeObject.setParameters( executeParameters) # 0bea40a420ca4ffa9140051cf20b778f
     execote= executeObject.execute()
     self.evalToken( execote, True)
    elif isinstance( executeObject, Function):
     executeObject.setEnvironment( env_locals) # 0bea40a420ca4ffa9140051cf20b778f
     executeObject.setParameters( executeParameters)
     execote= executeObject.execute()
     #print ConsRepr( execote).repr_wrapped( None, [ CpctReprCodeListConfigMake, CpctReprConses])
     self.evalToken( execote, True)
    else:
     print "typ nicht erwartet %s " % executeObject
     raise Exception( "") # baustelle1 ersetzt erstmal richtige Fehlermeldung

   else: # self.quotationModeIsActivated() 8191d96c8d9c4e31b9726088c66c7d67
    pass
    # baustelle0: executeObject ist von der semantischen Bedeutung her doppelt belegt

  else: # not rod in [ '(', ')']

   if not self.quotationModeIsActivated():
    
    if noo == rod: # baustelle0 : so nicht - 

     if None==self.codeListCurrentEvalTokenList:
      raise Exception()
     self.codeListCurrentEvalTokenList.cdr( nil)

    else:
     env_locals= self.getEnvLocals()
     if env_locals.has_key( rod):
      got= env_locals.get( rod) # baustelle1: noch zu unterscheiden: Value oder Symbol-Macro / Quotation
      self.evalToken( ConsSimple( ar_value, got), True) # baustelle1: in Funktion X001 auslagern, auch fuer den Listen-Fall | rod kann im aktuellen fall sogar eine Liste enthalten, die nicht in Einzelteilen an evalToken gefuettert werden muss, 7978cb4bee364b3a8359e2a0f8b7f1f4
      if self.currentEvalTokenIsInExecutePosition():
       if isinstance( got, Quotation) or isinstance( got, Macro): # 34c428c5375b49df9b919c610a5a9ce6
        self.quotationModeActivate()
     else:
      print "not found %s" % ConsRepr( rod).repr_wrapped( None, [ CpctReprCodeListConfigMake, CpctReprConses])
      raise Exception()
       
   else: # self.quotationModeIsActivated() 8191d96c8d9c4e31b9726088c66c7d67

    """ behandlung bezueglich uqset1 """
    if self.getEnvQuotationModeLocals().has_key( rod): # baustelle0 executeObject fuer diesen Fall umbenennen
     self.quotationModeDeActivate()
     env_quotationMode_locals= self.getEnvQuotationModeLocals().get( rod)
     del rod
     if self.currentEvalTokenIsInExecutePosition():
      self.codeListCurrentEvalTokenList.cdr().car( self.getEnvLocals().get( Symbol( 'progn'))) # ddfdc08cdef344b7bcd44d4e093d12ab, erweiterbar, siehe ideen.txt, 96c8d565e4f946c38838d30756ce5c0d
      parentCodeListConfig= self.getCurrentCodeListConfig( self.codeCurrentLeafList.cdr().car())
      self.quotationModeDeActivate( parentCodeListConfig)
     else:
      self.codeListCurrentEvalTokenList.cdr().car( nil) # ddfdc08cdef344b7bcd44d4e093d12ab, erweiterbar, siehe ideen.txt
     codeListConfig= self.getCurrentCodeListConfig()
     codeListConfigSet( codeListConfig, s_environment, env_quotationMode_locals)
     del env_quotationMode_locals
     del codeListConfig

    pass

   #evol= self.codeListCurrentEvalTokenList.cdr().car()
   evol= None # momentan bedeutungslos

  return evol
Beispiel #5
0
 def macroBufFeed_v2( self, l): # macroBufFeed
  if isinstance( l, Cons) and typeSymbolChk( l.car(), ar_codeList): # f69eef8ad76e459da16194dcdd0c73c6
   codeListEnsure( l) # b73fcfe5b4de4df6946ee586d8f79713
   return self.macroBufFeed( codeListGetParameterValues( l)) # 2849da4969b146bc88315f20fd205e06 baustelle0: hier wird das Environment verworfen
  else:
   return self.macroBufAdd( True, l)
Beispiel #6
0
 def currentEvalTokenIsInExecutePosition( self):
  if nil == self.codeListParent2EvalToken:
   return False
  codeList= self.codeListParent2EvalToken.car().cdr().car()
  codeListEnsure( codeList)
  return id( codeListGetParameterValues( codeList)) == id( self.codeListCurrentEvalTokenList.cdr()) # ehemals 76ff812ddb0f47f5be9ca34925a4a3b6