From d2e7c987d85f0a168f235d44ebf96d7e13617819 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Sun, 14 Feb 2010 18:59:05 -0800 Subject: [PATCH] # comments till the end of the current line --- compiler.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/compiler.rb b/compiler.rb index d72ef99..c86836d 100644 --- a/compiler.rb +++ b/compiler.rb @@ -69,6 +69,9 @@ class Compiler elsif newline?(@look) skip_any_whitespace scan + elsif comment_char?(@look) + skip_comment + scan else # XXX default to single char op... should probably raise. @token = :op @@ -737,6 +740,10 @@ class Compiler char == "\n" || char == "\r" end + def comment_char?(char) + char == '#' + end + def any_whitespace?(char) whitespace?(char) || newline?(char) end @@ -817,7 +824,12 @@ class Compiler get_char while any_whitespace?(@look) end - + def skip_comment + get_char until newline?(@look) + skip_any_whitespace + end + + def indent real_indent = if @value == 'else' || @value == 'end' @indent - 1