Skip to content

Commit

Permalink
Merge pull request #32 from cs50/develop
Browse files Browse the repository at this point in the history
v1.1.1
  • Loading branch information
Kareem Zidane authored Aug 18, 2019
2 parents 17edc19 + c571fdb commit 108370e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions compare50/passes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class structure(Pass):
preprocessors = [preprocessors.strip_whitespace,
preprocessors.strip_comments,
preprocessors.normalize_identifiers,
preprocessors.normalize_builtin_types,
preprocessors.normalize_string_literals,
preprocessors.normalize_numeric_literals]
comparator = comparators.Winnowing(k=25, t=35)
Expand Down
14 changes: 10 additions & 4 deletions compare50/preprocessors.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import re

import attr
from pygments.token import Comment, Name, Number, String, Text
from pygments.token import Comment, Name, Number, String, Text, Keyword

from ._data import Token

Expand All @@ -17,6 +17,14 @@ def strip_whitespace(tokens):
yield tok


def normalize_builtin_types(tokens):
"""Normalize builtin type names"""
for tok in tokens:
if tok.type in Keyword.Type:
tok.val = "t"
yield tok


def strip_comments(tokens):
"""Remove all comments from tokens."""
for tok in tokens:
Expand All @@ -36,9 +44,7 @@ def normalize_identifiers(tokens):
for tok in tokens:
if tok.type in Name:
tok.val = "v"
yield tok
else:
yield tok
yield tok


def normalize_string_literals(tokens):
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
license="GPLv3",
description="This is compare50, with which you can compare files for similarities.",
install_requires=["attrs>=18,<20", "intervaltree>=2.1.0,<3", "lib50>=1.1.0,<2", "numpy>=1.15,<2", "pygments>=2.2,<3", "jinja2>=2.10,<3", "termcolor>=1.1.0,<2", "tqdm>=4.32,<5"],
install_requires=["attrs>=18,<20", "intervaltree>=2.1.0,<3", "lib50>=2,<3", "numpy>=1.15,<2", "pygments>=2.2,<3", "jinja2>=2.10,<3", "termcolor>=1.1.0,<2", "tqdm>=4.32,<5"],
extras_require = {
"develop": ["sphinx", "sphinx_rtd_theme", "line_profiler"]
},
Expand All @@ -21,6 +21,6 @@
packages=find_packages(exclude=["tests"]),
scripts=["bin/compare50"],
url="https://github.com/cs50/compare50",
version="1.1.0",
version="1.1.1",
include_package_data=True,
)

0 comments on commit 108370e

Please sign in to comment.