break;
default:
- reporter.simple_warning ("GtkDoc: unsupported list type: %s".printf (list.bullet.to_string ()));
+ reporter.simple_warning ("GtkDoc: unsupported list type: %s", list.bullet.to_string ());
break;
}
var xml_file = Path.build_filename (xml_dir, "%s.xml".printf (to_docbook_id (name)));
var writer = new TextWriter (xml_file, "w");
if (!writer.open ()) {
- reporter.simple_error ("GtkDoc: unable to open %s for writing".printf (writer.filename));
+ reporter.simple_error ("GtkDoc: unable to open %s for writing", writer.filename);
return false;
}
writer.write_line (to_string (reporter));
unowned string[] gtkdoc_args = args;
opt_context.parse (ref gtkdoc_args);
} catch (OptionError e) {
- reporter.simple_error ("GtkDoc: Error: %s\nRun '-X --help' to see a full list of available command line options.".printf (e.message));
+ reporter.simple_error ("GtkDoc: Error: %s\nRun '-X --help' to see a full list of available command line options.", e.message);
return false;
}
}
if (!copy_file (filename, Path.build_filename (comments_dir, Path.get_basename (filename)))) {
- reporter.simple_error ("GtkDoc: Can't copy %s".printf (filename));
+ reporter.simple_error ("GtkDoc: Can't copy %s", filename);
}
}
prepared += filename;
if (!FileUtils.test (filename, FileTest.EXISTS)) {
- reporter.simple_error ("GtkDoc: %s not found".printf (relative_filename));
+ reporter.simple_error ("GtkDoc: %s not found", relative_filename);
continue;
}
} else if (filename.has_suffix (".h")) {
prepare_h_file (filename);
} else {
- reporter.simple_error ("GtkDoc: %s is not a supported source file type. Only .h, and .c files are supported.".printf (relative_filename));
+ reporter.simple_error ("GtkDoc: %s is not a supported source file type. Only .h, and .c files are supported.", relative_filename);
}
}
try {
Process.spawn_sync (settings.path, args, null, SpawnFlags.SEARCH_PATH, null, null, null);
} catch (Error e) {
- reporter.simple_error ("gtkdoc-scan: %s".printf (e.message));
+ reporter.simple_error ("gtkdoc-scan: %s", e.message);
return false;
}
string cflags;
Process.spawn_sync (null, pc_cflags, null, SpawnFlags.SEARCH_PATH, null, out cflags, out stderr, out status);
if (status != 0) {
- reporter.simple_error ("GtkDoc: pkg-config cflags error: %s".printf (stderr));
+ reporter.simple_error ("GtkDoc: pkg-config cflags error: %s", stderr);
return false;
}
cflags = cflags.strip ();
string libs;
Process.spawn_sync (null, pc_libs, null, SpawnFlags.SEARCH_PATH, null, out libs, out stderr, out status);
if (status != 0) {
- reporter.simple_error ("GtkDoc: pkg-config libs error: %s".printf (stderr));
+ reporter.simple_error ("GtkDoc: pkg-config libs error: %s", stderr);
return false;
}
Process.spawn_sync (settings.path, args, env, SpawnFlags.SEARCH_PATH, null, null, null);
} catch (Error e) {
- reporter.simple_error ("gtkdoc-scangobj: %s".printf (e.message));
+ reporter.simple_error ("gtkdoc-scangobj: %s", e.message);
return false;
}
try {
Process.spawn_sync (settings.path, args, null, SpawnFlags.SEARCH_PATH, null, null, null);
} catch (Error e) {
- reporter.simple_error ("gtkdoc-mkdb: %s".printf (e.message));
+ reporter.simple_error ("gtkdoc-mkdb: %s", e.message);
return false;
}
try {
FileUtils.get_contents (main_file, out contents);
} catch (Error e) {
- reporter.simple_error ("GtkDoc: Error while reading main file '%s' contents: %s".printf (main_file, e.message));
+ reporter.simple_error ("GtkDoc: Error while reading main file '%s' contents: %s", main_file, e.message);
return false;
}
try {
FileUtils.set_contents (main_file, contents);
} catch (Error e) {
- reporter.simple_error ("GtkDoc: Error while writing main file '%s' contents: %s".printf (main_file, e.message));
+ reporter.simple_error ("GtkDoc: Error while writing main file '%s' contents: %s", main_file, e.message);
return false;
}
}
settings.pkg_name, "../%s-docs.xml".printf (settings.pkg_name)},
null, SpawnFlags.SEARCH_PATH, null, null, null);
} catch (Error e) {
- reporter.simple_error ("gtkdoc-mkhtml: %s".printf (e.message));
+ reporter.simple_error ("gtkdoc-mkhtml: %s", e.message);
return false;
}
"--html-dir", html_dir },
null, SpawnFlags.SEARCH_PATH, null, null, null);
} catch (Error e) {
- reporter.simple_error ("gtkdoc-fixxref: %s".printf (e.message));
+ reporter.simple_error ("gtkdoc-fixxref: %s", e.message);
return false;
}
/* gcomment.vala
-*
-* Copyright (C) 2010 Luca Bruno
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License as published by the Free Software Foundation; either
-* version 2.1 of the License, or (at your option) any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*
-* Author:
-* Luca Bruno <lethalman88@gmail.com>
-*/
+ *
+ * Copyright (C) 2010 Luca Bruno
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Luca Bruno <lethalman88@gmail.com>
+ */
public class Gtkdoc.Header {
public string name;
} else if (header.name == "Since") {
since = header.value;
} else {
- reporter.simple_warning ("GtkDoc: Unknown versioning tag '%s'".printf (header.name));
+ reporter.simple_warning ("GtkDoc: Unknown versioning tag '%s'", header.name);
}
}
var sections_writer = new TextWriter (sections, "a");
if (!sections_writer.open ()) {
- reporter.simple_error ("GtkDoc: unable to open %s for writing".printf (sections_writer.filename));
+ reporter.simple_error ("GtkDoc: unable to open %s for writing", sections_writer.filename);
return false;
}
var cwriter = new TextWriter (Path.build_filename (code_dir, "%s.c".printf (basename)), "w");
if (!cwriter.open ()) {
- reporter.simple_error ("GtkDoc: unable to open %s for writing".printf (cwriter.filename));
+ reporter.simple_error ("GtkDoc: unable to open %s for writing", cwriter.filename);
return false;
}
Process.spawn_command_line_sync (pc, null, null, out exit_status);
return (0 == exit_status);
} catch (SpawnError e) {
- reporter.simple_warning ("GtkDoc: Error pkg-config --exists %s: %s".printf (package_name, e.message));
+ reporter.simple_warning ("GtkDoc: Error pkg-config --exists %s: %s", package_name, e.message);
return false;
}
}
public override void check (Api.Tree api_root, Api.Node container, ErrorReporter reporter, Settings settings) {
if (!FileUtils.test (url, FileTest.EXISTS | FileTest.IS_REGULAR)) {
- reporter.simple_error ("%s does not exist".printf (url));
+ reporter.simple_error ("%s does not exist", url);
} else {
package = container.package;
}
((InlineContent) peek ()).content.add (_factory.create_text (" "));
return;
} else if (list.bullet != bullet) {
- _parser.error ("Invalid bullet type '%s': expected '%s'".printf (bullet_type_string (bullet), bullet_type_string (list.bullet)));
+ _parser.error (null, "Invalid bullet type '%s': expected '%s'", bullet_type_string (bullet), bullet_type_string (list.bullet));
return;
}
private void gir_append_link (Token token) throws ParserError {
var taglet = _factory.create_taglet ("link") as Taglets.Link;
if (!(taglet is Inline)) {
- _parser.error ("Invalid taglet in this context: link");
+ _parser.error (null, "Invalid taglet in this context: link");
}
taglet.symbol_name = "c::"+token.to_string ();
push (taglet);
TokenType.any_word ().action ((token) => {
var taglet = _factory.create_taglet (token.to_string ());
if (!(taglet is Inline)) {
- _parser.error ("Invalid taglet in this context: %s".printf (token.to_string ()));
+ _parser.error (null, "Invalid taglet in this context: %s".printf (token.to_string ()));
}
push (taglet);
Rule? taglet_rule = taglet.get_parser_rule (multiline_run);
TokenType.any_word ().action ((token) => {
var taglet = _factory.create_taglet (token.to_string ());
if (!(taglet is Block)) {
- _parser.error ("Invalid taglet in this context", token);
+ _parser.error (token, "Invalid taglet in this context");
}
push (taglet);
Rule? taglet_rule = taglet.get_parser_rule (multiline_run);
FileUtils.get_contents (this.path, out content);
this.documentation_str = content;
} catch (FileError err) {
- reporter.simple_error ("Unable to read file `%s': %s".printf (this.path, err.message));
+ reporter.simple_error ("Unable to read file `%s': %s", this.path, err.message);
}
}
}
}
} catch (FileError err) {
- reporter.simple_error ("Unable to open directory `%s': %s".printf (path, err.message));
+ reporter.simple_error ("Unable to open directory `%s': %s", path, err.message);
}
}
private enum ErrorType {
WARNING,
- ERROR
+ ERROR;
+
+ public string to_string () {
+ switch (this) {
+ case ErrorType.WARNING:
+ return "warning";
+
+ case ErrorType.ERROR:
+ return "error";
+ }
+
+ assert_not_reached ();
+ }
}
- private inline void msg (ErrorType type, string file, long line, long startpos, long endpos, string errline, string msg) {
- this.stream.printf ("%s:%lu.%lu-%lu.%lu: %s: %s\n", file, line, startpos, line, endpos, (type == ErrorType.ERROR)? "error" : "warning", msg);
+ private inline void msg (ErrorType type, string file, long line, long startpos, long endpos, string errline, string msg_format, va_list args) {
+ this.stream.printf ("%s:%lu.%lu-%lu.%lu: %s: ", file, line, startpos, line, endpos, type.to_string ());
+ this.stream.vprintf (msg_format, args);
+ this.stream.putc ('\n');
+
if (startpos <= endpos) {
this.stream.printf ("%s\n", errline);
for (int i = 0; i < errline.char_count ()+1; i++) {
}
}
- public void simple_warning (string msg) {
- this.stream.puts (msg);
+ public void simple_warning (string msg_format, ...) {
+ var args = va_list();
+ this.stream.vprintf (msg_format, args);
this.stream.putc ('\n');
this._warnings++;
}
- public void simple_error (string msg) {
- this.stream.puts (msg);
+ public void simple_error (string msg_format, ...) {
+ var args = va_list();
+ this.stream.vprintf (msg_format, args);
this.stream.putc ('\n');
this._errors++;
}
- public void error (string file, long line, long startpos, long endpos, string errline, string msg) {
- this.msg (ErrorType.ERROR, file, line, startpos, endpos, errline, msg);
+ //TODO
+ public void error (string file, long line, long startpos, long endpos, string errline, string msg_format, ...) {
+ var args = va_list();
+ this.msg (ErrorType.ERROR, file, line, startpos, endpos, errline, msg_format, args);
this._errors++;
}
- public void warning (string file, long line, long startpos, long endpos, string errline, string msg) {
- this.msg (ErrorType.WARNING, file, line, startpos, endpos, errline, msg);
+ //TODO
+ public void warning (string file, long line, long startpos, long endpos, string errline, string msg_format, ...) {
+ var args = va_list();
+ this.msg (ErrorType.WARNING, file, line, startpos, endpos, errline, msg_format, args);
this._warnings++;
}
}
}
if (symbol == null) {
- reporter.simple_warning ("%s does not exist".printf (symbol_name));
+ reporter.simple_warning ("%s does not exist", symbol_name);
return ;
}
_parser.parse ((string) content, filename, 0, 0);
}
} catch (FileError err) {
- reporter.simple_error ("Unable to map file `%s': %s".printf (filename, err.message));
+ reporter.simple_error ("Unable to map file `%s': %s", filename, err.message);
} catch (ParserError err) {
}
}
}
if (_scheme is TokenType) {
- parser.error ("expected %s".printf (((TokenType) _scheme).to_pretty_string ()), token);
+ parser.error (null, "expected %s", ((TokenType) _scheme).to_pretty_string ());
} else {
- parser.error ("unexpected token", token);
+ parser.error (token, "unexpected token");
}
assert_not_reached ();
}
return false;
}
- parser.error ("unexpected token", token);
+ parser.error (token, "unexpected token");
assert_not_reached ();
}
_scanner.end ();
if (rule_stack.size != 0) {
- error ("Rule stack is not empty!");
+ error (null, "Rule stack is not empty!");
}
} catch (ParserError e) {
#if DEBUG
// Check for invalid recursion
if (rule_depth != rule_stack.size && peek_rule () == rule) {
- error ("Parser state error");
+ error (null, "Parser state error");
break;
}
rule = peek_rule ();
return false;
}
- public void warning (string message, Token? token = null) {
- string error_message = message + (token != null ? ": " + token.to_pretty_string () : "");
+ public void warning (Token? token, string message, ...) {
+ va_list args = va_list ();
+ string error_message;
+
+ if (token == null) {
+ error_message = message.vprintf (args) + ": " + token.to_pretty_string ();
+ } else {
+ error_message = message;
+ }
+
_reporter.warning (_filename,
get_line (token),
get_start_column (token),
error_message);
}
- public void error (string message, Token? token = null) throws ParserError {
- string error_message = message + (token != null ? ": " + token.to_pretty_string () : "");
- _reporter.error (_filename, get_line (token),
+ public void error (Token? token, string message, ...) throws ParserError {
+ va_list args = va_list ();
+ string error_message;
+
+ if (token == null) {
+ error_message = message.vprintf (args) + ": " + token.to_pretty_string ();
+ } else {
+ error_message = message;
+ }
+
+ _reporter.error (_filename,
+ get_line (token),
get_start_column (token),
get_end_column (token),
_scanner.get_line_content (),
error_message);
+
throw new ParserError.UNEXPECTED_TOKEN (error_message);
}
public abstract bool would_parent_accept_token (Token token);
public abstract bool would_parent_reduce_to_rule (Token token, Rule rule);
- public abstract void warning (string message, Token? token = null);
- public abstract void error (string message, Token? token = null) throws ParserError;
+ public abstract void warning (Token? token, string message, ...);
+ public abstract void error (Token? token, string message, ...) throws ParserError;
}
}
public enum Forward {
- NONE, PARENT, CHILD
+ NONE,
+ PARENT,
+ CHILD
}
public abstract bool is_optional ();
}
if (scheme_element is TokenType) {
- parser.error ("expected %s".printf (((TokenType) scheme_element).to_pretty_string ()), token);
+ parser.error (token, "expected %s", ((TokenType) scheme_element).to_pretty_string ());
} else {
- parser.error ("unexpected token", token);
+ parser.error (token, "unexpected token");
}
assert_not_reached ();
}
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
-
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
-
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
private TokenType (string string_value, int basic_value, Action? action) {
_string_value = string_value;
_basic_value = basic_value;
- _action = action;
+ if (_action != null) {
+ _action = (token) => { action (token); };
+ } else {
+ _action = null;
+ }
}
private TokenType.basic (string string_value, string? pretty_string = null) {
if (_symbol == null) {
// TODO use ContentElement's source reference
- reporter.simple_warning ("%s does not exist".printf (symbol_name));
+ reporter.simple_warning ("%s does not exist", symbol_name);
}
base.check (api_root, container, reporter, settings);
if (symbol == null) {
// TODO use ContentElement's source reference
- reporter.simple_warning ("%s does not exist".printf (symbol_name));
+ reporter.simple_warning ("%s does not exist", symbol_name);
}
}
error_domain = api_root.search_symbol_str (container, error_domain_name);
if (error_domain == null) {
// TODO use ContentElement's source reference
- reporter.simple_error ("%s does not exist".printf (error_domain_name));
+ reporter.simple_error ("%s does not exist", error_domain_name);
}
base.check (api_root, container, reporter, settings);