meta_compile 0.0.11 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -34,22 +34,22 @@ task :bootstrap do
34
34
  puts "1. Build bootstrap compiler"
35
35
  pexec "gcc -o bootstrapped_c bootstrap.c"
36
36
  puts "2. Use the c meta compiler to compile the meta_to_ruby_minimal.meta description"
37
- pexec "./bootstrapped_c meta_to_ruby_minimal.meta compile_to_ruby.c"
37
+ pexec "./bootstrapped_c ../syntaxes/meta_to_ruby_minimal.meta compile_to_ruby.c"
38
38
  puts "3. Build the stepping stone ruby compiler we created from the meta description"
39
39
  pexec "gcc -o meta_r compile_to_ruby.c"
40
40
  puts "4. Now use the generated stepping stone compiler to generate a ruby compiler for the ruby meta syntax"
41
- pexec "./meta_r meta_to_ruby_minimal.meta meta_ruby_compiler_from_c.rb"
41
+ pexec "./meta_r ../syntaxes/meta_to_ruby_minimal.meta meta_ruby_compiler_from_c.rb"
42
42
  puts "5. Run the generated ruby meta compiler to a ruby version"
43
- pexec "ruby -I. meta_ruby_compiler_from_c.rb meta_to_ruby_minimal.meta > meta_ruby_compiler.rb"
43
+ pexec "ruby -I. meta_ruby_compiler_from_c.rb ../syntaxes/meta_to_ruby_minimal.meta > meta_ruby_compiler.rb"
44
44
  puts "6. Ruby version differ since it has single instead of double quotes around strings"
45
45
  #pexec "diff meta_ruby_compiler_from_c.rb meta_ruby_compiler.rb"
46
46
  puts "7. But we can generate again and ensure it is a meta compiler"
47
- pexec "ruby -I. meta_ruby_compiler.rb meta_to_ruby_minimal.meta > meta_ruby_compiler2.rb"
47
+ pexec "ruby -I. meta_ruby_compiler.rb ../syntaxes/meta_to_ruby_minimal.meta > meta_ruby_compiler2.rb"
48
48
  pexec "diff meta_ruby_compiler.rb meta_ruby_compiler2.rb"
49
49
  puts "8. One more round just to show off... :)"
50
- pexec "ruby -I. meta_ruby_compiler2.rb meta_to_ruby_minimal.meta > meta_ruby_compiler3.rb"
50
+ pexec "ruby -I. meta_ruby_compiler2.rb ../syntaxes/meta_to_ruby_minimal.meta > meta_ruby_compiler3.rb"
51
51
  pexec "diff meta_ruby_compiler.rb meta_ruby_compiler3.rb"
52
- puts "Summary:\nCreated a #{loc('meta_ruby_compiler.rb')} line meta-II meta compiler from a #{loc('meta_to_ruby_minimal.meta')} line meta-II spec\n\n"
52
+ puts "Summary:\nCreated a #{loc('meta_ruby_compiler.rb')} line meta-II meta compiler from a #{loc('../syntaxes/meta_to_ruby_minimal.meta')} line meta-II spec\n\n"
53
53
  end
54
54
  end
55
55
 
@@ -89,13 +89,13 @@ end
89
89
 
90
90
  desc "Ensure it is a meta compiler"
91
91
  task :ensure_meta => [:make_bin] do
92
- ensure_is_meta "bin/meta_compile", "bootstrap/meta_to_ruby_minimal.meta"
92
+ ensure_is_meta "bin/meta_compile", "syntaxes/meta_to_ruby_minimal.meta"
93
93
  end
94
94
 
95
95
  desc "Update line counts in README.template.md to make README.md"
96
96
  task :update_readme => [:bootstrap] do
97
97
  rmeta2_compiler_loc = loc('bootstrap/meta_ruby_compiler.rb')
98
- rmeta2_spec_loc = loc('bootstrap/meta_to_ruby_minimal.meta')
98
+ rmeta2_spec_loc = loc('syntaxes/meta_to_ruby_minimal.meta')
99
99
  readme = File.read("README.template.md").gsub("%%RMetaII_SPEC_LOC%%", rmeta2_spec_loc.to_s)
100
100
  readme = readme.gsub("%%RMetaII_COMPILER_LOC%%", rmeta2_compiler_loc.to_s)
101
101
  File.open("README.md", "w") {|f| f.puts readme}
data/meta_compile.gemspec CHANGED
@@ -1,12 +1,12 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'meta_compile'
3
- s.version = '0.0.11'
3
+ s.version = '0.0.12'
4
4
  s.date = '2012-11-25'
5
5
  s.summary = "meta compiler framework"
6
6
  s.description = "A meta compilation framework à la Meta-II by Val Schorre"
7
7
  s.authors = ["Robert Feldt"]
8
8
  s.email = 'robert.feldt@gmail.com'
9
- s.files = ["Rakefile", "README.md", "meta_compile.gemspec"] + Dir.glob("bin/*") + Dir.glob("bootstrap/*")
9
+ s.files = ["Rakefile", "README.md", "meta_compile.gemspec"] + Dir.glob("bin/*") + Dir.glob("bootstrap/*") + Dir.glob("syntaxes/*")
10
10
  s.executables << 'meta_compile'
11
11
  s.homepage =
12
12
  'http://rubygems.org/gems/meta_compile'
@@ -0,0 +1 @@
1
+ a := b
@@ -0,0 +1,16 @@
1
+ .syntax aexp
2
+
3
+ aexp = as *as;
4
+ as = .id <'address' $> ':=' ex1 <'store'> ';';
5
+ ex1 = ex2 *( '+' ex2 <'add'>
6
+ | '-' ex2 <'sub'>);
7
+ ex2 = ex3 *( '*' ex3 <'mpy'>
8
+ | '/' ex3 <'div'>);
9
+ ex3 = ex4 *('^' ex3 <'exp'>);
10
+ ex4 = '+' ex5
11
+ | '-' ex5 <'minus'>
12
+ | ex5;
13
+ ex5 = .id <'load' $>
14
+ | '(' ex1 ')';
15
+
16
+ .end
@@ -0,0 +1,59 @@
1
+ .syntax program
2
+
3
+ outarg = '$' <'@out.print @token'>
4
+ | .string <'@out.print ' $>;
5
+
6
+ out = '<' *outarg '>' <'@out.print "\n"'>;
7
+
8
+ exp3 = .id <'compile_' $>
9
+
10
+ | .string <'@in.scan /\s*/'>
11
+ <'s=' $>
12
+ <'l=s.length'>
13
+ <'@flag = (@in.peek(l) == s) ? (@token=s; @in.pos += l) : nil'>
14
+
15
+ | '.id' <'@in.scan /\s*/; @flag = @token = @in.scan /[A-Za-z]+[A-Za-z0-9_]+/'>
16
+
17
+ | '.string' <'@in.scan /\s*/; @flag = @token = @in.scan /\047[^\047]*\047/'>
18
+
19
+ | '(' exp1 ')'
20
+
21
+ | '.e' <'@flag = true'>
22
+
23
+ | '*' <'begin'> exp3 <'end while @flag'> <'@flag = true'>;
24
+
25
+ exp2 = ( exp3 <'if @flag'> | out <'if true'> )
26
+ *( exp3 <'raise("error at: " + @in.rest.split("\n")[0]) if !@flag'>
27
+ | out ) <'end'>;
28
+
29
+ exp1 = <'begin'> exp2
30
+ *( '|' <'break if @flag'> exp2 )
31
+ <'end while false'>;
32
+
33
+ rule = .id <'def compile_' $> '=' exp1 ';' <'end'>;
34
+
35
+ program = '.syntax' .id
36
+ <'#!/usr/bin/env ruby'>
37
+ <'require "strscan"'>
38
+
39
+ <'class C_' $>
40
+ <' $c = self # so we can access it below if this is run from command line'>
41
+ <' def compile(str, out)'>
42
+ <' @in, @out = StringScanner.new(str), out'>
43
+ <' compile_' $>
44
+ <' end'>
45
+
46
+ *rule '.end'
47
+
48
+ <'end # end of class'>
49
+
50
+ <'if __FILE__ == $0'>
51
+ <' if ARGV.length != 1'>
52
+ <' puts("usage: " + $0 + " <input>")'>
53
+ <' exit -1'>
54
+ <' else'>
55
+ <' $c.new.compile(File.read(ARGV[0]), STDOUT)'>
56
+ <' end'>
57
+ <'end'>;
58
+
59
+ .end
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meta_compile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -25,10 +25,13 @@ files:
25
25
  - bootstrap/bootstrap.c
26
26
  - bootstrap/meta_ruby_compiler.rb
27
27
  - bootstrap/meta_to_c.meta
28
- - bootstrap/meta_to_ruby_minimal.meta
29
- - bootstrap/meta_to_ruby_minimal_single_flag.meta
30
28
  - bootstrap/original_support.h
31
29
  - bootstrap/support.h
30
+ - syntaxes/aexp.input1
31
+ - syntaxes/aexp.meta
32
+ - syntaxes/meta_to_ruby.meta
33
+ - syntaxes/meta_to_ruby_minimal.meta
34
+ - syntaxes/meta_to_ruby_minimal_single_flag.meta
32
35
  homepage: http://rubygems.org/gems/meta_compile
33
36
  licenses: []
34
37
  post_install_message: