diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 2018-06-10 08:58:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-10 08:58:23 (GMT) |
commit | 8f0fde6620dafc53f2932bd8510df602220961aa (patch) | |
tree | a0376fb4d8f1a80f0885a801af581904d2fb2b6a /src | |
parent | 7a5e7e2ffecd0df3c9bedaba01fe4f316a49a55b (diff) | |
parent | 48817487de116ee526714587900380e53b195f5e (diff) | |
download | Doxygen-8f0fde6620dafc53f2932bd8510df602220961aa.zip Doxygen-8f0fde6620dafc53f2932bd8510df602220961aa.tar.gz Doxygen-8f0fde6620dafc53f2932bd8510df602220961aa.tar.bz2 |
Merge pull request #739 from albert-github/feature/bug_python_code
Small problems when displaying python code
Diffstat (limited to 'src')
-rw-r--r-- | src/pycode.l | 30 | ||||
-rw-r--r-- | src/pyscanner.l | 1 |
2 files changed, 26 insertions, 5 deletions
diff --git a/src/pycode.l b/src/pycode.l index fe1eef5..1b176d6 100644 --- a/src/pycode.l +++ b/src/pycode.l @@ -884,7 +884,7 @@ SHORTSTRINGITEM ({SHORTSTRINGCHAR}|{ESCAPESEQ}) SHORTSTRINGCHAR [^\\\n"] STRINGLITERAL {STRINGPREFIX}?( {SHORTSTRING} | {LONGSTRING}) STRINGPREFIX ("r"|"u"|"ur"|"R"|"U"|"UR"|"Ur"|"uR") -KEYWORD ("lambda"|"import"|"class"|"assert"|"as"|"from"|"global"|"def"|"True"|"False") +KEYWORD ("lambda"|"import"|"class"|"assert"|"with"|"as"|"from"|"global"|"def"|"True"|"False") FLOWKW ("or"|"and"|"is"|"not"|"print"|"for"|"in"|"if"|"try"|"except"|"yield"|"raise"|"break"|"continue"|"pass"|"if"|"return"|"while"|"elif"|"else"|"finally") QUOTES ("\""[^"]*"\"") SINGLEQUOTES ("'"[^']*"'") @@ -1382,21 +1382,43 @@ TARGET ({IDENTIFIER}|"("{TARGET_LIST}")"|"["{TARGET_LIST}"]"|{ATTRIBUT } */ -<*>{STRINGPREFIX}?{TRISINGLEQUOTE} | +<*>{STRINGPREFIX}?{TRISINGLEQUOTE} { + if (YY_START==SingleQuoteString) REJECT; + startFontClass("stringliteral"); + g_stringContext=YY_START; + g_doubleQuote=yytext[yyleng-1]=='"'; + codify(yytext); + BEGIN(TripleString); + } <*>{STRINGPREFIX}?{TRIDOUBLEQUOTE} { - startFontClass("stringliteral"); + if (YY_START==DoubleQuoteString) REJECT; + startFontClass("stringliteral"); g_stringContext=YY_START; g_doubleQuote=yytext[yyleng-1]=='"'; - codify(yytext); + codify(yytext); BEGIN(TripleString); } <*>{STRINGPREFIX}?"'" { // single quoted string + if (YY_START==SingleQuoteString || + YY_START==DoubleQuoteString || + YY_START==TripleString + ) + { + REJECT; + } startFontClass("stringliteral"); g_stringContext=YY_START; codify(yytext); BEGIN(SingleQuoteString); } <*>{STRINGPREFIX}?"\"" { // double quoted string + if (YY_START==SingleQuoteString || + YY_START==DoubleQuoteString || + YY_START==TripleString + ) + { + REJECT; + } startFontClass("stringliteral"); g_stringContext=YY_START; codify(yytext); diff --git a/src/pyscanner.l b/src/pyscanner.l index 5c9aef5..4718e3b 100644 --- a/src/pyscanner.l +++ b/src/pyscanner.l @@ -487,7 +487,6 @@ SHORTSTRINGITEM ({SHORTSTRINGCHAR}|{ESCAPESEQ}) SHORTSTRINGCHAR [^\\\n"] STRINGLITERAL {STRINGPREFIX}?( {SHORTSTRING} | {LONGSTRING}) STRINGPREFIX ("r"|"u"|"ur"|"R"|"U"|"UR"|"Ur"|"uR") -KEYWORD ("lambda"|"import"|"class"|"assert"|"as"|"from"|"global"|"def"|"True"|"False") FLOWKW ("or"|"and"|"is"|"not"|"print"|"for"|"in"|"if"|"try"|"except"|"yield"|"raise"|"break"|"continue"|"pass"|"if"|"return"|"while"|"elif"|"else"|"finally") POUNDCOMMENT "#"[^#\n][^\n]* SCRIPTCOMMENT "#!".* |