Permalink
Browse files

Fresh new bootstrap process. Moved stable compiler to boot/compiler.

  • Loading branch information...
1 parent 3a50a1e commit 9b8199dd44ccb16114824930e54806ab95c5f790 @vic vic committed Nov 16, 2010
Showing with 469 additions and 467 deletions.
  1. +115 −33 Rakefile
  2. +2 −3 boot/compile.fy
  3. 0 boot/{.compiled → compiler}/argv.fyc
  4. 0 boot/{.compiled → compiler}/array.fyc
  5. 0 boot/{.compiled → compiler}/block.fyc
  6. 0 boot/{.compiled → compiler}/boot.fyc
  7. 0 boot/{.compiled → compiler}/class.fyc
  8. +13 −65 boot/{.compiled → compiler}/compile.fyc
  9. 0 boot/{.compiled → compiler}/compiler.fyc
  10. 0 boot/{.compiled → compiler}/compiler/ast.fyc
  11. 0 boot/{.compiled → compiler}/compiler/ast/assign.fyc
  12. 0 boot/{.compiled → compiler}/compiler/ast/block.fyc
  13. 0 boot/{.compiled → compiler}/compiler/ast/class_def.fyc
  14. 0 boot/{.compiled → compiler}/compiler/ast/expression_list.fyc
  15. 0 boot/{.compiled → compiler}/compiler/ast/identifier.fyc
  16. 0 boot/{.compiled → compiler}/compiler/ast/literals.fyc
  17. 0 boot/{.compiled → compiler}/compiler/ast/match.fyc
  18. 0 boot/{.compiled → compiler}/compiler/ast/message_send.fyc
  19. 0 boot/{.compiled → compiler}/compiler/ast/method_def.fyc
  20. 0 boot/{.compiled → compiler}/compiler/ast/node.fyc
  21. 0 boot/{.compiled → compiler}/compiler/ast/range.fyc
  22. 0 boot/{.compiled → compiler}/compiler/ast/require.fyc
  23. 0 boot/{.compiled → compiler}/compiler/ast/return.fyc
  24. 0 boot/{.compiled → compiler}/compiler/ast/script.fyc
  25. 0 boot/{.compiled → compiler}/compiler/ast/singleton_method_def.fyc
  26. 0 boot/{.compiled → compiler}/compiler/ast/super.fyc
  27. 0 boot/{.compiled → compiler}/compiler/ast/try_catch.fyc
  28. 0 boot/{.compiled → compiler}/compiler/ast/tuple_literal.fyc
  29. +132 −112 boot/{.compiled → compiler}/compiler/command.fyc
  30. 0 boot/{.compiled → compiler}/compiler/compiler.fyc
  31. 0 boot/{.compiled → compiler}/compiler/stages.fyc
  32. 0 boot/{.compiled → compiler}/directory.fyc
  33. 0 boot/{.compiled → compiler}/documentation.fyc
  34. 0 boot/{.compiled → compiler}/enumerable.fyc
  35. 0 boot/{.compiled → compiler}/fancy_spec.fyc
  36. 0 boot/{.compiled → compiler}/fdoc.fyc
  37. 0 boot/{.compiled → compiler}/fdoc_hook.fyc
  38. 0 boot/{.compiled → compiler}/file.fyc
  39. 0 boot/{.compiled → compiler}/hash.fyc
  40. 0 boot/{.compiled → compiler}/main.fyc
  41. 0 boot/{.compiled → compiler}/method.fyc
  42. 0 boot/{.compiled → compiler}/nil_class.fyc
  43. 0 boot/{.compiled → compiler}/number.fyc
  44. 0 boot/{.compiled → compiler}/object.fyc
  45. 0 boot/{.compiled → compiler}/package.fyc
  46. 0 boot/{.compiled → compiler}/package/dependency.fyc
  47. 0 boot/{.compiled → compiler}/package/installer.fyc
  48. 0 boot/{.compiled → compiler}/package/specification.fyc
  49. 0 boot/{.compiled → compiler}/package/uninstaller.fyc
  50. +1 −1 boot/{.compiled → compiler}/parser.fyc
  51. 0 boot/{.compiled → compiler}/parser/methods.fyc
  52. 0 boot/{.compiled → compiler}/rbx.fyc
  53. 0 boot/{.compiled → compiler}/rbx/array.fyc
  54. 0 boot/{.compiled → compiler}/rbx/bignum.fyc
  55. 0 boot/{.compiled → compiler}/rbx/block.fyc
  56. 0 boot/{.compiled → compiler}/rbx/class.fyc
  57. 0 boot/{.compiled → compiler}/rbx/code_loader.fyc
  58. 0 boot/{.compiled → compiler}/rbx/console.fyc
  59. 0 boot/{.compiled → compiler}/rbx/directory.fyc
  60. 0 boot/{.compiled → compiler}/rbx/documentation.fyc
  61. 0 boot/{.compiled → compiler}/rbx/environment_variables.fyc
  62. 0 boot/{.compiled → compiler}/rbx/exception.fyc
  63. 0 boot/{.compiled → compiler}/rbx/false_class.fyc
  64. 0 boot/{.compiled → compiler}/rbx/file.fyc
  65. 0 boot/{.compiled → compiler}/rbx/fixnum.fyc
  66. 0 boot/{.compiled → compiler}/rbx/float.fyc
  67. 0 boot/{.compiled → compiler}/rbx/hash.fyc
  68. 0 boot/{.compiled → compiler}/rbx/io.fyc
  69. 0 boot/{.compiled → compiler}/rbx/method.fyc
  70. 0 boot/{.compiled → compiler}/rbx/name_error.fyc
  71. 0 boot/{.compiled → compiler}/rbx/no_method_error.fyc
  72. 0 boot/{.compiled → compiler}/rbx/object.fyc
  73. 0 boot/{.compiled → compiler}/rbx/range.fyc
  74. 0 boot/{.compiled → compiler}/rbx/regexp.fyc
  75. 0 boot/{.compiled → compiler}/rbx/string.fyc
  76. 0 boot/{.compiled → compiler}/rbx/symbol.fyc
  77. 0 boot/{.compiled → compiler}/rbx/system.fyc
  78. 0 boot/{.compiled → compiler}/rbx/tcp_server.fyc
  79. 0 boot/{.compiled → compiler}/rbx/tcp_socket.fyc
  80. 0 boot/{.compiled → compiler}/rbx/thread.fyc
  81. 0 boot/{.compiled → compiler}/rbx/tuple.fyc
  82. 0 boot/{.compiled → compiler}/set.fyc
  83. 0 boot/{.compiled → compiler}/stack.fyc
  84. 0 boot/{.compiled → compiler}/string.fyc
  85. 0 boot/{.compiled → compiler}/symbol.fyc
  86. 0 boot/{.compiled → compiler}/true_class.fyc
  87. 0 boot/{.compiled → compiler}/version.fyc
  88. +8 −4 boot/load.rb
  89. +0 −55 boot/parser/Rakefile
  90. +0 −3 boot/parser/extconf.rb
  91. +5 −1 lib/compiler/command.fy
  92. +1 −1 lib/parser.fy
  93. 0 {boot/parser → lib/parser/ext}/README
  94. +1 −1 {boot/parser → lib/parser/ext}/ext.c
  95. 0 {boot/parser → lib/parser/ext}/ext.h
  96. +3 −0 lib/parser/ext/extconf.rb
  97. +63 −63 {boot/parser → lib/parser/ext}/lexer.c
  98. +1 −1 {boot/parser → lib/parser/ext}/lexer.h
  99. 0 {boot/parser → lib/parser/ext}/lexer.lex
  100. +122 −122 {boot/parser → lib/parser/ext}/parser.c
  101. +2 −2 {boot/parser → lib/parser/ext}/parser.h
  102. 0 {boot/parser → lib/parser/ext}/parser.y
View
148 Rakefile
@@ -1,49 +1,131 @@
-# This will eventually replace our current Makefile, once we can
-# remove all the old c++ code.
+require 'rbconfig'
-load File.dirname(__FILE__) + "/boot/parser/Rakefile"
-
-def _(f)
- File.expand_path(f, File.dirname(__FILE__))
+def _(f, base = File.dirname(__FILE__))
+ File.expand_path(f, base)
end
-desc "Deletes all .rbc and .fyc files."
-task :clean do
- rm_f Dir.glob(_ "**/*.{rbc,fyc}")
- rm_rf _(".compiled")
-end
-desc "Compile the parser extension"
-task :parser => "parser_ext:compile"
+dl_ext = RbConfig::CONFIG['DLEXT']
+ext_dir = _("lib/parser/ext")
+parser_e = _("fancy_parser.#{dl_ext}", ext_dir)
+
+namespace :parser do
+
+ lexer_lex = _("lexer.lex", ext_dir)
+ lexer_c = _("lexer.c", ext_dir)
+ parser_y = _("parser.y", ext_dir)
+ parser_c = _("parser.c", ext_dir)
+ extconf = _("extconf.rb", ext_dir)
+ makefile = _("Makefile", ext_dir)
+
+ file lexer_c => file(lexer_lex) do
+ Dir.chdir(ext_dir) do
+ sh 'flex', '--outfile', lexer_c, '--header-file=lexer.h', lexer_lex
+ end
+ end
+
+ file parser_c => file(parser_y) do
+ Dir.chdir(ext_dir) { sh 'bison', '--output', parser_c, '-d', '-v', parser_y }
+ end
+
+ file makefile => file(extconf) do
+ Dir.chdir(ext_dir) { sh 'rbx', extconf }
+ end
+
+ desc "Generate parser source from flex/bison"
+ task :generate => [parser_c, lexer_c, makefile]
-def compile_fancy(compiler_dir, output_dir)
- _("#{compiler_dir}/parser").tap do |parser_dir|
- mkdir_p parser_dir, :verbose => false
- cp Dir.glob(_ "boot/parser/fancy_parser_ext.*"), parser_dir
+ file parser_e => file(makefile) do
+ sh 'make', '-C', ext_dir
end
- # run each directory seperately (this fixes the crash i get)
- ["lib/*.fy", "lib/rbx/*.fy", "lib/package/*.fy",
- "lib/parser/*.fy", "lib/compiler/*.fy", "lib/compiler/ast/*.fy"].each do |path|
- lib_fy = Dir.glob(_ path).sort
- lib_fy.unshift "--batch" if RakeFileUtils.verbose_flag
- sh 'rbx', _("boot/load.rb"), _("#{compiler_dir}/boot.fyc"), _("#{compiler_dir}/compile.fyc"), '--source-path', _("lib"), '--output-path', _(output_dir), *lib_fy
+ desc "Compile the parser extension"
+ task :compile => file(parser_e)
+
+ desc "Removed generated parser sources"
+ task :remove do
+ rm_f [_("parser.h", ext_dir), _("lexer.h", ext_dir)], :verbose => false
+ rm_f [makefile, parser_c, lexer_c], :verbose => false
+ end
+
+ desc "Clean compiled files."
+ task :clean do
+ rm_f Dir.glob(_("*.{o,so,rbc,log,output}", ext_dir)), :verbose => false
end
- boot_fy = Dir.glob(_ "boot/**/*.fy").sort
- boot_fy.unshift "--batch" if RakeFileUtils.verbose_flag
- sh 'rbx', _("boot/load.rb"), _("#{compiler_dir}/boot.fyc"), _("#{compiler_dir}/compile.fyc"), '--source-path', _("boot"), '--output-path', _(output_dir), *boot_fy
end
-desc "Compile fancy into boot/.compiled dir. (Compiles using current compiler from .compiled)"
-task :bootstrap => :parser do
- compile_fancy ".compiled", "boot/.compiled"
+
+namespace :compiler do
+
+ load_rb = _("boot/load.rb")
+
+ desc "Compile fancy using the stable compiler (from boot/compiler)."
+ task :compile do
+ cmd = ['rbx', load_rb]
+ cmd << _("boot/compiler/boot.fyc")
+ cmd << _("boot/compiler/compiler.fyc")
+ cmd << _("boot/compiler/compiler/command.fyc")
+ cmd << _("boot/compiler/compile.fyc")
+ cmd << "--"
+ cmd << "--batch" if RakeFileUtils.verbose_flag == true
+
+ source_dirs = ["lib", "lib/parser", "lib/compiler", "lib/compiler/ast",
+ "lib/rbx", "lib/package", "boot"]
+
+ source_dirs.each do |dir|
+ sources = Dir.glob(_("*.fy", dir))
+ sh *(cmd + sources)
+ end
+ end
+
+ desc "Compile fancy using lib/ compiler into boot/compiler/"
+ task :wootstrap do
+ output = _("boot/.wootstrap")
+
+ cmd = ['rbx', load_rb]
+ cmd << _("lib/boot.fyc")
+ cmd << _("lib/compiler.fyc")
+ cmd << _("lib/compiler/command.fyc")
+ cmd << _("boot/compile.fyc")
+ cmd << "--"
+ cmd << "--batch" if RakeFileUtils.verbose_flag == true
+ cmd << "--output-path" << output
+
+ source_dirs = ["lib", "lib/parser", "lib/compiler", "lib/compiler/ast",
+ "lib/rbx", "lib/package", "boot"]
+
+ source_dirs.each do |dir|
+ sources = Dir.glob(_(dir + "/*.fy"))
+ src_path = ["--source-path", _(dir.split("/").first)]
+ sh *(cmd + src_path + sources)
+ end
+
+ mkdir_p _("parser/ext", output)
+ cp parser_e, _("parser/ext", output)
+
+ rm_rf _("boot/compiler")
+ mv _("boot/.wootstrap"), _("boot/compiler")
+ end
+
+ task :bootstrap do
+ task(:compile).invoke
+ task(:wootstrap).invoke
+ end
+
end
-desc "Compile fancy into .compiled dir. (Compiles using staged compiler from boot/.compiled)"
-task :compile => :parser do
- compile_fancy "boot/.compiled", ".compiled"
+desc "Deletes all .rbc and .fyc files."
+task :clean_compiled do
+ compiled = Dir.glob(_ "**/*.{rbc,fyc}", _("{bin,lib,examples,tests,spec}"))
+ rm_f compiled, :verbose => false
end
-task :default => :compile
+desc "Clean compiled files."
+task :clean => ["parser:clean", :clean_compiled]
+
+task :compile => ["parser:compile", "compiler:compile"]
+task :bootstrap => [:clean, "compiler:bootstrap"]
+
+task :default => :compile
View
@@ -1,4 +1,3 @@
-require: "compiler"
-require: "compiler/command"
-
+# Bootstrap Usage:
+# rbx boot/load.rb boot/compiler/boot.fyc boot/compiler/compiler.fyc boot/compiler/command.fyc boot/compile.fyc -- <FILES_TO_COMPILE>
Fancy Compiler Command run: ARGV
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -9,59 +9,25 @@ x
10
__script__
i
-50
-5
-7
-0
-64
-47
+16
45
+0
1
+43
2
43
3
-7
-0
-64
-49
-4
-1
-15
-5
-7
-5
-64
-47
45
-1
-6
-43
-3
-7
-5
-64
-49
4
-1
-15
-45
-1
-7
-43
-8
-43
-9
-45
-10
-11
+5
49
-12
+6
1
15
2
11
I
-6
+2
I
0
I
@@ -70,26 +36,12 @@ I
0
n
p
-13
-s
-8
-compiler
+7
x
5
Fancy
n
x
-10
-CodeLoader
-x
-8
-require:
-s
-16
-compiler/command
-n
-n
-x
8
Compiler
x
@@ -103,25 +55,21 @@ x
4
run:
p
-9
+7
I
0
I
-1
+4
I
-12
+0
I
-2
+3
I
-22
+a
I
4
I
-2c
-I
-5
-I
-32
+10
x
34
/more/vic/hk/fancy/boot/compile.fy
File renamed without changes.
File renamed without changes.
Oops, something went wrong.

0 comments on commit 9b8199d

Please sign in to comment.