@@ -88,6 +88,31 @@ public static PythonSourceCodeParse lex(final CodePolicy policy, final String so
8888 currentToken .depth = indentNumber ;
8989 currentToken .startLineNumber = lineNumber ;
9090 } else if (ch == '\'' ) {
91+ if (i +1 <l ) {
92+ final char ch1 = chars [i +1 ];
93+ if (ch1 == '\'' ) {
94+ if (i +2 <l ) {
95+ final char ch2 = chars [i +2 ];
96+ if (ch2 == '\'' ) {
97+ // comment literal """ <<comment>> """
98+ parse .tokenList .add (currentToken .finish (lineNumber ));
99+ currentToken = new Token (n ++, currentToken );
100+ currentToken .type = TokenClassification .APOS3_LITERAL ;
101+ currentToken .sourceCode .append (ch );
102+ currentToken .sourceCode .append (ch1 );
103+ currentToken .sourceCode .append (ch2 );
104+ currentToken .depth = indentNumber ;
105+ currentToken .startLineNumber = lineNumber ;
106+ ++i ;
107+ ++i ;
108+
109+ break ;
110+ }
111+ }
112+ }
113+ }
114+
115+ // otherwise, it is an apos literal
91116 parse .tokenList .add (currentToken .finish (lineNumber ));
92117 currentToken = new Token (n ++, currentToken );
93118 currentToken .type = TokenClassification .APOS_LITERAL ;
@@ -192,6 +217,40 @@ public static PythonSourceCodeParse lex(final CodePolicy policy, final String so
192217 currentToken .sourceCode .append (ch );
193218 }
194219 break ;
220+ case APOS3_LITERAL :
221+ if (ch == '\'' ) {
222+ if (i +1 <l ) {
223+ final char ch1 = chars [i +1 ];
224+ if (ch1 == '\'' ) {
225+ if (i +2 <l ) {
226+ final char ch2 = chars [i +2 ];
227+ if (ch2 == '\'' ) {
228+ // apos string literal ''' <<comment>> '''
229+ currentToken .sourceCode .append (ch );
230+ currentToken .sourceCode .append (ch1 );
231+ currentToken .sourceCode .append (ch2 );
232+ parse .tokenList .add (currentToken .finish (lineNumber ));
233+ currentToken = new Token (n ++, currentToken );
234+ currentToken .type = TokenClassification .SOURCE_CODE ;
235+ currentToken .depth = indentNumber ;
236+ currentToken .startLineNumber = lineNumber ;
237+ i +=2 ;
238+
239+ break ;
240+ }
241+ }
242+ }
243+ }
244+ }
245+ // behaves like any string
246+ if (ch == '\\' ) {
247+ currentToken .sourceCode .append (ch );
248+ final char ch2 = chars [++i ];
249+ currentToken .sourceCode .append (ch2 );
250+ } else {
251+ currentToken .sourceCode .append (ch );
252+ }
253+ break ;
195254 case APOS_LITERAL :
196255 if (ch == '\'' ) {
197256 currentToken .sourceCode .append (ch );
@@ -247,14 +306,15 @@ public static PythonSourceCodeParse lex(final CodePolicy policy, final String so
247306
248307 @ Override
249308 public boolean couldContainErrorNumber (Token token ) {
250- return token .type == TokenClassification .APOS_LITERAL || token .type == TokenClassification .BACKTICK_LITERAL || token .type == TokenClassification .QUOT_LITERAL ;
309+ return token .type == TokenClassification .APOS3_LITERAL || token . type == TokenClassification . APOS_LITERAL || token .type == TokenClassification .QUOT3_LITERAL || token .type == TokenClassification .QUOT_LITERAL ;
251310 }
252311
253312 @ Override
254313 public void classifyForErrorCode (ApiProvider apiProvider , GlobalState globalState , ProjectPolicy policy , StateItem stateItem , Token token ) {
255314 if (token .classification == Token .Classification .NOT_CLASSIFIED_YET ) {
256315 switch (token .type ) {
257316 case APOS_LITERAL :
317+ case APOS3_LITERAL :
258318 case QUOT_LITERAL :
259319 case QUOT3_LITERAL :
260320 {
@@ -300,7 +360,7 @@ public void classifyForErrorCode(ApiProvider apiProvider, GlobalState globalStat
300360 {
301361 token .classification = Token .Classification .NOT_FULLY_CLASSIFIED ;
302362 Token next = token .next ();
303- if (next != null && (next .type == TokenClassification .QUOT_LITERAL || next .type == TokenClassification .APOS_LITERAL || next .type == TokenClassification .QUOT3_LITERAL )) {
363+ if (next != null && (next .type == TokenClassification .QUOT_LITERAL || next .type == TokenClassification .APOS_LITERAL || next .type == TokenClassification .QUOT3_LITERAL || next . type == TokenClassification . APOS3_LITERAL )) {
304364 // rule 0 - this code must be followed by a string literal
305365 if (null != languageCodePolicy && languageCodePolicy .rules .size () > 0 ) {
306366 // classify according to rules.
0 commit comments