diff options
author | Li Jin <dragon-fly@qq.com> | 2022-10-18 10:26:48 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2022-10-18 10:26:48 +0800 |
commit | 6b6e98d062c7ec5f11be79ed5164aa59047dab30 (patch) | |
tree | e0893ac6b3a8a64b81d81b03a8e413b112114586 | |
parent | 374292d175c0dcea8b24fc0dc4c0636e9cc85afa (diff) | |
download | yuescript-6b6e98d062c7ec5f11be79ed5164aa59047dab30.tar.gz yuescript-6b6e98d062c7ec5f11be79ed5164aa59047dab30.tar.bz2 yuescript-6b6e98d062c7ec5f11be79ed5164aa59047dab30.zip |
move utf8 bom skipping to parser.
-rw-r--r-- | src/yuescript/yue_compiler.cpp | 2 | ||||
-rwxr-xr-x | src/yuescript/yue_parser.cpp | 3 | ||||
-rw-r--r-- | src/yuescript/yuescript.h | 1 |
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 | ||
61 | typedef std::list<std::string> str_list; | 61 | typedef std::list<std::string> str_list; |
62 | 62 | ||
63 | const std::string_view version = "0.15.4"sv; | 63 | const std::string_view version = "0.15.5"sv; |
64 | const std::string_view extension = "yue"sv; | 64 | const std::string_view extension = "yue"sv; |
65 | 65 | ||
66 | class YueCompilerImpl { | 66 | class 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 | ||
679 | ParseInfo YueParser::parse(std::string_view codes, rule& r) { | 679 | ParseInfo 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 |
45 | end | 44 | end |
46 | local function get_options(...) | 45 | local function get_options(...) |