Skip to content

Commit

Permalink
Fix tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Lenart12 committed Feb 19, 2023
1 parent fb46593 commit 3c483f9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions prev23/prg/lexer_test.p23
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# :-( [x.17 - x.23] Invalid char constant ['tabx']
# 'tab8'
# 'tab9'
# :-) 'tab10'

# Symbols
( ) { } [ ] . , : ; & | ! == != < > <= >= * / % + - ^ =
Expand Down Expand Up @@ -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 \"" "\"" "''''''''" " \\" " " \'"
Expand Down
5 changes: 3 additions & 2 deletions prev23/src/prev23/phase/lexan/PrevLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -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))); } |
.
)
(
'\'' |
Expand All @@ -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;

0 comments on commit 3c483f9

Please sign in to comment.