Permalink
Browse files

Initial commit. Does not include uncompiled parser.

  • Loading branch information...
0 parents commit 539f6a5243540a98c8fd25897ebcd3daa96f4e0e @trishume committed Jul 1, 2011
Showing with 26,638 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. BIN ParseTuring.jar
  3. +103 −0 ReadMe.txt
  4. +14 −0 SOURCE NOTES.txt
  5. +50 −0 TuringInTuring.t
  6. BIN advertising/Advertising_backup.pdf
  7. BIN advertising/Advertising_backup.png
  8. +11 −0 advertising/readme_advertising.txt
  9. +5 −0 antlr/NOTES.txt
  10. +48 −0 antlr/TinT1.g
  11. +264 −0 antlr/TinT2.g
  12. +109 −0 antlr/TuringExpressions.g
  13. +1 −0 ast.txt
  14. +46 −0 collections/BasicString.t
  15. +124 −0 collections/Collections.t
  16. +215 −0 collections/ListTest.t
  17. +943 −0 collections/Lists.t
  18. +106 −0 collections/MapTest.t
  19. +267 −0 collections/Maps.t
  20. +3 −0 collections/SOURCE NOTES.txt
  21. +65 −0 collections/THash.t
  22. +31 −0 collections/Test.t
  23. +95 −0 collections/Values.t
  24. +38 −0 docs/Docs.txt
  25. BIN docs/Tour/Canvas 2.png
  26. BIN docs/Tour/Canvas 3.png
  27. BIN docs/Tour/Page 1.png
  28. BIN docs/Turing Interpreter Docs.pdf
  29. BIN docs/Turing Interpreter Docs.png
  30. +187 −0 gui/EditGui.t
  31. +33 −0 gui/TuringHighlighter.t
  32. +1,434 −0 gui/altgui/GUI
  33. +435 −0 gui/altgui/TextBoxBodyClass.tu
  34. +34 −0 gui/altgui/TextBoxClass.tu
  35. +242 −0 gui/altgui/guiclass/ButtonClass.tu
  36. +474 −0 gui/altgui/guiclass/CanvasClass.tu
  37. +280 −0 gui/altgui/guiclass/CheckBoxClass.tu
  38. +570 −0 gui/altgui/guiclass/EditTextBoxBodyClass.tu
  39. +33 −0 gui/altgui/guiclass/EditTextBoxClass.tu
  40. +138 −0 gui/altgui/guiclass/FrameClass.tu
  41. +143 −0 gui/altgui/guiclass/GenericActiveWidgetClass.tu
  42. +181 −0 gui/altgui/guiclass/GenericButtonClass.tu
  43. +168 −0 gui/altgui/guiclass/GenericLabelledWidgetClass.tu
  44. +288 −0 gui/altgui/guiclass/GenericRadioButtonClass.tu
  45. +512 −0 gui/altgui/guiclass/GenericScrollBarClass.tu
  46. +406 −0 gui/altgui/guiclass/GenericSliderClass.tu
  47. +460 −0 gui/altgui/guiclass/GenericWidgetBodyClass.tu
  48. +78 −0 gui/altgui/guiclass/GenericWidgetClass.tu
  49. +397 −0 gui/altgui/guiclass/HorizontalScrollBarClass.tu
  50. +237 −0 gui/altgui/guiclass/HorizontalSliderClass.tu
  51. +182 −0 gui/altgui/guiclass/LabelClass.tu
  52. +246 −0 gui/altgui/guiclass/LabelledFrameClass.tu
  53. +143 −0 gui/altgui/guiclass/LineClass.tu
  54. +277 −0 gui/altgui/guiclass/MenuBarClass.tu
  55. +405 −0 gui/altgui/guiclass/MenuClass.tu
  56. +242 −0 gui/altgui/guiclass/MenuItemClass.tu
  57. +223 −0 gui/altgui/guiclass/PictureButtonClass.tu
  58. +96 −0 gui/altgui/guiclass/PictureClass.tu
  59. +238 −0 gui/altgui/guiclass/PictureRadioButtonClass.tu
  60. +279 −0 gui/altgui/guiclass/RadioButtonClass.tu
  61. +365 −0 gui/altgui/guiclass/TextBoxBodyClass.tu
  62. +29 −0 gui/altgui/guiclass/TextBoxClass.tu
  63. +29 −0 gui/altgui/guiclass/TextBoxModule.tu
  64. +766 −0 gui/altgui/guiclass/TextFieldClass.tu
  65. +400 −0 gui/altgui/guiclass/VerticalScrollBarClass.tu
  66. +238 −0 gui/altgui/guiclass/VerticalSliderClass.tu
  67. +168 −0 gui/altgui/guiclass/WidgetGlobals.tu
  68. +456 −0 gui/altgui/guiclass/WidgetModule.tu
  69. +19 −0 gui/altgui/guiclass/imageToken.tu
  70. +98 −0 gui/altgui/guiclass/lineRec.tu
  71. +28 −0 gui/altgui/guiclass/lineToken.tu
  72. BIN gui/altgui/guiclass/scrollthumb.bmp
  73. BIN gui/altgui/guiclass/scrollthumb.gif
  74. +92 −0 gui/altgui/guiclass/textLineRec.tu
  75. +39 −0 gui/altgui/guiclass/textToken.tu
  76. BIN gui/altgui/scrollthumb.bmp
  77. BIN gui/altgui/scrollthumb.gif
  78. +45 −0 gui/inputbox.t
  79. +78 −0 interpreter/AST.t
  80. +79 −0 interpreter/AstLexer.t
  81. +58 −0 interpreter/AstParser.t
  82. +93 −0 interpreter/BuiltInSymbols.t
  83. +105 −0 interpreter/Lexer.t
  84. +95 −0 interpreter/Lexer2.t
  85. +345 −0 interpreter/Numerics.t
  86. +81 −0 interpreter/Output.t
  87. +65 −0 interpreter/Parser.t
  88. +66 −0 interpreter/Parser2.t
  89. +121 −0 interpreter/RunProgram.t
  90. +106 −0 interpreter/Scope.t
  91. +299 −0 interpreter/Symbol.t
  92. +32 −0 interpreter/Test.t
  93. +43 −0 interpreter/Token.t
  94. +495 −0 interpreter/TuringInterpreter.t
  95. +145 −0 interpreter/TuringLexer.t
  96. +73 −0 interpreter/TuringParser.t
  97. +1 −0 interpreter/prog-big.tt
  98. +17 −0 interpreter/prog-old.tt
  99. +7 −0 interpreter/prog.tt
  100. BIN media/EndScreen.bmp
  101. BIN media/EndScreen.jpg
  102. BIN media/Space-crop-nodot.bmp
  103. BIN media/Space-crop.bmp
  104. BIN media/Space-crop.gif
  105. BIN media/Space-crop.jpg
  106. BIN media/Space-crop.png
  107. BIN media/Tour/1-o.gif
  108. BIN media/Tour/1.gif
  109. BIN media/Tour/2.gif
  110. BIN media/Tour/3.gif
  111. BIN media/Tour/3.jpg
  112. BIN media/button bar 2.bmp
  113. BIN media/button bar.GIF
  114. BIN media/button bar.JPG
  115. BIN media/button bar.bmp
  116. BIN media/button bar.png
  117. BIN media/car10wk.gif
  118. BIN media/car21go.gif
  119. BIN media/gradient-big.jpg
  120. BIN media/gradient-light.jpg
  121. BIN media/gradient.bmp
  122. BIN media/gradient.gif
  123. BIN media/scrollthumb-light.gif
  124. BIN media/scrollthumb.bmp
  125. BIN media/scrollthumb.gif
  126. BIN media/sounds/ 8bit.mp3
  127. BIN media/sounds/blip 8.wav
  128. BIN media/sounds/blip 9.wav
  129. BIN media/sounds/crop-8bit.mp3
  130. BIN media/sounds/crop-8bit.wav
  131. BIN other/ICS3M_Major_Project Evaluation.doc
  132. BIN other/Tour.graffle/QuickLook/Preview.pdf
  133. BIN other/Tour.graffle/QuickLook/Thumbnail.tiff
  134. +1,176 −0 other/Tour.graffle/data.plist
  135. BIN other/Tour.graffle/image1.PNG
  136. BIN other/Tour.graffle/image2.pdf
  137. +2 −0 other/compile.sh
  138. +17 −0 other/linecount.sh
  139. +75 −0 programs/1-Features.t
  140. +38 −0 programs/2-RandomSoundTimerRace.t
  141. +27 −0 programs/3-3DSphere.t
  142. +488 −0 programs/4-Vervoort_MAJORPROJECT.t
  143. +43 −0 programs/5-Etch-a-Sketch_Simple.t
  144. +107 −0 programs/6-DiceSamp.t
  145. +15 −0 programs/7-Rand_Rand.t
  146. +22 −0 programs/8-SprayCan.t
  147. +12 −0 programs/9-RandomOvals.t
  148. +56 −0 programs/Reid_Text_Quiz.t
  149. +33 −0 programs/arnold_program.t
  150. +23 −0 programs/keytest.t
  151. +18 −0 programs/myprog.t
  152. +75 −0 progtest.txt
  153. +174 −0 tdocparse/BuiltInSymbols.t
  154. +574 −0 tdocparse/Keyword Lookup.txt
  155. +10 −0 tdocparse/consts.txt
  156. +266 −0 tdocparse/filt.txt
  157. +313 −0 tdocparse/filtered.txt
  158. +117 −0 tdocparse/funcs.txt
  159. +158 −0 tdocparse/gen.rb
  160. +3 −0 tdocparse/gen.sh
  161. +62 −0 tdocparse/genconsts.t
  162. +3,708 −0 tdocparse/gendefs.t
  163. +1,287 −0 tdocparse/geninits.t
  164. +257 −0 tdocparse/outmethods.txt
  165. +168 −0 tdocparse/procs.txt
  166. 0 tdocparse/repet.sh
  167. +2 −0 tdocparse/test.txt
  168. +531 −0 tdocparse/tout.txt
  169. +5 −0 turing_files.ini
@@ -0,0 +1 @@
+antlr/**/*
Binary file not shown.
@@ -0,0 +1,103 @@
+TURING IN TURING
+BY Tristan Hume
+
+My major project is an interpreter capable of running turing programs.
+
+HOW TO USE
+
+When you open the program you are presented with an editor.
+YOu can type your own code into the box and press run to execute it.
+The editor doesn't function entirely like a normal multi-line text box
+because of the difficulty of coding one. Fun Fact: a good rich text editor is really
+hard to program because of problems like wrapping,sizing,scrolling,etc...
+
+You can also open a variety of sample programs that I have collected.
+
+Click the Tour button in the editor to learn more.
+
+HOW IT WORKS
+
+First, the code is saved to a file. The program then uses Sys.Exec
+to run the java program that parses the file. The java program takes the file,
+parses it and translates it in to an easier to parse syntax. You can view the output
+in the file ast.txt.
+
+The Turing program takes this text file and parses it into a data structure called an
+AST (Abstract Syntax Tree.) Then the interpreter gets to work. It uses complex recursion to
+walk down the tree. When It encounters a node, it performs the action associated with it.
+
+EXAMPLE
+Say you have a program that contains the line Sys.Exec("ed")
+This is how it would be executed:
+
+- First, the parser parses the code in to the form (CALL (. Sys Exec) "ed")
+- The turing program parses the intermediate representation into a tree.
+- Then the interpreter starts walking the tree:
+ - When it finds the CALL node, it walks to it's first child and finds a . node
+ - It then finds the two children of the dot.
+ - It looks up the first child (Sys) and finds that it is a built in module.
+ - It then looks up the function Exec in the module Sys.
+ - It returns the function that it found to the CALL node.
+ - The CALL node then passes the parameter ("ed") to the function's code and runs it.
+ - The CALL node then returns the result of the Sys.Exec function to whoever called it.
+
+SUPPORTED CODE CONSTRUCTS
+
+-variables
+-functions and procedures
+-built in functions
+-loops and for loops
+-functions as variables
+-records
+-dynamic typing
+-conditions (if,elsif,else)
+-boolean logic (or,and,xor,not)
+-integer math (+,-,*,div,mod)
+-real math (+,-,*,div,mod)
+-equality (=,~=)
+-rudimentary error handling
+
+UNSUPPORTED FEATURES
+
+-arrays
+-automatic type promotion (int + real)
+-classes and objects
+-pointers
+
+TROUBLESHOOTING
+
+some problems you may encounter:
+-stuck on parsing file:
+ You may not have java installed. The Turing program can not run the java program.
+-when I try to view some files, There are no lines, just boxes:
+ I wrote some of the files on my my mac.
+ Mac's have different line endings which do not work correctly
+
+
+FOLDER STRUCTURE
+
+antlr/
+ Contains files dealing with the parser.
+ The parser is generated with the antlr parser generator from the file TinT2.g
+docs/
+ Extra documentation files.
+other/
+ Support files and scripts. Probably only usable on my mac.
+advertising/
+ The link to the advertising website and the documentation.
+gui/
+ My modified GUI library and the files dealing with the editor GUI.
+interpreter/
+ The actual interpreter. Mostly support files.
+ The main file of interest is TuringInterpreter.t
+collections/
+ I did not write most of the code in this folder.
+ It is a turing linked list and hash map library.
+media/
+ Pictures, sound, etc...
+programs/
+ All the sample programs that can be run.
+ The editor also saves files here.
+tdocparse/
+ My ruby program that parses the turing documentation and generates function interfaces.
+ The program is gen.rb, the generated interfaces are in gendefs.t
@@ -0,0 +1,14 @@
+Some code in this project was not written by me. Here is what I didn't write.
+
+- everything in the collections folder except THash.t and Values.t
+- everything in the programs folder except 1-Features.t
+- everything in the gui/altgui folder except EditTextBoxBodyClass.t
+
+I made all the images except for the car pictures.
+
+I did not make any of the sounds.
+
+I used a 3rd party parser generator called ANTLR to generate the 12,000 line parser.
+However, I did write the 500 line grammar that it was generated from.
+
+I wrote a program to generate the turing files in the tdocparse folder that start with "gen"
@@ -0,0 +1,50 @@
+% TURING IN TURING
+% A turing program, that runs turing programs!
+% My major project for Gr. 11 Programming ICS3UG
+% June 20, 2011
+% --------------------------------------------
+
+% import my alternate gui library
+import GUI in "gui/altgui/GUI",
+ EditTextBoxClass in "gui/altgui/guiclass/EditTextBoxClass.tu",
+ TextFieldClass in "gui/altgui/guiclass/TextFieldClass.tu"
+
+%turns of auto parsing for when I am emulating windows on my mac
+const MAC := false
+%allows debug messages
+const DEBUG := false
+%allow dramatic pauses
+const DRAMA := true
+const DRAMATIME := 500
+
+%collections
+include "collections/THash.t"
+%AST parser support files
+include "interpreter/Output.t"
+include "interpreter/Token.t"
+include "interpreter/Lexer2.t"
+include "interpreter/AstLexer.t"
+include "interpreter/AST.t"
+include "interpreter/Parser2.t"
+include "interpreter/AstParser.t"
+%interpreter support files
+include "interpreter/Symbol.t"
+include "interpreter/Numerics.t"
+include "interpreter/Scope.t"
+include "tdocparse/BuiltInSymbols.t"
+include "interpreter/TuringInterpreter.t"
+include "interpreter/RunProgram.t"
+%gui
+include "gui/TuringHighlighter.t"
+include "gui/EditGui.t"
+
+View.Set ("graphics:800;600,offscreenonly,nobuttonbar")
+
+% title screen
+Pic.ScreenLoad("media/Space-crop.jpg",0,0,picCopy)
+var dummy : int
+Mouse.ButtonWait("up",dummy,dummy,dummy,dummy)
+cls
+
+% start the editor gui
+EditFileGui()
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,11 @@
+The advertising for the project is in the form of a website.
+
+You can access it at:
+http://tristan.hume.ca/tint/
+
+It was tested in firefox and chrome but it doesn't work properly in IE.
+
+In case of the website not working properly,
+I have included a pdf and image version of the site.
+
+If you do not have firefox or chrome, view the PDF version
@@ -0,0 +1,5 @@
+this folder contains files used by the java parser generator that I am using.
+
+The files that I wrote were the files defining the turing language TinT1.g and TinT2.g
+
+The output folders contains the generated code.
@@ -0,0 +1,48 @@
+grammar TuringInTuring1;
+
+ID : ('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*
+ ;
+
+INT : '0'..'9'+
+ ;
+
+COMMENT
+ : '%' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;}
+ | '/*' ( options {greedy=false;} : . )* '*/' {$channel=HIDDEN;}
+ ;
+
+WS : ( ' '
+ | '\t'
+ | '\r'
+ | '\n'
+ ) {$channel=HIDDEN;}
+ ;
+
+STRING
+ : '"' ( ESC_SEQ | ~('\\'|'"') )* '"'
+ ;
+
+CHAR: '\'' ( ESC_SEQ | ~('\''|'\\') ) '\''
+ ;
+
+fragment
+HEX_DIGIT : ('0'..'9'|'a'..'f'|'A'..'F') ;
+
+fragment
+ESC_SEQ
+ : '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\')
+ | UNICODE_ESC
+ | OCTAL_ESC
+ ;
+
+fragment
+OCTAL_ESC
+ : '\\' ('0'..'3') ('0'..'7') ('0'..'7')
+ | '\\' ('0'..'7') ('0'..'7')
+ | '\\' ('0'..'7')
+ ;
+
+fragment
+UNICODE_ESC
+ : '\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
+ ;
Oops, something went wrong. Retry.

0 comments on commit 539f6a5

Please sign in to comment.