Skip to content

Commit 97d1d7f

Browse files
authored
Prompt user for grammar input when fn is empty
Add error message prompting for grammar input from stdin
1 parent b62e747 commit 97d1d7f

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

stable/QapGen/visitor_gen.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ struct t_templ_sys_v05:t_templ_sys_v04,
11381138
if(fn=="go_any")QapAssert(bad_type_checker(f.type,"string"));
11391139
if(fn=="go_any_char")QapAssert(bad_type_checker(f.type,"char"));
11401140
auto p0=cmd.params.arr[0].body;
1141-
auto p1=cmd.params.arr[1].body;// âûðàæåíèå òèïà gen_dips("09")+"str"+"other_str"
1141+
auto p1=cmd.params.arr[1].body;// âûðàæåíèå òèïà gen_dips("09")+"str"+"other_str"
11421142
t_cmd_param p1p;
11431143
QapAssert(load_obj(p1p,p1));
11441144
collect_expected_chars(p1p,out);
@@ -1152,7 +1152,7 @@ struct t_templ_sys_v05:t_templ_sys_v04,
11521152
auto&f=find_field(lexer,cpa0b);
11531153
QapAssert(bad_type_checker(f.type,"string"));
11541154
auto p0=cmd.params.arr[0].body;
1155-
auto p1=cmd.params.arr[1].body;// âûðàæåíèå òèïà split("0,9",",")
1155+
auto p1=cmd.params.arr[1].body;// âûðàæåíèå òèïà split("0,9",",")
11561156
t_cmd_param p1p;
11571157
QapAssert(load_obj(p1p,p1));
11581158
collect_expected_chars(p1p,out,true);
@@ -1580,7 +1580,7 @@ struct t_templ_sys_v05:t_templ_sys_v04,
15801580
}
15811581
return nullptr;
15821582
}
1583-
// Ðåêóðñèâíûé ïîèñê ëåêñåðà ñ èìåíåì name âíóòðè óçëà node
1583+
// Ðåêóðñèâíûé ïîèñê ëåêñåðà ñ èìåíåì name âíóòðè óçëà node
15841584
const t_lexer_node* findByNameInside(const t_lexer_node* node, const std::string& name) const {
15851585
if (!node) return nullptr;
15861586

@@ -1596,7 +1596,7 @@ struct t_templ_sys_v05:t_templ_sys_v04,
15961596
return nullptr;
15971597
}
15981598
const t_lexer_node* findLexerByNameRelative(const std::string& name, const t_lexer& from) const {
1599-
// 1. Íàéòè êîðíåâîé óçåë äëÿ from.name
1599+
// 1. Íàéòè êîðíåâîé óçåë äëÿ from.name
16001600
const t_lexer_node* fromNode = nullptr;
16011601
for (auto& n : lexers_nodes) {
16021602
if (n.lexer->fullname == from.fullname) {
@@ -1605,14 +1605,14 @@ struct t_templ_sys_v05:t_templ_sys_v04,
16051605
}
16061606
}
16071607

1608-
// 2. Åñëè íàøëè fromNode — èùåì âíóòðè íåãî
1608+
// 2. Åñëè íàøëè fromNode — èùåì âíóòðè íåãî
16091609
if (fromNode) {
16101610
if (auto* inside = findByNameInside(fromNode, name)) {
16111611
return inside;
16121612
}
16131613
}
16141614

1615-
// 3. Åñëè íå íàøëè âíóòðè, èùåì ïî àáñîëþòíîìó ïóòè (åñëè åñòü)
1615+
// 3. Åñëè íå íàøëè âíóòðè, èùåì ïî àáñîëþòíîìó ïóòè (åñëè åñòü)
16161616
if (name.size() >= 2 && name[0] == ':' && name[1] == ':') {
16171617
std::string absName = name.substr(2);
16181618
for (auto& root : lexers_nodes) {
@@ -1623,7 +1623,7 @@ struct t_templ_sys_v05:t_templ_sys_v04,
16231623
return nullptr;
16241624
}
16251625

1626-
// 4. Åñëè from.fullowner íå ïóñòîé — èùåì ïî ñîñòàâíîìó èìåíè
1626+
// 4. Åñëè from.fullowner íå ïóñòîé — èùåì ïî ñîñòàâíîìó èìåíè
16271627
if (!from.fullowner.empty()) {
16281628
std::vector<std::string> fromParts = split(from.fullowner, "::");
16291629
for (auto i = static_cast<long long int>(fromParts.size()) - 1; i >= 0; --i) {
@@ -1641,7 +1641,7 @@ struct t_templ_sys_v05:t_templ_sys_v04,
16411641
}
16421642
}
16431643

1644-
// 5. È, íàêîíåö, ãëîáàëüíûé ïîèñê ïî èìåíè
1644+
// 5. È, íàêîíåö, ãëîáàëüíûé ïîèñê ïî èìåíè
16451645
for (auto& root : lexers_nodes) {
16461646
if (auto* found = findByFullname(root, name)) {
16471647
return found;
@@ -1950,6 +1950,7 @@ static void test_2025_06_10(/*IEnvRTTI&Env*/string fn,bool dontoptimize=false)
19501950
gg=1;
19511951
string inp;
19521952
if(fn.empty()){
1953+
cerr<<"waiting when you type your grammar to stdin"<<endl;
19531954
string line;
19541955
while(std::getline(std::cin,line)){
19551956
inp+=line+"\n";
@@ -1976,4 +1977,4 @@ static void test_2025_06_10(/*IEnvRTTI&Env*/string fn,bool dontoptimize=false)
19761977
std::cout<<out;
19771978
std::cerr<<"{\"parse_ms\":"<<v5.parse_ms<<",\"total_ms\":"<<clock.MS()<<",\"lexers\":"<<v5.lexers.size()<<",\"fields\":"<<v5.fields_counter<<",\"g_unique_pool_ptr_counter\":"<<g_unique_pool_ptr_counter<<"}"<<endl;
19781979
gg=2;
1979-
}
1980+
}

0 commit comments

Comments
 (0)