Permalink
Browse files

initial add

  • Loading branch information...
0 parents commit 05eedb5e3a66ceb7681b6ba6802aa5d2556d0e60 @itod committed Jan 26, 2010
Showing with 38,044 additions and 0 deletions.
  1. +5 −0 .gitignore
  2. +11 −0 English.lproj/.svn/all-wcprops
  3. +69 −0 English.lproj/.svn/entries
  4. +5 −0 English.lproj/.svn/prop-base/InfoPlist.strings.svn-base
  5. BIN English.lproj/.svn/text-base/InfoPlist.strings.svn-base
  6. BIN English.lproj/InfoPlist.strings
  7. +26 −0 Info.plist
  8. +20 −0 JSParseKit-Info.plist
  9. +175 −0 License.txt
  10. +11 −0 ParseKit.xcodeproj/.svn/all-wcprops
  11. +12 −0 ParseKit.xcodeproj/.svn/dir-prop-base
  12. +69 −0 ParseKit.xcodeproj/.svn/entries
  13. +3,720 −0 ParseKit.xcodeproj/.svn/text-base/project.pbxproj.svn-base
  14. +3,720 −0 ParseKit.xcodeproj/.svn/tmp/project.pbxproj.tmp
  15. +3,720 −0 ParseKit.xcodeproj/project.pbxproj
  16. +5 −0 ParseKitMobile_Prefix.pch
  17. +14 −0 ParseKit_Prefix.pch
  18. 0 README.txt
  19. +47 −0 debugapp/.svn/all-wcprops
  20. +273 −0 debugapp/.svn/entries
  21. +24 −0 debugapp/.svn/text-base/DebugApp-Info.plist.svn-base
  22. +17 −0 debugapp/.svn/text-base/DebugAppDelegate.h.svn-base
  23. +510 −0 debugapp/.svn/text-base/DebugAppDelegate.m.svn-base
  24. +3,529 −0 debugapp/.svn/text-base/DebugAppMainMenu.xib.svn-base
  25. +36 −0 debugapp/.svn/text-base/JSONAssembler.h.svn-base
  26. +163 −0 debugapp/.svn/text-base/JSONAssembler.m.svn-base
  27. +13 −0 debugapp/.svn/text-base/main.m.svn-base
  28. +433 −0 debugapp/.svn/tmp/tempfile.tmp
  29. +24 −0 debugapp/DebugApp-Info.plist
  30. +23 −0 debugapp/DebugAppDelegate.h
  31. +516 −0 debugapp/DebugAppDelegate.m
  32. +3,529 −0 debugapp/DebugAppMainMenu.xib
  33. +42 −0 debugapp/JSONAssembler.h
  34. +169 −0 debugapp/JSONAssembler.m
  35. +13 −0 debugapp/main.m
  36. +107 −0 demoapp/.svn/all-wcprops
  37. +613 −0 demoapp/.svn/entries
  38. +24 −0 demoapp/.svn/text-base/DemoApp-Info.plist.svn-base
  39. +23 −0 demoapp/.svn/text-base/DemoAppDelegate.h.svn-base
  40. +35 −0 demoapp/.svn/text-base/DemoAppDelegate.m.svn-base
  41. +2,268 −0 demoapp/.svn/text-base/DemoAppMainMenu.xib.svn-base
  42. +32 −0 demoapp/.svn/text-base/DemoTokensViewController.h.svn-base
  43. +119 −0 demoapp/.svn/text-base/DemoTokensViewController.m.svn-base
  44. +29 −0 demoapp/.svn/text-base/DemoTreesViewController.h.svn-base
  45. +157 −0 demoapp/.svn/text-base/DemoTreesViewController.m.svn-base
  46. +21 −0 demoapp/.svn/text-base/PKParseTreeView.h.svn-base
  47. +184 −0 demoapp/.svn/text-base/PKParseTreeView.m.svn-base
  48. +25 −0 demoapp/.svn/text-base/TDGutterView.h.svn-base
  49. +92 −0 demoapp/.svn/text-base/TDGutterView.m.svn-base
  50. +21 −0 demoapp/.svn/text-base/TDSourceCodeTextView.h.svn-base
  51. +116 −0 demoapp/.svn/text-base/TDSourceCodeTextView.m.svn-base
  52. +939 −0 demoapp/.svn/text-base/TokensView.xib.svn-base
  53. +1,391 −0 demoapp/.svn/text-base/TreesView.xib.svn-base
  54. +13 −0 demoapp/.svn/text-base/main.m.svn-base
  55. +24 −0 demoapp/DemoApp-Info.plist
  56. +29 −0 demoapp/DemoAppDelegate.h
  57. +41 −0 demoapp/DemoAppDelegate.m
  58. +2,268 −0 demoapp/DemoAppMainMenu.xib
  59. +38 −0 demoapp/DemoTokensViewController.h
  60. +125 −0 demoapp/DemoTokensViewController.m
  61. +35 −0 demoapp/DemoTreesViewController.h
  62. +163 −0 demoapp/DemoTreesViewController.m
  63. +27 −0 demoapp/PKParseTreeView.h
  64. +190 −0 demoapp/PKParseTreeView.m
  65. +25 −0 demoapp/TDGutterView.h
  66. +92 −0 demoapp/TDGutterView.m
  67. +21 −0 demoapp/TDSourceCodeTextView.h
  68. +116 −0 demoapp/TDSourceCodeTextView.m
  69. +939 −0 demoapp/TokensView.xib
  70. +1,391 −0 demoapp/TreesView.xib
  71. +13 −0 demoapp/main.m
  72. +17 −0 docs/.svn/all-wcprops
  73. +6 −0 docs/.svn/dir-prop-base
  74. +106 −0 docs/.svn/entries
  75. +5 −0 docs/.svn/prop-base/ParseKit.key.svn-base
  76. +291 −0 docs/.svn/text-base/Doxyfile.svn-base
  77. BIN docs/.svn/text-base/ParseKit.key.svn-base
  78. +1,546 −0 docs/.svn/tmp/tempfile.2.tmp
  79. +291 −0 docs/Doxyfile
  80. +53 −0 docs/web/.svn/all-wcprops
  81. +346 −0 docs/web/.svn/entries
  82. +11 −0 docs/web/.svn/text-base/common-footer.inc.svn-base
  83. +6 −0 docs/web/.svn/text-base/common-header.inc.svn-base
  84. +16 −0 docs/web/.svn/text-base/common-nav.inc.svn-base
  85. +167 −0 docs/web/.svn/text-base/grammars.html.svn-base
  86. +5 −0 docs/web/.svn/text-base/htaccess.svn-base
  87. +257 −0 docs/web/.svn/text-base/index.html.svn-base
  88. +59 −0 docs/web/.svn/text-base/iphone.html.svn-base
  89. +366 −0 docs/web/.svn/text-base/tokenization.html.svn-base
  90. +11 −0 docs/web/common-footer.inc
  91. +6 −0 docs/web/common-header.inc
  92. +16 −0 docs/web/common-nav.inc
  93. +5 −0 docs/web/css/.svn/all-wcprops
  94. +62 −0 docs/web/css/.svn/entries
  95. +88 −0 docs/web/css/.svn/text-base/master.css.svn-base
  96. +88 −0 docs/web/css/master.css
  97. +167 −0 docs/web/grammars.html
  98. +5 −0 docs/web/htaccess
  99. +5 −0 docs/web/img/.svn/all-wcprops
  100. +538 −0 docs/web/img/.svn/entries
  101. +5 −0 docs/web/img/.svn/prop-base/step1a.png.svn-base
  102. +5 −0 docs/web/img/.svn/prop-base/step1a.psd.svn-base
  103. +5 −0 docs/web/img/.svn/prop-base/step1b.png.svn-base
  104. +5 −0 docs/web/img/.svn/prop-base/step1b.psd.svn-base
  105. +5 −0 docs/web/img/.svn/prop-base/step2a.png.svn-base
  106. +5 −0 docs/web/img/.svn/prop-base/step2a.psd.svn-base
  107. +5 −0 docs/web/img/.svn/prop-base/step3a.png.svn-base
  108. +5 −0 docs/web/img/.svn/prop-base/step3a.psd.svn-base
  109. +5 −0 docs/web/img/.svn/prop-base/step4a.png.svn-base
  110. +5 −0 docs/web/img/.svn/prop-base/step4a.psd.svn-base
  111. +5 −0 docs/web/img/.svn/prop-base/step4b.png.svn-base
  112. +5 −0 docs/web/img/.svn/prop-base/step4b.psd.svn-base
  113. +5 −0 docs/web/img/.svn/prop-base/step5a.png.svn-base
  114. +5 −0 docs/web/img/.svn/prop-base/step6a.png.svn-base
  115. +5 −0 docs/web/img/.svn/prop-base/step7a.png.svn-base
  116. BIN docs/web/img/.svn/text-base/step1a.png.svn-base
  117. BIN docs/web/img/.svn/text-base/step1a.psd.svn-base
  118. BIN docs/web/img/.svn/text-base/step1b.png.svn-base
  119. BIN docs/web/img/.svn/text-base/step1b.psd.svn-base
  120. BIN docs/web/img/.svn/text-base/step2a.png.svn-base
  121. BIN docs/web/img/.svn/text-base/step2a.psd.svn-base
  122. BIN docs/web/img/.svn/text-base/step3a.png.svn-base
  123. BIN docs/web/img/.svn/text-base/step3a.psd.svn-base
  124. BIN docs/web/img/.svn/text-base/step4a.png.svn-base
  125. BIN docs/web/img/.svn/text-base/step4a.psd.svn-base
  126. BIN docs/web/img/.svn/text-base/step4b.png.svn-base
  127. BIN docs/web/img/.svn/text-base/step4b.psd.svn-base
  128. BIN docs/web/img/.svn/text-base/step5a.png.svn-base
  129. BIN docs/web/img/.svn/text-base/step6a.png.svn-base
  130. BIN docs/web/img/.svn/text-base/step7a.png.svn-base
  131. BIN docs/web/img/step1a.png
  132. BIN docs/web/img/step1a.psd
  133. BIN docs/web/img/step1b.png
  134. BIN docs/web/img/step1b.psd
  135. BIN docs/web/img/step2a.png
  136. BIN docs/web/img/step2a.psd
  137. BIN docs/web/img/step3a.png
  138. BIN docs/web/img/step3a.psd
  139. BIN docs/web/img/step4a.png
  140. BIN docs/web/img/step4a.psd
  141. BIN docs/web/img/step4b.png
  142. BIN docs/web/img/step4b.psd
  143. BIN docs/web/img/step5a.png
  144. BIN docs/web/img/step6a.png
  145. BIN docs/web/img/step7a.png
  146. +257 −0 docs/web/index.html
  147. +59 −0 docs/web/iphone.html
  148. +366 −0 docs/web/tokenization.html
  149. +5 −0 frameworks/.svn/all-wcprops
  150. +31 −0 frameworks/.svn/entries
  151. +23 −0 frameworks/OCMock.framework/.svn/all-wcprops
Sorry, we could not display the entire diff because too many files (1,476) changed.
5 .gitignore
@@ -0,0 +1,5 @@
+build
+*.pbxuser
+*.mode1v3
+*.mode2v3
+*.perspectivev3
11 English.lproj/.svn/all-wcprops
@@ -0,0 +1,11 @@
+K 25
+svn:wc:ra_dav:version-url
+V 37
+/svn/!svn/ver/483/trunk/English.lproj
+END
+InfoPlist.strings
+K 25
+svn:wc:ra_dav:version-url
+V 55
+/svn/!svn/ver/483/trunk/English.lproj/InfoPlist.strings
+END
69 English.lproj/.svn/entries
@@ -0,0 +1,69 @@
+10
+
+dir
+1411
+https://todd.ditchendorf@todparsekit.googlecode.com/svn/trunk/English.lproj
+https://todd.ditchendorf@todparsekit.googlecode.com/svn
+
+
+
+2008-12-27T08:01:40.325565Z
+483
+todd.ditchendorf
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7c5183cd-b054-0410-b1f0-833f5c61cfe1
+
+
+
+
+
+
+0
+
+InfoPlist.strings
+file
+
+
+
+
+2009-07-03T20:42:39.000000Z
+47eff3f1530a2a5635a1327e8c5330a4
+2008-12-27T08:01:40.325565Z
+483
+todd.ditchendorf
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+202
+
5 English.lproj/.svn/prop-base/InfoPlist.strings.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mime-type
+V 24
+application/octet-stream
+END
BIN English.lproj/.svn/text-base/InfoPlist.strings.svn-base
Binary file not shown.
BIN English.lproj/InfoPlist.strings
Binary file not shown.
26 Info.plist
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundleIconFile</key>
+ <string></string>
+ <key>CFBundleIdentifier</key>
+ <string>com.parsekit.ParseKit</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>FMWK</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.6b</string>
+ <key>NSPrincipalClass</key>
+ <string></string>
+</dict>
+</plist>
20 JSParseKit-Info.plist
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>JSParseKit</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>FMWK</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+</dict>
+</plist>
175 License.txt
@@ -0,0 +1,175 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
11 ParseKit.xcodeproj/.svn/all-wcprops
@@ -0,0 +1,11 @@
+K 25
+svn:wc:ra_dav:version-url
+V 43
+/svn/!svn/ver/1402/trunk/ParseKit.xcodeproj
+END
+project.pbxproj
+K 25
+svn:wc:ra_dav:version-url
+V 59
+/svn/!svn/ver/1402/trunk/ParseKit.xcodeproj/project.pbxproj
+END
12 ParseKit.xcodeproj/.svn/dir-prop-base
@@ -0,0 +1,12 @@
+K 10
+svn:ignore
+V 36
+*.pbxuser
+*.mode1v3
+*.perspectivev3
+
+K 13
+svn:mergeinfo
+V 0
+
+END
69 ParseKit.xcodeproj/.svn/entries
@@ -0,0 +1,69 @@
+10
+
+dir
+1411
+https://todd.ditchendorf@todparsekit.googlecode.com/svn/trunk/ParseKit.xcodeproj
+https://todd.ditchendorf@todparsekit.googlecode.com/svn
+
+
+
+2009-09-26T04:05:15.940742Z
+1402
+todd.ditchendorf
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+7c5183cd-b054-0410-b1f0-833f5c61cfe1
+
+
+
+
+
+
+0
+
+project.pbxproj
+file
+
+
+
+
+2009-09-26T04:04:56.000000Z
+a219b667fef5cb9d730c2de94b36d330
+2009-09-26T04:05:15.940742Z
+1402
+todd.ditchendorf
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+309408
+
3,720 ParseKit.xcodeproj/.svn/text-base/project.pbxproj.svn-base
3,720 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
3,720 ParseKit.xcodeproj/.svn/tmp/project.pbxproj.tmp
3,720 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
3,720 ParseKit.xcodeproj/project.pbxproj
3,720 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
5 ParseKitMobile_Prefix.pch
@@ -0,0 +1,5 @@
+#ifdef __OBJC__
+ #import <Foundation/Foundation.h>
+ #import <Foundation/NSObject.h>
+ #import <CoreGraphics/CoreGraphics.h>
+#endif
14 ParseKit_Prefix.pch
@@ -0,0 +1,14 @@
+//
+// Prefix header for all source files of the 'ParseKit' target in the 'ParseKit' project.
+//
+
+#ifdef __OBJC__
+ #import <Foundation/Foundation.h>
+#endif
+
+#if defined(MAC_OS_X_VERSION_10_6) && defined(TARGET_OS_MAC)
+ #define TARGET_OS_SNOW_LEOPARD
+#endif
+
+#define PLATFORM(PK_FEATURE) (defined PK_PLATFORM_##PK_FEATURE && PK_PLATFORM_##PK_FEATURE)
+
0 README.txt
No changes.
47 debugapp/.svn/all-wcprops
@@ -0,0 +1,47 @@
+K 25
+svn:wc:ra_dav:version-url
+V 33
+/svn/!svn/ver/1405/trunk/debugapp
+END
+main.m
+K 25
+svn:wc:ra_dav:version-url
+V 39
+/svn/!svn/ver/583/trunk/debugapp/main.m
+END
+DebugAppMainMenu.xib
+K 25
+svn:wc:ra_dav:version-url
+V 53
+/svn/!svn/ver/647/trunk/debugapp/DebugAppMainMenu.xib
+END
+JSONAssembler.m
+K 25
+svn:wc:ra_dav:version-url
+V 49
+/svn/!svn/ver/1405/trunk/debugapp/JSONAssembler.m
+END
+DebugAppDelegate.h
+K 25
+svn:wc:ra_dav:version-url
+V 52
+/svn/!svn/ver/1171/trunk/debugapp/DebugAppDelegate.h
+END
+DebugApp-Info.plist
+K 25
+svn:wc:ra_dav:version-url
+V 53
+/svn/!svn/ver/1173/trunk/debugapp/DebugApp-Info.plist
+END
+DebugAppDelegate.m
+K 25
+svn:wc:ra_dav:version-url
+V 52
+/svn/!svn/ver/1365/trunk/debugapp/DebugAppDelegate.m
+END
+JSONAssembler.h
+K 25
+svn:wc:ra_dav:version-url
+V 49
+/svn/!svn/ver/1171/trunk/debugapp/JSONAssembler.h
+END
273 debugapp/.svn/entries
@@ -0,0 +1,273 @@
+10
+
+dir
+1411
+https://todd.ditchendorf@todparsekit.googlecode.com/svn/trunk/debugapp
+https://todd.ditchendorf@todparsekit.googlecode.com/svn
+
+
+
+2009-10-07T23:23:48.841577Z
+1405
+todd.ditchendorf
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7c5183cd-b054-0410-b1f0-833f5c61cfe1
+
+
+
+
+
+
+0
+
+main.m
+file
+
+
+
+
+2009-06-16T06:56:24.000000Z
+fb19bae94920d49fd7c1459593d19bf3
+2009-01-11T01:15:32.782160Z
+583
+todd.ditchendorf
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+256
+
+DebugAppMainMenu.xib
+file
+
+
+
+
+2009-01-21T20:59:46.000000Z
+03ecb4bb9b7274244a359af9e9116fc5
+2009-01-21T19:56:44.943333Z
+647
+todd.ditchendorf
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+153676
+
+JSONAssembler.m
+file
+
+
+
+
+2009-11-13T07:14:30.000000Z
+875a47aff9e3f18fcc8e97569e1b3bd3
+2009-10-07T23:23:48.841577Z
+1405
+todd.ditchendorf
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6095
+
+DebugAppDelegate.h
+file
+
+
+
+
+2009-07-03T19:31:31.000000Z
+6613e707e43f42ae0bcd0c50db743bd4
+2009-07-03T19:36:16.806225Z
+1171
+todd.ditchendorf
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+343
+
+DebugApp-Info.plist
+file
+
+
+
+
+2009-07-03T20:30:15.000000Z
+84e79a9792ef7d7c36e888315f843322
+2009-07-03T20:39:51.719779Z
+1173
+todd.ditchendorf
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+756
+
+DebugAppDelegate.m
+file
+
+
+
+
+2009-09-04T02:11:38.000000Z
+ac89521d384479682eabd8290dc861ee
+2009-09-04T02:11:47.318283Z
+1365
+todd.ditchendorf
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+18661
+
+JSONAssembler.h
+file
+
+
+
+
+2009-07-03T19:31:30.000000Z
+cae2b7069c00d1a5a53c923b1cb9f16d
+2009-07-03T19:36:16.806225Z
+1171
+todd.ditchendorf
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+868
+
24 debugapp/.svn/text-base/DebugApp-Info.plist.svn-base
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.yourcompany.${PRODUCT_NAME:identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>NSMainNibFile</key>
+ <string>DebugAppMainMenu</string>
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+</dict>
+</plist>
17 debugapp/.svn/text-base/DebugAppDelegate.h.svn-base
@@ -0,0 +1,17 @@
+//
+// DebugAppDelegate.h
+// ParseKit
+//
+// Created by Todd Ditchendorf on 8/12/08.
+// Copyright 2009 Todd Ditchendorf. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+@interface DebugAppDelegate : NSObject {
+ NSAttributedString *displayString;
+}
+- (IBAction)run:(id)sender;
+
+@property (retain) NSAttributedString *displayString;
+@end
510 debugapp/.svn/text-base/DebugAppDelegate.m.svn-base
@@ -0,0 +1,510 @@
+//
+// DebugAppDelegate.m
+// ParseKit
+//
+// Created by Todd Ditchendorf on 8/12/08.
+// Copyright 2009 Todd Ditchendorf. All rights reserved.
+//
+
+#import "DebugAppDelegate.h"
+#import <ParseKit/ParseKit.h>
+#import "PKParserFactory.h"
+#import "TDJsonParser.h"
+#import "TDFastJsonParser.h"
+#import "TDRegularParser.h"
+#import "EBNFParser.h"
+#import "TDPlistParser.h"
+#import "TDXmlNameState.h"
+#import "TDXmlToken.h"
+#import "TDHtmlSyntaxHighlighter.h"
+#import "JSONAssembler.h"
+#import "TDMiniCSSAssembler.h"
+#import "TDGenericAssembler.h"
+#import "NSArray+ParseKitAdditions.h"
+#import "TDSyntaxHighlighter.h"
+#import "TDJavaScriptParser.h"
+#import "TDNSPredicateEvaluator.h"
+#import <OCMock/OCMock.h>
+
+@protocol TDMockAssember
+- (void)didMatchFoo:(PKAssembly *)a;
+- (void)didMatchBaz:(PKAssembly *)a;
+- (void)didMatchStart:(PKAssembly *)a;
+- (void)didMatchStart:(PKAssembly *)a;
+- (void)didMatch_Start:(PKAssembly *)a;
+@end
+
+@interface PKParserFactory ()
+- (PKSequence *)parserFromExpression:(NSString *)s;
+@property (retain) PKCollectionParser *expressionParser;
+@end
+
+@implementation DebugAppDelegate
+
+- (void)dealloc {
+ self.displayString = nil;
+ [super dealloc];
+}
+
+
+- (void)doPlistParser {
+ NSString *s = nil;
+ PKTokenAssembly *a = nil;
+ PKAssembly *res = nil;
+ TDPlistParser *p = nil;
+
+ p = [[[TDPlistParser alloc] init] autorelease];
+
+ s = @"{"
+ @" 0 = 0;"
+ @" dictKey = {"
+ @" bar = foo;"
+ @" };"
+ @" 47 = 0;"
+ @" IntegerKey = 1;"
+ @" 47.7 = 0;"
+ @" <null> = <null>;"
+ @" ArrayKey = ("
+ @" \"one one\","
+ @" two,"
+ @" three"
+ @" );"
+ @" \"Null Key\" = <null>;"
+ @" emptyDictKey = {"
+ @" };"
+ @" StringKey = String;"
+ @" \"1.0\" = 1;"
+ @" YESKey = 1;"
+ @" \"NO Key\" = 0;"
+ @"}";
+
+ p.tokenizer.string = s;
+ a = [PKTokenAssembly assemblyWithTokenizer:p.tokenizer];
+ res = [p.dictParser completeMatchFor:a];
+
+ id attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSColor whiteColor], NSForegroundColorAttributeName,
+ [NSFont fontWithName:@"Monaco" size:12.], NSFontAttributeName,
+ nil];
+ id dict = [res pop];
+
+ p.tokenizer.string = [[[dict description] copy] autorelease];
+ a = [PKTokenAssembly assemblyWithTokenizer:p.tokenizer];
+ res = [p.dictParser bestMatchFor:a];
+ dict = [res pop];
+
+ p.tokenizer.string = nil; // prevent retain cycle leak
+ s = [[[dict description] copy] autorelease];
+
+ self.displayString = [[[NSAttributedString alloc] initWithString:s attributes:attrs] autorelease];
+}
+
+
+- (void)doHtmlSyntaxHighlighter {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"nyt" ofType:@"html"];
+ NSString *s = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+ //NSString *s = @"ア";
+
+ TDHtmlSyntaxHighlighter *highlighter = [[TDHtmlSyntaxHighlighter alloc] initWithAttributesForDarkBackground:YES];
+ NSAttributedString *o = [highlighter attributedStringForString:s];
+ //NSLog(@"o: %@", [o string]);
+ self.displayString = o;
+ [highlighter release];
+}
+
+
+- (void)doJsonParser {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"yahoo" ofType:@"json"];
+ NSString *s = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+
+ TDJsonParser *p = [[[TDJsonParser alloc] init] autorelease];
+// TDFastJsonParser *p = [[[TDFastJsonParser alloc] init] autorelease];
+
+ id result = nil;
+
+ @try {
+ result = [p parse:s];
+ } @catch (NSException *e) {
+ NSLog(@"\n\n\nexception:\n\n %@", [e reason]);
+ }
+ NSLog(@"result %@", result);
+}
+
+
+- (void)doEBNFParser {
+ //NSString *s = @"foo (bar|baz)*;";
+ NSString *s = @"$baz = bar; ($baz|foo)*;";
+ //NSString *s = @"foo;";
+ EBNFParser *p = [[[EBNFParser alloc] init] autorelease];
+
+ // PKAssembly *a = [p bestMatchFor:[PKTokenAssembly assemblyWithString:s]];
+ // NSLog(@"a: %@", a);
+ // NSLog(@"a.target: %@", a.target);
+
+ PKParser *res = [p parse:s];
+ // NSLog(@"res: %@", res);
+ // NSLog(@"res: %@", res.string);
+ // NSLog(@"res.subparsers: %@", res.subparsers);
+ // NSLog(@"res.subparsers 0: %@", [[res.subparsers objectAtIndex:0] string]);
+ // NSLog(@"res.subparsers 1: %@", [[res.subparsers objectAtIndex:1] string]);
+
+ s = @"bar foo bar foo";
+ PKAssembly *a = [res completeMatchFor:[PKTokenAssembly assemblyWithString:s]];
+ NSLog(@"\n\na: %@\n\n", a);
+}
+
+
+- (void)doGrammarParser {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"json" ofType:@"grammar"];
+ NSString *s = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+// s = @"@start = openCurly closeCurly; openCurly = '{'; closeCurly = '}';";
+// s = @"@start = start*; start = 'bar';";
+
+ PKParserFactory *factory = [PKParserFactory factory];
+
+ JSONAssembler *ass = [[[JSONAssembler alloc] init] autorelease];
+ PKParser *lp = [factory parserFromGrammar:s assembler:ass];
+
+ path = [[NSBundle bundleForClass:[self class]] pathForResource:@"yahoo" ofType:@"json"];
+ s = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+
+// s = @"bar bar";
+ PKTokenizer *t = [PKTokenizer tokenizerWithString:s];
+ t.whitespaceState.reportsWhitespaceTokens = YES;
+ PKTokenAssembly *a = [PKTokenAssembly assemblyWithTokenizer:t];
+ a.preservesWhitespaceTokens = YES;
+ //PKAssembly *res =
+ [lp completeMatchFor:a];
+
+ self.displayString = ass.displayString;
+}
+
+
+- (void)doJavaScriptGrammarParser {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"javascript" ofType:@"grammar"];
+ NSString *s = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+ PKParser *p = [[PKParserFactory factory] parserFromGrammar:s assembler:nil];
+ //PKParser *plus = [p parserNamed:@"plus"];
+
+ s = @";";
+ p.tokenizer.string = s;
+ //PKAssembly *a = [PKTokenAssembly assemblyWithTokenizer:p.tokenizer];
+ //PKAssembly *res = [p bestMatchFor:a];
+ // TDEqualObjects(@"[var, foo, =, 'bar', ;]var/foo/=/bar/;^", [res description]);
+}
+
+
+- (void)doProf {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"json_with_discards" ofType:@"grammar"];
+ NSString *s = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+ PKTokenizer *t = [PKTokenizer tokenizerWithString:s];
+ PKToken *eof = [PKToken EOFToken];
+ PKToken *tok = nil;
+ NSDate *start = [NSDate date];
+ while ((tok = [t nextToken]) != eof) ;
+ CGFloat ms4tok = -([start timeIntervalSinceNow]);
+
+ PKParserFactory *factory = [PKParserFactory factory];
+ TDJsonParser *p = nil;
+
+ p = [[[TDJsonParser alloc] initWithIntentToAssemble:NO] autorelease];
+
+ //JSONAssembler *assembler = [[[JSONAssembler alloc] init] autorelease];
+ start = [NSDate date];
+ PKParser *lp = [factory parserFromGrammar:s assembler:p];
+ CGFloat ms4grammar = -([start timeIntervalSinceNow]);
+
+ path = [[NSBundle bundleForClass:[self class]] pathForResource:@"yahoo" ofType:@"json"];
+ s = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+
+ start = [NSDate date];
+ PKAssembly *a = [PKTokenAssembly assemblyWithString:s];
+ a = [lp completeMatchFor:a];
+ CGFloat ms4json = -([start timeIntervalSinceNow]);
+
+ PKReleaseSubparserTree(lp);
+
+ p = [[TDJsonParser alloc] initWithIntentToAssemble:NO];
+ start = [NSDate date];
+ id res = [p parse:s];
+ CGFloat ms4json2 = -([start timeIntervalSinceNow]);
+ [p release];
+
+ p = [[TDJsonParser alloc] initWithIntentToAssemble:YES];
+ start = [NSDate date];
+ res = [p parse:s];
+ CGFloat ms4json3 = -([start timeIntervalSinceNow]);
+ [p release];
+
+ id fp = [[[TDFastJsonParser alloc] init] autorelease];
+ start = [NSDate date];
+ res = [fp parse:s];
+ CGFloat ms4json4 = -([start timeIntervalSinceNow]);
+
+ id attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSFont fontWithName:@"Monaco" size:14.], NSFontAttributeName,
+ [NSColor whiteColor], NSForegroundColorAttributeName,
+ nil];
+
+ s = [NSString stringWithFormat:@"tokenization: %f \n\ngrammar parse: %f sec\n\nlp json parse: %f sec\n\np json parse (not assembled): %f sec\n\np json parse (assembled): %f sec\n\nfast json parse (assembled): %f sec\n\n %f", ms4tok, ms4grammar, ms4json, ms4json2, ms4json3, ms4json4, (ms4json3/ms4json4)];
+ self.displayString = [[[NSMutableAttributedString alloc] initWithString:s attributes:attrs] autorelease];
+}
+
+
+- (void)doTokenize {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"yahoo" ofType:@"json"];
+ NSString *s = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+
+ PKTokenizer *t = [PKTokenizer tokenizerWithString:s];
+ PKToken *eof = [PKToken EOFToken];
+ PKToken *tok = nil;
+
+ NSDate *start = [NSDate date];
+ while ((tok = [t nextToken]) != eof) ;
+ CGFloat secs = -([start timeIntervalSinceNow]);
+
+ id attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSFont fontWithName:@"Monaco" size:14.], NSFontAttributeName,
+ [NSColor whiteColor], NSForegroundColorAttributeName,
+ nil];
+
+ s = [NSString stringWithFormat:@"tokenize: %f", secs];
+ self.displayString = [[[NSMutableAttributedString alloc] initWithString:s attributes:attrs] autorelease];
+}
+
+
+- (void)doSimpleCSS {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"mini_css" ofType:@"grammar"];
+ NSString *s = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+ PKParserFactory *factory = [PKParserFactory factory];
+
+ TDMiniCSSAssembler *assembler = [[[TDMiniCSSAssembler alloc] init] autorelease];
+ PKParser *lp = [factory parserFromGrammar:s assembler:assembler];
+ s = @"foo { color:rgb(111.0, 99.0, 255.0); }";
+ PKAssembly *a = [PKTokenAssembly assemblyWithString:s];
+ a = [lp completeMatchFor:a];
+
+}
+
+
+- (void)doSimpleCSS2 {
+ PKParserFactory *factory = [PKParserFactory factory];
+
+ // create CSS parser
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"mini_css" ofType:@"grammar"];
+ NSString *grammarString = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+ TDMiniCSSAssembler *cssAssembler = [[[TDMiniCSSAssembler alloc] init] autorelease];
+ PKParser *cssParser = [factory parserFromGrammar:grammarString assembler:cssAssembler];
+
+ // parse CSS
+ path = [[NSBundle bundleForClass:[self class]] pathForResource:@"json" ofType:@"css"];
+ NSString *s = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+ PKAssembly *a = [PKTokenAssembly assemblyWithString:s];
+ a = [cssParser bestMatchFor:a];
+
+ // get attributes from css
+ id attrs = cssAssembler.attributes;
+
+ // create JSON Parser
+ path = [[NSBundle bundleForClass:[self class]] pathForResource:@"json" ofType:@"grammar"];
+ grammarString = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+ TDGenericAssembler *genericAssembler = [[[TDGenericAssembler alloc] init] autorelease];
+
+ // give it the attrs from CSS
+ genericAssembler.attributes = attrs;
+ PKParser *jsonParser = [factory parserFromGrammar:grammarString assembler:genericAssembler];
+
+ // parse JSON
+ path = [[NSBundle bundleForClass:[self class]] pathForResource:@"yahoo" ofType:@"json"];
+ s = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+
+ // take care to preseve the whitespace in the JSON
+ PKTokenizer *t = [PKTokenizer tokenizerWithString:s];
+ t.whitespaceState.reportsWhitespaceTokens = YES;
+ PKTokenAssembly *a1 = [PKTokenAssembly assemblyWithTokenizer:t];
+ a1.preservesWhitespaceTokens = YES;
+// [jsonParser completeMatchFor:a1];
+// self.displayString = genericAssembler.displayString;
+ self.displayString = [[jsonParser completeMatchFor:a1] target];
+}
+
+
+- (void)doJSONHighlighting {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"yahoo" ofType:@"json"];
+ NSString *s = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+ TDSyntaxHighlighter *shc = [[[TDSyntaxHighlighter alloc] init] autorelease];
+ self.displayString = [shc highlightedStringForString:s ofGrammar:@"json"];
+}
+
+
+- (void)doCSSHighlighting {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"example" ofType:@"css"];
+ NSString *s = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+ TDSyntaxHighlighter *shc = [[[TDSyntaxHighlighter alloc] init] autorelease];
+ self.displayString = [shc highlightedStringForString:s ofGrammar:@"css"];
+}
+
+
+- (void)doHTMLHighlighting {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"example" ofType:@"html"];
+ NSString *s = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+ TDSyntaxHighlighter *shc = [[[TDSyntaxHighlighter alloc] init] autorelease];
+ self.displayString = [shc highlightedStringForString:s ofGrammar:@"html"];
+}
+
+
+- (void)doMultiLineComment {
+ NSString *s = @"/* foo */ ";
+ PKTokenizer *t = [PKTokenizer tokenizerWithString:s];
+ t.commentState.reportsCommentTokens = YES;
+ //PKToken *tok =
+ [t nextToken];
+}
+
+
+- (void)doRubyHashParser {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"rubyhash" ofType:@"grammar"];
+ NSString *s = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+ PKParser *lp = [[PKParserFactory factory] parserFromGrammar:s assembler:nil];
+
+ s = @"{\"brand\"=>{\"name\"=>\"something\","
+ @"\"logo\"=>#<File:/var/folders/RK/RK1vsZigGhijmL6ObznDJk+++TI/-Tmp-/CGI66145-4>,"
+ @"\"summary\"=>\"wee\", \"content\"=>\"woopy doo\"}, \"commit\"=>\"Save\","
+ @"\"authenticity_token\"=>\"43a94d60304a7fb13a4ff61a5960461ce714e92b\","
+ @"\"action\"=>\"create\", \"controller\"=>\"admin/brands\"}";
+
+ NSLog(@"%@", [lp parse:s]);
+}
+
+
+
+- (void)doFactory {
+// id mock = [OCMockObject mockForProtocol:@protocol(TDMockAssember)];
+// PKParserFactory *factory = [PKParserFactory factory];
+// NSString *s = nil;
+// s = @"@start = foo|baz; foo (didMatchFooAssembly:) = 'bar'; baz (didMatchBazAssembly:) = 'bat'";
+// factory.assemblerSettingBehavior = PKParserFactoryAssemblerSettingBehaviorOnExplicit;
+// PKParser *lp = [factory parserFromGrammar:s assembler:mock];
+//
+//// [[mock expect] didMatchBazAssembly:OCMOCK_ANY];
+//// NSString *s = @"bar bat";
+//// a = [PKTokenAssembly assemblyWithString:s];
+//// res = [lp completeMatchFor:a];
+//// TDEqualObjects(@"[bar, bat]bar/bat^", [res description]);
+//// [mock verify];
+
+// NSString *g = @"@delimitState = '$'; @delimitedString = '$' '%' nil; @start = DelimitedString('$', '%');";
+// PKParser *lp = [[PKParserFactory factory] parserFromGrammar:g assembler:nil];
+//
+// NSString *s = @"$foo%";
+// PKTokenizer *t = lp.tokenizer;
+// t.string = s;
+// PKAssembly *res = [lp bestMatchFor:[PKTokenAssembly assemblyWithTokenizer:t]];
+
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"xpath1_0" ofType:@"grammar"];
+ NSString *g = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+ PKParser *p = [[PKParserFactory factory] parserFromGrammar:g assembler:nil];
+ PKTokenizer *t = p.tokenizer;
+ t.string = @"foo";
+ //PKAssembly *res = [p completeMatchFor:[PKTokenAssembly assemblyWithTokenizer:t]];
+
+}
+
+
+- (void)doParenStuff {
+ NSString *s = @"-(ab+5)";
+ PKTokenizer *t = [PKTokenizer tokenizerWithString:s];
+
+ PKToken *tok = [t nextToken];
+
+// TDTrue(tok.isSymbol);
+// TDEqualObjects(tok.stringValue, @"-");
+// TDEquals((CGFloat)0.0, tok.floatValue);
+
+ tok = [t nextToken];
+// TDTrue(tok.isSymbol);
+// TDEqualObjects(tok.stringValue, @"(");
+// TDEquals((CGFloat)0.0, tok.floatValue);
+}
+
+
+- (void)doDelimitedString {
+ NSString *s = @"<?= 'foo' ?>";
+
+ PKTokenizer *t = [PKTokenizer tokenizerWithString:s];
+ NSCharacterSet *cs = nil;
+
+ [t setTokenizerState:t.delimitState from:'<' to:'<'];
+ [t.delimitState addStartMarker:@"<?=" endMarker:@"?>" allowedCharacterSet:cs];
+
+// PKToken *tok = [t nextToken];
+
+ //TDTrue(tok.isDelimitedString);
+
+}
+
+
+- (void)doJSParser {
+ TDJavaScriptParser *jsp = [TDJavaScriptParser parser];
+ NSString *s = @"for( ; true; true) {}";
+ jsp.tokenizer.string = s;
+// PKTokenAssembly *a = [PKTokenAssembly assemblyWithTokenizer:jsp.tokenizer];
+// id res = [jsp bestMatchFor:a];
+ //TDEqualObjects([res description], @"['foo']'foo'^");
+
+ //TDEqualObjects([res description], @"[for, (, ;, true, ;, true, ), {, }]for/(/;/true/;/true/)/{/}^");
+}
+
+
+- (void)doNSPredicateEvaluator {
+ //TDNSPredicateEvaluator *eval = [[[TDNSPredicateEvaluator alloc] initWithKeyPathResolver:nil] autorelease];
+}
+
+
+- (void)doXMLParser {
+// NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"xml" ofType:@"grammar"];
+// NSString *g = [NSString stringWithContentsOfFile:path];
+// PKParser *p = [[PKParserFactory factory] parserFromGrammar:g assembler:self];
+// PKTokenizer *t = p.tokenizer;
+}
+
+
+
+
+- (IBAction)run:(id)sender {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+// [self doPlistParser];
+// [self doHtmlSyntaxHighlighter];
+// [self doJsonParser];
+// [self doRubyHashParser];
+
+// [self doJSParser];
+
+ [self doProf];
+
+ //[self doJavaScriptGrammarParser];
+
+ // [self doTokenize];
+// [self doGrammarParser];
+// [self doSimpleCSS];
+// [self doSimpleCSS2];
+// [self doParenStuff];
+
+// [self doJSONHighlighting];
+// [self doCSSHighlighting];
+// [self doHTMLHighlighting];
+
+// [self doMultiLineComment];
+// [self doDelimitedString];
+
+// [self doFactory];
+
+// [self doXMLParser];
+// [self doNSPredicateEvaluator];
+
+ [pool drain];
+}
+
+@synthesize displayString;
+@end
3,529 debugapp/.svn/text-base/DebugAppMainMenu.xib.svn-base
3,529 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
36 debugapp/.svn/text-base/JSONAssembler.h.svn-base
@@ -0,0 +1,36 @@
+//
+// JSONAssembler.h
+// ParseKit
+//
+// Created by Todd Ditchendorf on 12/16/08.
+// Copyright 2009 Todd Ditchendorf. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@class PKToken;
+
+@interface JSONAssembler : NSObject {
+ NSMutableAttributedString *displayString;
+ id defaultAttrs;
+ id objectAttrs;
+ id arrayAttrs;
+ id propertyNameAttrs;
+ id valueAttrs;
+ id constantAttrs;
+
+ PKToken *comma;
+ PKToken *curly;
+ PKToken *bracket;
+}
+@property (retain) NSMutableAttributedString *displayString;
+@property (retain) id defaultAttrs;
+@property (retain) id objectAttrs;
+@property (retain) id arrayAttrs;
+@property (retain) id propertyNameAttrs;
+@property (retain) id valueAttrs;
+@property (retain) id constantAttrs;
+@property (retain) PKToken *comma;
+@property (retain) PKToken *curly;
+@property (retain) PKToken *bracket;
+@end
163 debugapp/.svn/text-base/JSONAssembler.m.svn-base
@@ -0,0 +1,163 @@
+//
+// JSONAssembler.m
+// ParseKit
+//
+// Created by Todd Ditchendorf on 12/16/08.
+// Copyright 2009 Todd Ditchendorf. All rights reserved.
+//
+
+#import "JSONAssembler.h"
+#import "NSArray+ParseKitAdditions.h"
+#import <ParseKit/ParseKit.h>
+
+@implementation JSONAssembler
+
+- (id)init {
+ self = [super init];
+ if (self != nil) {
+ NSColor *textColor = [NSColor whiteColor];
+ NSColor *tagColor = [NSColor colorWithDeviceRed:.70 green:.14 blue:.53 alpha:1.];
+ NSColor *attrNameColor = [NSColor colorWithDeviceRed:.33 green:.45 blue:.48 alpha:1.];
+ NSColor *attrValueColor = [NSColor colorWithDeviceRed:.77 green:.18 blue:.20 alpha:1.];
+ NSColor *commentColor = [NSColor colorWithDeviceRed:.24 green:.70 blue:.27 alpha:1.];
+ NSColor *piColor = [NSColor colorWithDeviceRed:.09 green:.62 blue:.74 alpha:1.];
+
+ NSFont *monacoFont = [NSFont fontWithName:@"Monaco" size:11.];
+
+ self.defaultAttrs = [NSDictionary dictionaryWithObjectsAndKeys:
+ textColor, NSForegroundColorAttributeName,
+ monacoFont, NSFontAttributeName,
+ nil];
+ self.objectAttrs = [NSDictionary dictionaryWithObjectsAndKeys:
+ tagColor, NSForegroundColorAttributeName,
+ monacoFont, NSFontAttributeName,
+ nil];
+ self.propertyNameAttrs = [NSDictionary dictionaryWithObjectsAndKeys:
+ attrNameColor, NSForegroundColorAttributeName,
+ monacoFont, NSFontAttributeName,
+ nil];
+ self.valueAttrs = [NSDictionary dictionaryWithObjectsAndKeys:
+ attrValueColor, NSForegroundColorAttributeName,
+ monacoFont, NSFontAttributeName,
+ nil];
+ self.constantAttrs = [NSDictionary dictionaryWithObjectsAndKeys:
+ piColor, NSForegroundColorAttributeName,
+ monacoFont, NSFontAttributeName,
+ nil];
+ self.arrayAttrs = [NSDictionary dictionaryWithObjectsAndKeys:
+ commentColor, NSForegroundColorAttributeName,
+ monacoFont, NSFontAttributeName,
+ nil];
+
+ self.displayString = [[[NSMutableAttributedString alloc] initWithString:@"" attributes:defaultAttrs] autorelease];
+
+ self.comma = [PKToken tokenWithTokenType:PKTokenTypeSymbol stringValue:@"," floatValue:0];
+ self.curly = [PKToken tokenWithTokenType:PKTokenTypeSymbol stringValue:@"{" floatValue:0];
+ self.bracket = [PKToken tokenWithTokenType:PKTokenTypeSymbol stringValue:@"[" floatValue:0];
+ }
+ return self;
+}
+
+
+- (void)dealloc {
+ self.displayString = nil;
+ self.defaultAttrs = nil;
+ self.objectAttrs = nil;
+ self.arrayAttrs = nil;
+ self.propertyNameAttrs = nil;
+ self.valueAttrs = nil;
+ self.constantAttrs = nil;
+ self.comma = nil;
+ self.curly = nil;
+ self.bracket = nil;
+ [super dealloc];
+}
+
+
+- (void)appendAttributedStringForObjects:(NSArray *)objs withAttrs:(id)attrs {
+ for (id obj in objs) {
+ NSAttributedString *as = [[NSAttributedString alloc] initWithString:[obj stringValue] attributes:attrs];
+ [displayString appendAttributedString:as];
+ [as release];
+ }
+}
+
+
+- (void)consumeWhitespaceFrom:(PKAssembly *)a {
+ NSMutableArray *whitespaceToks = [NSMutableArray array];
+ PKToken *tok = nil;
+ while (1) {
+ tok = [a pop];
+ if (PKTokenTypeWhitespace == tok.tokenType) {
+ [whitespaceToks addObject:tok];
+ } else {
+ [a push:tok];
+ break;
+ }
+ }
+
+ if ([whitespaceToks count]) {
+ whitespaceToks = [whitespaceToks reversedMutableArray];
+ [self appendAttributedStringForObjects:whitespaceToks withAttrs:defaultAttrs];
+ }
+}
+
+
+- (void)didMatchSymbolChar:(PKAssembly *)a {
+ NSArray *objs = [NSArray arrayWithObject:[a pop]];
+ [self consumeWhitespaceFrom:a];
+ [self appendAttributedStringForObjects:objs withAttrs:objectAttrs];
+}
+
+
+- (void)didMatchPropertyName:(PKAssembly *)a {
+ NSArray *objs = [NSArray arrayWithObject:[a pop]];
+ [self consumeWhitespaceFrom:a];
+ [self appendAttributedStringForObjects:objs withAttrs:propertyNameAttrs];
+}
+
+
+- (void)didMatchString:(PKAssembly *)a {
+ NSArray *objs = [NSArray arrayWithObject:[a pop]];
+ [self consumeWhitespaceFrom:a];
+ [self appendAttributedStringForObjects:objs withAttrs:arrayAttrs];
+}
+
+
+- (void)didMatchNumber:(PKAssembly *)a {
+ NSArray *objs = [NSArray arrayWithObject:[a pop]];
+ [self consumeWhitespaceFrom:a];
+ [self appendAttributedStringForObjects:objs withAttrs:valueAttrs];
+}
+
+
+- (void)didMatchConstant:(PKAssembly *)a {
+ NSArray *objs = [NSArray arrayWithObject:[a pop]];
+ [self consumeWhitespaceFrom:a];
+ [self appendAttributedStringForObjects:objs withAttrs:constantAttrs];
+}
+
+
+- (void)didMatchNull:(PKAssembly *)a { [self didMatchConstant:a]; }
+- (void)didMatchTrue:(PKAssembly *)a { [self didMatchConstant:a]; }
+- (void)didMatchFalse:(PKAssembly *)a { [self didMatchConstant:a]; }
+
+- (void)didMatchColon:(PKAssembly *)a { [self didMatchSymbolChar:a]; }
+- (void)didMatchComma:(PKAssembly *)a { [self didMatchSymbolChar:a]; }
+- (void)didMatchOpenCurly:(PKAssembly *)a { [self didMatchSymbolChar:a]; }
+- (void)didMatchCloseCurly:(PKAssembly *)a { [self didMatchSymbolChar:a]; }
+- (void)didMatchOpenBracket:(PKAssembly *)a { [self didMatchSymbolChar:a]; }
+- (void)didMatchCloseBracket:(PKAssembly *)a { [self didMatchSymbolChar:a]; }
+
+@synthesize displayString;
+@synthesize defaultAttrs;
+@synthesize objectAttrs;
+@synthesize arrayAttrs;
+@synthesize propertyNameAttrs;
+@synthesize valueAttrs;
+@synthesize constantAttrs;
+@synthesize comma;
+@synthesize curly;
+@synthesize bracket;
+@end
+
13 debugapp/.svn/text-base/main.m.svn-base
@@ -0,0 +1,13 @@
+//
+// main.m
+// TestApp
+//
+// Created by Todd Ditchendorf on 7/12/08.
+// Copyright Todd Ditchendorf 2008. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+int main(int argc, char *argv[]) {
+ return NSApplicationMain(argc, (const char **) argv);
+}
433 debugapp/.svn/tmp/tempfile.tmp
@@ -0,0 +1,433 @@
+//
+// DebugAppDelegate.m
+// TDParseKit
+//
+// Created by Todd Ditchendorf on 8/12/08.
+// Copyright 2008 Todd Ditchendorf. All rights reserved.
+//
+
+#import "DebugAppDelegate.h"
+#import <TDParseKit/TDParseKit.h>
+#import "TDJsonParser.h"
+#import "TDFastJsonParser.h"
+#import "TDRegularParser.h"
+#import "EBNFParser.h"
+#import "TDPlistParser.h"
+#import "TDXmlNameState.h"
+#import "TDXmlToken.h"
+#import "TDHtmlSyntaxHighlighter.h"
+#import "TDParserFactory.h"
+#import "JSONAssembler.h"
+#import "TDMiniCSSAssembler.h"
+#import "TDGenericAssembler.h"
+#import "NSArray+TDParseKitAdditions.h"
+#import "TDSyntaxHighlighter.h"
+#import <OCMock/OCMock.h>
+
+@protocol TDMockAssember
+- (void)workOnFooAssembly:(TDAssembly *)a;
+- (void)workOnBazAssembly:(TDAssembly *)a;
+- (void)workOnStart:(TDAssembly *)a;
+- (void)workOnStartAssembly:(TDAssembly *)a;
+- (void)workOn_StartAssembly:(TDAssembly *)a;
+@end
+
+@interface TDParserFactory ()
+- (TDSequence *)parserFromExpression:(NSString *)s;
+@property (retain) TDCollectionParser *expressionParser;
+@end
+
+@implementation DebugAppDelegate
+
+- (void)dealloc {
+ self.displayString = nil;
+ [super dealloc];
+}
+
+
+- (void)doPlistParser {
+ NSString *s = nil;
+ TDTokenAssembly *a = nil;
+ TDAssembly *res = nil;
+ TDPlistParser *p = nil;
+
+ p = [[[TDPlistParser alloc] init] autorelease];
+
+ s = @"{"
+ @" 0 = 0;"
+ @" dictKey = {"
+ @" bar = foo;"
+ @" };"
+ @" 47 = 0;"
+ @" IntegerKey = 1;"
+ @" 47.7 = 0;"
+ @" <null> = <null>;"
+ @" ArrayKey = ("
+ @" \"one one\","
+ @" two,"
+ @" three"
+ @" );"
+ @" \"Null Key\" = <null>;"
+ @" emptyDictKey = {"
+ @" };"
+ @" StringKey = String;"
+ @" \"1.0\" = 1;"
+ @" YESKey = 1;"
+ @" \"NO Key\" = 0;"
+ @"}";
+
+ p.tokenizer.string = s;
+ a = [TDTokenAssembly assemblyWithTokenizer:p.tokenizer];
+ res = [p.dictParser completeMatchFor:a];
+
+ id attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSColor whiteColor], NSForegroundColorAttributeName,
+ [NSFont fontWithName:@"Monaco" size:12.], NSFontAttributeName,
+ nil];
+ id dict = [res pop];
+
+ p.tokenizer.string = [[[dict description] copy] autorelease];
+ a = [TDTokenAssembly assemblyWithTokenizer:p.tokenizer];
+ res = [p.dictParser bestMatchFor:a];
+ dict = [res pop];
+
+ p.tokenizer.string = nil; // prevent retain cycle leak
+ s = [[[dict description] copy] autorelease];
+
+ self.displayString = [[[NSAttributedString alloc] initWithString:s attributes:attrs] autorelease];
+}
+
+
+- (void)doHtmlSyntaxHighlighter {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"nyt" ofType:@"html"];
+ NSString *s = [NSString stringWithContentsOfFile:path];
+ //NSString *s = @"ア";
+
+ TDHtmlSyntaxHighlighter *highlighter = [[TDHtmlSyntaxHighlighter alloc] initWithAttributesForDarkBackground:YES];
+ NSAttributedString *o = [highlighter attributedStringForString:s];
+ //NSLog(@"o: %@", [o string]);
+ self.displayString = o;
+ [highlighter release];
+}
+
+
+- (void)doJsonParser {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"yahoo" ofType:@"json"];
+ NSString *s = [NSString stringWithContentsOfFile:path];
+
+ TDJsonParser *p = [[[TDJsonParser alloc] init] autorelease];
+// TDFastJsonParser *p = [[[TDFastJsonParser alloc] init] autorelease];
+
+ id result = nil;
+
+ @try {
+ result = [p parse:s];
+ } @catch (NSException *e) {
+ NSLog(@"\n\n\nexception:\n\n %@", [e reason]);
+ }
+ NSLog(@"result %@", result);
+}
+
+
+- (void)doEBNFParser {
+ //NSString *s = @"foo (bar|baz)*;";
+ NSString *s = @"$baz = bar; ($baz|foo)*;";
+ //NSString *s = @"foo;";
+ EBNFParser *p = [[[EBNFParser alloc] init] autorelease];
+
+ // TDAssembly *a = [p bestMatchFor:[TDTokenAssembly assemblyWithString:s]];
+ // NSLog(@"a: %@", a);
+ // NSLog(@"a.target: %@", a.target);
+
+ TDParser *res = [p parse:s];
+ // NSLog(@"res: %@", res);
+ // NSLog(@"res: %@", res.string);
+ // NSLog(@"res.subparsers: %@", res.subparsers);
+ // NSLog(@"res.subparsers 0: %@", [[res.subparsers objectAtIndex:0] string]);
+ // NSLog(@"res.subparsers 1: %@", [[res.subparsers objectAtIndex:1] string]);
+
+ s = @"bar foo bar foo";
+ TDAssembly *a = [res completeMatchFor:[TDTokenAssembly assemblyWithString:s]];
+ NSLog(@"\n\na: %@\n\n", a);
+}
+
+
+- (void)doGrammarParser {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"json" ofType:@"grammar"];
+ NSString *s = [NSString stringWithContentsOfFile:path];
+// s = @"@start = openCurly closeCurly; openCurly = '{'; closeCurly = '}';";
+// s = @"@start = start*; start = 'bar';";
+
+ TDParserFactory *factory = [TDParserFactory factory];
+
+ JSONAssembler *ass = [[[JSONAssembler alloc] init] autorelease];
+ TDParser *lp = [factory parserFromGrammar:s assembler:ass];
+
+ path = [[NSBundle bundleForClass:[self class]] pathForResource:@"yahoo" ofType:@"json"];
+ s = [NSString stringWithContentsOfFile:path];
+
+// s = @"bar bar";
+ TDTokenizer *t = [TDTokenizer tokenizerWithString:s];
+ t.whitespaceState.reportsWhitespaceTokens = YES;
+ TDTokenAssembly *a = [TDTokenAssembly assemblyWithTokenizer:t];
+ a.preservesWhitespaceTokens = YES;
+ //TDAssembly *res =
+ [lp completeMatchFor:a];
+
+ self.displayString = ass.displayString;
+}
+
+
+- (void)doProf {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"json_with_discards" ofType:@"grammar"];
+ NSString *s = [NSString stringWithContentsOfFile:path];
+ TDTokenizer *t = [TDTokenizer tokenizerWithString:s];
+ TDToken *eof = [TDToken EOFToken];
+ TDToken *tok = nil;
+ NSDate *start = [NSDate date];
+ while ((tok = [t nextToken]) != eof) ;
+ CGFloat ms4tok = -([start timeIntervalSinceNow]);
+
+ TDParserFactory *factory = [TDParserFactory factory];
+ TDJsonParser *p = nil;
+
+ p = [[[TDJsonParser alloc] initWithIntentToAssemble:NO] autorelease];
+
+ //JSONAssembler *assembler = [[[JSONAssembler alloc] init] autorelease];
+ start = [NSDate date];
+ TDParser *lp = [factory parserFromGrammar:s assembler:p];
+ CGFloat ms4grammar = -([start timeIntervalSinceNow]);
+
+ path = [[NSBundle bundleForClass:[self class]] pathForResource:@"yahoo" ofType:@"json"];
+ s = [NSString stringWithContentsOfFile:path];
+
+ start = [NSDate date];
+ TDAssembly *a = [TDTokenAssembly assemblyWithString:s];
+ a = [lp completeMatchFor:a];
+ CGFloat ms4json = -([start timeIntervalSinceNow]);
+
+ p = [[TDJsonParser alloc] initWithIntentToAssemble:NO];
+ start = [NSDate date];
+ id res = [p parse:s];
+ CGFloat ms4json2 = -([start timeIntervalSinceNow]);
+ [p release];
+
+ p = [[TDJsonParser alloc] initWithIntentToAssemble:YES];
+ start = [NSDate date];
+ res = [p parse:s];
+ CGFloat ms4json3 = -([start timeIntervalSinceNow]);
+ [p release];
+
+ id fp = [[[TDFastJsonParser alloc] init] autorelease];
+ start = [NSDate date];
+ res = [fp parse:s];
+ CGFloat ms4json4 = -([start timeIntervalSinceNow]);
+
+ id attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSFont fontWithName:@"Monaco" size:14.], NSFontAttributeName,
+ [NSColor whiteColor], NSForegroundColorAttributeName,
+ nil];
+
+ s = [NSString stringWithFormat:@"tokenization: %f \n\ngrammar parse: %f sec\n\nlp json parse: %f sec\n\np json parse (not assembled): %f sec\n\np json parse (assembled): %f sec\n\nfast json parse (assembled): %f sec\n\n %f", ms4tok, ms4grammar, ms4json, ms4json2, ms4json3, ms4json4, (ms4json3/ms4json4)];
+ self.displayString = [[[NSMutableAttributedString alloc] initWithString:s attributes:attrs] autorelease];
+}
+
+
+- (void)doTokenize {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"yahoo" ofType:@"json"];
+ NSString *s = [NSString stringWithContentsOfFile:path];
+
+ TDTokenizer *t = [TDTokenizer tokenizerWithString:s];
+ TDToken *eof = [TDToken EOFToken];
+ TDToken *tok = nil;
+
+ NSDate *start = [NSDate date];
+ while ((tok = [t nextToken]) != eof) ;
+ CGFloat secs = -([start timeIntervalSinceNow]);
+
+ id attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSFont fontWithName:@"Monaco" size:14.], NSFontAttributeName,
+ [NSColor whiteColor], NSForegroundColorAttributeName,
+ nil];
+
+ s = [NSString stringWithFormat:@"tokenize: %f", secs];
+ self.displayString = [[[NSMutableAttributedString alloc] initWithString:s attributes:attrs] autorelease];
+}
+
+
+- (void)doSimpleCSS {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"mini_css" ofType:@"grammar"];
+ NSString *s = [NSString stringWithContentsOfFile:path];
+ TDParserFactory *factory = [TDParserFactory factory];
+
+ TDMiniCSSAssembler *assembler = [[[TDMiniCSSAssembler alloc] init] autorelease];
+ TDParser *lp = [factory parserFromGrammar:s assembler:assembler];
+ s = @"foo { color:rgb(111.0, 99.0, 255.0); }";
+ TDAssembly *a = [TDTokenAssembly assemblyWithString:s];
+ a = [lp completeMatchFor:a];
+
+}
+
+
+- (void)doSimpleCSS2 {
+ TDParserFactory *factory = [TDParserFactory factory];
+
+ // create CSS parser
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"mini_css" ofType:@"grammar"];
+ NSString *grammarString = [NSString stringWithContentsOfFile:path];
+ TDMiniCSSAssembler *cssAssembler = [[[TDMiniCSSAssembler alloc] init] autorelease];
+ TDParser *cssParser = [factory parserFromGrammar:grammarString assembler:cssAssembler];
+
+ // parse CSS
+ path = [[NSBundle bundleForClass:[self class]] pathForResource:@"json" ofType:@"css"];
+ NSString *s = [NSString stringWithContentsOfFile:path];
+ TDAssembly *a = [TDTokenAssembly assemblyWithString:s];
+ a = [cssParser bestMatchFor:a];
+
+ // get attributes from css
+ id attrs = cssAssembler.attributes;
+
+ // create JSON Parser
+ path = [[NSBundle bundleForClass:[self class]] pathForResource:@"json" ofType:@"grammar"];
+ grammarString = [NSString stringWithContentsOfFile:path];
+ TDGenericAssembler *genericAssembler = [[[TDGenericAssembler alloc] init] autorelease];
+
+ // give it the attrs from CSS
+ genericAssembler.attributes = attrs;
+ TDParser *jsonParser = [factory parserFromGrammar:grammarString assembler:genericAssembler];
+
+ // parse JSON
+ path = [[NSBundle bundleForClass:[self class]] pathForResource:@"yahoo" ofType:@"json"];
+ s = [NSString stringWithContentsOfFile:path];
+
+ // take care to preseve the whitespace in the JSON
+ TDTokenizer *t = [TDTokenizer tokenizerWithString:s];
+ t.whitespaceState.reportsWhitespaceTokens = YES;
+ TDTokenAssembly *a1 = [TDTokenAssembly assemblyWithTokenizer:t];
+ a1.preservesWhitespaceTokens = YES;
+ [jsonParser completeMatchFor:a1];
+
+ self.displayString = genericAssembler.displayString;
+}
+
+
+- (void)doJSONHighlighting {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"yahoo" ofType:@"json"];
+ NSString *s = [NSString stringWithContentsOfFile:path];
+ TDSyntaxHighlighter *shc = [[[TDSyntaxHighlighter alloc] init] autorelease];
+ self.displayString = [shc highlightedStringForString:s ofGrammar:@"json"];
+}
+
+
+- (void)doCSSHighlighting {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"example" ofType:@"css"];
+ NSString *s = [NSString stringWithContentsOfFile:path];
+ TDSyntaxHighlighter *shc = [[[TDSyntaxHighlighter alloc] init] autorelease];
+ self.displayString = [shc highlightedStringForString:s ofGrammar:@"css"];
+}
+
+
+- (void)doHTMLHighlighting {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"example" ofType:@"html"];
+ NSString *s = [NSString stringWithContentsOfFile:path];
+ TDSyntaxHighlighter *shc = [[[TDSyntaxHighlighter alloc] init] autorelease];
+ self.displayString = [shc highlightedStringForString:s ofGrammar:@"html"];
+}
+
+
+- (void)doMultiLineComment {
+ NSString *s = @"/* foo */ ";
+ TDTokenizer *t = [TDTokenizer tokenizerWithString:s];
+ t.commentState.reportsCommentTokens = YES;
+ //TDToken *tok =
+ [t nextToken];
+}
+
+
+- (void)doRubyHashParser {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"rubyhash" ofType:@"grammar"];
+ NSString *s = [NSString stringWithContentsOfFile:path];
+ TDTokenizer *t = nil;
+ TDParser *lp = [[TDParserFactory factory] parserFromGrammar:s assembler:nil getTokenizer:&t];
+
+ s = @"{\"brand\"=>{\"name\"=>\"something\","
+ @"\"logo\"=>#<File:/var/folders/RK/RK1vsZigGhijmL6ObznDJk+++TI/-Tmp-/CGI66145-4>,"
+ @"\"summary\"=>\"wee\", \"content\"=>\"woopy doo\"}, \"commit\"=>\"Save\","
+ @"\"authenticity_token\"=>\"43a94d60304a7fb13a4ff61a5960461ce714e92b\","
+ @"\"action\"=>\"create\", \"controller\"=>\"admin/brands\"}";
+
+ t.string = s; //@"{\"foo\"=>\"bar\"}";
+ t.commentState.reportsCommentTokens = YES;
+
+ TDAssembly *a = [TDTokenAssembly assemblyWithTokenizer:t];
+ TDAssembly *res = [lp bestMatchFor:a];
+ NSLog(@"%@", res);
+}
+
+
+
+- (void)doFactory {
+// id mock = [OCMockObject mockForProtocol:@protocol(TDMockAssember)];
+// TDParserFactory *factory = [TDParserFactory factory];
+// NSString *s = nil;
+// s = @"@start = foo|baz; foo (workOnFooAssembly:) = 'bar'; baz (workOnBazAssembly:) = 'bat'";
+// factory.assemblerSettingBehavior = TDParserFactoryAssemblerSettingBehaviorOnExplicit;
+// TDParser *lp = [factory parserFromGrammar:s assembler:mock];
+//
+//// [[mock expect] workOnBazAssembly:OCMOCK_ANY];
+//// NSString *s = @"bar bat";
+//// a = [TDTokenAssembly assemblyWithString:s];
+//// res = [lp completeMatchFor:a];
+//// TDEqualObjects(@"[bar, bat]bar/bat^", [res description]);
+//// [mock verify];
+}
+
+
+- (void)doParenStuff {
+ NSString *s = @"-(ab+5)";
+ TDTokenizer *t = [TDTokenizer tokenizerWithString:s];
+
+ TDToken *tok = [t nextToken];
+
+// TDTrue(tok.isSymbol);
+// TDEqualObjects(tok.stringValue, @"-");
+// TDEquals((CGFloat)0.0, tok.floatValue);
+
+ tok = [t nextToken];
+// TDTrue(tok.isSymbol);
+// TDEqualObjects(tok.stringValue, @"(");
+// TDEquals((CGFloat)0.0, tok.floatValue);
+}
+
+
+- (IBAction)run:(id)sender {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+// [self doPlistParser];
+// [self doHtmlSyntaxHighlighter];
+// [self doJsonParser];
+<<<<<<< .mine
+// [self doProf];
+=======
+ [self doRubyHashParser];
+// [self doProf];
+>>>>>>> .r657
+// [self doTokenize];
+// [self doGrammarParser];
+// [self doSimpleCSS];
+// [self doSimpleCSS2];
+// [self doParenStuff];
+
+ [self doJSONHighlighting];
+// [self doCSSHighlighting];
+// [self doHTMLHighlighting];
+
+// [self doMultiLineComment];
+
+ [self doFactory];
+
+ [pool drain];
+}
+
+@synthesize displayString;
+@end
24 debugapp/DebugApp-Info.plist
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.yourcompany.${PRODUCT_NAME:identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>NSMainNibFile</key>
+ <string>DebugAppMainMenu</string>
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+</dict>
+</plist>
23 debugapp/DebugAppDelegate.h
@@ -0,0 +1,23 @@
+// Copyright 2010 Todd Ditchendorf
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#import <Cocoa/Cocoa.h>
+
+@interface DebugAppDelegate : NSObject {
+ NSAttributedString *displayString;
+}
+- (IBAction)run:(id)sender;
+
+@property (retain) NSAttributedString *displayString;
+@end
516 debugapp/DebugAppDelegate.m
@@ -0,0 +1,516 @@
+// Copyright 2010 Todd Ditchendorf
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#import "DebugAppDelegate.h"
+#import <ParseKit/ParseKit.h>
+#import "PKParserFactory.h"
+#import "TDJsonParser.h"
+#import "TDFastJsonParser.h"
+#import "TDRegularParser.h"
+#import "EBNFParser.h"
+#import "TDPlistParser.h"
+#import "TDXmlNameState.h"
+#import "TDXmlToken.h"
+#import "TDHtmlSyntaxHighlighter.h"
+#import "JSONAssembler.h"
+#import "TDMiniCSSAssembler.h"
+#import "TDGenericAssembler.h"
+#import "NSArray+ParseKitAdditions.h"
+#import "TDSyntaxHighlighter.h"
+#import "TDJavaScriptParser.h"
+#import "TDNSPredicateEvaluator.h"
+#import <OCMock/OCMock.h>
+
+@protocol TDMockAssember
+- (void)didMatchFoo:(PKAssembly *)a;
+- (void)didMatchBaz:(PKAssembly *)a;
+- (void)didMatchStart:(PKAssembly *)a;
+- (void)didMatchStart:(PKAssembly *)a;
+- (void)didMatch_Start:(PKAssembly *)a;
+@end
+
+@interface PKParserFactory ()
+- (PKSequence *)parserFromExpression:(NSString *)s;
+@property (retain) PKCollectionParser *expressionParser;
+@end
+
+@implementation DebugAppDelegate
+
+- (void)dealloc {
+ self.displayString = nil;
+ [super dealloc];
+}
+
+
+- (void)doPlistParser {
+ NSString *s = nil;
+ PKTokenAssembly *a = nil;
+ PKAssembly *res = nil;
+ TDPlistParser *p = nil;
+
+ p = [[[TDPlistParser alloc] init] autorelease];
+
+ s = @"{"
+ @" 0 = 0;"
+ @" dictKey = {"
+ @" bar = foo;"
+ @" };"
+ @" 47 = 0;"
+ @" IntegerKey = 1;"
+ @" 47.7 = 0;"
+ @" <null> = <null>;"
+ @" ArrayKey = ("
+ @" \"one one\","
+ @" two,"
+ @" three"
+ @" );"
+ @" \"Null Key\" = <null>;"
+ @" emptyDictKey = {"
+ @" };"
+ @" StringKey = String;"
+ @" \"1.0\" = 1;"
+ @" YESKey = 1;"
+ @" \"NO Key\" = 0;"
+ @"}";
+
+ p.tokenizer.string = s;
+ a = [PKTokenAssembly assemblyWithTokenizer:p.tokenizer];
+ res = [p.dictParser completeMatchFor:a];
+
+ id attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSColor whiteColor], NSForegroundColorAttributeName,
+ [NSFont fontWithName:@"Monaco" size:12.], NSFontAttributeName,
+ nil];
+ id dict = [res pop];
+
+ p.tokenizer.string = [[[dict description] copy] autorelease];
+ a = [PKTokenAssembly assemblyWithTokenizer:p.tokenizer];
+ res = [p.dictParser bestMatchFor:a];
+ dict = [res pop];
+
+ p.tokenizer.string = nil; // prevent retain cycle leak
+ s = [[[dict description] copy] autorelease];
+
+ self.displayString = [[[NSAttributedString alloc] initWithString:s attributes:attrs] autorelease];
+}
+
+
+- (void)doHtmlSyntaxHighlighter {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"nyt" ofType:@"html"];
+ NSString *s = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+ //NSString *s = @"ア";
+
+ TDHtmlSyntaxHighlighter *highlighter = [[TDHtmlSyntaxHighlighter alloc] initWithAttributesForDarkBackground:YES];
+ NSAttributedString *o = [highlighter attributedStringForString:s];
+ //NSLog(@"o: %@", [o string]);
+ self.displayString = o;
+ [highlighter release];
+}
+
+
+- (void)doJsonParser {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"yahoo" ofType:@"json"];
+ NSString *s = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+
+ TDJsonParser *p = [[[TDJsonParser alloc] init] autorelease];
+// TDFastJsonParser *p = [[[TDFastJsonParser alloc] init] autorelease];
+
+ id result = nil;
+
+ @try {
+ result = [p parse:s];
+ } @catch (NSException *e) {
+ NSLog(@"\n\n\nexception:\n\n %@", [e reason]);
+ }
+ NSLog(@"result %@", result);
+}
+
+
+- (void)doEBNFParser {
+ //NSString *s = @"foo (bar|baz)*;";
+ NSString *s = @"$baz = bar; ($baz|foo)*;";
+ //NSString *s = @"foo;";
+ EBNFParser *p = [[[EBNFParser alloc] init] autorelease];
+
+ // PKAssembly *a = [p bestMatchFor:[PKTokenAssembly assemblyWithString:s]];
+ // NSLog(@"a: %@", a);
+ // NSLog(@"a.target: %@", a.target);
+
+ PKParser *res = [p parse:s];
+ // NSLog(@"res: %@", res);
+ // NSLog(@"res: %@", res.string);
+ // NSLog(@"res.subparsers: %@", res.subparsers);
+ // NSLog(@"res.subparsers 0: %@", [[res.subparsers objectAtIndex:0] string]);
+ // NSLog(@"res.subparsers 1: %@", [[res.subparsers objectAtIndex:1] string]);
+
+ s = @"bar foo bar foo";
+ PKAssembly *a = [res completeMatchFor:[PKTokenAssembly assemblyWithString:s]];
+ NSLog(@"\n\na: %@\n\n", a);
+}
+
+
+- (void)doGrammarParser {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"json" ofType:@"grammar"];
+ NSString *s = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+// s = @"@start = openCurly closeCurly; openCurly = '{'; closeCurly = '}';";
+// s = @"@start = start*; start = 'bar';";
+
+ PKParserFactory *factory = [PKParserFactory factory];
+
+ JSONAssembler *ass = [[[JSONAssembler alloc] init] autorelease];
+ PKParser *lp = [factory parserFromGrammar:s assembler:ass];
+
+ path = [[NSBundle bundleForClass:[self class]] pathForResource:@"yahoo" ofType:@"json"];
+ s = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+
+// s = @"bar bar";
+ PKTokenizer *t = [PKTokenizer tokenizerWithString:s];
+ t.whitespaceState.reportsWhitespaceTokens = YES;
+ PKTokenAssembly *a = [PKTokenAssembly assemblyWithTokenizer:t];
+ a.preservesWhitespaceTokens = YES;
+ //PKAssembly *res =
+ [lp completeMatchFor:a];
+
+ self.displayString = ass.displayString;
+}
+
+
+- (void)doJavaScriptGrammarParser {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"javascript" ofType:@"grammar"];
+ NSString *s = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+ PKParser *p = [[PKParserFactory factory] parserFromGrammar:s assembler:nil];
+ //PKParser *plus = [p parserNamed:@"plus"];
+
+ s = @";";
+ p.tokenizer.string = s;
+ //PKAssembly *a = [PKTokenAssembly assemblyWithTokenizer:p.tokenizer];
+ //PKAssembly *res = [p bestMatchFor:a];
+ // TDEqualObjects(@"[var, foo, =, 'bar', ;]var/foo/=/bar/;^", [res description]);
+}
+
+
+- (void)doProf {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"json_with_discards" ofType:@"grammar"];
+ NSString *s = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+ PKTokenizer *t = [PKTokenizer tokenizerWithString:s];
+ PKToken *eof = [PKToken EOFToken];
+ PKToken *tok = nil;
+ NSDate *start = [NSDate date];
+ while ((tok = [t nextToken]) != eof) ;
+ CGFloat ms4tok = -([start timeIntervalSinceNow]);
+
+ PKParserFactory *factory = [PKParserFactory factory];
+ TDJsonParser *p = nil;
+
+ p = [[[TDJsonParser alloc] initWithIntentToAssemble:NO] autorelease];
+
+ //JSONAssembler *assembler = [[[JSONAssembler alloc] init] autorelease];
+ start = [NSDate date];
+ PKParser *lp = [factory parserFromGrammar:s assembler:p];
+ CGFloat ms4grammar = -([start timeIntervalSinceNow]);
+
+ path = [[NSBundle bundleForClass:[self class]] pathForResource:@"yahoo" ofType:@"json"];
+ s = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+
+ start = [NSDate date];
+ PKAssembly *a = [PKTokenAssembly assemblyWithString:s];
+ a = [lp completeMatchFor:a];
+ CGFloat ms4json = -([start timeIntervalSinceNow]);
+
+ PKReleaseSubparserTree(lp);
+
+ p = [[TDJsonParser alloc] initWithIntentToAssemble:NO];
+ start = [NSDate date];
+ id res = [p parse:s];
+ CGFloat ms4json2 = -([start timeIntervalSinceNow]);
+ [p release];
+
+ p = [[TDJsonParser alloc] initWithIntentToAssemble:YES];
+ start = [NSDate date];
+ res = [p parse:s];
+ CGFloat ms4json3 = -([start timeIntervalSinceNow]);
+ [p release];
+
+ id fp = [[[TDFastJsonParser alloc] init] autorelease];
+ start = [NSDate date];
+ res = [fp parse:s];
+ CGFloat ms4json4 = -([start timeIntervalSinceNow]);
+
+ id attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSFont fontWithName:@"Monaco" size:14.], NSFontAttributeName,
+ [NSColor whiteColor], NSForegroundColorAttributeName,
+ nil];
+
+ s = [NSString stringWithFormat:@"tokenization: %f \n\ngrammar parse: %f sec\n\nlp json parse: %f sec\n\np json parse (not assembled): %f sec\n\np json parse (assembled): %f sec\n\nfast json parse (assembled): %f sec\n\n %f", ms4tok, ms4grammar, ms4json, ms4json2, ms4json3, ms4json4, (ms4json3/ms4json4)];
+ self.displayString = [[[NSMutableAttributedString alloc] initWithString:s attributes:attrs] autorelease];
+}
+
+
+- (void)doTokenize {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"yahoo" ofType:@"json"];
+ NSString *s = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+
+ PKTokenizer *t = [PKTokenizer tokenizerWithString:s];
+ PKToken *eof = [PKToken EOFToken];
+ PKToken *tok = nil;
+
+ NSDate *start = [NSDate date];
+ while ((tok = [t nextToken]) != eof) ;
+ CGFloat secs = -([start timeIntervalSinceNow]);
+
+ id attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSFont fontWithName:@"Monaco" size:14.], NSFontAttributeName,
+ [NSColor whiteColor], NSForegroundColorAttributeName,
+ nil];
+
+ s = [NSString stringWithFormat:@"tokenize: %f", secs];
+ self.displayString = [[[NSMutableAttributedString alloc] initWithString:s attributes:attrs] autorelease];
+}
+
+
+- (void)doSimpleCSS {
+ NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"mini_css" ofType:@"grammar"];
+ NSString *s = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+ PKParserFactory *factory = [PKParserFactory factory];
+
+ TDMiniCSSAssembler *assembler = [[[TDMiniCSSAssembler alloc] init] autorelease];
+ PKParser *lp = [factory parserFromGrammar:s assembler:assembler];
+ s = @"foo { color:rgb(111.0, 99.0, 255.0); }";
+ PKAssembly *a = [PKTokenAssembly assemblyWithString:s];
+ a = [lp completeMatchFor:a];