Compare commits

...

3 Commits

5 changed files with 26 additions and 12 deletions

View File

@ -7,9 +7,12 @@ export type error = !(syntaxerr | io::error | utf8::invalid);
// All syntax errors defined in this module.
export type syntaxerr = !(
invalid_group_header |
invalid_entry |
invalid_ascii |
invalid_escape);
invalid_entry |
invalid_ascii |
invalid_escape |
invalid_boolean |
invalid_numeric |
expected_single);
// Returned when a malformed group header is encountered while parsing.
export type invalid_group_header = !void;
@ -24,6 +27,18 @@ export type invalid_ascii = !void;
// Returned when an invalid escape sequence was enctountered while parsing.
export type invalid_escape = !void;
// Returned when a boolean value was expected while parsing, but something else
// was given.
export type invalid_boolean = !void;
// Returned when a numeric value was expected while parsing, but something else
// was given.
export type invalid_numeric = !void;
// Returned when a singular value was expected while parsing, but multiple
// values were given.
export type expected_single = !void;
// Returns a user-friendly representation of [[error]]. The result may be
// statically allocated.
export fn strerror(err: error) str = match (err) {
@ -31,6 +46,9 @@ case invalid_group_header => yield "invalid group header";
case invalid_entry => yield "invalid entry";
case invalid_ascii => yield "invalid ascii";
case invalid_escape => yield "invalid escape";
case invalid_boolean => yield "invalid boolean";
case invalid_numeric => yield "invalid numeric";
case expected_single => yield "expected single";
case let err: io::error => yield io::strerror(err);
case let err: utf8::invalid => yield utf8::strerror(err);
};

View File

@ -23,13 +23,9 @@ export fn scan(input: io::handle) scanner = scanner {
// borrowed from the [[scanner]]. Use [[strings::dup]], [[entry_dup]], etc. to
// retain a copy. If all you want is the file's data, use [[next_entry]].
export fn next(this: *scanner) (line | io::EOF | error) = {
let text = match (bufio::scan_line(&this.scanner)) {
case let text: const str =>
yield text;
case let err: (io::error | utf8::invalid) =>
return err;
case io::EOF =>
return io::EOF;
let text = match (bufio::scan_line(&this.scanner)?) {
case let text: const str => yield text;
case io::EOF => return io::EOF;
};
if (text == "") {

View File

@ -9,6 +9,7 @@ use os;
let h_dac = "Desktop Action Create";
let correct: []line = [
"This is a comment": comment,
blank,
h_de: group_header,
entry_new(h_de, "Version", "1.0", locale::c),
entry_new(h_de, "Type", "Application", locale::c),

View File

@ -12,8 +12,6 @@ Icon=fooview
MimeType=image/x-foo;
Actions=Gallery;Create;
Name[en_US]=foo.desktop
[Desktop Action Gallery]
Exec=fooview --gallery
Name=Browse Gallery
@ -22,5 +20,6 @@ Name=Browse Gallery
Exec=fooview --create-new
Name=Create a new Foo!
Name[en_US]=Create a new Foo!
Name[xx_XX.UTF-8]=Zweep zoop flooble glorp
#Another comment
Icon=fooview-new

View File