Created
April 7, 2011 19:22
-
-
Save NilsHaldenwang/908494 to your computer and use it in GitHub Desktop.
This works,...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| > mirahc macro_test.mirah | |
| Parsing... | |
| macro_test.mirah | |
| NativeException: jmeta.SyntaxError: expected f_arglist before '=(val:String)' (at line: 12, char: 17) | |
| parse_ruby at /home/nils/.rvm/gems/jruby-1.6.0/gems/mirah-0.0.7-java/lib/mirah/transform.rb:327 | |
| parse at /home/nils/.rvm/gems/jruby-1.6.0/gems/mirah-0.0.7-java/lib/mirah/impl.rb:120 | |
| generate at /home/nils/.rvm/gems/jruby-1.6.0/gems/mirah-0.0.7-java/lib/mirah/impl.rb:84 | |
| each at org/jruby/RubyArray.java:1572 | |
| generate at /home/nils/.rvm/gems/jruby-1.6.0/gems/mirah-0.0.7-java/lib/mirah/impl.rb:75 | |
| compile at /home/nils/.rvm/gems/jruby-1.6.0/gems/mirah-0.0.7-java/lib/mirah/impl.rb:54 | |
| compile at /home/nils/.rvm/gems/jruby-1.6.0/gems/mirah-0.0.7-java/lib/mirah.rb:45 | |
| (root) at /home/nils/.rvm/gems/jruby-1.6.0/gems/mirah-0.0.7-java/bin/mirahc:25 | |
| load at org/jruby/RubyKernel.java:1062 | |
| (root) at /home/nils/.rvm/gems/jruby-1.6.0/bin/mirahc:19 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MacroTest | |
| macro def attr_reader(attr) | |
| quote { | |
| def `attr` | |
| @`attr` | |
| end | |
| } | |
| end | |
| attr_reader :name | |
| def name=(val:String) | |
| @name = val | |
| end | |
| def self.main(args:String[]):void | |
| m = MacroTest.new | |
| m.name = "Nils" | |
| puts "My name is #{m.name}." | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MacroTest | |
| macro def attr_reader(attr) | |
| quote { | |
| def `attr` | |
| @`attr` | |
| end | |
| } | |
| end | |
| macro def attr_writer(attr) | |
| quote { | |
| def `attr`=(val:String) | |
| @`attr` = val | |
| end | |
| } | |
| end | |
| attr_reader :name | |
| attr_writer :name | |
| def self.main(args:String[]):void | |
| m = MacroTest.new | |
| m.name = "Nils" | |
| puts "My name is #{m.name}." | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment