aboutsummaryrefslogtreecommitdiff
path: root/src/yuescript/yue_parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/yuescript/yue_parser.cpp37
1 files changed, 18 insertions, 19 deletions
diff --git a/src/yuescript/yue_parser.cpp b/src/yuescript/yue_parser.cpp
index ad76517..194d04d 100644
--- a/src/yuescript/yue_parser.cpp
+++ b/src/yuescript/yue_parser.cpp
@@ -358,7 +358,7 @@ YueParser::YueParser() {
358 }); 358 });
359 advance_match = and_(advance); 359 advance_match = and_(advance);
360 360
361 push_indent = pl::user(plain_space, [](const item_t& item) { 361 push_indent = pl::user(plain_space >> not_(stop), [](const item_t& item) {
362 int indent = 0; 362 int indent = 0;
363 for (input_it i = item.begin->m_it; i != item.end->m_it; ++i) { 363 for (input_it i = item.begin->m_it; i != item.end->m_it; ++i) {
364 switch (*i) { 364 switch (*i) {
@@ -738,12 +738,18 @@ YueParser::YueParser() {
738 return st->noChainBlockStack.empty() || !st->noChainBlockStack.back(); 738 return st->noChainBlockStack.empty() || !st->noChainBlockStack.back();
739 }) >> +space_break >> advance_match >> ensure( 739 }) >> +space_break >> advance_match >> ensure(
740 chain_line >> *(+space_break >> chain_line), pop_indent); 740 chain_line >> *(+space_break >> chain_line), pop_indent);
741 ChainValue = 741 ChainValue = Seperator >> (
742 Seperator >> 742 (
743 chain >> 743 chain >>
744 -ExistentialOp >> 744 -ExistentialOp >>
745 -(InvokeArgs | chain_block) >> 745 -(InvokeArgs | chain_block) >> -TableAppendingOp
746 -TableAppendingOp; 746 ) | String >> -(
747 and_(white >> set(".\\:")) >> (
748 chain_items >> -(InvokeArgs | chain_block) >> -TableAppendingOp |
749 chain_block >> -TableAppendingOp
750 )
751 )
752 );
747 753
748 inc_exp_level = pl::user(true_(), [](const item_t& item) { 754 inc_exp_level = pl::user(true_(), [](const item_t& item) {
749 State* st = reinterpret_cast<State*>(item.user_data); 755 State* st = reinterpret_cast<State*>(item.user_data);
@@ -762,7 +768,7 @@ YueParser::YueParser() {
762 }); 768 });
763 769
764 SimpleTable = Seperator >> key_value >> *(space >> ',' >> space >> key_value); 770 SimpleTable = Seperator >> key_value >> *(space >> ',' >> space >> key_value);
765 Value = inc_exp_level >> ensure(SimpleValue | SimpleTable | ChainValue | String, dec_exp_level); 771 Value = inc_exp_level >> ensure(SimpleValue | SimpleTable | ChainValue, dec_exp_level);
766 772
767 single_string_inner = '\\' >> set("'\\") | not_('\'') >> any_char; 773 single_string_inner = '\\' >> set("'\\") | not_('\'') >> any_char;
768 SingleString = '\'' >> *single_string_inner >> ('\'' | unclosed_single_string_error); 774 SingleString = '\'' >> *single_string_inner >> ('\'' | unclosed_single_string_error);
@@ -828,21 +834,13 @@ YueParser::YueParser() {
828 TableAppendingOp = and_('[') >> "[]"; 834 TableAppendingOp = and_('[') >> "[]";
829 PlainItem = +any_char; 835 PlainItem = +any_char;
830 836
831 chain_call = ( 837 chain_call = Callable >> -ExistentialOp >> -chain_items;
832 Callable >> -ExistentialOp >> -chain_items
833 ) | (
834 String >> chain_items
835 );
836 chain_index_chain = index >> -ExistentialOp >> -chain_items; 838 chain_index_chain = index >> -ExistentialOp >> -chain_items;
837 chain_dot_chain = DotChainItem >> -ExistentialOp >> -chain_items; 839 chain_dot_chain = DotChainItem >> -ExistentialOp >> -chain_items;
838 840
839 chain = chain_call | chain_dot_chain | colon_chain | chain_index_chain; 841 chain = chain_call | chain_dot_chain | colon_chain | chain_index_chain;
840 842
841 chain_call_list = ( 843 chain_call_list = Callable >> -ExistentialOp >> chain_items;
842 Callable >> -ExistentialOp >> chain_items
843 ) | (
844 String >> chain_items
845 );
846 chain_list = chain_call_list | chain_dot_chain | colon_chain | chain_index_chain; 844 chain_list = chain_call_list | chain_dot_chain | colon_chain | chain_index_chain;
847 845
848 AssignableChain = Seperator >> chain_list; 846 AssignableChain = Seperator >> chain_list;
@@ -1030,7 +1028,7 @@ YueParser::YueParser() {
1030 1028
1031 fn_arg_def_lit_lines = fn_arg_def_lit_line >> *(-(space >> ',') >> space_break >> fn_arg_def_lit_line); 1029 fn_arg_def_lit_lines = fn_arg_def_lit_line >> *(-(space >> ',') >> space_break >> fn_arg_def_lit_line);
1032 1030
1033 FnArgDef = (Variable | SelfItem >> -ExistentialOp) >> -(space >> '`' >> space >> Name) >> -(space >> '=' >> space >> Exp) | TableLit | SimpleTable; 1031 FnArgDef = (Variable | SelfItem >> -ExistentialOp) >> -(space >> '`' >> space >> Name) >> -(space >> '=' >> space >> Exp) | TableLit | SimpleTable | Comprehension;
1034 1032
1035 check_vararg_position = and_(white >> (')' | key("using"))) | white >> -(',' >> white) >> vararg_position_error; 1033 check_vararg_position = and_(white >> (')' | key("using"))) | white >> -(',' >> white) >> vararg_position_error;
1036 1034
@@ -1391,6 +1389,7 @@ std::string ParseInfo::errorMessage(std::string_view msg, int errLine, int errCo
1391 } 1389 }
1392 errorDisplayCol = displayCol; 1390 errorDisplayCol = displayCol;
1393 } 1391 }
1392 errorDisplayCol = std::max(errorDisplayCol, 1);
1394 1393
1395 for (int lineNum = startLine; lineNum <= endLine; ++lineNum) { 1394 for (int lineNum = startLine; lineNum <= endLine; ++lineNum) {
1396 int displayLineNum = lineNum + lineOffset; 1395 int displayLineNum = lineNum + lineOffset;