File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
joern-cli/frontends/pysrc2cpg
src/test/scala/io/joern/pythonparser Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -822,7 +822,13 @@ SPECIAL_TOKEN: {
822822
823823<INDENT_CHECK> SKIP: {
824824 <INDENT_CHECK_SPACE: " "> { currentIndent += 1; }
825- | <INDENT_CHECK_TAB: "\t"> { currentIndent = currentIndent / 8 + 8; }
825+ | <INDENT_CHECK_TAB: "\t"> {
826+ // The "/ 8 * 8" rounds down to the closest multiple of 8.
827+ // This is needed to handle python 2 mixed space and tab use cases
828+ // where tab is not strictly counted as 8 spaces but rather adds the
829+ // amount of spaces to get to the next multiple of 8.
830+ currentIndent = currentIndent / 8 * 8 + 8;
831+ }
826832| <INDENT_CHECK_NEWLINE: "\n" | "\r"> { currentIndent = 0; }
827833| <INDENT_CHECK_END_OF_MEDIUM: "\u0019">
828834| <INDENT_CHECK_END: ~[]> {
Original file line number Diff line number Diff line change @@ -350,6 +350,7 @@ class ParserTests extends AnyFreeSpec with Matchers {
350350 | z = (x,y)
351351 |a""" .stripMargin
352352 )
353+ testT(" def init():\n\t match x:\n\t\t case 'C':\n\t\t\t z = 1" )
353354 }
354355
355356 " explicit line joining tests" in {
You can’t perform that action at this time.
0 commit comments