lib/parser/methods.fy in fancy-0.5.0 vs lib/parser/methods.fy in fancy-0.6.0
- old
+ new
@@ -11,13 +11,17 @@
def self parse_code: code file: filename line: line (1) {
new: filename line: line . parse_string: code . script
}
+ def self ast: line parse_error: text {
+ ParseError new: line message: text filename: (Thread current['__fancy__parser__filename__]) . raise!
+ }
+
read_write_slots: ['filename, 'line, 'script]
- def initialize: @filename line: @line { }
+ def initialize: @filename line: @line { Thread current['__fancy__parser__filename__]: @filename }
def body: body {
@script = AST Script new: @line file: @filename body: body
}
@@ -67,19 +71,19 @@
match str {
# OK, I know this is ugly. But it works for now, so let's just go with it.
# TODO: Clean this up or make it simpler...
# this case handles string interpolation
- case /(.*)#{(.*)}(.*)/ -> |matches|
+ case /(.*)#{(.*)}(.*)/m -> |matches|
prefix = matches[1]
interpol_str = matches[2]
suffix = matches[3]
prefix_str = ast: line string: (" " + prefix + " ") # hack, pre- & append " " since it gets removed
suffix_str = ast: line string: (" " + suffix + " ")
interpol_ast = AST StringInterpolation new: line code: interpol_str
# create messagesend to concatenate:
- concat_ident = ast: line identifier: "++"
+ concat_ident = ast: line identifier: "<<"
interpol_send = AST MessageSend new: line message: concat_ident to: prefix_str args: (AST MessageArgs new: line args: [interpol_ast])
# don't concatenate suffix if it's empty..
unless: (suffix == "") do: {
interpol_send = AST MessageSend new: line message: concat_ident to: interpol_send args: (AST MessageArgs new: line args: [suffix_str])