|
14 | 14 | from typing import Any, Callable, List |
15 | 15 |
|
16 | 16 | from mathics.version import __version__ # noqa used in loading to check consistency. |
17 | | -from mathics.builtin.base import BinaryOperator, Builtin, Test, Predefined |
| 17 | +from mathics.builtin.base import ( |
| 18 | + BinaryOperator, |
| 19 | + Builtin, |
| 20 | + Test, |
| 21 | + Predefined, |
| 22 | + PrefixOperator, |
| 23 | +) |
18 | 24 | from mathics.core.expression import ( |
19 | 25 | Expression, |
20 | 26 | Symbol, |
@@ -1878,6 +1884,31 @@ def apply_form(self, value, form, evaluation, options): |
1878 | 1884 | return String(text) |
1879 | 1885 |
|
1880 | 1886 |
|
| 1887 | +class InterpretedBox(PrefixOperator): |
| 1888 | + """ |
| 1889 | + <dl> |
| 1890 | + <dt>'InterpretedBox[$box$]' |
| 1891 | + <dd>is the ad hoc fullform for \! $box$. just |
| 1892 | + for internal use... |
| 1893 | +
|
| 1894 | + >> \! \(2+2\) |
| 1895 | + = 4 |
| 1896 | + </dl> |
| 1897 | + """ |
| 1898 | + |
| 1899 | + operator = "\\!" |
| 1900 | + precedence = 670 |
| 1901 | + |
| 1902 | + def apply_dummy(self, boxes, evaluation): |
| 1903 | + """InterpretedBox[boxes_]""" |
| 1904 | + # TODO: the following is a very raw and dummy way to |
| 1905 | + # handle these expressions. |
| 1906 | + # In the first place, this should handle different kind |
| 1907 | + # of boxes in different ways. |
| 1908 | + reinput = boxes.boxes_to_text() |
| 1909 | + return Expression("ToExpression", reinput).evaluate(evaluation) |
| 1910 | + |
| 1911 | + |
1881 | 1912 | class ToExpression(Builtin): |
1882 | 1913 | """ |
1883 | 1914 | <dl> |
@@ -1926,7 +1957,6 @@ class ToExpression(Builtin): |
1926 | 1957 | #> ToExpression["log(x)", StandardForm] |
1927 | 1958 | = log x |
1928 | 1959 | """ |
1929 | | - |
1930 | 1960 | attributes = ("Listable", "Protected") |
1931 | 1961 |
|
1932 | 1962 | messages = { |
|
0 commit comments