From: Didier 'Ptitjes Date: Sat, 31 Oct 2009 02:37:33 +0000 (+0100) Subject: Parser: Add support for <
> X-Git-Tag: 0.37.1~3^2~502 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=30ee5b0b29e7e61bfcbc2a24630c0fa0c18fea3d;p=thirdparty%2Fvala.git Parser: Add support for <
> --- diff --git a/src/libvaladoc/documentation/documentationparser.vala b/src/libvaladoc/documentation/documentationparser.vala index 28e0fcc38..c5edb741e 100644 --- a/src/libvaladoc/documentation/documentationparser.vala +++ b/src/libvaladoc/documentation/documentationparser.vala @@ -208,6 +208,14 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator { } } + private void add_content_string (string str) { + var text = peek () as Text; + if (text == null) { + push (text = _factory.create_text ()); + } + text.content += str; + } + private void init_rules () { // Inline rules @@ -215,11 +223,7 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator { run.set_name ("Run"); TokenType.Action add_text = (token) => { - var text = peek () as Text; - if (text == null) { - push (text = _factory.create_text ()); - } - text.content += token.to_string (); + add_content_string (token.to_string ()); }; TokenType word = TokenType.any_word ().action (add_text); @@ -233,6 +237,7 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator { Rule.many ({ Rule.one_of ({ word, + TokenType.BREAK.action ((token) => { add_content_string ("\n"); }), TokenType.LESS_THAN.action (add_text), TokenType.GREATER_THAN.action (add_text), TokenType.ALIGN_RIGHT.action (add_text), diff --git a/src/libvaladoc/documentation/wikiscanner.vala b/src/libvaladoc/documentation/wikiscanner.vala index 47640a7aa..c2ae1772e 100644 --- a/src/libvaladoc/documentation/wikiscanner.vala +++ b/src/libvaladoc/documentation/wikiscanner.vala @@ -226,7 +226,9 @@ public class Valadoc.WikiScanner : Object, Scanner { break; case '<': - emit_token (TokenType.LESS_THAN); + if (!look_for ("<
>", TokenType.BREAK)) { + emit_token (TokenType.LESS_THAN); + } break; case '>': @@ -383,4 +385,16 @@ public class Valadoc.WikiScanner : Object, Scanner { emit_token (one); } } + + private bool look_for (string str, TokenType type) throws ParserError { + for (int i = 1; i < str.length; i++) { + if (get_next_char (i) != str[i]) { + return false; + } + } + + emit_token (type); + _skip = (int) (str.length - 1); + return true; + } } diff --git a/src/libvaladoc/parser/tokentype.vala b/src/libvaladoc/parser/tokentype.vala index 598aac3e8..86f87dc4f 100644 --- a/src/libvaladoc/parser/tokentype.vala +++ b/src/libvaladoc/parser/tokentype.vala @@ -29,6 +29,7 @@ public class Valadoc.TokenType : Object { public static TokenType ANY_NUMBER; public static TokenType EOF; public static TokenType EOL; + public static TokenType BREAK; public static TokenType AROBASE; public static TokenType SPACE; public static TokenType TAB; @@ -68,6 +69,7 @@ public class Valadoc.TokenType : Object { ANY_NUMBER = new TokenType.basic (""); EOF = new TokenType.basic ("\0", ""); EOL = new TokenType.basic ("\n", ""); + BREAK = new TokenType.basic ("<
>"); AROBASE = new TokenType.basic ("@"); SPACE = new TokenType.basic (" ", ""); TAB = new TokenType.basic ("\t", "");