From fa266ccdd8d5193e26151ff3af0ef9f44d6a9cb7 Mon Sep 17 00:00:00 2001 From: Theophile Ranquet Date: Wed, 31 Oct 2012 16:14:03 +0000 Subject: [PATCH] Fix a symbolic comparison token inversion in scanner * THANKS (Pablo Oliveira, Theophile Ranquet): Add. * src/Scan.hs (scanToKeyword): Here. * tests/Makefile.am: Adjust for... * tests/cmp.lir, * tests/cmp.out, * tests/cmp.test: ...this new test. Reported by Pablo Oliveira. --- THANKS | 5 +++++ src/Scan.hs | 4 ++-- tests/Makefile.am | 4 ++-- tests/cmp.lir | 17 +++++++++++++++++ tests/cmp.out | 1 + tests/cmp.test | 33 +++++++++++++++++++++++++++++++++ 6 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 tests/cmp.lir create mode 100644 tests/cmp.out create mode 100755 tests/cmp.test diff --git a/THANKS b/THANKS index be2ebe1..54315be 100644 --- a/THANKS +++ b/THANKS @@ -9,6 +9,11 @@ People who contributed to Havm: * Yann Régis-Gianas yann.regisgianas@gmail.com - Port to GHC 6.4 +* Pablo Oliveira pablo@sifflez.org + - Patch scanner + +* Théophile Ranquet ranquet@lrde.epita.fr + - Version 0.25 Local Variables: mode: outline diff --git a/src/Scan.hs b/src/Scan.hs index 651564b..2023545 100644 --- a/src/Scan.hs +++ b/src/Scan.hs @@ -168,8 +168,8 @@ scanTokKeyword "ge" loc = TokRelop (Ge, loc) scanTokKeyword "(=)" loc = TokRelop (Eq, loc) scanTokKeyword "(<>)" loc = TokRelop (Ne, loc) scanTokKeyword "(<)" loc = TokRelop (Lt, loc) -scanTokKeyword "(<=)" loc = TokRelop (Gt, loc) -scanTokKeyword "(>)" loc = TokRelop (Le, loc) +scanTokKeyword "(<=)" loc = TokRelop (Le, loc) +scanTokKeyword "(>)" loc = TokRelop (Gt, loc) scanTokKeyword "(>=)" loc = TokRelop (Ge, loc) scanTokKeyword str loc = TokString (str, loc) diff --git a/tests/Makefile.am b/tests/Makefile.am index b223ae1..5849e8a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -5,9 +5,9 @@ XFAIL_TESTS = TESTS = \ -trace.test +cmp.test trace.test -EXTRA_DIST = fact.lir fact.out $(TESTS) +EXTRA_DIST = cmp.lir cmp.out fact.lir fact.out $(TESTS) # Each test case depends on defs. check_SCRIPTS = defs diff --git a/tests/cmp.lir b/tests/cmp.lir new file mode 100644 index 0000000..cbbe096 --- /dev/null +++ b/tests/cmp.lir @@ -0,0 +1,17 @@ +seq + label main + seq + cjump (>) + const 2 + const 1 + name L2 name L3 + label L2 + sxp + call + name print_int + const 1 + call end + label L3 + seq end + label end +seq end diff --git a/tests/cmp.out b/tests/cmp.out new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/tests/cmp.out @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/tests/cmp.test b/tests/cmp.test new file mode 100755 index 0000000..49c7646 --- /dev/null +++ b/tests/cmp.test @@ -0,0 +1,33 @@ +#! /bin/sh +# Copyright (C) 2006 LRDE +# +# This file is part of HAVM. +# +# HAVM is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# HAVM is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Texinfo; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. + +. ./defs || exit 1 + +set -e + +HAVM_pass --trace $srcdir/cmp.lir +cmp stdout $srcdir/cmp.out +test -s stderr + +HAVM_pass --trace=3 $srcdir/cmp.lir 3>stdtrc +cmp stdout $srcdir/cmp.out +test ! -s stderr +test -s stdtrc + -- GitLab