-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathTODO
97 lines (89 loc) · 2.82 KB
/
TODO
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
Built with: 8b98e5a296d95c5e832db0756828e5bec31c6f50 (0.5)
* Might want to replace list wih sepBy functions (see parsec3).
* Update web page
* Talk about info and debug logging.
* Note and err should not print all of the input.
* Would be more efficient to use char_range_at instead of converting the text to [char]
- is this true given that we want to add EOT? could rely on the embedded null char
- getting the col might be a little icky because that requires going backwards
* Talk about the theory and limitations.
http://blogs.msdn.com/b/lukeh/archive/2007/08/19/monadic-parser-combinators-using-c-3-0.aspx
* May want to package the exported items into rparse namespace. See #1238.
* Might want an example of parsing significant whitespace.
* Probably better to build as a static library, see #552.
* Would be nice if there was a way to localize messages:
- maybe state could have a fn to map key strings to localized versions
* Release checklist:
- search for TODO (in all files)
- make sure readme example works when using rparse
- run unit tests in release
- run unit tests in debug
- review README
- use git log --oneline > CHANGE_LOG
- update CHANGES file
- push changes
- upload new source package
- review the front page of the web site
- update cargo, see bug 2266
- create a new branch for the release
- update version (both in the crate and the readme)
/~https://github.com/jesse99/rparse
/Users/jessejones/Documents/Developer/rust.rtf
/// Calls fun with an index into the characters to be parsed until it returns zero characters.
/// Returns the matched characters.
///
/// This does increment line.
fn scan0(fun: fn@ (@[char], uint) -> uint) -> Parser<@~str>
{
|input: State|
{
let mut i = input.index;
let mut line = input.line;
let mut result = result::Err({old_state: input, err_state: input, mesg: @~"dummy"});
while result::is_err(result)
{
let count = fun(input.text, i);
if count > 0u && input.text[i] != EOT // EOT check makes it easier to write funs that do stuff like matching chars that are not something
{
for uint::range(0u, count)
|_k|
{
if input.text[i] == '\r'
{
line += 1;
}
else if input.text[i] == '\n' && (i == 0u || input.text[i-1u] != '\r')
{
line += 1;
}
i += 1u;
}
}
else
{
let text = str::from_chars(vec::slice(input.text, input.index, i));
result = result::Ok({new_state: {index: i, line: line, ..input}, value: @text});
}
}
result
}
}
/// Like scan0 except that at least one character must be consumed.
fn scan1(fun: fn@ (@[char], uint) -> uint) -> Parser<@~str>
{
|input: State|
{
do result::chain(scan0(fun)(input))
|pass|
{
if pass.new_state.index > input.index
{
result::Ok(pass)
}
else
{
result::Err({old_state: input, err_state: pass.new_state, mesg: @~""})
}
}
}
}