Commit 82d83f5a authored by Taddeüs Kroes's avatar Taddeüs Kroes

Significantly improved the parser.

- Thought over and reconfigured precedences. These are now also synchronized
  with precedences in the line printer.
- The subscript operator ("_") has been added to the grammar similarly to
  exponentiation ("^"). This resolved some issues with the use of operators in
  integral bounds.
- Unary negation now has a higher precedence, but the parser moves negations up
  in the tree as far as possible (within the bounds of correctness and without
  causing cycles during reduction).
- All unit tests have been updated using the new syntax.
- graph_drawing has been updated to include the new syntax of the line printer.
parent d8bb1889
......@@ -116,7 +116,6 @@ class Parser(BisonParser):
('left', ('MINUS', 'PLUS')),
('nonassoc', ('INTEGRAL', 'DERIVATIVE')),
('left', ('TIMES', )),
('left', ('PRIME', )),
('left', ('DIVIDE', )),
('nonassoc', ('PRIME', )),
('nonassoc', ('NEG', )),
......
......@@ -12,7 +12,7 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with TRS. If not, see <http://www.gnu.org/licenses/>.
from tests.rulestestcase import RulesTestCase as TestCase, rewrite
from tests.rulestestcase import RulesTestCase as TestCase
class TestLeidenOefenopgave(TestCase):
......
......@@ -101,7 +101,8 @@ class TestParser(RulesTestCase):
self.assertEqual(tree('sin cos x'), sin(cos(x)))
self.assertEqual(tree('sin cos x ^ 2'), sin(cos(x ** 2)))
self.assertEqual(tree('sin cos(x) ^ 2'), sin(cos(x) ** 2))
self.assertEqual(tree('sin cos(x) ^ 2'), sin(cos(x ** 2)))
self.assertEqual(tree('sin (cos x) ^ 2'), sin(cos(x) ** 2))
self.assertEqual(tree('sin (cos x) ^ 2'), sin(cos(x)) ** 2)
self.assertEqual(tree('sin((cos x) ^ 2)'), sin(cos(x) ** 2))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment