From: Didier 'Ptitjes Date: Mon, 12 Oct 2009 11:32:44 +0000 (+0200) Subject: Reorganize some classes and remove some garbage X-Git-Tag: 0.37.1~3^2~572 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=17cdb0ef6801c2b6d6a3cb87a32aeb430c5c4024;p=thirdparty%2Fvala.git Reorganize some classes and remove some garbage --- diff --git a/src/libvaladoc/Makefile.am b/src/libvaladoc/Makefile.am index 7b4a1f38d..59b2aedb1 100644 --- a/src/libvaladoc/Makefile.am +++ b/src/libvaladoc/Makefile.am @@ -23,13 +23,16 @@ valadocdir = $(libdir)/valadoc/ libvaladoc_la_VALASOURCES = \ doclet.vala \ drawer.vala \ + errorreporter.vala \ filehelper.vala \ langlet.vala \ + moduleloader.vala \ settings.vala \ + documentation/commentscanner.vala \ documentation/documentation.vala \ - documentation/errorreporter.vala \ - documentation/moduleloader.vala \ + documentation/documentationparser.vala \ documentation/wiki.vala \ + documentation/wikiscanner.vala \ apitree/apitree.vala \ apitree/array.vala \ apitree/basic.vala \ @@ -100,8 +103,6 @@ libvaladoc_la_VALASOURCES = \ content/tablerow.vala \ content/taglet.vala \ content/text.vala \ - parser/commentscanner.vala \ - parser/documentationparser.vala \ parser/manyrule.vala \ parser/oneofrule.vala \ parser/optionalrule.vala \ @@ -114,7 +115,6 @@ libvaladoc_la_VALASOURCES = \ parser/stubrule.vala \ parser/token.vala \ parser/tokentype.vala \ - parser/wikiscanner.vala \ taglets/tagletdeprecated.vala \ taglets/tagletinheritdoc.vala \ taglets/tagletinit.vala \ diff --git a/src/libvaladoc/parser/commentscanner.vala b/src/libvaladoc/documentation/commentscanner.vala similarity index 100% rename from src/libvaladoc/parser/commentscanner.vala rename to src/libvaladoc/documentation/commentscanner.vala diff --git a/src/libvaladoc/parser/documentationparser.vala b/src/libvaladoc/documentation/documentationparser.vala similarity index 100% rename from src/libvaladoc/parser/documentationparser.vala rename to src/libvaladoc/documentation/documentationparser.vala diff --git a/src/libvaladoc/documentation/parser.vala b/src/libvaladoc/documentation/parser.vala deleted file mode 100755 index 290525fac..000000000 --- a/src/libvaladoc/documentation/parser.vala +++ /dev/null @@ -1,1455 +0,0 @@ - -using GLib; - - - - -public class Valadoc.Parser : Object { - private ModuleLoader modules; - private Settings settings; - private ErrorReporter err; - private Tree tree; - - public Parser (Settings settings, ErrorReporter reporter, Tree tree, ModuleLoader modules) { - this.settings = settings; - this.modules = modules; - this.err = reporter; - this.tree = tree; - } - - /* == error: == */ - private enum ErrorNumber { - UNKNOWN_TAGLET, - MISSING_IMAGE, - INVALID_LINK, - OPEN_TAG, - TABLE_CELL_ATTRIBUTES, - TABLE_CELL, - CONTEXT - } - - private struct ErrMsg { - public ErrorLevel lvl; - public string msg; - } - - private const ErrMsg[] errmsg = { - { ErrorLevel.ERROR, "Taglet does not exist" }, - { ErrorLevel.ASSUMPTION, "Image not found" }, - { ErrorLevel.ASSUMPTION, "Invalid address specified" }, - { ErrorLevel.ASSUMPTION, "Tag may be not closed" }, - { ErrorLevel.ASSUMPTION, "Cell attributes may be broken" }, - { ErrorLevel.ASSUMPTION, "Cell may be broken" }, - { ErrorLevel.ERROR, "Taglet is not allowed in this context" } - }; - - private void printr ( ErrorNumber errno, string filename, string str, long strlen, long line, long linestartpos, long pos, long len ) { - this.printr_custom ( errmsg[(int)errno].lvl, filename, str, strlen, line, linestartpos, pos, len, errmsg[(int)errno].msg ); - } - - private void printr_custom ( ErrorLevel errlvl, string filename, string str, long strlen, long line, long linestartpos, long pos, long len, string errmsg ) { - if ( this.settings.verbose == false && errlvl == ErrorLevel.ASSUMPTION ) { - return ; - } - - weak string linestr = str.offset( linestartpos ); - if (linestr[0] == '\r') { - linestr = linestr.offset(1); -// linestartpos++; - len--; - } - - if ( linestr[0] == '\n' ) { - linestr = linestr.offset(1); -// linestartpos++; - len--; - } - - weak string end = linestr.chr( -1, '\n' ); - long linelen = (end == null)? (long)linestr.len() : linestr.pointer_to_offset(end); - - - long underlinestartpos = pos-linestartpos; - long underlineendpos = underlinestartpos+((len == -1)?(linelen-(pos-linestartpos)):len); - - if ( errlvl == ErrorLevel.ERROR ) { - this.err.error ( filename, line, underlinestartpos, /*pos-linestartpos*/ underlineendpos, linestr.ndup(linelen), errmsg ); - } - else { - this.err.warning ( filename, line, underlinestartpos, /*pos-linestartpos*/ underlineendpos, linestr.ndup(linelen), errmsg ); - } - } - - /* == helpers == */ - private StringTaglet create_string_taglet (string str, long strlen, ref long startpos, long pos, long lpos, StringBuilder buf ) { - buf.append_len (str.offset(startpos), lpos-startpos); - StringTaglet strtag = (StringTaglet)GLib.Object.new ( this.modules.string ); - strtag.parse ( buf.str ); - buf.erase ( 0, -1 ); - startpos = pos+1; - return strtag; - } - - private void prepend_string_taglet (string str, long strlen, Gee.ArrayList content, ref long startpos, long pos, long lpos, StringBuilder buf ) { - StringTaglet strtag = this.create_string_taglet (str, strlen, ref startpos, pos, lpos, buf ); - content.insert (content.size-1, strtag); - } - - private void append_string_taglet (string str, long strlen, Gee.ArrayList content, ref long startpos, long pos, long lpos, StringBuilder buf ) { - StringTaglet strtag = this.create_string_taglet ( str, strlen, ref startpos, pos, lpos, buf ); - content.add ( strtag ); - } - - - /* == rules: == */ - private bool skip_deadzone_pos ( string str, long strlen, ref long pos, ref long line, ref long linestartpos, bool wikimode ) { - linestartpos=pos; - for ( pos++; str[pos]==' '||str[pos]=='\t' ; pos++ ); - line++; - - if ( wikimode == false ) { - if ( str[pos]=='*' ) { - linestartpos = pos; - return true; - } - } - - linestartpos = --pos; - return true; - } - - private bool parse_newline_pos ( string str, long strlen, ref long npos, ref long nline, ref long nnewlinepos, bool wikimode ) { - if ( str[npos] == '\n' ) { - return this.skip_deadzone_pos (str, strlen, ref npos, ref nline, ref nnewlinepos, wikimode); - } - return false; - } - - private bool parse_linebreak_pos ( string str, long strlen, ref long npos, ref long nline, ref long nnewlinepos, bool wikimode) { - if ( str[npos] == '\\' ) { - long newlinepos = nnewlinepos; - long line = nline; - long pos = npos; - - long mpos = pos+1; - for ( ; str[mpos]==' '||str[mpos]=='\t' ; mpos++ ); - if ( str[mpos]=='\r' ) - mpos++; - - if ( str[mpos]=='\n' ) { - pos = mpos; - if (this.skip_deadzone_pos (str, strlen, ref pos, ref line, ref newlinepos, wikimode)) { - nnewlinepos = newlinepos; - nline = line; - npos = pos; - return true; - } - return false; - } - } - return false; - } - - private string? parse_taglet_name (Documentation? curelement, string str, long strlen, ref long pos, long line, long newlinepos, long npos, bool _inline) { - long startpos = pos; - for (; str[pos]!=' '&&str[pos]!='\t'&&str[pos]!='\n'&&str[pos]!='\0'&&(_inline&&str[pos+1]!='}'); pos++); - if (str[pos]=='\0'|| !str[pos].isspace()) { - if (curelement != null) { - this.printr (ErrorNumber.OPEN_TAG, curelement.get_filename(), str, strlen, line, newlinepos, npos, -1); - } - return null; - } - return str.substring (startpos, pos-startpos); - } - - private bool parse_inline_taglet_pos ( Documentation curelement, string str, long strlen, Gee.ArrayList content, ref long npos, ref long nline, ref long nnewlinepos, bool wikimode ) { - if ( str[npos] != '{' ) { - return false; - } - - long newlinepos = nnewlinepos; - long line = nline; - long pos = npos; - - - for (pos++; str[pos]!='@' && pos content, ref long pos, ref long line, ref long newlinepos, ref long space, bool wikimode ) { - if ( this.parse_align_helper (curelement, str, strlen, content, ref pos, ref line, ref newlinepos, ref space, wikimode, this.modules.right, "))" ) ) { - return true; - } - - if ( this.parse_align_helper (curelement, str, strlen, content, ref pos, ref line, ref newlinepos, ref space, wikimode, this.modules.center, ")(" ) ) { - return true; - } - return false; - } - - private bool parse_highlighting_pos (Documentation curelement, string str, long strlen, Gee.ArrayList content, ref long pos, ref long line, ref long newlinepos, bool wikimode ) { - if ( this.parse_bold_pos (curelement, str, strlen, content, ref pos, ref line, ref newlinepos, wikimode) ) { - return true; - } - else if ( this.parse_italic_pos (curelement, str, strlen, content, ref pos, ref line, ref newlinepos, wikimode) ) { - return true; - } - else if ( this.parse_underline_pos (curelement, str, strlen, content, ref pos, ref line, ref newlinepos, wikimode) ) { - return true; - } - return false; - } - - private bool parse_align_helper ( Documentation curelement, string str, long strlen, Gee.ArrayList content, ref long npos, ref long nline, ref long nnewlinepos, ref long space, bool wikimode, GLib.Type tagtype, string tag ) { - long newlinepos = nnewlinepos; - long line = nline; - long pos = npos; - - if ( !str.offset(pos).has_prefix(tag) ) - return false; - - for ( ; str[pos]==' '||str[pos]=='\t'; pos++ ); - - Gee.ArrayList subcontent = new Gee.ArrayList (); - StringBuilder buf = new StringBuilder (); - long startpos = pos + 2; - long lpos = startpos; - - - for (; pos content, ref long npos, ref long nline, ref long nnewlinepos, ref long nspace, bool wikimode ) { - weak string strpos = str.offset( npos ); - if ( !strpos.has_prefix( "[[warning:" ) ) { - return false; - } - - - Gee.ArrayList subcontent = new Gee.ArrayList (); - long newlinepos = nnewlinepos; - long pos = npos + 10; - long line = nline; - long space = 0; - - if(!this.skip_empty_spaces_pos (str, strlen, ref pos, ref line, ref newlinepos, ref space, wikimode)) { - return false; - } - - StringBuilder buf = new StringBuilder (); - long startpos = pos; - - for (; pos content, ref long npos, ref long nline, ref long nnewlinepos, ref long space, bool wikimode ) { - weak string strpos = str.offset( npos ); - if ( !strpos.has_prefix( "{{{" ) ) - return false; - - StringBuilder buf = new StringBuilder (); - long newlinepos = nnewlinepos; - long startpos = npos+3; - long pos = startpos; - long line = nline; - - - for ( long lpos = pos; pos content, ref long npos, ref long line, ref long newlinepos, bool wikimode ) { - return this.parse_highlighting_helper_pos (curelement, str, strlen, content, ref npos, ref line, ref newlinepos, wikimode, this.modules.bold, "++" ); - } - - private bool parse_italic_pos (Documentation curelement, string str, long strlen, Gee.ArrayList content, ref long npos, ref long line, ref long newlinepos, bool wikimode ) { - return this.parse_highlighting_helper_pos (curelement, str, strlen, content, ref npos, ref line, ref newlinepos, wikimode, this.modules.italic, "//" ); - } - - private bool parse_underline_pos (Documentation curelement, string str, long strlen, Gee.ArrayList content, ref long npos, ref long line, ref long newlinepos, bool wikimode ) { - return this.parse_highlighting_helper_pos (curelement, str, strlen, content, ref npos, ref line, ref newlinepos, wikimode, this.modules.underline, "__" ); - } - - private bool parse_highlighting_helper_pos (Documentation curelement, string str, long strlen, Gee.ArrayList content, ref long npos, ref long nline, ref long nnewlinepos, bool wikimode, GLib.Type tagtype, string markup ) { - weak string strpos = str.offset( npos ); - if ( !strpos.has_prefix( markup ) ) { - return false; - } - - Gee.ArrayList subcontent = new Gee.ArrayList (); - StringBuilder buf = new StringBuilder (); - long startpos = npos+2; - long pos = startpos; - - long newlinepos = nnewlinepos; - long line = nline; - - - for ( ; pos content, ref long npos, ref long line, ref long newlinepos, ref long space, bool wikimode ) { - StringBuilder buf = new StringBuilder (); - long startpos = npos; - long lpos = npos; - - for (; npos < strlen ; npos++ ) { - lpos = npos; - - if (this.parse_linebreak_pos (str, strlen, ref npos, ref line, ref newlinepos, wikimode) ) { - buf.append_len (str.offset(startpos), lpos-startpos); - startpos=npos+1; - continue; - } - - if (this.parse_newline_pos ( str, strlen, ref npos, ref line, ref newlinepos, wikimode)) { - npos++; - break; - } - - if (this.parse_inline_taglet_pos (curelement, str, strlen, content, ref npos, ref line, ref newlinepos, wikimode)) { - this.prepend_string_taglet ( str, strlen, content, ref startpos, npos, lpos, buf ); - } - else if ( this.parse_url_pos (curelement, str, strlen, content, ref npos, ref line, ref newlinepos ) ) { - this.prepend_string_taglet ( str, strlen, content, ref startpos, npos, lpos, buf ); - } - else if ( this.parse_highlighting_pos (curelement, str, strlen, content, ref npos, ref line, ref newlinepos, wikimode) ) { - this.prepend_string_taglet ( str, strlen, content, ref startpos, npos, lpos, buf ); - } - } - this.append_string_taglet ( str, strlen, content, ref startpos, lpos, lpos, buf ); - for ( ; str[npos]==' '||str[npos]=='\t' ; npos++, space++ ); - return true; - } - - private static bool check_img_url ( string url ) { - return FileUtils.test (url, FileTest.IS_REGULAR); - } - - private static bool check_url ( string url ) { - return url.has_prefix("http://") || url.has_prefix("http://") || (url.has_prefix("/")&&url.has_suffix(".valadoc")); - } - - private bool parse_url_pos ( Documentation curelement, string str, long strlen, Gee.ArrayList content, ref long rpos, ref long nline, ref long newlinepos ) { - if ( !str.offset(rpos).has_prefix ("[[") ) - return false; - - - //long newlinepos = nnewlinepos; - long pos = rpos+2; - long urlend = -1; - long line = nline; - - for ( ; pos content, ref long npos, ref long line, ref long newlinepos ) { - if ( str[npos]!='{'||str[npos+1]!='{' ) - return false; - - long pos = npos+2; - long urlend = -1; - - for ( ; pos content, ref long npos, ref long nline, ref long nnewlinepos, ref long nspace, ref int depth, bool wikimode ) { - if ( str[npos] != '@' ) { - return false; - } - - ErrorLevel errlvl = ErrorLevel.ASSUMPTION; - string errmsg; - - - long newlinepos = nnewlinepos; - long line = nline; - long pos = npos+1; - - long keywordnewlinepos = nnewlinepos; - long keywordstartpos = npos; - long keywordline = nline; - - - string keyword = this.parse_taglet_name (curelement, str, strlen, ref pos, line, newlinepos, npos, false); - if ( keyword == null ) { - return false; - } - - if ( !this.modules.taglets.contains(keyword) ) { - this.printr ( ErrorNumber.UNKNOWN_TAGLET, curelement.get_filename (), str, strlen, line, newlinepos, npos, keyword.len()+1 ); - return false; - } - - Taglet taglet = (Taglet)GLib.Object.new ( this.modules.taglets.get (keyword) ); - if ( taglet is MainTaglet == false ) { - this.printr ( ErrorNumber.CONTEXT, curelement.get_filename (), str, strlen, line, newlinepos, npos, keyword.len()+1 ); - return false; - } - - Gee.ArrayList subcontent = new Gee.ArrayList (); - StringBuilder buf = new StringBuilder (); - long startpos = pos+1; - long space = nspace; - long lpos = pos+1; - - for ( ; pos < strlen ; pos++ ) { - lpos = pos; - if (this.parse_linebreak_pos (str, strlen, ref pos, ref line, ref newlinepos, wikimode) ) { - buf.append_len (str.offset(startpos), lpos-startpos); - startpos=pos+1; - } - else if (this.parse_newline_pos (str, strlen, ref pos, ref line, ref newlinepos, wikimode)) { - buf.append_len (str.offset(startpos), lpos-startpos); - startpos=pos+1; - - for ( pos++; str[pos]=='\t'||str[pos]==' '; pos++); - - if (this.parse_taglet (curelement, str, strlen, content, ref pos, ref line, ref newlinepos, ref space, ref depth, wikimode ) ) { - this.append_string_taglet ( str, strlen, subcontent, ref startpos, pos, startpos, buf ); - - if ( !((MainTaglet)taglet).parse ( this.settings, this.tree, curelement, subcontent, ref errlvl, out errmsg ) ) { - this.printr_custom ( errlvl, curelement.get_filename (), str, strlen, keywordline, keywordnewlinepos, keywordstartpos, keyword.len()+1, errmsg ); - } - - nnewlinepos = newlinepos; - nspace=pos-startpos; - nline = line; - npos = pos; - - content.insert (content.size-depth, taglet); - depth++; - return true; - } - buf.append_c ( '\n' ); - pos--; - } - else if (this.parse_inline_taglet_pos (curelement, str, strlen, subcontent, ref pos, ref line, ref newlinepos, wikimode )) { - this.prepend_string_taglet ( str, strlen, subcontent, ref startpos, pos, lpos, buf ); - } - else if ( this.parse_url_pos (curelement, str, strlen, subcontent, ref pos, ref line, ref newlinepos ) ) { - this.prepend_string_taglet ( str, strlen, subcontent, ref startpos, pos, lpos, buf ); - } - else if ( this.parse_highlighting_pos (curelement, str, strlen, subcontent, ref pos, ref line, ref newlinepos, wikimode) ) { - this.prepend_string_taglet ( str, strlen, subcontent, ref startpos, pos, lpos, buf ); - } - } - this.append_string_taglet ( str, strlen, subcontent, ref startpos, pos, lpos, buf ); - - if ( !((MainTaglet)taglet).parse ( this.settings, this.tree, curelement, subcontent, ref errlvl, out errmsg ) ) { - this.printr_custom ( errlvl, curelement.get_filename (), str, strlen, keywordline, keywordnewlinepos, keywordstartpos, keyword.len()+1, errmsg ); - } - - nnewlinepos = newlinepos; - nspace=pos-startpos; - nline = line; - npos = pos; - - content.add ( taglet ); - depth++; - return true; - } - - private bool extract_color ( string str, long strlen, ref long pos, out int nr ) { - long startpos = pos; - - for ( pos++; str[pos].isdigit()||(str[pos]>='A'&&str[pos]<='F')||(str[pos]>='a'&&str[pos]<='f'); pos++ ); - pos--; - - string strnr = str.offset(startpos+1).ndup(pos-startpos); - startpos = pos-startpos; - - if ( startpos != 3 && startpos != 6 ) { - return false; - } - - strnr.scanf ("%x", out nr); - return true; - } - - private bool extract_decimal ( string str, long strlen, ref long pos, out int nr ) { - long startpos = pos; - - for ( pos++; str[pos].isdigit(); pos++ ); - pos--; - - string strnr = str.offset(startpos+1).ndup(pos-startpos); - nr = strnr.to_int(); - return true; - } - - private long get_table_cell_attributes_error_len ( string str, long strlen, long startpos ) { - weak string strstartpos = str.offset(startpos); - - weak string? endposstr = strstartpos.chr (-1, '>'); - weak string? cellendstr = strstartpos.str("||"); - weak string? lineendstr = strstartpos.chr (-1, '\n'); - - long endpos = (endposstr == null)? long.MAX : (strstartpos.pointer_to_offset(endposstr)+1); - long cellend = (cellendstr == null)? long.MAX : strstartpos.pointer_to_offset(cellendstr); - long lineend = (lineendstr == null)? long.MAX : strstartpos.pointer_to_offset(lineendstr); - - return long.min(long.min( long.min( cellend, lineend), endpos), strlen-startpos); - } - - private bool parse_table_cell_attributes (Documentation curelement, string str, long strlen, ref long npos, long line, long newlinepos, out TextPosition vpos, out TextVerticalPosition hpos, out int hwidth, out int vwidth, out int color) { - if ( str[npos] != '<' ) { - return false; - } - - hpos = TextVerticalPosition.MIDDLE; - vpos = TextPosition.LEFT; - hwidth = 1; - vwidth = 1; - color = -1; - - - for ( long pos = npos+1; pos < strlen; pos++ ) { - switch ( str[pos] ) { - case '-': - if ( !this.extract_decimal ( str, strlen, ref pos, out hwidth ) ) { - this.printr ( ErrorNumber.TABLE_CELL_ATTRIBUTES, curelement.get_filename (), str, strlen, line, newlinepos, npos, this.get_table_cell_attributes_error_len (str, strlen, npos) ); - return false; - } - break; - case '|': - if ( !this.extract_decimal ( str, strlen, ref pos, out vwidth ) ) { - this.printr ( ErrorNumber.TABLE_CELL_ATTRIBUTES, curelement.get_filename (), str, strlen, line, newlinepos, npos, this.get_table_cell_attributes_error_len (str, strlen, npos) ); - return false; - } - break; - case ')': - switch ( str[pos+1] ) { - case '(': - vpos = TextPosition.CENTER; - pos++; - break; - case ')': - vpos = TextPosition.RIGHT; - pos++; - break; - default: - this.printr ( ErrorNumber.TABLE_CELL_ATTRIBUTES, curelement.get_filename (), str, strlen, line, newlinepos, npos, this.get_table_cell_attributes_error_len (str, strlen, npos) ); - return false; - } - break; - case '#': - if ( !this.extract_color(str, strlen, ref pos, out color) ) { - this.printr ( ErrorNumber.TABLE_CELL_ATTRIBUTES, curelement.get_filename (), str, strlen, line, newlinepos, npos, this.get_table_cell_attributes_error_len (str, strlen, npos) ); - return false; - } - break; - case '>': - npos = pos+1; - return true; - case 'v': - hpos = TextVerticalPosition.BOTTOM; - break; - case '^': - hpos = TextVerticalPosition.TOP; - break; - case '\t': - break; - case ' ': - break; - default: - this.printr ( ErrorNumber.TABLE_CELL_ATTRIBUTES, curelement.get_filename (), str, strlen, line, newlinepos, npos, this.get_table_cell_attributes_error_len (str, strlen, npos) ); - return false; - } - } - this.printr ( ErrorNumber.TABLE_CELL_ATTRIBUTES, curelement.get_filename (), str, strlen, line, newlinepos, npos, this.get_table_cell_attributes_error_len (str, strlen, npos) ); - return false; - } - - private bool parse_table_cell ( Documentation curelement, string str, long strlen, Gee.ArrayList cells, ref long pos, ref long line, ref long newlinepos, bool wikimode ) { - if ( !str.offset(pos).has_prefix("||") ) { - return false; - } - - Gee.ArrayList content = new Gee.ArrayList (); - StringBuilder buf = new StringBuilder (); - pos = pos + 2; - long lpos; - - TextVerticalPosition hpos; - TextPosition vpos; - int hwidth; - int vwidth; - int color; - - long cellstartnewlinepos = newlinepos; - long cellstartline = line; - long cellstartpos = pos; - - this.parse_table_cell_attributes (curelement, str, strlen, ref pos, line, newlinepos, out vpos, out hpos, out hwidth, out vwidth, out color); - - for ( long startpos = pos; pos < strlen ; pos++ ) { - lpos = pos; - if ( str.offset(pos).has_prefix("||") ) { - this.append_string_taglet ( str, strlen, content, ref startpos, pos, lpos, buf ); - - TableCellDocElement celltag = (TableCellDocElement)GLib.Object.new ( this.modules.table_cell ); - celltag.parse ( vpos, hpos, hwidth, vwidth, content ); - cells.add ( celltag ); - return true; - } - else if (this.parse_linebreak_pos (str, strlen, ref pos, ref line, ref newlinepos, wikimode) ) { - buf.append_len (str.offset(startpos), lpos-startpos); - startpos=pos+1; - } - else if (this.parse_inline_taglet_pos (curelement, str, strlen, content, ref pos, ref line, ref newlinepos, wikimode )) { - this.prepend_string_taglet ( str, strlen, content, ref startpos, pos, lpos, buf ); - startpos=pos+1; - } - else if ( this.parse_url_pos (curelement, str, strlen, content, ref pos, ref line, ref newlinepos ) ) { - this.prepend_string_taglet ( str, strlen, content, ref startpos, pos, lpos, buf ); - } - else if ( this.parse_img_pos (curelement, str, strlen, content, ref pos, ref line, ref newlinepos ) ) { - this.prepend_string_taglet ( str, strlen, content, ref startpos, pos, lpos, buf ); - } - else if ( this.parse_highlighting_pos (curelement, str, strlen, content, ref pos, ref line, ref newlinepos, wikimode) ) { - this.prepend_string_taglet ( str, strlen, content, ref startpos, pos, lpos, buf ); - } - else if (this.parse_newline_pos (str, strlen, ref pos, ref line, ref newlinepos, wikimode)) { - this.printr ( ErrorNumber.TABLE_CELL, curelement.get_filename (), str, strlen, cellstartline, cellstartnewlinepos, cellstartpos, -1 ); - return false; - } - } - this.printr ( ErrorNumber.TABLE_CELL, curelement.get_filename (), str, strlen, cellstartline, cellstartnewlinepos, cellstartpos, -1 ); - return false; - } - - private bool parse_is_last_table_cell ( string str, long strlen, ref long npos, ref long nline, ref long newlinepos, out long nspace, bool wikimode) { - long line = nline; - long pos = npos; - - for ( pos = pos+2; str[pos]==' '||str[pos]=='\t' ; pos++ ); - - if ( this.parse_newline_pos(str, strlen, ref pos, ref line, ref newlinepos, wikimode) ) { - for ( nspace=++pos; str[pos]==' '||str[pos]=='\t' ; pos++ ); - nspace = pos-nspace; - nline = line; - npos = pos-1; - return true; - } - - return false; - } - - private bool parse_table_row ( Documentation curelement, string str, long strlen, Gee.ArrayList> rows, ref long npos, ref long nline, ref long nnewlinepos, ref long nspace, bool wikimode ) { - if ( !str.offset(npos).has_prefix("||") ) { - return false; - } - - Gee.ArrayList cells = new Gee.ArrayList (); - long newlinepos = nnewlinepos; - long space = nspace; - long line = nline; - long pos = npos; - do { - if (!this.parse_table_cell ( curelement, str, strlen, cells, ref pos, ref line, ref newlinepos, wikimode )) { - return false; - } - - if ( this.parse_is_last_table_cell (str, strlen, ref pos, ref line, ref newlinepos, out space, wikimode) ) { - break; - } - } - while (pos < strlen); - - nnewlinepos = newlinepos; - nspace = space; - nline = line; - npos = pos; - rows.add ( cells ); - return true; - } - - private bool parse_table ( Documentation curelement, string str, long strlen, Gee.ArrayList content, ref long npos, ref long nline, ref long nnewlinepos, ref long nspace, bool wikimode ) { - if ( !str.offset(npos).has_prefix("||") ) { - return false; - } - - Gee.ArrayList> rows = new Gee.ArrayList> (); - - for (;this.parse_table_row (curelement, str, strlen, rows, ref npos, ref nline, ref nnewlinepos, ref nspace, wikimode); npos++); - - if ( rows.size == 0 ) { - return false; - } - - npos--; - - TableDocElement tabletag = (TableDocElement)GLib.Object.new ( this.modules.table ); - tabletag.parse ( rows ); - content.add ( tabletag ); - return true; - } - - private bool parse_inherit_doc_taglet_pos ( string str, long strlen, ref uint counter, ref long npos, ref long nline, ref long nnewlinepos ) { - if ( str[npos] != '{' ) - return false; - - long newlinepos = nnewlinepos; - long line = nline; - long pos = npos; - - for (pos++; str[pos]!='@' && pos 0; - } - - private bool parse_headline_pos ( string str, long strlen, Gee.ArrayList content, ref long npos, ref long nline, ref long nnewlinepos, ref long space, bool wikimode ) { - weak string startstr = str.offset(npos); - if ( !startstr.has_prefix("==") ) { - return false; - } - - long pos = npos+2; - int lvl = 0; - - for ( startstr = startstr.offset(2); startstr[lvl]=='=' ; lvl++ ); - lvl++; - - if ( lvl > 5 ) { - return false; - } - - GLib.StringBuilder buf = new GLib.StringBuilder(); - long newlinepos = nnewlinepos; - long startpos = pos+lvl; - long rpos = startpos; - long line = nline; - - for ( ; rpos content = new Gee.ArrayList (); - GLib.StringBuilder buf = new GLib.StringBuilder(); - weak string str = wikipage.documentation_str; - long strlen = str.len(); - long newlinepos = 0; - long startpos = 0; - long line = 1; - long lpos = 0; - long pos = 0; - - for ( pos=0; str[pos]==' '||str[pos]=='\t' ; pos++ ); - long linestart = pos; - long space = pos; - - for ( ; pos content = new Gee.ArrayList (); - DocumentationTree doctree = new DocumentationTree (); - long strlen = str.len(); - long newlinepos = 0; - long space = 0; - int depth = 0; - long line = 0; - long pos = 0; - - if (!this.skip_header_pos ( str, strlen, ref pos, ref line, ref newlinepos, false )) { - return null; - } - - if(!this.parse_short_desc_pos(self, str, strlen, content, ref pos, ref line, ref newlinepos, ref space, false )) { - return null; - } - - doctree.add_brief ( content ); - - StringBuilder buf = new StringBuilder (); - long startpos = pos; //+1 - long linestart = pos; - long lpos = pos; - - content = new Gee.ArrayList (); - - - for ( ; pos taglets = new Gee.ArrayList(); - - this.parse_taglet ( self, str, strlen, taglets, ref pos, ref line, ref newlinepos, ref space, ref depth, false ); - this.append_string_taglet ( str, strlen, content, ref startpos, strlen-1, lpos, buf ); - doctree.add_description ( content ); - doctree.add_taglets (taglets); - return doctree; - } - else if ( this.parse_table ( self, str, strlen, content, ref pos, ref line, ref newlinepos, ref space, false ) ) { - this.prepend_string_taglet ( str, strlen, content, ref startpos, pos, lpos, buf ); - linestart = startpos = pos+1; - continue ; - } - } - - if (this.parse_inline_taglet_pos ( self, str, strlen, content, ref pos, ref line, ref newlinepos, false )) { - this.prepend_string_taglet ( str, strlen, content, ref startpos, pos, lpos, buf ); - } - else if ( this.parse_url_pos ( self, str, strlen, content, ref pos, ref line, ref newlinepos ) ) { - this.prepend_string_taglet ( str, strlen, content, ref startpos, pos, lpos, buf ); - } - else if ( this.parse_img_pos ( self, str, strlen, content, ref pos, ref line, ref newlinepos ) ) { - this.prepend_string_taglet ( str, strlen, content, ref startpos, pos, lpos, buf ); - } - else if ( this.parse_highlighting_pos ( self, str, strlen, content, ref pos, ref line, ref newlinepos, false ) ) { - this.prepend_string_taglet ( str, strlen, content, ref startpos, pos, lpos, buf ); - } - } - - this.append_string_taglet ( str, strlen, content, ref startpos, strlen-1, lpos, buf ); - doctree.add_description ( content ); - return doctree; - } - - private bool skip_header_pos ( string str, long strlen, ref long npos, ref long line, ref long linestartpos, bool wikimode ) { - if ( str[0] != '*' ) { - return false; - } - - for (; str[npos]=='*'; npos++ ); - for (; str[npos]==' '||str[npos]=='\t'; npos++ ); - - this.parse_newline_pos (str, strlen, ref npos, ref line, ref linestartpos, wikimode); - if ( str[npos]=='*' ) { - npos++; - } - return true; - } - - private bool skip_empty_spaces_pos ( string str, long strlen, ref long npos, ref long nline, ref long nnewlinepos, ref long space, bool wikimode ) { - long newlinepos = nnewlinepos; - long line = nline; - long pos = npos; - long lpos = 0; - do { - for (lpos = pos; str[pos]==' '|| str[pos]=='\t';pos++); - space = pos-lpos; - - if(this.parse_newline_pos (str, strlen, ref pos, ref line, ref newlinepos, wikimode)) { - pos++; - } - } while (lpos!=pos); - nnewlinepos = newlinepos; - nline = line; - npos = pos; - return true; - } - - public static bool is_documentation ( string cmnt ) { - return cmnt[0] == '*'; - } - - private bool parse_list_template_pos ( Documentation curelement, string str, long strlen, Gee.ArrayList content, ref long pos, ref long line, ref long newlinepos, ref long space, ref long linestart, bool wikimode, ListType listtype, unichar tag ) { - if ( str[pos]!=tag ) - return false; - - Gee.ArrayList listelements = new Gee.ArrayList (); - long lspace = space; - - do { - if(!this.parse_list_entry_pos ( curelement, str, strlen, listelements, ref pos, ref line, ref newlinepos, out space, wikimode, listtype, tag )) - break; - - if ( space > lspace ) { - if (this.parse_unsorted_list_pos ( curelement, str, strlen, listelements, ref pos, ref line, ref newlinepos, ref space, ref linestart, wikimode )){ - continue; - } - if (this.parse_sorted_list_pos ( curelement, str, strlen, listelements, ref pos, ref line, ref newlinepos, ref space, ref linestart, wikimode )){ - continue; - } - } - } - while ( pos < strlen && space == lspace ); - - ListDocElement listtag = (ListDocElement)GLib.Object.new ( this.modules.list ); - listtag.parse ( listtype, listelements ); - content.add ( listtag ); - return true; - } - - private bool parse_unsorted_list_pos ( Documentation curelement, string str, long strlen, Gee.ArrayList content, ref long pos, ref long line, ref long newlinepos, ref long space, ref long linestart, bool wikimode ) { - return parse_list_template_pos ( curelement, str, strlen, content, ref pos, ref line, ref newlinepos, ref space, ref linestart, wikimode, ListType.UNSORTED, '-' ); - } - - private bool parse_sorted_list_pos ( Documentation curelement, string str, long strlen, Gee.ArrayList content, ref long pos, ref long line, ref long newlinepos, ref long space, ref long linestart, bool wikimode ) { - return parse_list_template_pos ( curelement, str, strlen, content, ref pos, ref line, ref newlinepos, ref space, ref linestart, wikimode, ListType.SORTED, '#' ); - } - - private bool parse_list_pos ( Documentation curelement, string str, long strlen, Gee.ArrayList content, ref long npos, ref long line, ref long newlinepos, ref long space, ref long linestart, bool wikimode ) { - if (this.parse_unsorted_list_pos ( curelement, str, strlen, content, ref npos, ref line, ref newlinepos, ref space, ref linestart, wikimode )) { - npos--; - return true; - } - if (this.parse_sorted_list_pos ( curelement, str, strlen, content, ref npos, ref line, ref newlinepos, ref space, ref linestart, wikimode )) { - npos--; - return true; - } - return false; - } - - private bool parse_list_entry_pos ( Documentation curelement, string str, long strlen, Gee.ArrayList listelements, ref long npos, ref long line, ref long newlinepos, out long space, bool wikimode, ListType listtype, unichar tag ) { - if ( str[npos]!=tag ) - return false; - - - Gee.ArrayList content = new Gee.ArrayList (); - StringBuilder buf = new StringBuilder (); - long startpos = npos+1; - long lpos = startpos; - long pos = npos+1; - - for ( ; pos Joint Header Cell || - * ||
Joint Cell || Cell3 || - * || Cell1 || <|2> Joint Cell || - * - * == Header 2 == - * === Header 3 === - * One can write immediately after headers - * - * ==== Header 4 ==== - * A. Mixed with ordered items - * 1. Another ordered items - * - * And some other data - * - * @param test a test parameter - * that continues here - * @return the value it returns - * and this is the @@last line - \ No newline at end of file diff --git a/src/libvaladoc/testparser.sh b/src/libvaladoc/testparser.sh deleted file mode 100755 index 46c8c5177..000000000 --- a/src/libvaladoc/testparser.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh - -DEBUG_FLAGS="" -#DEBUG_FLAGS="$DEBUG_FLAGS -D DEBUG" -#DEBUG_FLAGS="$DEBUG_FLAGS -D HARD_DEBUG" -#DEBUG_FLAGS="$DEBUG_FLAGS -D VERY_HARD_DEBUG" - -COMMAND="./testparser testcomment.test" -COMMAND="gdb -ex run -ex bt -ex finish -ex quit --args $COMMAND" - -valac -C $DEBUG_FLAGS -g -o testparser --pkg vala-1.0 \ - parser/commentscanner.vala \ - parser/documentationfactory.vala \ - parser/documentationparser.vala \ - parser/manyrule.vala \ - parser/oneofrule.vala \ - parser/parser.vala \ - parser/parsercallback.vala \ - parser/rule.vala \ - parser/scanner.vala \ - parser/sequencerule.vala \ - parser/stubrule.vala \ - parser/token.vala \ - parser/wikiscanner.vala \ - documentation/errorreporter.vala \ - settings.vala \ - testparser.vala \ -&& valac $DEBUG_FLAGS -g -o testparser --pkg vala-1.0 \ - parser/commentscanner.vala \ - parser/documentationfactory.vala \ - parser/documentationparser.vala \ - parser/manyrule.vala \ - parser/oneofrule.vala \ - parser/parser.vala \ - parser/parsercallback.vala \ - parser/rule.vala \ - parser/scanner.vala \ - parser/sequencerule.vala \ - parser/stubrule.vala \ - parser/token.vala \ - parser/wikiscanner.vala \ - documentation/errorreporter.vala \ - settings.vala \ - testparser.vala \ -&& $COMMAND diff --git a/src/libvaladoc/testparser.vala b/src/libvaladoc/testparser.vala deleted file mode 100644 index fff2230d5..000000000 --- a/src/libvaladoc/testparser.vala +++ /dev/null @@ -1,16 +0,0 @@ -/** Just a test file for parser2 **/ - -namespace Valadoc { - void main (string[] args) { - Settings settings = new Settings (); - ErrorReporter reporter = new ErrorReporter (); - DocumentationParser parser = new DocumentationParser(settings, reporter); - - string filename = args[1]; - string content; - if (FileUtils.get_contents (filename, out content)) { - Object root = parser.parse_comment (content, filename, 0, 0); - stdout.printf ("\n%s\n", ((Node) root).to_string ()); - } - } -}