Meine keine Programmiersprache "0011" [Prob mit Sc

Für allgemeine Fragen zur Programmierung mit PureBasic.
IcedCoffee
Beiträge: 115
Registriert: 09.07.2005 12:11
Wohnort: Fürstenwald [Internat], Berlin[wen keine lust auf Internat], Wildau[Einfamilienhaus]
Kontaktdaten:

Meine keine Programmiersprache "0011" [Prob mit Sc

Beitrag von IcedCoffee »

Moin

ich bin heute zufälig über Ook! gestolpert

und dachte mir so eine einfache prog.sprache will ich auch mal schreiben
und da ich das bin zahlensystem so liebe habe ich die sprache 0011 geschrieben

aber ich habe jetzt ein prob mit den schleiffen also mit den befehen 1010 0101 und 1001

also hier erst mal mein interpretter

Code: Alles auswählen

; 0001 = > Ein Byte nach Rechts
; 1000 = < Ein Byte Nach Links

; 0011 = + Das Akruelle Byte wird um 1 erhöhen
; 1100 = - Das Aktuelle Byte wird um 1 erniedrigen

; 0100 = = Wenn das Aktuelle Byte den selben wert wie das Linke Byte hat
; 0010 = ! Wenn das Aktuelle Byte nicht den selben wert wie das Linke Byte hat
; 0110 = E Ende Der Wenn funktion

; 1010 = [ Der folgende Code wird so oft ausgefürt bis das Aktuelle Element 0 ist
; 1001 = | Der folgende Code wird so oft ausgefürt bis das Aktuelle Element nicht 0 ist
; 0101 = ] Bis hir soll der code ausgefürt werden

; 1011 = % Das Aktuelle Byte Wird als Zahl ausgegeben
; 1101 = ? Das Aktuelle Byte Wird als ACSII ausgegeben

; 1110 = " Das Aktuelle Byte wir mit dem ACSII wert der Aktuell gedrückten teste beschreiben
; 1111 = * Das Aktuelle Byte bekommt die Zahl die gerade gedrückenten taste

; 0111 = $ Löcht alle Byts

Global Code.s
Code = "00110011101011000001001100110011001100111010110000010011001100110011101011000001001100110011001100111000010110000101100001010001000100011011"
e.l
BytePosition.l
NewList Byte.l()
AddElement(Byte())

Structure Schleiffe
  BytePosition.l
  PositionToStart.l
  PositionToEnd.l
  SchleiffenType.s
EndStructure
NewList Schleiffe.Schleiffe()
AddElement(Schleiffe())
Schleiffe()\PositionToEnd = 0
;--------------
Procedure IC0001()
  If NextElement(Byte()) = 0
    AddElement(Byte())
  EndIf
  Debug ">"
EndProcedure
Procedure IC1000()
  If PreviousElement(Byte()) = 0
    MessageRequester("0011 - ERROR", "Error bei Befehl "+Str(e)+" <")
    ProcedureReturn 0
  EndIf
  Debug "<"
EndProcedure
Procedure.l IC0100(e.l)
  Protected OldByte.b, e.l, i.l, Sumper.l
  Debug "="
  OldByte = Byte()
  If PreviousElement(Byte()) = 0
    MessageRequester("0011 - ERROR", "Error bei Befehl "+Str(e/4)+Chr(13)+Chr(10)+" !")
    ProcedureReturn e
  EndIf
  If OldByte <> Byte()
    For i = e To Len(Code) Step 4
      If Mid(Code, i, 4) = "0100" Or Mid(Code, i, 4) = "0010"
        Sumper = Sumper + 1
      ElseIf Mid(Code, i, 4) = "0110"
        Sumper = Sumper - 1
      EndIf
      If Sumper = 0 And Mid(Code, i, 4) = "0110"
        NextElement(Byte())
        ProcedureReturn i; - 4
      EndIf
    Next
  EndIf
  NextElement(Byte())
  ProcedureReturn e
EndProcedure
Procedure.l IC0010(e.l)
  Protected OldByte.b, e.l, i.l, Sumper.l
  Debug "!"
  OldByte = Byte()
  If PreviousElement(Byte()) = 0
    MessageRequester("0011 - ERROR", "Error bei Befehl "+Str(e/4)+Chr(13)+Chr(10)+" !")
    ProcedureReturn e
  EndIf
  If OldByte = Byte()
    For i = e To Len(Code) Step 4
      If Mid(Code, i, 4) = "0100" Or Mid(Code, i, 4) = "0010"
        Sumper = Sumper + 1
      ElseIf Mid(Code, i, 4) = "0110"
        Sumper = Sumper - 1
      EndIf
      If Sumper = 0 And Mid(Code, i, 4) = "0110"
        NextElement(Byte())
        ProcedureReturn i; - 4
      EndIf
    Next
  EndIf
  NextElement(Byte())
  ProcedureReturn e
EndProcedure

Procedure IC1010(e.l)
  Protected e.l, i.l
  AddElement(Schleiffe())
  Schleiffe()\BytePosition = ListIndex(Byte())
  Schleiffe()\PositionToStart = e + 4
  Schleiffe()\SchleiffenType = "1010"
  For i = e To Len(Code) Step 4
    If Mid(Code, i, 4) = "1010" Or Mid(Code, i, 4) = "1001"
      Sumper = Sumper + 1
    ElseIf Mid(Code, i, 4) = "0101"
      Sumper = Sumper - 1
    EndIf
    If Sumper = 0 And Mid(Code, i, 4) = "0101"
      Schleiffe()\PositionToEnd = i
      Break
    EndIf
  Next
EndProcedure
Procedure IC1001(e.l)
  Protected e.l, i.l
  AddElement(Schleiffe())
  Schleiffe()\BytePosition = ListIndex(Byte())
  Schleiffe()\PositionToStart = e + 4
  Schleiffe()\SchleiffenType = "1001"
  For i = e To Len(Code) Step 4
    If Mid(Code, i, 4) = "1010" Or Mid(Code, i, 4) = "1001"
      Sumper = Sumper + 1
    ElseIf Mid(Code, i, 4) = "0101"
      Sumper = Sumper - 1
    EndIf
    If Sumper = 0 And Mid(Code, i, 4) = "0101"
      Schleiffe()\PositionToEnd = i
      Break
    EndIf
  Next
EndProcedure
;--------------
OpenConsole()
For e = 1 To Len(Code) Step 4
  
  If e = Schleiffe()\PositionToEnd
    BytePosition = ListIndex(Byte())
    SelectElement(Byte(), Schleiffe()\BytePosition)
    If Schleiffe()\SchleiffenType = "1010" And Byte() <> 0
      e = Schleiffe()\PositionToStart
    Else
      DeleteElement(Schleiffe())
    EndIf
    If Schleiffe()\SchleiffenType = "1010" And Byte() = 0
      e = Schleiffe()\PositionToStart
    Else
      DeleteElement(Schleiffe())
    EndIf
    SelectElement(Byte(), BytePosition)
  EndIf
  
  Select Mid(Code, e, 4)
    Case "0001" ;--v
      IC0001()
    Case "1000" ;--v
      IC1000()
    Case "0011" ;--v
      Byte() = Byte()+1
      Debug "+"
    Case "1100" ;--v
      Byte() = Byte()-1
      Debug "-"
    Case "0100" ;--v
      e = IC0100(e)
    Case "0010" ;--v
      e = IC0010(e)
    ;Case "0110" ;--v
    ;  Debug "E"
    Case "1010" ;--A
      IC1010(e)
      Debug "["
    Case "1001" ;--A
      Debug "|"
    ;Case "0101" ;--v
    ;  Debug "]"
    Case "1011" ;--v
      Print(Str(Byte()))
      Debug "%"
    Case "1101" ;--v
      Print(Chr(Byte()))
      Debug "?"
    Case "1110" ;----------------------------------
      Debug Chr(34)
    Case "1111" ;----------------------------------
      Debug "*"
    Case "0111" ;--v
      ClearList(Byte())
      Debug "$"
  EndSelect
Next
PrintN("")
Print("Enter zum Beenden")
Input()
CloseConsole()
und hier jetzt mein 0011 code

Code: Alles auswählen

0011 0011	[A = A + 2]
1010		[Schleiffen Start]
1100		  [A = A - 1]
0001		  [B]
0011 0011
0011 0011
0011		  [B = B + 5]
1010		  [Schleiffen Start]
1100		    [B = B - 1]
0001		    [C]
0011 0011
0011 0011	    [C = C + 4]
1010		    [Schleiffen Start]
1100		      [C = C - 1]
0001		      [D]
0011 0011
0011 0011
0011		      [D = D + 5]
1000		      [C]
0101		    [Schleiffen Ende]
1000		    [B]
0101		  [Schleiffen Ende]
1000		  [A]
0101		[Schleiffen Ende]
0001		[B]
0001		[C]
0001		[D]
1011		[Output müsste 200 sein]
in meinem 0011 code will ich 2*5*4*5 rechnen und da kommt ja eigentlich 200 raus aber ich komme immer nur auf 40

und da einige jetzt bestimmt ein paar probleme mit der sytax habe hier die regeln:
1) ein befehl ist IMMER 4 zeichen lang
2) die 4 zeichen von einem befehl konnen nur 0 oder 1 sein
3) es gibt nicht den befehl 0000 [da der code sonst zu un übersichtlich wird]
4) alle befehle sind hinter einander zu schreiben ohne chr(13) chr(10) oder chr(32)
5) der code muss im mom noch in die var "Code.s" geschrieben werden

ps: und noch eine andere frage ab wann ist eine sprache eine Programmiersprache?
xperience2003
Beiträge: 972
Registriert: 04.10.2004 18:42
Computerausstattung: Amiga, LinuxMint, Windows7
Wohnort: gotha
Kontaktdaten:

Beitrag von xperience2003 »

: und noch eine andere frage ab wann ist eine sprache eine Programmiersprache?
wenn ich diesen "code" hier sehe, eines hello world progs

Code: Alles auswählen

Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook.
Ook! Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook?
Ook! Ook! Ook? Ook! Ook? Ook. Ook. Ook. Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook. Ook! Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook! Ook. Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook.
Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook.
Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook! Ook. Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook.
Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook!
Ook! Ook. Ook. Ook? Ook. Ook? Ook. Ook. Ook! Ook. 
is das für mich eher keine sprache im herkömmlichen sinne
...eher nen programmier-Ook lololol
amiga rulez...
Rebirth Software
Benutzeravatar
Sylvia
verheiratet<br>1. PureGolf-Gewinner
Beiträge: 487
Registriert: 29.08.2004 09:42
Wohnort: Old Europe

Beitrag von Sylvia »

>>: und noch eine andere frage ab wann ist eine sprache eine Programmiersprache?

Erst dann, wenn sie einen Sinn macht ! /:->
Basic Pur = PureBasic
IcedCoffee
Beiträge: 115
Registriert: 09.07.2005 12:11
Wohnort: Fürstenwald [Internat], Berlin[wen keine lust auf Internat], Wildau[Einfamilienhaus]
Kontaktdaten:

Beitrag von IcedCoffee »

ist ja auch keine sprache um programme zu schreiben viel mehr eine sprache um zeit zu vertreiben

aber wenn ich ^^ zum laufen brinnge ist das bestimmt eine gute methode um daten zu verschlüssen
edit:
Sylvia hat geschrieben:>>: und noch eine andere frage ab wann ist eine sprache eine Programmiersprache?

Erst dann, wenn sie einen Sinn macht ! /:->
ok also ist Ook auch eine progsprache
Antworten