Commit d183de8a8d80a21bb8a94381d12e1d23becfdb28
1 parent
f41fe365
olevba: enabled packrat to improve pyparsing performance
Showing
1 changed file
with
6 additions
and
1 deletions
oletools/olevba.py
| @@ -183,6 +183,7 @@ https://github.com/unixfreak0037/officeparser | @@ -183,6 +183,7 @@ https://github.com/unixfreak0037/officeparser | ||
| 183 | # - detect_autoexec now returns the exact keyword found | 183 | # - detect_autoexec now returns the exact keyword found |
| 184 | # 2016-09-05 PL: - added autoexec keywords for MS Publisher (.pub) | 184 | # 2016-09-05 PL: - added autoexec keywords for MS Publisher (.pub) |
| 185 | # 2016-09-06 PL: - fixed issue #20, is_zipfile on Python 2.6 | 185 | # 2016-09-06 PL: - fixed issue #20, is_zipfile on Python 2.6 |
| 186 | +# 2016-09-12 PL: - enabled packrat to improve pyparsing performance | ||
| 186 | 187 | ||
| 187 | __version__ = '0.50' | 188 | __version__ = '0.50' |
| 188 | 189 | ||
| @@ -256,7 +257,7 @@ from thirdparty.pyparsing.pyparsing import \ | @@ -256,7 +257,7 @@ from thirdparty.pyparsing.pyparsing import \ | ||
| 256 | CaselessKeyword, CaselessLiteral, Combine, Forward, Literal, \ | 257 | CaselessKeyword, CaselessLiteral, Combine, Forward, Literal, \ |
| 257 | Optional, QuotedString,Regex, Suppress, Word, WordStart, \ | 258 | Optional, QuotedString,Regex, Suppress, Word, WordStart, \ |
| 258 | alphanums, alphas, hexnums,nums, opAssoc, srange, \ | 259 | alphanums, alphas, hexnums,nums, opAssoc, srange, \ |
| 259 | - infixNotation | 260 | + infixNotation, ParserElement |
| 260 | import ppt_parser | 261 | import ppt_parser |
| 261 | 262 | ||
| 262 | # monkeypatch email to fix issue #32: | 263 | # monkeypatch email to fix issue #32: |
| @@ -671,6 +672,10 @@ re_printable_string = re.compile(r'[\t\r\n\x20-\xFF]{5,}') | @@ -671,6 +672,10 @@ re_printable_string = re.compile(r'[\t\r\n\x20-\xFF]{5,}') | ||
| 671 | # TODO: set whitespaces according to VBA | 672 | # TODO: set whitespaces according to VBA |
| 672 | # TODO: merge extended lines before parsing | 673 | # TODO: merge extended lines before parsing |
| 673 | 674 | ||
| 675 | +# Enable PackRat for better performance: | ||
| 676 | +# (see https://pythonhosted.org/pyparsing/pyparsing.ParserElement-class.html#enablePackrat) | ||
| 677 | +ParserElement.enablePackrat() | ||
| 678 | + | ||
| 674 | # VBA identifier chars (from MS-VBAL 3.3.5) | 679 | # VBA identifier chars (from MS-VBAL 3.3.5) |
| 675 | vba_identifier_chars = alphanums + '_' | 680 | vba_identifier_chars = alphanums + '_' |
| 676 | 681 |