My previous series broke dealing with backslashes. I missunderstood
how 'next_char' actually worked. It should check if the next char is a
backslash. So move the check to after we advanced the string pointer
to the next char.

I fixed and moved the test to be executed, which is what caught the bug.

I also fixed the typos in the second patch.

There are no changes to the third patch.

This is the interdiff between v1 and v2:

diff -u b/gcc/algol68/a68-parser-scanner.cc b/gcc/algol68/a68-parser-scanner.cc
--- b/gcc/algol68/a68-parser-scanner.cc
+++ b/gcc/algol68/a68-parser-scanner.cc
@@ -393,10 +393,6 @@
   if (*ref_l == NO_LINE)
     return STOP_CHAR;
 
-  /* Skip backslash at the end of lines.  */
-  if ((*ref_s)[0] == BACKSLASH_CHAR && (*ref_s)[1] == NEWLINE_CHAR)
-    (*ref_s)++;
-
   if ((*ref_s)[0] == NEWLINE_CHAR || (*ref_s)[0] == '\0')
     {
       /* Go to new line.  */
@@ -408,6 +404,13 @@
   else
     (*ref_s)++;
 
+  /* Skip backslash at the end of lines.  */
+  if ((*ref_s)[0] == BACKSLASH_CHAR && (*ref_s)[1] == NEWLINE_CHAR)
+    {
+      (*ref_s)++;
+      return next_char (ref_l, ref_s, allow_typo, allow_one_under, 
found_under);
+    }
+
   /* Deliver next char.  */
   ch = (*ref_s)[0];
   if ((allow_typo && (ISSPACE (ch) || ch == FORMFEED_CHAR))
reverted:
--- b/gcc/testsuite/algol68/compile/backslash-1.a68
+++ /dev/null
@@ -1,6 +0,0 @@
-begin
-    string foobar = "foo bar";
-    string fubar = "foo \
-ar";
-    assert (foobar = fubar)
-end
only in patch2:
unchanged:
--- /dev/null
+++ b/gcc/testsuite/algol68/execute/backslash-1.a68
@@ -0,0 +1,6 @@
+begin
+    string foobar = "foo bar";
+    string fubar = "foo \
+bar";
+    assert (foobar = fubar)
+end

diff -u b/gcc/algol68/a68.h b/gcc/algol68/a68.h
--- b/gcc/algol68/a68.h
+++ b/gcc/algol68/a68.h
@@ -109,7 +109,7 @@
 
 /* Location-tracking functions.  */
 
-/* Get the line name that LINE belongs to.  */
+/* Get the file name that LINE belongs to.  */
 
 inline const char *
 FILENAME (LINE_T *line)
@@ -120,7 +120,7 @@
   return LINEMAP_FILE (ord_map);
 }
 
-/* Get the 1-based line nuber of LINE.  */
+/* Get the 1-based line number of LINE.  */
 
 inline unsigned int
 LINE_NO (LINE_T *line)


---
Pietro Monteiro (3):
  algol68: Skip backslash at the end of lines on the scanner
  algol68: Add location_t to LINE_T
  algol68: Improve location tracking

 gcc/algol68/a68-low-bits.cc                   |  2 +-
 gcc/algol68/a68-low-chars.cc                  |  2 +-
 gcc/algol68/a68-low-coercions.cc              |  2 +-
 gcc/algol68/a68-low-misc.cc                   |  2 +-
 gcc/algol68/a68-low-multiples.cc              | 10 +--
 gcc/algol68/a68-low.cc                        |  2 +-
 gcc/algol68/a68-parser-scanner.cc             | 88 ++++++++-----------
 gcc/algol68/a68-parser-top-down.cc            |  3 +-
 gcc/algol68/a68-parser.cc                     | 26 +++---
 gcc/algol68/a68-pretty-print.h                |  7 +-
 gcc/algol68/a68-types.h                       |  7 +-
 gcc/algol68/a68.h                             | 24 +++++
 gcc/testsuite/algol68/execute/backslash-1.a68 |  6 ++
 13 files changed, 95 insertions(+), 86 deletions(-)
 create mode 100644 gcc/testsuite/algol68/execute/backslash-1.a68

-- 
2.55.0

Reply via email to