static tree parse_comment (string s, int& i) { string comment= parse_delimited (s, i, "(*", "*)", false); if (is_star_rule (comment, 0)) return compound ("hrule"); return compound ("coq-comment", from_verbatim (comment, false)); }
static tree parse_coqdoc_hide_show_comment (string str, int &i) { tree r (UNINIT); string s= parse_delimited (str, i, "(*", "*)", false); int j= 0, n= N(s); while (j<n && s[j] == ' ') j++; if (test(s, j, "begin")) { r= tree (BEGIN); j+= 5; } else if (test(s, j, "end")) { r= tree (END); j+= 3; } else return r; while (j<n && s[j] == ' ') j++; if (test(s, j, "hide") || test(s, j, "show")) { r << s (j, j+4); return r; } return tree (UNINIT); }
static tree parse_coqdoc (string s, int& i) { string coqdoc= parse_delimited (s, i, "(*", "*)", false); coqdoc= trim_spaces (coqdoc (1, N(coqdoc))); return compound ("coq-coqdoc", coqdoc_to_tree (coqdoc)); }
static tree coqdoc_to_tree (string s) { bool newline= true; int i=0, n= N(s); tree coqdoc (DOCUMENT), line (CONCAT); if (starts (s, "(**")) { line << "(**"; i+= 3; } while (i < n) { if (test (s, i, "[[\n")) { add_line (line, coqdoc); tree vernac= vernac_to_tree (parse_delimited (s, i, "[[\n", "\n]]", false)); coqdoc << compound ("coqdoc-vernac", vernac); newline= true; } else if (s[i] == '[') line << compound ("coqdoc-coq", from_verbatim (parse_delimited (s, i, "[", "]", false))); else if (newline && (test (s, i, "**** ") || test (s, i, "*** ") || test (s, i, "** ") || test (s, i, "* "))) { string header= "section"; if (test (s, i, "** ")) header= "subsection"; if (test (s, i, "*** ")) header= "subsubsection"; if (test (s, i, "**** ")) header= "paragraph"; while (i<n && s[i] == '*') i++; while (i<n && is_spacing (s[i])) i++; int start= i; while (i<n && (s[i] != '\n' && !test (s, i, "*)"))) i++; line << compound (header, coqdoc_to_tree (s (start, i))); } else if (newline && is_defining_pretty_printing (s, i)) { string str= parse_delimited (s, i, "(*", "*)", false); parse_pretty_printing_definition (str); } else if (newline && is_removing_pretty_printing (s, i)) { string str= parse_delimited (s, i, "(*", "*)", false); parse_pretty_printing_removal (str); } else if (test (s, i, "%%")) { line << "%"; newline= false; i+= 2; } else if (test (s, i, "$$")) { line << "$"; newline= false; i+= 2; } else if (test (s, i, "##")) { line << "#"; newline= false; i+= 2; } else if (s[i] == '#' || s[i] == '%' || s[i] == '$') { newline= false; char delim= s[i]; string ext= unescape_coqdoc (parse_delimited (s, i, delim)); tree tm; if (delim == '#') tm= compound ("coqdoc-html", generic_to_tree (ext, "html-snippet")); else if (delim == '$') tm= compound ("coqdoc-latex", generic_to_tree ("$"*ext*"$", "latex-snippet")); else if (delim == '%') tm= compound ("coqdoc-latex", generic_to_tree (ext, "latex-snippet")); if (is_multi_paragraph (tm)) { add_line (line, coqdoc); coqdoc << tm; } else line << tm; } else if (is_list_begining (s, i)) { tree list= parse_list (s, i); add_line (line, coqdoc); coqdoc << list; newline= true; } else if (test (s, i, "\n<<")) { add_line (line, coqdoc); string parsed= parse_delimited (s, i, "\n<<", "\n>>", false); if (N(parsed) > 0 && parsed[0] == '\n') parsed= parsed(1, N(parsed)); tree verb= verbatim_to_tree (parsed, false, "SourceCode"); if (is_atomic (verb)) verb= document (verb); coqdoc << compound ("coqdoc-verbatim", verb); newline= true; } else if (test (s, i, "<<")) { string parsed= parse_delimited (s, i, "<<", ">>", false); tree verb= verbatim_to_tree (parsed, true, "SourceCode"); line << compound ("coqdoc-verbatim", verb); } else if (s[i] == '_' && (i == 0 || !start_ident(s[i-1]))) { line << coqdoc_parse_emphasis (s, i); newline= false; } else if (test (s, i, "----")) { i+= 4; add_line (line, coqdoc); coqdoc << compound ("hrule"); while (i<n && s[i] == '-') i++; newline= true; } else if (s[i] == '\n') { add_line (line, coqdoc); i++; if (is_whiteline (s, i)) { coqdoc << ""; do skip_whiteline (s, i); while (is_whiteline (s, i)); i--; } newline= true; } else if (s[i] == '<') { line << "<less>"; i++; newline= false; } else if (s[i] == '>') { line << "<gtr>"; i++; newline= false; } else { if (!is_spacing (s[i])) newline= false; int start= i; decode_from_utf8 (s, i); line << from_verbatim (s(start, i)); } } if (N(line) > 0) add_line (line, coqdoc); if (N(coqdoc) == 0) return ""; else if (N(coqdoc) == 1) return coqdoc[0]; else return coqdoc; }
std::vector<std::string *> SQL_ROW::parse_list(std::string &s) { // Parses informix lists of the format "LIST{a,b,c}" return parse_delimited(s,'{','}'); }
std::vector<std::string *> SQL_ROW::parse_type(std::string &s) { // Parses informix defined types of the format "ROW(a,b,c)::typename" return parse_delimited(s,'(',')'); }