Permalink
Browse files

# comments till the end of the current line

  • Loading branch information...
1 parent 509c7a8 commit d2e7c987d85f0a168f235d44ebf96d7e13617819 @samsonjs committed Feb 15, 2010
Showing with 13 additions and 1 deletion.
  1. +13 −1 compiler.rb
View
14 compiler.rb
@@ -69,6 +69,9 @@ def scan
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 @@ def newline?(char)
char == "\n" || char == "\r"
end
+ def comment_char?(char)
+ char == '#'
+ end
+
def any_whitespace?(char)
whitespace?(char) || newline?(char)
end
@@ -817,7 +824,12 @@ def skip_any_whitespace
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

0 comments on commit d2e7c98

Please sign in to comment.