aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2022-10-18 10:26:48 +0800
committerLi Jin <dragon-fly@qq.com>2022-10-18 10:26:48 +0800
commit6b6e98d062c7ec5f11be79ed5164aa59047dab30 (patch)
treee0893ac6b3a8a64b81d81b03a8e413b112114586
parent374292d175c0dcea8b24fc0dc4c0636e9cc85afa (diff)
downloadyuescript-6b6e98d062c7ec5f11be79ed5164aa59047dab30.tar.gz
yuescript-6b6e98d062c7ec5f11be79ed5164aa59047dab30.tar.bz2
yuescript-6b6e98d062c7ec5f11be79ed5164aa59047dab30.zip
move utf8 bom skipping to parser.
-rw-r--r--src/yuescript/yue_compiler.cpp2
-rwxr-xr-xsrc/yuescript/yue_parser.cpp3
-rw-r--r--src/yuescript/yuescript.h1
3 files changed, 4 insertions, 2 deletions
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp
index bdb07e0..2be4498 100644
--- a/src/yuescript/yue_compiler.cpp
+++ b/src/yuescript/yue_compiler.cpp
@@ -60,7 +60,7 @@ namespace yue {
60 60
61typedef std::list<std::string> str_list; 61typedef std::list<std::string> str_list;
62 62
63const std::string_view version = "0.15.4"sv; 63const std::string_view version = "0.15.5"sv;
64const std::string_view extension = "yue"sv; 64const std::string_view extension = "yue"sv;
65 65
66class YueCompilerImpl { 66class YueCompilerImpl {
diff --git a/src/yuescript/yue_parser.cpp b/src/yuescript/yue_parser.cpp
index 9fca97e..f86afb4 100755
--- a/src/yuescript/yue_parser.cpp
+++ b/src/yuescript/yue_parser.cpp
@@ -678,6 +678,9 @@ YueParser::YueParser() {
678 678
679ParseInfo YueParser::parse(std::string_view codes, rule& r) { 679ParseInfo YueParser::parse(std::string_view codes, rule& r) {
680 ParseInfo res; 680 ParseInfo res;
681 if (codes.substr(0, 3) == "\xEF\xBB\xBF"sv) {
682 codes = codes.substr(3);
683 }
681 try { 684 try {
682 res.codes = std::make_unique<input>(); 685 res.codes = std::make_unique<input>();
683 *(res.codes) = _converter.from_bytes(&codes.front(), &codes.back() + 1); 686 *(res.codes) = _converter.from_bytes(&codes.front(), &codes.back() + 1);
diff --git a/src/yuescript/yuescript.h b/src/yuescript/yuescript.h
index a327387..2d2d660 100644
--- a/src/yuescript/yuescript.h
+++ b/src/yuescript/yuescript.h
@@ -40,7 +40,6 @@ yue.read_file = function(fname)
40 end 40 end
41 local text = assert(file:read("*a")) 41 local text = assert(file:read("*a"))
42 file:close() 42 file:close()
43 if string.sub(text, 1, 3) == "\239\187\191" then text = string.sub(text, 4) end
44 return text 43 return text
45end 44end
46local function get_options(...) 45local function get_options(...)