mirror of
https://github.com/samsonjs/compiler.git
synced 2026-04-27 14:57:45 +00:00
# comments till the end of the current line
This commit is contained in:
parent
509c7a88ce
commit
d2e7c987d8
1 changed files with 13 additions and 1 deletions
12
compiler.rb
12
compiler.rb
|
|
@ -69,6 +69,9 @@ class Compiler
|
||||||
elsif newline?(@look)
|
elsif newline?(@look)
|
||||||
skip_any_whitespace
|
skip_any_whitespace
|
||||||
scan
|
scan
|
||||||
|
elsif comment_char?(@look)
|
||||||
|
skip_comment
|
||||||
|
scan
|
||||||
else
|
else
|
||||||
# XXX default to single char op... should probably raise.
|
# XXX default to single char op... should probably raise.
|
||||||
@token = :op
|
@token = :op
|
||||||
|
|
@ -737,6 +740,10 @@ class Compiler
|
||||||
char == "\n" || char == "\r"
|
char == "\n" || char == "\r"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def comment_char?(char)
|
||||||
|
char == '#'
|
||||||
|
end
|
||||||
|
|
||||||
def any_whitespace?(char)
|
def any_whitespace?(char)
|
||||||
whitespace?(char) || newline?(char)
|
whitespace?(char) || newline?(char)
|
||||||
end
|
end
|
||||||
|
|
@ -817,6 +824,11 @@ class Compiler
|
||||||
get_char while any_whitespace?(@look)
|
get_char while any_whitespace?(@look)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def skip_comment
|
||||||
|
get_char until newline?(@look)
|
||||||
|
skip_any_whitespace
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def indent
|
def indent
|
||||||
real_indent = if @value == 'else' || @value == 'end'
|
real_indent = if @value == 'else' || @value == 'end'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue