Skip to content

Commit

Permalink
Misc grammar and spelling typos
Browse files Browse the repository at this point in the history
  • Loading branch information
rocky committed Aug 8, 2024
1 parent 5d63ea8 commit c115937
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions mathics_pygments/builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -6550,7 +6550,7 @@ def get_datadir():
"$WolframUUID",
}

# The Mathics parser can't handle Degree ("uB0" ) as an operator so we'll add it here.
# The Mathics parser can't handle Degree ("uB0") as an operator, so we'll add it here.
UNICODE_OPERATORS = set(list(_data["unicode-operators"].keys()) + ["\u00B0"])

UNICODE_OPERATORS_OLD = {
Expand All @@ -6565,7 +6565,7 @@ def get_datadir():
"∮", # \[ContourIntegral]
"∳", # \[CounterClockwiseContourIntegral]
"∯", # \[DoubleContourIntegral]
"°", # \[Degree] # this is wrong and not an operator but letterlike
"°", # \[Degree] # this is wrong and not an operator but letterlike
"∇", # \[Del]
"÷", # \[Divide]
"≐", # \[DotEqual]
Expand Down
28 changes: 14 additions & 14 deletions mathics_pygments/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class MToken:
Mathics Tokens. Like Pygments Token but for Mathics.
Class variables contain Mathics tokens like BUILTIN, COMMENT.
These variables hold corresponding Pygments token-name value.
These variables hold the corresponding Pygments token-name value.
The style, e.g. "colorful", "zenburn", "xcode", ultimately determines
out this appears on a terminal
Expand Down Expand Up @@ -97,8 +97,8 @@ class MathematicaLexer(RegexLexer):
),
(Regex.OPERATORS, MToken.OPERATOR),
(r"\s+", MToken.WHITESPACE),
# Note IDENTIFER should come after tokens that have IDENTIFIER parts, like SYMBOLS.
# Otherwise we may have System`foo matching identifier System over Symbol System`foo
# Note IDENTIFIER should come after tokens that have IDENTIFIER parts, like SYMBOLS.
# Otherwise, we may have System`foo matching identifier System over Symbol System`foo
#
# I don't understand why this is not a problem in pygments-mathematica.
(Regex.IDENTIFIER, MToken.SYMBOL),
Expand Down Expand Up @@ -179,11 +179,11 @@ def _reset_scope_state(self):
self.scope.keyword = False
self.scope.active = False

# level tracks the nestedness of local scopes (e.g. Block[{x = Block[{y = ...}, ...]}, ...])
# level tracks the nestedness of local scopes (e.g., Block[{x = Block[{y = ...}, ...]}, ...])
self.scope.level = 0

# The next three variables are stacks that track opening and closing brackets, braces and
# and other groupings (associations, angle brackets, etc.) at each level.
# other groupings (associations, angle brackets, etc.) at each level.
# Braces are tracked only immediately after entering an active scope, which is where the
# local variables are defined.
self.scope.brackets = defaultdict(int)
Expand Down Expand Up @@ -279,7 +279,7 @@ def lexical_scope(self, index, token, value):
# The parser is inside the local variables section.
self.scope.braces[level] += 1
else:
# In all other cases don't modify the stack.
# In all other cases, don't modify the stack.
pass

return index, token, value
Expand All @@ -299,15 +299,15 @@ def lexical_scope(self, index, token, value):
return index, token, value

elif self.scope.active and self.scope.braces[level]:
# If the parser is on an assignment operator, mark rhs = True so that symbols from the
# RHS of the assignment are not considered as local variables. The rhs value is reset
# when:
# 1. the parser is on a , inside the local variables section and the stack state
# If the parser is on an assignment operator, mark rsh = True so that symbols from the
# RHS of the assignment are not considered as local variables.
# The RHS value is reset when:
# 1. The parser is on a comma inside the local variables section, and the stack state
# is the same as when it entered the section. For example, in
# Block[{x = 1, y = 2}, x + y], the stack state is the same at { and the first ,.
# But in Block[{x = {1, a}, y = 2}, x + y], the stack state is not the same at {
# and the first , so it is still part of the RHS.
# 2. if it has exited the local variables section (handled earlier)
# Block[{x = 1, y = 2}, x + y], the stack state is the same at left brace and the first comma.
# But in Block[{x = {1, a}, y = 2}, x + y], the stack state is not the same at left brace
# and the first comma, so it is still part of the RHS.
# 2. If it has exited the local variables section (handled earlier).
if token is MToken.OPERATOR and value in ("=", ":="):
self.scope.rhs[level] = True
elif (
Expand Down

0 comments on commit c115937

Please sign in to comment.