Skip to content

Commit 2fba7db

Browse files
authored
Revise API for position tracking (#1413)
Start tracking locations in specific expressions to aid error reporting and debugging. We need to take care to avoid bloating memory with positions. Right now, start locations are tagged for FunctionApplyRule, an ExpressionPattern -> Python method. Here, the location is the Python method, or rather, can be extracted from that. So we can reuse the location information that Python is storing anyway. For Expressions and ExpressionPatterns that are read in from Files, Things are more complicated.. This needs to be coordinated with a change in mathics-scanner with the same git branch name.
1 parent ae82c9f commit 2fba7db

32 files changed

Lines changed: 402 additions & 102 deletions

.github/workflows/consistency-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
sudo apt update -qq && sudo apt install llvm-dev remake
2424
python -m pip install --upgrade pip
2525
# We can comment out after next Mathics-Scanner release
26-
python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]
26+
python -m pip install -e git+https://github.com/Mathics3/mathics-scanner@position-tracking#egg=Mathics-Scanner[full]
2727
pip install -e .
2828
2929
- name: Install Mathics with minimum dependencies

.github/workflows/macos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
cd ..
3636
# We can comment out after next Mathics-Scanner release
3737
# python -m pip install Mathics-Scanner[full]
38-
python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]
38+
python -m pip install -e git+https://github.com/Mathics3/mathics-scanner@position-tracking#egg=Mathics-Scanner[full]
3939
pip install -e .
4040
remake -x develop-full
4141
- name: Test Mathics3

.github/workflows/mypy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
run: |
2828
pip install mypy==1.13 sympy==1.12
2929
# Adjust below for right branch
30-
git clone --depth 1 https://github.com/Mathics3/mathics-scanner.git
30+
git clone --depth 1 --branch position-tracking https://github.com/Mathics3/mathics-scanner
3131
cd mathics-scanner/
3232
pip install -e .
3333
bash ./admin-tools/make-JSON-tables.sh

.github/workflows/packages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
run: |
2626
python -m pip install --upgrade pip
2727
# We can comment out after next Mathics-Scanner release
28-
python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]
28+
python -m pip install -e git+https://github.com/Mathics3/mathics-scanner@position-tracking#egg=Mathics-Scanner[full]
2929
- name: Run Mathics3 Combinatorica tests
3030
run: |
3131
git submodule init

.github/workflows/pyodide.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
pip install "setuptools>=70.0.0" PyYAML click packaging pytest
5656
5757
# We can comment out after next Mathics-Scanner release
58-
python -m pip install --no-build-isolation -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner
58+
python -m pip install --no-build-isolation -e git+https://github.com/Mathics3/mathics-scanner@position-tracking#egg=Mathics-Scanner
5959
# pip install --no-build-isolation -e .
6060
# cd ..
6161

.github/workflows/ubuntu-cython.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
pip install -e .
3131
cd ..
3232
# We can comment out after next Mathics-Scanner release
33-
python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]
33+
python -m pip install -e git+https://github.com/Mathics3/mathics-scanner@position-tracking#egg=Mathics-Scanner[full]
3434
pip install -e .
3535
cd ..
3636

.github/workflows/ubuntu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
cd ..
3232
# We can comment out after next Mathics-Scanner release
3333
# python -m pip install Mathics-Scanner[full]
34-
python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]
34+
python -m pip install -e git+https://github.com/Mathics3/mathics-scanner@position-tracking#egg=Mathics-Scanner[full]
3535
pip install -e .
3636
remake -x develop-full
3737
- name: Test Mathics

.github/workflows/windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
pip install -e .
4040
cd ..
4141
# We can comment out after next Mathics-Scanner release
42-
python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]
42+
python -m pip install -e git+https://github.com/Mathics3/mathics-scanner@position-tracking#egg=Mathics-Scanner[full]
4343
pip install -e .
4444
4545
# python -m pip install Mathics-Scanner[full]

examples/symbolic_logic/gries_schneider/test_gs.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

4+
from mathics_scanner.location import ContainerKind
45

56
from mathics.core.definitions import Definitions
67
from mathics.core.evaluation import Evaluation
@@ -13,5 +14,8 @@
1314
for i in range(0, 4):
1415
evaluation = Evaluation(definitions=definitions, catch_interrupt=False)
1516

16-
expr = parse(definitions, MathicsSingleLineFeeder(f"<< GS{i}.m"))
17+
expr = parse(
18+
definitions,
19+
MathicsSingleLineFeeder(f"<< GS{i}.m", "<test_gs>", ContainerKind.STRING),
20+
)
1721
expr.evaluate(evaluation)

mathics/builtin/testing_expressions/string_tests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import re
66

77
from mathics_scanner import SingleLineFeeder, SyntaxError
8+
from mathics_scanner.location import ContainerKind
89

910
from mathics.builtin.atomic.strings import anchor_pattern
1011
from mathics.core.atoms import Integer1, String
@@ -278,7 +279,7 @@ def eval(self, string, evaluation: Evaluation):
278279
)
279280
return
280281

281-
feeder = SingleLineFeeder(string.value)
282+
feeder = SingleLineFeeder(string.value, "<SyntaxQ>", ContainerKind.STRING)
282283
try:
283284
parser.parse(feeder)
284285
except SyntaxError:

0 commit comments

Comments
 (0)