From 61bbf8ba7e76804df07ff9f853ef076224e3acef Mon Sep 17 00:00:00 2001
From: Murphy Berzish <murphy.berzish@gmail.com>
Date: Thu, 23 Feb 2017 18:24:08 -0500
Subject: [PATCH 1/2] add octal escape to seq_decl_plugin

---
 src/ast/seq_decl_plugin.cpp | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/ast/seq_decl_plugin.cpp b/src/ast/seq_decl_plugin.cpp
index c645aa1a7..66e1cf239 100644
--- a/src/ast/seq_decl_plugin.cpp
+++ b/src/ast/seq_decl_plugin.cpp
@@ -38,8 +38,16 @@ static bool is_hex_digit(char ch, unsigned& d) {
     return false;
 }
 
+static bool is_octal_digit(char ch, unsigned& d) {
+    if ('0' <= ch && ch <= '7') {
+        d = ch - '0';
+        return true;
+    }
+    return false;
+}
+
 static bool is_escape_char(char const *& s, unsigned& result) {
-    unsigned d1, d2;
+    unsigned d1, d2, d3;
     if (*s != '\\' || *(s + 1) == 0) {
         return false;
     }
@@ -49,6 +57,12 @@ static bool is_escape_char(char const *& s, unsigned& result) {
         s += 4;
         return true;
     }
+    if (is_octal_digit(*(s + 1), d1) && is_octal_digit(*(s + 2), d2) &&
+            is_octal_digit(*(s + 3), d3)) {
+        result = d1*64 + d2*8 + d3;
+        s += 4;
+        return true;
+    }
     switch (*(s + 1)) {
     case 'a':
         result = '\a';

From eb0ba26f907c0e662e0c236292757a6fd3b4ad43 Mon Sep 17 00:00:00 2001
From: Murphy Berzish <murphy.berzish@gmail.com>
Date: Thu, 23 Feb 2017 18:33:10 -0500
Subject: [PATCH 2/2] C-style octal escapes, including 1- and 2-digit escapes

---
 src/ast/seq_decl_plugin.cpp | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/ast/seq_decl_plugin.cpp b/src/ast/seq_decl_plugin.cpp
index 66e1cf239..16ce65ec3 100644
--- a/src/ast/seq_decl_plugin.cpp
+++ b/src/ast/seq_decl_plugin.cpp
@@ -57,6 +57,23 @@ static bool is_escape_char(char const *& s, unsigned& result) {
         s += 4;
         return true;
     }
+    /* C-standard octal escapes: either 1, 2, or 3 octal digits,
+     * stopping either at 3 digits or at the first non-digit character.
+     */
+    /* 1 octal digit */
+    if (is_octal_digit(*(s + 1), d1) && !is_octal_digit(*(s + 2), d2)) {
+        result = d1;
+        s += 2;
+        return true;
+    }
+    /* 2 octal digits */
+    if (is_octal_digit(*(s + 1), d1) && is_octal_digit(*(s + 2), d2) &&
+            !is_octal_digit(*(s + 3), d3)) {
+        result = d1 * 8 + d2;
+        s += 3;
+        return true;
+    }
+    /* 3 octal digits */
     if (is_octal_digit(*(s + 1), d1) && is_octal_digit(*(s + 2), d2) &&
             is_octal_digit(*(s + 3), d3)) {
         result = d1*64 + d2*8 + d3;