diff --git a/prev23/prg/lexer_test.p23 b/prev23/prg/lexer_test.p23 index 3264616..3157cf8 100644 --- a/prev23/prg/lexer_test.p23 +++ b/prev23/prg/lexer_test.p23 @@ -17,6 +17,7 @@ # :-( [x.17 - x.23] Invalid char constant ['tabx'] # 'tab8' # 'tab9' +# :-) 'tab10' # Symbols ( ) { } [ ] . , : ; & | ! == != < > <= >= * / % + - ^ = @@ -55,6 +56,7 @@ none true false nil #' # Nekoncan char #'a" # Napacen konec #' ' # Nedovoljen vsebovan znak +#' # Nedovoljen vsebovan in nezakljucen # string "" "str str" "str # str #" "str \" str \"" "\"" "''''''''" " \\" " " \'" diff --git a/prev23/src/prev23/phase/lexan/PrevLexer.g4 b/prev23/src/prev23/phase/lexan/PrevLexer.g4 index d688350..e322ffa 100644 --- a/prev23/src/prev23/phase/lexan/PrevLexer.g4 +++ b/prev23/src/prev23/phase/lexan/PrevLexer.g4 @@ -86,7 +86,8 @@ CONST_CHAR: [\u0020-\u0026] | [\u0028-\u007E] | ('\'' { LexError("Empty char constant"); }) | - . { LexError(String.format("Unexpected symbol [%c] inside char constant", _input.LA(-1))); } + . '\'' { LexError(String.format("Unexpected symbol [%c] inside char constant", _input.LA(-2))); } | + . ) ( '\'' | @@ -112,7 +113,7 @@ ID // Ignored WS : [ \r] -> skip ; NL : [\n] { tab_offset = 0; } ->skip ; -TAB : [\t] { tab_offset += 7 - (_tokenStartCharPositionInLine % 8); } -> skip ; +TAB : [\t] { tab_offset += 7 - ((tab_offset + _tokenStartCharPositionInLine) % 8); } -> skip ; COMMENT: '#' .*? ('\n' | EOF) -> skip ; ERROR : . { LexError("Undefined symbol or token"); } -> skip; \ No newline at end of file