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
| object_with_size = derive_from(basic_object) | |
| send(object_with_size, :add_method, :size) do |this, params| | |
| this[:size] | |
| 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
| send(object_with_size, :size) | |
| # => 1 |
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
| blank_object = { | |
| :parent => nil, | |
| :slots => {}, | |
| :size => 0 | |
| } | |
| def send(receiver, message, *params, &block) | |
| method_owner = receiver | |
| while(method_owner[:slots][:lookup].nil?) | |
| puts "ERR: lookup failed for ':lookup' on object:\n#{receiver.inspect}" and break if(method_owner[:parent].nil?) |
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
| # lexer.rl | |
| %%{ | |
| machine test_lexer; | |
| }%% | |
| %% write data; |
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
| %%{ | |
| machine test_lexer; | |
| <scanner_name> := |* | |
| <token_description> => {<action>}; | |
| <token_description> => {<action>}; | |
| *|; | |
| }%% |
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
| %%{ | |
| machine test_lexer; | |
| integer = <token_description>; | |
| float = <token_description>; | |
| main := |* | |
| integer => {<action>}; | |
| float => {<action>}; |
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
| ragel -R lexer.rl |
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
| def run_lexer(data) | |
| data = data.unpack("c*") if(data.is_a?(String)) | |
| eof = data.length | |
| token_array = [] | |
| %% write init; | |
| %% write exec; | |
| puts token_array.inspect | |
| 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
| %%{ | |
| machine test_lexer; | |
| integer = ('+'|'-')?[0-9]+; | |
| }%% |
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
| %%{ | |
| machine test_lexer; | |
| integer = ('+'|'-')?[0-9]+; | |
| main := |* | |
| integer; | |
| *|; | |