aboutsummaryrefslogtreecommitdiff
path: root/gcc/go/gofrontend/lex.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2012-09-17 05:15:36 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2012-09-17 05:15:36 +0000
commit5dbeb128d9d33ef23e15b65dad1c7cc28793692d (patch)
tree5324a239d8658af99c9f07bfb4bc67b31c74c90b /gcc/go/gofrontend/lex.cc
parentf0e1e86d226c40d8f13f1abd1f8fac7017075000 (diff)
downloadgcc-5dbeb128d9d33ef23e15b65dad1c7cc28793692d.zip
gcc-5dbeb128d9d33ef23e15b65dad1c7cc28793692d.tar.gz
gcc-5dbeb128d9d33ef23e15b65dad1c7cc28793692d.tar.bz2
compile: Detect invalid and likely-bad import statements.
* Make-lang.in (go/gogo.o): Depend on filenames.h. From-SVN: r191372
Diffstat (limited to 'gcc/go/gofrontend/lex.cc')
-rw-r--r--gcc/go/gofrontend/lex.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/gcc/go/gofrontend/lex.cc b/gcc/go/gofrontend/lex.cc
index 5b7ce68..42d444b 100644
--- a/gcc/go/gofrontend/lex.cc
+++ b/gcc/go/gofrontend/lex.cc
@@ -1705,6 +1705,27 @@ struct Unicode_range
unsigned int stride;
};
+// A table of whitespace characters--Unicode code points classified as
+// "Space", "C" locale whitespace characters, the "next line" control
+// character (0085), the line separator (2028), the paragraph
+// separator (2029), and the "zero-width non-break space" (feff).
+
+static const Unicode_range unicode_space[] =
+{
+ { 0x0009, 0x000d, 1 },
+ { 0x0020, 0x0020, 1 },
+ { 0x0085, 0x0085, 1 },
+ { 0x00a0, 0x00a0, 1 },
+ { 0x1680, 0x1680, 1 },
+ { 0x180e, 0x180e, 1 },
+ { 0x2000, 0x200a, 1 },
+ { 0x2028, 0x2029, 1 },
+ { 0x202f, 0x202f, 1 },
+ { 0x205f, 0x205f, 1 },
+ { 0x3000, 0x3000, 1 },
+ { 0xfeff, 0xfeff, 1 },
+};
+
// A table of Unicode digits--Unicode code points classified as
// "Digit".
@@ -2294,6 +2315,15 @@ Lex::is_in_unicode_range(unsigned int c, const Unicode_range* ranges,
}
}
+// Return whether C is a space character.
+
+bool
+Lex::is_unicode_space(unsigned int c)
+{
+ return Lex::is_in_unicode_range(c, unicode_space,
+ ARRAY_SIZE(unicode_space));
+}
+
// Return whether C is a Unicode digit--a Unicode code point
// classified as "Digit".