Skip to content

Commit

Permalink
Merge pull request #8 from akash-akya/fix-line-break-op
Browse files Browse the repository at this point in the history
Update LINE_BREAK_OPERATORS characters
  • Loading branch information
ananthakumaran authored Apr 10, 2021
2 parents 9f044a1 + 5368355 commit 24709af
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/scanner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const char SIGIL_CHARS[] = {
};

const char LINE_BREAK_OPERATORS[] = {
'#', '.', ':', '|', '!', '=', '<', '>', '+', '-', '*', '/', '\\', ',', 'w', 'a', 'o', 'i', 'n', '&'
'#', '.', ':', '|', '!', '=', '<', '>', '+', '-', '*', '/', '\\', ',', 'w', 'a', 'o', 'i', 'n', '&', '^', '~'
};

const char SYMBOL_OPERATORS[] = {
Expand Down Expand Up @@ -902,12 +902,18 @@ struct Scanner {
return true;
}
return false;
// ~>
// ~>, ~>>
case '~':
advance(lexer);
if (lexer->lookahead == '>') {
advance(lexer);
if (lexer->lookahead == ':') {
if (lexer->lookahead == '>') {
advance(lexer);
if (lexer->lookahead == ':') {
return !is_keyword_end(lexer, valid_symbols);
}
return true;
} else if (lexer->lookahead == ':') {
return !is_keyword_end(lexer, valid_symbols);
}
return true;
Expand Down
38 changes: 38 additions & 0 deletions test/corpus/operator.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,41 @@ x not in [y, z]
(list
(identifier)
(identifier))))

================================================================================
^^^
================================================================================

abcd
^^^ xyz

--------------------------------------------------------------------------------

(program
(binary_op
(identifier)
(identifier)))

================================================================================
~>
================================================================================
a
~> b
--------------------------------------------------------------------------------

(program
(binary_op
(identifier)
(identifier)))

================================================================================
~>>
================================================================================
a
~>> b
--------------------------------------------------------------------------------

(program
(binary_op
(identifier)
(identifier)))

0 comments on commit 24709af

Please sign in to comment.