/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::str::CharIndices;
// support arguments like '4', 'ab', '4.0', '>=10.14', '*123' fn acceptable_arg_character(c: char) -> bool {
c.is_alphanumeric() || c == '.' || c == '-' || c == '<' || c == '>' || c == '=' || c == '*'
}
// A crappy parser for parsing strings like "translate(1, 3) blahblah" // Returns a tuple with three components: // - First component is the function name (e.g. "translate") // - Second component is the list of arguments (e.g. vec!["1", "3"]) // - Third component is the rest of the string "blahblah" pubfn parse_function(s: &str) -> (&str, Vec<&str>, &str) { // XXX: This is not particularly easy to read. Sorry. struct Parser<'a> {
itr: CharIndices<'a>,
start: usize,
o: Option<(usize, char)>,
} impl<'a> Parser<'a> { fn skip_whitespace(&mutself) { whilelet Some(k) = self.o { if !k.1.is_whitespace() { break;
} self.start = k.0 + k.1.len_utf8(); self.o = self.itr.next();
}
}
} letmut c = s.char_indices(); let o = c.next(); letmut p = Parser {
itr: c,
start: 0,
o,
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.