From 6ebd62020a8a83c380e4738a536a24d36cb8713b Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sat, 21 Sep 2019 01:23:53 +0300 Subject: [PATCH] double quote --- compiler/scanner.v | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/compiler/scanner.v b/compiler/scanner.v index 98ac6d70bf..f446bea969 100644 --- a/compiler/scanner.v +++ b/compiler/scanner.v @@ -4,8 +4,15 @@ module main -import os -import strings +import ( + os + strings +) + +const ( + single_quote = `\'` + double_quote = `"` +) struct Scanner { mut: @@ -71,10 +78,10 @@ fn (s ScannerPos) str() string { return 'ScannerPos{ ${s.pos:5d} , ${s.line_nr:5d} }' } fn (s &Scanner) get_scanner_pos() ScannerPos { - return ScannerPos{ pos: s.pos line_nr: s.line_nr } + return ScannerPos{ pos: s.pos line_nr: s.line_nr } } fn (s mut Scanner) goto_scanner_position(scp ScannerPos) { - s.pos = scp.pos + s.pos = scp.pos s.line_nr = scp.line_nr } @@ -352,11 +359,10 @@ fn (s mut Scanner) scan() ScanRes { return scan_res(.mod, '') case `?`: return scan_res(.question, '') - case `\'`: + case single_quote: + return scan_res(.str, s.ident_string()) + case double_quote: return scan_res(.str, s.ident_string()) - // TODO allow double quotes - // case QUOTE: - // return scan_res(.str, s.ident_string()) case `\``: // ` // apostrophe balance comment. do not remove return scan_res(.chartoken, s.ident_char()) case `(`: