simplecss-0.1.0/.gitignore01006440001750000175000000000022130243340330013710 0ustar0000000000000000target Cargo.lock simplecss-0.1.0/Cargo.toml01006440001750000175000000001502130364647500013671 0ustar0000000000000000# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g. crates.io) dependencies # # If you believe there's an error in this file please file an # issue against the rust-lang/cargo repository. If you're # editing this file be aware that the upstream Cargo.toml # will likely look very different (and much more reasonable) [package] name = "simplecss" version = "0.1.0" authors = ["Reizner Evgeniy "] description = "A very simple CSS 2.1 tokenizer." readme = "README.md" keywords = ["css", "parser", "tokenizer"] license = "MPL-2.0" repository = "https://github.com/RazrFalcon/simplecss" [lib] doctest = false simplecss-0.1.0/Cargo.toml.orig01006440001750000175000000000466130364647500014640 0ustar0000000000000000[package] name = "simplecss" version = "0.1.0" authors = ["Reizner Evgeniy "] license = "MPL-2.0" readme = "README.md" description = "A very simple CSS 2.1 tokenizer." repository = "https://github.com/RazrFalcon/simplecss" keywords = ["css", "parser", "tokenizer"] [lib] doctest = false simplecss-0.1.0/LICENSE.txt01006440001750000175000000040530126533755410013573 0ustar0000000000000000Mozilla Public License Version 2.0 ================================== 1. Definitions -------------- 1.1. "Contributor" means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software. 1.2. "Contributor Version" means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributor's Contribution. 1.3. "Contribution" means Covered Software of a particular Contributor. 1.4. "Covered Software" means Source Code Form to which the initial Contributor has attached the notice in Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source Code Form, in each case including portions thereof. 1.5. "Incompatible With Secondary Licenses" means (a) that the initial Contributor has attached the notice described in Exhibit B to the Covered Software; or (b) that the Covered Software was made available under the terms of version 1.1 or earlier of the License, but not also under the terms of a Secondary License. 1.6. "Executable Form" means any form of the work other than Source Code Form. 1.7. "Larger Work" means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software. 1.8. "License" means this document. 1.9. "Licensable" means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently, any and all of the rights conveyed by this License. 1.10. "Modifications" means any of the following: (a) any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or (b) any new file in Source Code Form that contains any Covered Software. 1.11. "Patent Claims" of a Contributor means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the License, by the making, using, selling, offering for sale, having made, import, or transfer of either its Contributions or its Contributor Version. 1.12. "Secondary License" means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses. 1.13. "Source Code Form" means the form of the work preferred for making modifications. 1.14. "You" (or "Your") means an individual or a legal entity exercising rights under this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with You. For purposes of this definition, "control" means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. 2. License Grants and Conditions -------------------------------- 2.1. Grants Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license: (a) under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and (b) under Patent Claims of such Contributor to make, use, sell, offer for sale, have made, import, and otherwise transfer either its Contributions or its Contributor Version. 2.2. Effective Date The licenses granted in Section 2.1 with respect to any Contribution become effective for each Contribution on the date the Contributor first distributes such Contribution. 2.3. Limitations on Grant Scope The licenses granted in this Section 2 are the only rights granted under this License. No additional rights or licenses will be implied from the distribution or licensing of Covered Software under this License. Notwithstanding Section 2.1(b) above, no patent license is granted by a Contributor: (a) for any code that a Contributor has removed from Covered Software; or (b) for infringements caused by: (i) Your and any other third party's modifications of Covered Software, or (ii) the combination of its Contributions with other software (except as part of its Contributor Version); or (c) under Patent Claims infringed by Covered Software in the absence of its Contributions. This License does not grant any rights in the trademarks, service marks, or logos of any Contributor (except as may be necessary to comply with the notice requirements in Section 3.4). 2.4. Subsequent Licenses No Contributor makes additional grants as a result of Your choice to distribute the Covered Software under a subsequent version of this License (see Section 10.2) or under the terms of a Secondary License (if permitted under the terms of Section 3.3). 2.5. Representation Each Contributor represents that the Contributor believes its Contributions are its original creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by this License. 2.6. Fair Use This License is not intended to limit any rights You have under applicable copyright doctrines of fair use, fair dealing, or other equivalents. 2.7. Conditions Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1. 3. Responsibilities ------------------- 3.1. Distribution of Source Form All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients' rights in the Source Code Form. 3.2. Distribution of Executable Form If You distribute Covered Software in Executable Form then: (a) such Covered Software must also be made available in Source Code Form, as described in Section 3.1, and You must inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and (b) You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients' rights in the Source Code Form under this License. 3.3. Distribution of a Larger Work You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for the Covered Software. If the Larger Work is a combination of Covered Software with a work governed by one or more Secondary Licenses, and the Covered Software is not Incompatible With Secondary Licenses, this License permits You to additionally distribute such Covered Software under the terms of such Secondary License(s), so that the recipient of the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s). 3.4. Notices You may not remove or alter the substance of any license notices (including copyright notices, patent notices, disclaimers of warranty, or limitations of liability) contained within the Source Code Form of the Covered Software, except that You may alter any license notices to the extent required to remedy known factual inaccuracies. 3.5. Application of Additional Terms You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, You may do so only on Your own behalf, and not on behalf of any Contributor. You must make it absolutely clear that any such warranty, support, indemnity, or liability obligation is offered by You alone, and You hereby agree to indemnify every Contributor for any liability incurred by such Contributor as a result of warranty, support, indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction. 4. Inability to Comply Due to Statute or Regulation --------------------------------------------------- If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. 5. Termination -------------- 5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice. 5.2. If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section 2.1 of this License shall terminate. 5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination. ************************************************************************ * * * 6. Disclaimer of Warranty * * ------------------------- * * * * Covered Software is provided under this License on an "as is" * * basis, without warranty of any kind, either expressed, implied, or * * statutory, including, without limitation, warranties that the * * Covered Software is free of defects, merchantable, fit for a * * particular purpose or non-infringing. The entire risk as to the * * quality and performance of the Covered Software is with You. * * Should any Covered Software prove defective in any respect, You * * (not any Contributor) assume the cost of any necessary servicing, * * repair, or correction. This disclaimer of warranty constitutes an * * essential part of this License. No use of any Covered Software is * * authorized under this License except under this disclaimer. * * * ************************************************************************ ************************************************************************ * * * 7. Limitation of Liability * * -------------------------- * * * * Under no circumstances and under no legal theory, whether tort * * (including negligence), contract, or otherwise, shall any * * Contributor, or anyone who distributes Covered Software as * * permitted above, be liable to You for any direct, indirect, * * special, incidental, or consequential damages of any character * * including, without limitation, damages for lost profits, loss of * * goodwill, work stoppage, computer failure or malfunction, or any * * and all other commercial damages or losses, even if such party * * shall have been informed of the possibility of such damages. This * * limitation of liability shall not apply to liability for death or * * personal injury resulting from such party's negligence to the * * extent applicable law prohibits such limitation. Some * * jurisdictions do not allow the exclusion or limitation of * * incidental or consequential damages, so this exclusion and * * limitation may not apply to You. * * * ************************************************************************ 8. Litigation ------------- Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a party's ability to bring cross-claims or counter-claims. 9. Miscellaneous ---------------- This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor. 10. Versions of the License --------------------------- 10.1. New Versions Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number. 10.2. Effect of New Versions You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward. 10.3. Modified Versions If you create software not governed by this License, and you want to create a new license for such software, you may create and use a modified version of this License if you rename the license and remove any references to the name of the license steward (except to note that such modified license differs from this License). 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached. Exhibit A - Source Code Form License Notice ------------------------------------------- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice. You may add additional accurate notices of copyright ownership. Exhibit B - "Incompatible With Secondary Licenses" Notice --------------------------------------------------------- This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0. simplecss-0.1.0/README.md01006440001750000175000000004662130327537320013227 0ustar0000000000000000# simplecss A very simple streaming parser/tokenizer for [CSS 2.1](https://www.w3.org/TR/CSS21/) data format without heap allocations. Since it's very simple we will start with limitations: ## Limitations - [At-rules](https://www.w3.org/TR/CSS21/syndata.html#at-rules) are not supported. `@import`, `@media`, etc. will lead to a parsing error. - The ident token must be ASCII only. CSS like `#аттр { имя:значение }` will lead to a parsing error. - Property values are not parsed. In CSS like `* { width: 5px }` you will get `width` property with `5px` values as a string. - Attribute selector rule is not parsed. `[foo~="warning"]` will be parsed as `Token::AttributeSelector("foo~=\"warning\"")`. - There are no data validation. - Pseudo-class tokens can contain any text, language pseudo-class can contain any text or even none. - Declarations can contain any kind of names and values. - All comments will be ignored. They didn't have it's own `Token` item. - CDO/CDC comments are not supported. - Parser is case sensitive. All keywords should be lowercase. - Unicode escape, like `\26`, is not supported. - No spec-defined error handling. If something will go wrong you will get an error. Parser will not recover an invalid input. [Details](https://www.w3.org/TR/CSS21/syndata.html#rule-sets). ## Where to use `simplecss` can be useful for parsing a very simple or predefined CSS. It's tiny, dependency free and pretty fast. ## Examples Simple ```text * { color : red } | | | || | | | |+- Token::EndOfStream | | | +- Token::BlockEnd | | +- Token::Declaration("color", "red") | +- Token::BlockStart +- Token::UniversalSelector ``` Complex ```text div#x:first-letter em[id] + .hh1 { color : red } | | | || | | | | | || | | | || | | | | | |+- Token::EndOfStream | | | || | | | | | +- Token::BlockEnd | | | || | | | | +- Token::Declaration("color", "red") | | | || | | | +- Token::BlockStart | | | || | | +- Token::ClassSelector("hh1") | | | || | +- Token::Combinator(Combinator::Plus) | | | || +- Token::AttributeSelector("id") | | | |+- Token::TypeSelector("em") | | | +- Token::Combinator(Combinator::Space) | | +- Token::PseudoClass("first-letter") | +- Token::IdSelector("x") +- Token::TypeSelector("div") ``` simplecss-0.1.0/src/error.rs01006440001750000175000000004040130262274320014220 0ustar0000000000000000// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. use std::fmt; /// Position of an error. /// /// Position indicates row/line and column. Starting positions is 1:1. #[derive(Clone,Copy,PartialEq)] pub struct ErrorPos { #[allow(missing_docs)] pub row: usize, #[allow(missing_docs)] pub col: usize, } impl ErrorPos { /// Constructs a new error position. pub fn new(row: usize, col: usize) -> ErrorPos { ErrorPos { row: row, col: col, } } } impl fmt::Debug for ErrorPos { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}:{}", &self.row, &self.col) } } /// List of all supported errors. #[derive(Clone,Copy,PartialEq)] pub enum Error { /// The steam ended earlier than we expected. /// /// Should only appear on invalid input data. UnexpectedEndOfStream(ErrorPos), /// Can appear during moving along the data stream. InvalidAdvance { /// The advance step. expected: isize, /// Full length of the steam. total: usize, /// Absolute stream position. pos: ErrorPos, }, /// Unsupported token. UnsupportedToken(ErrorPos), /// Unknown token. UnknownToken(ErrorPos), } impl fmt::Debug for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { Error::UnexpectedEndOfStream(ref pos) => write!(f, "Unexpected end of stream at {:?}", pos), Error::InvalidAdvance{ref expected, ref total, ref pos} => write!(f, "Attempt to advance to the pos {} from {:?}, but total len is {}", expected, pos, total), Error::UnsupportedToken(ref pos) => write!(f, "Unsupported token at {:?}", pos), Error::UnknownToken(ref pos) => write!(f, "Unknown token at {:?}", pos), } } } simplecss-0.1.0/src/lib.rs01006440001750000175000000005444130327537020013647 0ustar0000000000000000// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. /*! A very simple streaming parser/tokenizer for [CSS 2.1](https://www.w3.org/TR/CSS21/) data format without heap allocations. Since it's very simple we will start with limitations: ## Limitations - [At-rules](https://www.w3.org/TR/CSS21/syndata.html#at-rules) are not supported. `@import`, `@media`, etc. will lead to a parsing error. - The ident token must be ASCII only. CSS like `#аттр { имя:значение }` will lead to a parsing error. - Property values are not parsed. In CSS like `* { width: 5px }` you will get `width` property with `5px` values as a string. - Attribute selector rule is not parsed. `[foo~="warning"]` will be parsed as `Token::AttributeSelector("foo~=\"warning\"")`. - There are no data validation. - Pseudo-class tokens can contain any text, language pseudo-class can contain any text or even none. - Declarations can contain any kind of names and values. - All comments will be ignored. They didn't have it's own `Token` item. - CDO/CDC comments are not supported. - Parser is case sensitive. All keywords should be lowercase. - Unicode escape, like `\26`, is not supported. - No spec-defined error handling. If something will go wrong you will get an error. Parser will not recover an invalid input. [Details](https://www.w3.org/TR/CSS21/syndata.html#rule-sets). ## Where to use `simplecss` can be useful for parsing a very simple or predefined CSS. It's tiny, dependency free and pretty fast. ## Examples Simple ```text * { color : red } | | | || | | | |+- Token::EndOfStream | | | +- Token::BlockEnd | | +- Token::Declaration("color", "red") | +- Token::BlockStart +- Token::UniversalSelector ``` Complex ```text div#x:first-letter em[id] + .hh1 { color : red } | | | || | | | | | || | | | || | | | | | |+- Token::EndOfStream | | | || | | | | | +- Token::BlockEnd | | | || | | | | +- Token::Declaration("color", "red") | | | || | | | +- Token::BlockStart | | | || | | +- Token::ClassSelector("hh1") | | | || | +- Token::Combinator(Combinator::Plus) | | | || +- Token::AttributeSelector("id") | | | |+- Token::TypeSelector("em") | | | +- Token::Combinator(Combinator::Space) | | +- Token::PseudoClass("first-letter") | +- Token::IdSelector("x") +- Token::TypeSelector("div") ``` */ #![forbid(unsafe_code)] #![warn(missing_docs)] pub use error::{Error, ErrorPos}; pub use tokenizer::{Tokenizer, Token, Combinator}; mod error; mod stream; mod tokenizer; simplecss-0.1.0/src/stream.rs01006440001750000175000000014615130257653600014401 0ustar0000000000000000// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. use std::str; use error::{Error, ErrorPos}; /// Streaming interface for `&[u8]` data. #[derive(PartialEq,Clone,Copy)] pub struct Stream<'a> { text: &'a [u8], pos: usize, end: usize, } #[inline] fn is_letter(c: u8) -> bool { match c { b'A'...b'Z' => true, b'a'...b'z' => true, _ => false, } } #[inline] fn is_digit(c: u8) -> bool { match c { b'0'...b'9' => true, _ => false, } } #[inline] pub fn is_space(c: u8) -> bool { match c { b' ' | b'\t' | b'\n' | b'\r' => true, _ => false, } } impl<'a> Stream<'a> { /// Constructs a new `Stream` from data. #[inline] pub fn new(text: &[u8]) -> Stream { Stream { text: text, pos: 0, end: text.len(), } } /// Constructs a new `Stream` from data. #[inline] pub fn new_bound(text: &[u8], start: usize, end: usize) -> Stream { assert!(start < end); Stream { text: text, pos: start, end: end, } } /// Returns current position. #[inline] pub fn pos(&self) -> usize { self.pos } /// Returns `true` if we are at the end of the stream. /// /// Any [`pos()`] value larger than original text length indicates stream end. /// /// Accessing stream after reaching end via safe methods will produce `simplecss::Error`. /// /// Accessing stream after reaching end via unsafe/_raw methods will produce /// rust bound checking error. /// /// [`pos()`]: #method.pos #[inline] pub fn at_end(&self) -> bool { self.pos >= self.end } /// Returns a char from current stream position. /// /// # Errors /// /// Returns `Error::UnexpectedEndOfStream` if we at the end of the stream. #[inline] pub fn curr_char(&self) -> Result { if self.at_end() { return Err(self.gen_end_of_stream_error()); } Ok(self.text[self.pos]) } /// Unsafe version of [`curr_char()`]. /// /// [`curr_char()`]: #method.curr_char #[inline] pub fn curr_char_raw(&self) -> u8 { self.text[self.pos] } /// Compares selected char with char from current stream position. /// /// # Errors /// /// Returns `Error::UnexpectedEndOfStream` if we at the end of the stream. #[inline] pub fn is_char_eq(&self, c: u8) -> Result { if self.at_end() { return Err(self.gen_end_of_stream_error()); } Ok(self.curr_char_raw() == c) } /// Advance by `n` chars. /// /// # Errors /// /// Returns `Error::AdvanceError` if new position beyond stream end. /// ``` #[inline] pub fn advance(&mut self, n: usize) -> Result<(), Error> { try!(self.adv_bound_check(n)); self.pos += n; Ok(()) } /// Unsafe version of [`advance()`]. /// /// [`advance()`]: #method.advance #[inline] pub fn advance_raw(&mut self, n: usize) { debug_assert!(self.pos + n <= self.end); self.pos += n; } /// Checks that char at the current position is (white)space. /// /// Accepted chars: ' ', '\n', '\r', '\t'. #[inline] pub fn is_space_raw(&self) -> bool { is_space(self.curr_char_raw()) } pub fn is_ident_raw(&self) -> bool { let c = self.curr_char_raw(); is_digit(c) || is_letter(c) || c == b'_' || c == b'-' } /// Skips (white)space's. #[inline] pub fn skip_spaces(&mut self) { while !self.at_end() && self.is_space_raw() { self.advance_raw(1); } } #[inline] fn get_char_raw(&self, pos: usize) -> u8 { self.text[pos] } /// Calculates length to the selected char. #[inline] pub fn length_to(&self, c: u8) -> Result { let mut n = 0; while self.pos + n != self.end { if self.get_char_raw(self.pos + n) == c { return Ok(n); } else { n += 1; } } Err(self.gen_end_of_stream_error()) } pub fn length_to_either(&self, c1: u8, c2: u8) -> Result { let mut n = 0; while self.pos + n != self.end { let c = self.get_char_raw(self.pos + n); if c == c1 || c == c2 { return Ok(n); } else { n += 1; } } Err(self.gen_end_of_stream_error()) } /// Returns reference to data with length `len` and advance stream to the same length. #[inline] pub fn read_raw_str(&mut self, len: usize) -> &'a str { let s = &self.text[self.pos..(self.pos + len)]; self.advance_raw(s.len()); str::from_utf8(s).unwrap() } /// Returns data of stream within selected region. #[inline] pub fn slice_region_raw_str(&self, start: usize, end: usize) -> &'a str { str::from_utf8(&self.text[start..end]).unwrap() } fn calc_current_row(&self) -> usize { let mut row = 1; row += self.text.iter().take(self.pos).filter(|c| **c == b'\n').count(); row } fn calc_current_col(&self) -> usize { let mut col = 1; for n in 0..self.pos { if n > 0 && self.text[n-1] == b'\n' { col = 2; } else { col += 1; } } col } /// Calculates a current absolute position. pub fn gen_error_pos(&self) -> ErrorPos { let row = self.calc_current_row(); let col = self.calc_current_col(); ErrorPos::new(row, col) } /// Generates a new `UnexpectedEndOfStream` error from the current position. pub fn gen_end_of_stream_error(&self) -> Error { Error::UnexpectedEndOfStream(self.gen_error_pos()) } fn adv_bound_check(&self, n: usize) -> Result<(), Error> { let new_pos = self.pos + n; if new_pos > self.end { return Err(Error::InvalidAdvance{ expected: new_pos as isize, total: self.end, pos: self.gen_error_pos(), }); } Ok(()) } } simplecss-0.1.0/src/tokenizer.rs01006440001750000175000000026364130364641030015115 0ustar0000000000000000// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. use stream; use stream::Stream; use error::Error; /// CSS combinator. #[derive(PartialEq,Debug)] pub enum Combinator { /// Descendant selector Space, /// Child selector GreaterThan, /// Adjacent sibling selector Plus, } /// CSS token. #[derive(PartialEq,Debug)] pub enum Token<'a> { /// Universal selector /// /// https://www.w3.org/TR/CSS21/selector.html#universal-selector UniversalSelector, /// Type selector /// /// https://www.w3.org/TR/CSS21/selector.html#type-selectors TypeSelector(&'a str), /// ID selector /// /// Value contains ident without `#`. /// /// https://www.w3.org/TR/CSS21/selector.html#id-selectors IdSelector(&'a str), /// Class selector /// /// Value contains ident without `.`. /// /// https://www.w3.org/TR/CSS21/selector.html#class-html ClassSelector(&'a str), /// Attribute selector /// /// We do not parse it's content yet, so value contains everything between `[]`. /// /// https://www.w3.org/TR/CSS21/selector.html#attribute-selectors AttributeSelector(&'a str), /// Pseudo-class /// /// Value contains ident without `:`. /// We do not validate it in any way. /// /// https://www.w3.org/TR/CSS21/selector.html#pseudo-class-selectors PseudoClass(&'a str), /// Language pseudo-class /// /// Value contains everything between `()`. /// We do not validate it in any way. It can contain any text or even be empty. /// /// https://www.w3.org/TR/CSS21/selector.html#lang LangPseudoClass(&'a str), /// `Combinator` Combinator(Combinator), /// Rules separator /// /// https://www.w3.org/TR/CSS21/selector.html#grouping Comma, /// Block start /// /// Indicates `{`. /// /// https://www.w3.org/TR/CSS21/syndata.html#rule-sets BlockStart, /// Block end /// /// Indicates `}`. /// /// https://www.w3.org/TR/CSS21/syndata.html#rule-sets BlockEnd, /// Declaration /// /// Contains property name and property value. /// /// https://www.w3.org/TR/CSS21/syndata.html#declaration Declaration(&'a str, &'a str), /// End of stream /// /// Parsing is finished. EndOfStream, } #[derive(PartialEq)] enum State { Rule, Declaration, } /// CSS tokenizer. pub struct Tokenizer<'a> { stream: Stream<'a>, state: State, after_selector: bool, at_start: bool, } impl<'a> Tokenizer<'a> { /// Constructs a new `Tokenizer`. pub fn new(text: &str) -> Tokenizer { Tokenizer { stream: Stream::new(text.as_bytes()), state: State::Rule, after_selector: false, at_start: true, } } /// Constructs a new bounded `Tokenizer`. /// /// It can be useful if CSS data is inside other data, like HTML. /// Using this method you will get an absolute error positions and not relative, /// like when using [`new()`]. /// /// [`new()`]: #method.new pub fn new_bound(text: &str, start: usize, end: usize) -> Tokenizer { Tokenizer { stream: Stream::new_bound(text.as_bytes(), start, end), state: State::Rule, after_selector: false, at_start: true, } } /// Returns a current position in the text. pub fn pos(&self) -> usize { self.stream.pos() } /// Parses a next token. pub fn parse_next(&mut self) -> Result, Error> { if self.at_start { self.stream.skip_spaces(); self.at_start = false; } if self.stream.at_end() { return Ok(Token::EndOfStream); } match self.state { State::Rule => self.consume_rule(), State::Declaration => self.consume_declaration(), } } fn consume_rule(&mut self) -> Result, Error> { match self.stream.curr_char_raw() { b'@' => { return Err(Error::UnsupportedToken(self.stream.gen_error_pos())); } b'#' => { self.after_selector = true; self.stream.advance_raw(1); let s = try!(self.consume_ident()); return Ok(Token::IdSelector(s)); } b'.' => { self.after_selector = true; self.stream.advance_raw(1); let s = try!(self.consume_ident()); return Ok(Token::ClassSelector(s)); } b'*' => { self.after_selector = true; self.stream.advance_raw(1); self.stream.skip_spaces(); return Ok(Token::UniversalSelector); } b':' => { self.after_selector = true; self.stream.advance_raw(1); let s = try!(self.consume_ident()); if s == "lang" { try!(self.stream.advance(1)); // ( let len = try!(self.stream.length_to(b')')); let lang = self.stream.read_raw_str(len); self.stream.advance_raw(1); // ) return Ok(Token::LangPseudoClass(lang)); } else { return Ok(Token::PseudoClass(s)); } } b'[' => { self.after_selector = true; self.stream.advance_raw(1); let len = try!(self.stream.length_to(b']')); let s = self.stream.read_raw_str(len); self.stream.advance_raw(1); // ] self.stream.skip_spaces(); return Ok(Token::AttributeSelector(s)); } b',' => { self.after_selector = false; self.stream.advance_raw(1); self.stream.skip_spaces(); return Ok(Token::Comma); } b'{' => { self.after_selector = false; self.state = State::Declaration; self.stream.advance_raw(1); return Ok(Token::BlockStart); } b'>' => { if self.after_selector { self.after_selector = false; self.stream.advance_raw(1); self.stream.skip_spaces(); return Ok(Token::Combinator(Combinator::GreaterThan)); } else { return Err(Error::UnknownToken(self.stream.gen_error_pos())); } } b'+' => { if self.after_selector { self.after_selector = false; self.stream.advance_raw(1); self.stream.skip_spaces(); return Ok(Token::Combinator(Combinator::Plus)); } else { return Err(Error::UnknownToken(self.stream.gen_error_pos())); } } b'/' => { if try!(self.consume_comment()) { return self.parse_next(); } else { return Err(Error::UnknownToken(self.stream.gen_error_pos())); } } _ => { if self.stream.is_space_raw() { self.stream.skip_spaces(); if !self.after_selector { return self.parse_next(); } return match try!(self.stream.curr_char()) { b'{' | b'/' | b'>' | b'+' | b'*' => self.parse_next(), _ => { self.after_selector = false; Ok(Token::Combinator(Combinator::Space)) } }; } self.after_selector = true; let s = try!(self.consume_ident()); return Ok(Token::TypeSelector(s)); } } } fn consume_declaration(&mut self) -> Result, Error> { self.stream.skip_spaces(); match self.stream.curr_char_raw() { b'}' => { self.state = State::Rule; self.stream.advance_raw(1); self.stream.skip_spaces(); return Ok(Token::BlockEnd); } b'/' => { if try!(self.consume_comment()) { return self.parse_next(); } else { return Err(Error::UnknownToken(self.stream.gen_error_pos())); } } _ => { let name = try!(self.consume_ident()); self.stream.skip_spaces(); if try!(self.stream.is_char_eq(b'/')) { if !try!(self.consume_comment()) { return Err(Error::UnknownToken(self.stream.gen_error_pos())); } } self.stream.advance_raw(1); // : self.stream.skip_spaces(); if try!(self.stream.is_char_eq(b'/')) { if !try!(self.consume_comment()) { return Err(Error::UnknownToken(self.stream.gen_error_pos())); } } let len = try!(self.stream.length_to_either(b';', b'}')); if len == 0 { return Err(Error::UnknownToken(self.stream.gen_error_pos())); } let mut value = self.stream.read_raw_str(len); // trim spaces at the end of the value if let Some(p) = value.as_bytes().iter().rposition(|c| !stream::is_space(*c)) { value = &value[0..(p + 1)]; } self.stream.skip_spaces(); while try!(self.stream.is_char_eq(b';')) { self.stream.advance_raw(1); self.stream.skip_spaces(); } return Ok(Token::Declaration(name, value)); } } } fn consume_ident(&mut self) -> Result<&'a str, Error> { let start = self.stream.pos(); while !self.stream.at_end() { if self.stream.is_ident_raw() { try!(self.stream.advance(1)); } else { break; } } if start == self.stream.pos() { return Err(Error::UnknownToken(self.stream.gen_error_pos())); } let s = self.stream.slice_region_raw_str(start, self.stream.pos()); Ok(s) } fn consume_comment(&mut self) -> Result { self.stream.advance_raw(1); if try!(self.stream.is_char_eq(b'*')) { self.stream.advance_raw(1); // * while !self.stream.at_end() { let len = try!(self.stream.length_to(b'*')); try!(self.stream.advance(len + 1)); if try!(self.stream.is_char_eq(b'/')) { self.stream.advance_raw(1); break; } } return Ok(true); } else { return Ok(false); } } } simplecss-0.1.0/tests/css.rs01006440001750000175000000037305130262404010014233 0ustar0000000000000000// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. extern crate simplecss; use simplecss::{Tokenizer, Token, Combinator, Error, ErrorPos}; macro_rules! test { ($name:ident, $text:expr, $( $token:expr ),*) => { #[test] fn $name() { let mut t = Tokenizer::new($text); $( assert_eq!(t.parse_next().unwrap(), $token); )* assert_eq!(t.parse_next().unwrap(), Token::EndOfStream); } }; } macro_rules! test_selectors { ($name:ident, $text:expr, $( $token:expr ),*) => { #[test] fn $name() { let mut t = Tokenizer::new($text); $( assert_eq!(t.parse_next().unwrap(), $token); )* assert_eq!(t.parse_next().unwrap(), Token::BlockStart); assert_eq!(t.parse_next().unwrap(), Token::Declaration("color", "red")); assert_eq!(t.parse_next().unwrap(), Token::BlockEnd); assert_eq!(t.parse_next().unwrap(), Token::EndOfStream); } }; } macro_rules! test_err { ($name:ident, $text:expr, $err:expr) => { #[test] fn $name() { let mut t = Tokenizer::new($text); assert_eq!(t.parse_next().unwrap_err(), $err); } }; } test_selectors!(selectors_1, "* { color: red }", Token::UniversalSelector ); test_selectors!(selectors_2, "p { color: red }", Token::TypeSelector("p") ); test_selectors!(selectors_3, ":first-child { color: red }", Token::PseudoClass("first-child") ); test_selectors!(selectors_4, ":lang(fr) { color: red }", Token::LangPseudoClass("fr") ); test_selectors!(selectors_6, ".cls { color: red }", Token::ClassSelector("cls") ); test_selectors!(selectors_7, "#p2 { color: red }", Token::IdSelector("p2") ); test_selectors!(selectors_8, "#p2{color:red}", Token::IdSelector("p2") ); test_selectors!(selectors_9, " div { color:red }", Token::TypeSelector("div") ); test_selectors!(complex_selectors_1, "h1 p { color: red; }", Token::TypeSelector("h1"), Token::Combinator(Combinator::Space), Token::TypeSelector("p") ); test_selectors!(complex_selectors_2, "h1 p g k { color: red; }", Token::TypeSelector("h1"), Token::Combinator(Combinator::Space), Token::TypeSelector("p"), Token::Combinator(Combinator::Space), Token::TypeSelector("g"), Token::Combinator(Combinator::Space), Token::TypeSelector("k") ); test_selectors!(complex_selectors_3, "[rel=\"author\"], [rel=\"alternate\"] { color: red; }", Token::AttributeSelector("rel=\"author\""), Token::Comma, Token::AttributeSelector("rel=\"alternate\"") ); test_selectors!(complex_selectors_4, "div:after, div:before { color: red; }", Token::TypeSelector("div"), Token::PseudoClass("after"), Token::Comma, Token::TypeSelector("div"), Token::PseudoClass("before") ); test_selectors!(complex_selectors_5, "p.valid { color: red; }", Token::TypeSelector("p"), Token::ClassSelector("valid") ); test_selectors!(complex_selectors_6, ".test:first-letter { color: red; }", Token::ClassSelector("test"), Token::PseudoClass("first-letter") ); test_selectors!(complex_selectors_7, ".test, .control { color: red; }", Token::ClassSelector("test"), Token::Comma, Token::ClassSelector("control") ); test_selectors!(complex_selectors_8, "div>h1 { color: red; }", Token::TypeSelector("div"), Token::Combinator(Combinator::GreaterThan), Token::TypeSelector("h1") ); test_selectors!(complex_selectors_9, "div > h1 { color: red; }", Token::TypeSelector("div"), Token::Combinator(Combinator::GreaterThan), Token::TypeSelector("h1") ); test_selectors!(complex_selectors_10, "div+h1 { color: red; }", Token::TypeSelector("div"), Token::Combinator(Combinator::Plus), Token::TypeSelector("h1") ); test_selectors!(complex_selectors_11, "div+h1 { color: red; }", Token::TypeSelector("div"), Token::Combinator(Combinator::Plus), Token::TypeSelector("h1") ); test_selectors!(complex_selectors_12, "p.test:first-letter { color: red; }", Token::TypeSelector("p"), Token::ClassSelector("test"), Token::PseudoClass("first-letter") ); test_selectors!(complex_selectors_13, "#div1 + p { color: red; }", Token::IdSelector("div1"), Token::Combinator(Combinator::Plus), Token::TypeSelector("p") ); test_selectors!(complex_selectors_14, "button[type=\"submit\"] { color: red; }", Token::TypeSelector("button"), Token::AttributeSelector("type=\"submit\"") ); test_selectors!(complex_selectors_15, "div em[id] { color: red; }", Token::TypeSelector("div"), Token::Combinator(Combinator::Space), Token::TypeSelector("em"), Token::AttributeSelector("id") ); test_selectors!(complex_selectors_16, "div * em { color: red; }", Token::TypeSelector("div"), Token::UniversalSelector, Token::TypeSelector("em") ); test_selectors!(complex_selectors_17, "div#div1 { color: red; }", Token::TypeSelector("div"), Token::IdSelector("div1") ); test_selectors!(complex_selectors_18, "div#x:first-letter { color: red; }", Token::TypeSelector("div"), Token::IdSelector("x"), Token::PseudoClass("first-letter") ); test_selectors!(complex_selectors_19, "[class=foo] + div + div + div + div { color: red; }", Token::AttributeSelector("class=foo"), Token::Combinator(Combinator::Plus), Token::TypeSelector("div"), Token::Combinator(Combinator::Plus), Token::TypeSelector("div"), Token::Combinator(Combinator::Plus), Token::TypeSelector("div"), Token::Combinator(Combinator::Plus), Token::TypeSelector("div") ); test_selectors!(complex_selectors_20, "input[type=\"radio\"]:focus + label { color: red; }", Token::TypeSelector("input"), Token::AttributeSelector("type=\"radio\""), Token::PseudoClass("focus"), Token::Combinator(Combinator::Plus), Token::TypeSelector("label") ); test_selectors!(complex_selectors_21, ":visited:active { color: red; }", Token::PseudoClass("visited"), Token::PseudoClass("active") ); // it's actually invalid, but we do not validate it test_selectors!(complex_selectors_22, "p:first-line p, #p1 { color: red; }", Token::TypeSelector("p"), Token::PseudoClass("first-line"), Token::Combinator(Combinator::Space), Token::TypeSelector("p"), Token::Comma, Token::IdSelector("p1") ); test_selectors!(complex_selectors_23, "p * { color: red; }", Token::TypeSelector("p"), Token::UniversalSelector ); test_selectors!(complex_selectors_24, "*:active { color: red; }", Token::UniversalSelector, Token::PseudoClass("active") ); test_selectors!(complex_selectors_25, "html > body > *:first-line { color: red; }", Token::TypeSelector("html"), Token::Combinator(Combinator::GreaterThan), Token::TypeSelector("body"), Token::Combinator(Combinator::GreaterThan), Token::UniversalSelector, Token::PseudoClass("first-line") ); test_selectors!(attribute_selector_1, "[attr=\"test\"] { color: red }", Token::AttributeSelector("attr=\"test\"") ); test_selectors!(attribute_selector_2, "[attr=\"test\"][attr2=\"test2\"] { color: red }", Token::AttributeSelector("attr=\"test\""), Token::AttributeSelector("attr2=\"test2\"") ); test!(blocks_1, "p { color: red; } p { color: red; }", Token::TypeSelector("p"), Token::BlockStart, Token::Declaration("color", "red"), Token::BlockEnd, Token::TypeSelector("p"), Token::BlockStart, Token::Declaration("color", "red"), Token::BlockEnd ); test!(blocks_2, "p{color:red;}p{color:red;}", Token::TypeSelector("p"), Token::BlockStart, Token::Declaration("color", "red"), Token::BlockEnd, Token::TypeSelector("p"), Token::BlockStart, Token::Declaration("color", "red"), Token::BlockEnd ); test!(blocks_3, "p { color:red; }", Token::TypeSelector("p"), Token::BlockStart, Token::Declaration("color", "red"), Token::BlockEnd ); test!(blocks_4, "p { color:red; }", Token::TypeSelector("p"), Token::BlockStart, Token::Declaration("color", "red"), Token::BlockEnd ); test!(blocks_5, "p{}", Token::TypeSelector("p"), Token::BlockStart, Token::BlockEnd ); #[test] fn declarations_1() { let vec = vec![ "p {color:red}", "p {color:red;}", "p {color:red }", "p { color: red; }", "p { color : red ; }", "p { color : red ; } ", "p { color : red ; }" ]; for css in vec { let mut t = Tokenizer::new(css); assert_eq!(t.parse_next().unwrap(), Token::TypeSelector("p")); assert_eq!(t.parse_next().unwrap(), Token::BlockStart); assert_eq!(t.parse_next().unwrap(), Token::Declaration("color", "red")); assert_eq!(t.parse_next().unwrap(), Token::BlockEnd); assert_eq!(t.parse_next().unwrap(), Token::EndOfStream); } } test!(declarations_2, "p { color:red;;;;color:red; }", Token::TypeSelector("p"), Token::BlockStart, Token::Declaration("color", "red"), Token::Declaration("color", "red"), Token::BlockEnd ); test!(declarations_3, "* {list-style-image: url(\"img.png\");}", Token::UniversalSelector, Token::BlockStart, Token::Declaration("list-style-image", "url(\"img.png\")"), Token::BlockEnd ); test!(declarations_4, "* { color: white ! important; }", Token::UniversalSelector, Token::BlockStart, Token::Declaration("color", "white ! important"), Token::BlockEnd ); test!(declarations_5, "* { border: 1em solid blue; background: navy url(support/diamond.png) -2em -2em no-repeat }", Token::UniversalSelector, Token::BlockStart, Token::Declaration("border", "1em solid blue"), Token::Declaration("background", "navy url(support/diamond.png) -2em -2em no-repeat"), Token::BlockEnd ); test!(declarations_6, "* {stroke-width:2}", Token::UniversalSelector, Token::BlockStart, Token::Declaration("stroke-width", "2"), Token::BlockEnd ); test!(comment_1, "/* .test { color: green ! important; } */ * { color: red; }", Token::UniversalSelector, Token::BlockStart, Token::Declaration("color", "red"), Token::BlockEnd ); test!(comment_2, "p /* comment */ { color:red }", Token::TypeSelector("p"), Token::BlockStart, Token::Declaration("color", "red"), Token::BlockEnd ); test!(comment_3, "p /* comment */ div { color:red }", Token::TypeSelector("p"), Token::Combinator(Combinator::Space), Token::TypeSelector("div"), Token::BlockStart, Token::Declaration("color", "red"), Token::BlockEnd ); test!(comment_4, "div { /**/color: red; }", Token::TypeSelector("div"), Token::BlockStart, Token::Declaration("color", "red"), Token::BlockEnd ); test!(comment_5, "div { /**/color: red; }", Token::TypeSelector("div"), Token::BlockStart, Token::Declaration("color", "red"), Token::BlockEnd ); test!(comment_6, "div { /* *\\/*/color: red; }", Token::TypeSelector("div"), Token::BlockStart, Token::Declaration("color", "red"), Token::BlockEnd ); // TODO: comment can be between 'red' and ';' test!(comment_7, "/*Comment*/div/*Comment*/ { /*Comment*/color/*Comment*/: /*Comment*/red; /*Comment*/ }/*Comment*/", Token::TypeSelector("div"), Token::BlockStart, Token::Declaration("color", "red"), Token::BlockEnd ); test!(comment_8, " /* * Comment */ div { color : red }", Token::TypeSelector("div"), Token::BlockStart, Token::Declaration("color", "red"), Token::BlockEnd ); test_err!(invalid_2, "# div1", Error::UnknownToken(ErrorPos::new(1, 2)) ); // test_err!(invalid_3, // "#1div ", // Error::UnknownToken(ErrorPos::new(1, 2)) // ); test_err!(invalid_4, "@import", Error::UnsupportedToken(ErrorPos::new(1, 1)) ); #[test] fn invalid_5() { let mut t = Tokenizer::new("div { {color: red;} }"); assert_eq!(t.parse_next().unwrap(), Token::TypeSelector("div")); assert_eq!(t.parse_next().unwrap(), Token::BlockStart); assert_eq!(t.parse_next().unwrap_err(), Error::UnknownToken(ErrorPos::new(1, 7))); } #[test] fn invalid_6() { let mut t = Tokenizer::new("div { (color: red;) }"); assert_eq!(t.parse_next().unwrap(), Token::TypeSelector("div")); assert_eq!(t.parse_next().unwrap(), Token::BlockStart); assert_eq!(t.parse_next().unwrap_err(), Error::UnknownToken(ErrorPos::new(1, 7))); } #[test] fn invalid_7() { let mut t = Tokenizer::new("div { [color: red;] }"); assert_eq!(t.parse_next().unwrap(), Token::TypeSelector("div")); assert_eq!(t.parse_next().unwrap(), Token::BlockStart); assert_eq!(t.parse_next().unwrap_err(), Error::UnknownToken(ErrorPos::new(1, 7))); } #[test] fn invalid_8() { let mut t = Tokenizer::new("div { color: }"); assert_eq!(t.parse_next().unwrap(), Token::TypeSelector("div")); assert_eq!(t.parse_next().unwrap(), Token::BlockStart); // assert_eq!(t.parse_next().unwrap(), Token::Property("color")); assert_eq!(t.parse_next().unwrap_err(), Error::UnknownToken(ErrorPos::new(1, 14))); } #[test] fn invalid_9() { let mut t = Tokenizer::new("div"); assert_eq!(t.parse_next().unwrap(), Token::TypeSelector("div")); // TODO: should be UnexpectedEndOfStream assert_eq!(t.parse_next().unwrap(), Token::EndOfStream); } #[test] fn invalid_10() { let mut t = Tokenizer::new("div { /\\*;color: green;*/ }"); assert_eq!(t.parse_next().unwrap(), Token::TypeSelector("div")); assert_eq!(t.parse_next().unwrap(), Token::BlockStart); assert_eq!(t.parse_next().unwrap_err(), Error::UnknownToken(ErrorPos::new(1, 8))); } #[test] fn invalid_11() { let mut t = Tokenizer::new("div { /*\\*/*/color: red; }"); assert_eq!(t.parse_next().unwrap(), Token::TypeSelector("div")); assert_eq!(t.parse_next().unwrap(), Token::BlockStart); assert_eq!(t.parse_next().unwrap_err(), Error::UnknownToken(ErrorPos::new(1, 12))); } test_err!(invalid_12, ".平和 { color: red; }", Error::UnknownToken(ErrorPos::new(1, 2)) ); // #[test] // fn invalid_13() { // let mut t = Tokenizer::new("div { causta: \"}\" + ({7} * '\'') }"); // assert_eq!(t.parse_next().unwrap(), Token::TypeSelector("div")); // assert_eq!(t.parse_next().unwrap(), Token::BlockStart); // assert_eq!(t.parse_next().unwrap(), Token::Declaration("causta", "\"")); // assert_eq!(t.parse_next().unwrap_err(), Error::UnknownToken(ErrorPos::new(1, 15))); // } #[test] fn invalid_14() { let mut t = Tokenizer::new( "div { \"this is a string]}\"\"[{\\\"'\"; /*should be parsed as a string but be ignored*/ {{}}[]''; /*should be parsed as nested blocks and a string but be ignored*/ color: green; }"); assert_eq!(t.parse_next().unwrap(), Token::TypeSelector("div")); assert_eq!(t.parse_next().unwrap(), Token::BlockStart); assert_eq!(t.parse_next().unwrap_err(), Error::UnknownToken(ErrorPos::new(3, 5))); } test_err!(invalid_15, ".\\xC3\\xA9 { color: red; }", Error::UnknownToken(ErrorPos::new(1, 2)) ); test_err!(invalid_16, "::invalidPseudoElement", Error::UnknownToken(ErrorPos::new(1, 2)) ); #[test] fn invalid_17() { let mut t = Tokenizer::new(" "); assert_eq!(t.parse_next().unwrap(), Token::EndOfStream); } #[test] fn invalid_18() { let mut t = Tokenizer::new("div > >"); assert_eq!(t.parse_next().unwrap(), Token::TypeSelector("div")); assert_eq!(t.parse_next().unwrap(), Token::Combinator(Combinator::GreaterThan)); assert_eq!(t.parse_next().unwrap_err(), Error::UnknownToken(ErrorPos::new(1, 7))); } simplecss-0.1.0/simplecss.sublime-project01006440001750000175000000002116130243346310016762 0ustar0000000000000000{ "folders": [ { "path": "/media/data/Programming/Projects/rust/simplecss/", "folder_exclude_patterns": ["target"] } ], "build_systems": [ { "name": "Cargo Build", "cmd": ["cargo", "build"], "selector": "source.rust", "file_regex": "(?|, ([^,<\n]*\\.[A-z]{2}):([0-9]+)|[ \t]*-->[ \t]*([^<\n]*):([0-9]+):([0-9]+))", "syntax": "Cargo.build-language", "working_dir": "/media/data/Programming/Projects/rust/simplecss/", "path": "$HOME/.cargo/bin:$PATH", }, { "name": "Cargo Test", "cmd": ["cargo", "test", "--", "--nocapture"], "selector": "source.rust", "file_regex": "(?|, ([^,<\n]*\\.[A-z]{2}):([0-9]+)|[ \t]*-->[ \t]*([^<\n]*):([0-9]+):([0-9]+))", "syntax": "Cargo.build-language", "working_dir": "/media/data/Programming/Projects/rust/simplecss/", // "env": { "RUST_BACKTRACE":"1" }, "path": "$HOME/.cargo/bin:$PATH", } ] } simplecss-0.1.0/simplecss.sublime-workspace01006440001750000175000000104173130342271750017325 0ustar0000000000000000{ "auto_complete": { "selected_items": [ [ "C", "Combinator EnumVariant (tokenizer.rs) : Combinator(Combinator), " ], [ "B", "BlockEnd EnumVariant (tokenizer.rs) : BlockEnd, " ], [ "ge", "gen_error_pos Function (stream.rs) : pub fn gen_error_pos(&self) -> ErrorPos " ], [ "a", "assert\tassert!(…)" ], [ "Com", "Combinator EnumVariant (tokenizer.rs) : Combinator(Combinator)," ], [ "cons", "consume_rule Function (tokenizer.rs) : fn consume_rule(&mut self) -> Result<&'a str, Error> " ], [ "s", "consume_comment Function (tokenizer.rs) : fn consume_comment(&mut self) -> Result<(), Error> " ], [ "Bloc", "BlockStart EnumVariant (tokenizer.rs) : BlockStart," ], [ "Erro", "ErrorPos Struct (error.rs) : pub struct ErrorPos " ], [ "Blo", "OpenBlock" ], [ "len", "len_to" ], [ "curr", "curr_char_raw Function (stream.rs) : pub fn curr_char_raw(&self) -> u8 " ], [ "con", "consume_ident Function (tokenizer.rs) : fn consume_ident(&mut self) -> Result<&'a str, Error>" ], [ "par", "parse_at_keyword Function (tokenizer.rs) : fn parse_at_keyword(&mut self) -> Result, Error>" ], [ "as", "as_bytes" ], [ "E", "EmptyLang EnumVariant (error.rs) : EmptyLang(ErrorPos)," ], [ "read", "read_raw_str Function (stream.rs) : pub fn read_raw_str(&mut self, len: usize) -> &'a str " ], [ "isc", "is_char_eq Function (stream.rs) : pub fn is_char_eq(&self, c: u8) -> Result " ], [ "is_spa", "is_space_raw Function (stream.rs) : pub fn is_space_raw(&self) -> bool " ], [ "is_ch", "is_char_eq_raw Function (stream.rs) : pub fn is_char_eq_raw(&self, c: u8) -> bool " ], [ "cur", "curr_char_raw Function (stream.rs) : pub fn curr_char_raw(&self) -> u8 " ], [ "Open", "OpenCurly EnumVariant (tokenizer.rs) : OpenCurly, " ], [ "sele", "selectors Let (tokenizer.rs) : let mut selectors = Vec::new()\\ " ], [ "while", "while\twhile … { … }" ], [ "adva", "advance_raw Function (stream.rs) : pub fn advance_raw(&mut self, n: usize) " ], [ "jump", "jump_to Function (stream.rs) : pub fn jump_to(&mut self, c: u8) -> Result<(), Error> " ], [ "stre", "stream Module (stream.rs) : /media/data/Programming/Projects/rust/simplecss/src/stream.rs" ], [ "sty", "styles2" ], [ "fuz", "fuzzy_eq" ], [ "macro", "macro_rules\tmacro_rules! … { … }" ], [ "prev", "previous" ], [ "impl", "implicit" ], [ "imp", "implicit" ], [ "up", "use_implicit_lineto_commands StructField (write_options.rs) : bool" ], [ "use", "use_implicit_lineto_commands" ], [ "wr", "write_dom" ], [ "Att", "Attribute Struct (attribute.rs) : pub struct Attribute " ], [ "ext", "extern-crate\textern crate …;" ], [ "set", "set_attribute" ], [ "tran", "transforms" ], [ "get_", "get_scale" ], [ "new", "new_x" ], [ "get", "get_skew Function (transform.rs) : pub fn get_skew(&self) -> (f64, f64) " ], [ "chid", "children_all" ], [ "child", "children" ], [ "refe", "reference" ], [ "first", "first_element_child Function (dom.rs) : pub fn first_element_child(&self) -> Option" ], [ "Nodet", "NodeType Enum (dom.rs) : pub enum NodeType { " ], [ "supp", "support" ], [ "write", "write_buf_opt Function (attribute.rs) : fn write_buf_opt(&self, opt: &WriteOptions, buf: &mut Vec)" ], [ "Seg", "SegmentData Enum (path.rs) : pub enum SegmentData {" ], [ "is", "is_absolute Function (path.rs) : pub fn is_absolute(&self) -> bool " ], [ "abs", "absolute" ], [ "i", "is_absolute Function (path.rs) : pub fn is_absolute(c: u8) -> bool" ], [ "S", "SmoothQuadratic EnumVariant (path.rs) : SmoothQuadratic," ], [ "data", "data_mut" ], [ "to", "to_absolute" ], [ "pa", "path Module (path.rs) : /media/data/Programming/Projects/rust/svgdom/../svgparser/src/path.rs " ], [ "print", "println\tprintln!(…)" ], [ "refr", "referenced" ], [ "L", "Link EnumVariant (attribute.rs) : Link(Node), " ], [ "Attr", "AttributeValue Enum (attribute.rs) : pub enum AttributeValue { " ], [ "lo", "linked_nodes Function (dom.rs) : pub fn linked_nodes(&self) -> LinkAttributes " ], [ "rem", "remove_attribute Function (dom.rs) : pub fn remove_attribute(&self, id: AttributeId) " ], [ "borro", "borrow_mut" ], [ "remove", "remove_attribute" ], [ "Cir", "circle" ], [ "f", "Filter EnumVariant (attribute.rs) : Filter, " ], [ "att", "attr_id" ], [ "Fall", "PaintFallback" ], [ "u", "UnsupportedPaintFallback EnumVariant (error.rs) : UnsupportedPaintFallback(String), // FuncIRI name" ], [ "Err", "Error Enum (error.rs) : pub enum Error { " ], [ "suppo", "supported" ], [ "Us", "Unsupported" ], [ "Value", "PredefValue" ], [ "is_e", "is_element" ], [ "is_", "is_some Function (option.rs) : pub fn is_some(&self) -> bool " ], [ "des", "descendants_all Function (dom.rs) : pub fn descendants_all(&self) -> DescendantsAll " ], [ "recur", "recursive" ], [ "next", "next_sibling" ], [ "previ", "previous_sibling" ], [ "contai", "container" ], [ "leng", "LengthUnit" ], [ "firs", "first_child" ], [ "Vec", "VecMap Struct (lib.rs) : pub struct VecMap " ], [ "the", "their" ], [ "iter", "iterator" ], [ "gra", "gradient Let (domapi.rs) : let gradient = doc.create_element(EId::LinearGradient)\\ " ], [ "Line", "LinearGradient EnumVariant (element.rs) : LinearGradient," ], [ "Node", "NodeType Enum (dom.rs) : pub enum NodeType { " ], [ "from", "from_data_with_opt Function (dom.rs) : pub fn from_data_with_opt(data: &[u8], opt: &ParseOptions) -> Result " ], [ "tra", "traits Module (traits.rs) : /media/data/Programming/Projects/rust/svgdom/src/traits.rs " ], [ "wri", "write_num" ], [ "Wri", "WriteOptions Struct (write_options.rs) : pub struct WriteOptions " ], [ "Write", "WriteOptions Struct (write_options.rs) : pub struct WriteOptions " ], [ "Parse", "ParseOptions" ], [ "sub", "subitem" ], [ "Pars", "ParseError" ], [ "fr", "from_stream" ], [ "seg", "Segment" ], [ "Tra", "transforms" ], [ "Uni", "UnicodeBidi EnumVariant (attribute.rs) : UnicodeBidi, " ], [ "Text", "TextAnchor EnumVariant (attribute.rs) : TextAnchor, " ], [ "Len", "LengthUnit Enum (length.rs) : pub enum LengthUnit " ], [ "Stroke", "StrokeOpacity EnumVariant (attribute.rs) : StrokeOpacity, " ], [ "Strok", "StrokeMiterlimit EnumVariant (attribute.rs) : StrokeMiterlimit, " ], [ "Stro", "StrokeLinecap EnumVariant (attribute.rs) : StrokeLinecap, " ], [ "Str", "StrokeDasharray EnumVariant (attribute.rs) : StrokeDasharray, " ], [ "Gly", "GlyphOrientationHorizontal EnumVariant (attribute.rs) : GlyphOrientationHorizontal," ], [ "FontSize", "FontSizeAdjust EnumVariant (attribute.rs) : FontSizeAdjust," ], [ "Floo", "FloodOpacity EnumVariant (attribute.rs) : FloodOpacity, " ], [ "Color", "ColorProfile EnumVariant (attribute.rs) : ColorProfile, " ], [ "from_", "from_name" ], [ "Eleme", "ElementId Enum (element.rs) : pub enum ElementId { " ], [ "Ele", "ElementId Enum (element.rs) : pub enum ElementId { " ], [ "Al", "AlignmentBaseline EnumVariant (attribute.rs) : AlignmentBaseline," ], [ "pow", "powi" ], [ "pat", "paths StructField (options.rs) : Paths " ], [ "pus", "push_str Function (string.rs) : pub fn push_str(&mut self, string: &str) " ], [ "prin", "println\tprintln!(…)" ], [ "Uns", "UnsupportedCSS EnumVariant (parser.rs) : UnsupportedCSS(ErrorPos), " ], [ "entity", "ENTITY" ], [ "slic", "slice_next_raw Function (stream.rs) : pub fn slice_next_raw(&self, len: usize) -> &'a [u8] " ], [ "skip", "skip_svg_elements" ], [ "va", "values Function (lib.rs) : pub fn values(&self) -> Values " ], [ "uw", "unwrap_or Function (option.rs) : pub fn unwrap_or(self, def: T) -> T " ], [ "w", "write_buf Function (mod.rs) : fn write_buf(&self, buf: &mut Vec) " ], [ "Paths", "PathSegment Struct (path.rs) : pub struct PathSegment { " ] ] }, "buffers": [ { "file": "src/lib.rs", "settings": { "buffer_size": 2837, "encoding": "UTF-8", "line_ending": "Unix" } }, { "file": "src/tokenizer.rs", "settings": { "buffer_size": 11542, "encoding": "UTF-8", "line_ending": "Unix" } }, { "file": "tests/css.rs", "settings": { "buffer_size": 16065, "encoding": "UTF-8", "line_ending": "Unix" } } ], "build_system": "Cargo Test", "build_system_choices": [ [ [ [ "Cargo Build", "" ], [ "Cargo Test", "" ], [ "Packages/Rust Enhanced/Cargo.sublime-build", "" ], [ "Packages/Rust Enhanced/Cargo.sublime-build", "Run" ], [ "Packages/Rust Enhanced/Cargo.sublime-build", "Test" ], [ "Packages/Rust Enhanced/Cargo.sublime-build", "Bench" ], [ "Packages/Rust Enhanced/Cargo.sublime-build", "Clean" ], [ "Packages/Rust Enhanced/Cargo.sublime-build", "Release" ], [ "Packages/Rust Enhanced/Cargo.sublime-build", "Clippy" ], [ "Packages/Rust Enhanced/Rust.sublime-build", "" ], [ "Packages/Rust Enhanced/Rust.sublime-build", "Run" ] ], [ "Cargo Test", "" ] ] ], "build_varint": "", "command_palette": { "height": 291.0, "last_filter": "men", "selected_items": [ [ "men", "View: Toggle Menu" ], [ "sett", "Preferences: Settings" ], [ "me", "View: Toggle Menu" ], [ "package", "Package Control: Upgrade Package" ], [ "up", "Package Control: Upgrade Package" ], [ "insta", "Package Control: Install Package" ], [ "git co", "Git: Commit history" ], [ "git di", "Git: Diff All Files" ], [ "m", "View: Toggle Menu" ], [ "", "About" ], [ "pc", "Package Control: Upgrade Package" ], [ "tm", "View: Toggle Menu" ], [ "pa", "Package Control: Install Package" ], [ "v", "View: Toggle Menu" ], [ "pack", "Package Control: Upgrade Package" ], [ "p", "Package Control: Upgrade Package" ], [ "vmen", "View: Toggle Menu" ], [ "pae", "Package Control: Enable Package" ], [ "rpv", "PackageResourceViewer: Extract Package" ], [ "prv", "PackageResourceViewer: Extract Package" ] ], "width": 400.0 }, "console": { "height": 153.0, "history": [ "import urllib.request,os,hashlib; h = '2915d1851351e5ee549c20394736b442' + '8bc59f460fa1548d1514676163dafc88'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)" ] }, "distraction_free": { "menu_visible": true, "show_minimap": false, "show_open_files": false, "show_tabs": false, "side_bar_visible": false, "status_bar_visible": false }, "expanded_folders": [ "/media/data/Programming/Projects/rust/simplecss", "/media/data/Programming/Projects/rust/simplecss/src", "/media/data/Programming/Projects/rust/simplecss/tests" ], "file_history": [ "/media/data/Programming/Projects/rust/simplecss/README.md", "/media/data/Programming/Projects/rust/simplecss/src/error.rs", "/media/data/Programming/Projects/rust/simplecss/src/stream.rs", "/media/data/Programming/Projects/rust/simplecss/tests/css.rs", "/media/data/Programming/Projects/rust/simplecss/Cargo.toml", "/media/data/Programming/Projects/rust/simplecss/src/lib.rs", "/media/data/Stuff/home/rustc-1.12.0/src/libcollections/str.rs", "/media/data/Stuff/home/rustc-1.12.0/src/libcore/str/mod.rs", "/media/data/Programming/Projects/rust/simplecss/--> src/error.rs", "/media/data/Programming/Projects/rust/svgdom/tests/parser.rs", "/media/data/Programming/Projects/rust/svgdom/src/lib.rs", "/media/data/Programming/Projects/rust/svgdom/tests/css.rs", "/media/data/Programming/Projects/rust/svgdom/svgdom.sublime-project", "/media/data/Programming/Projects/rust/svgdom/CHANGELOG.md", "/media/data/Programming/Projects/rust/svgdom/src/parse_options.rs", "/media/data/Programming/Projects/rust/svgdom/src/error.rs", "/home/razr/.cargo/registry/src/github.com-1ecc6299db9ec823/svgparser-0.1.0/src/path.rs", "/media/data/Programming/Projects/rust/svgdom/src/types/number.rs", "/media/data/Programming/Projects/rust/svgdom/src/types/mod.rs", "/media/data/Programming/Projects/rust/svgdom/src/attribute/attributes.rs", "/media/data/Programming/Projects/rust/svgdom/src/dom/doc.rs", "/media/data/Programming/Projects/rust/svgdom/src/attribute/attribute_value.rs", "/media/data/Programming/Projects/rust/svgdom/src/writer.rs", "/media/data/Programming/Projects/rust/svgdom/src/types/path.rs", "/media/data/Programming/Projects/rust/svgdom/src/write_options.rs", "/media/data/Programming/Projects/rust/svgdom/examples/custom_writer.rs", "/media/data/Programming/Projects/rust/svgdom/src/dom/node.rs", "/media/data/Programming/Projects/rust/svgdom/src/dom/iterators.rs", "/media/data/Programming/Projects/rust/svgdom/src/types/color.rs", "/media/data/Programming/Projects/rust/svgdom/src/types/transform.rs", "/media/data/Programming/Projects/rust/svgdom/Cargo.toml", "/media/data/Programming/Projects/rust/svgdom/src/types/float_cmp.rs", "/media/data/Programming/Projects/rust/svgdom/README.md", "/media/data/Programming/Projects/rust/svgdom/src/parser.rs", "/media/data/Programming/Projects/rust/svgdom/src/traits.rs", "/media/data/Programming/Projects/rust/svgdom/src/attribute/attribute.rs", "/media/data/Programming/Projects/rust/svgdom/src/attribute/mod.rs", "/media/data/Programming/Projects/rust/svgdom/src/write.rs", "/media/data/Programming/Projects/rust/svgdom/src/dom.rs", "/media/data/Programming/Projects/rust/svgdom/src/attribute.rs", "/media/data/Programming/Projects/rust/svgdom/src/attributes.rs", "/media/data/Programming/Projects/rust/svgdom/tests/domapi.rs", "/media/data/Programming/Projects/rust/svgdom/src/dom.rs:425:52: 425:54src/dom.rs", "/media/data/Programming/Projects/rust/svgparser/src/path.rs", "/media/data/Programming/Projects/rust/svgdom/examples/count_curveto_segments.rs", "/home/razr/.cargo/registry/src/github.com-1ecc6299db9ec823/vec_map-0.6.0/src/lib.rs", "/media/data/Stuff/home/rustc-1.10.0/src/libcore/mem.rs", "/media/data/Stuff/home/rustc-1.10.0/src/libcollections/vec.rs", "/media/data/Stuff/home/rustc-1.10.0/src/liballoc/raw_vec.rs", "/media/data/Stuff/home/rustc-1.10.0/src/libcore/cell.rs", "/media/data/Programming/Projects/rust/svgdom/Cargo.lock", "/media/data/Programming/Projects/rust/svgdom/tests/generator.rs", "/media/data/Programming/Projects/rust/svgdom/examples/resave.rs", "/media/data/Programming/Projects/rust/svgparser/src/rgbcolor.rs", "/media/data/Programming/Projects/rust/svgparser/src/values_list.rs", "/media/data/Programming/Projects/rust/svgdom/src/types/length.rs", "/media/data/Programming/Projects/rust/svgdom/src/dom.rs:466:5: 466:8src/dom.rs", "/media/data/Stuff/home/rustc-1.10.0/src/libcollections/string.rs", "/media/data/Programming/Projects/rust/svgparser/src/element.rs", "/media/data/Stuff/home/rustc-1.10.0/src/libcollections/borrow.rs", "/media/data/Programming/Projects/rust/svgdom/src/write/mod.rs", "/media/data/Programming/Projects/rust/svgdom/src/write/options.rs", "/media/data/Programming/Projects/rust/svgdom/src/types/attributes.rs", "/media/data/Programming/Projects/rust/svgdom/src/write/number.rs", "/media/data/Stuff/home/rustc-1.10.0/src/liballoc/boxed.rs", "/media/data/Stuff/home/rustc-1.10.0/src/libcore/ops.rs", "/media/data/Programming/Projects/rust/svgparser/src/stream.rs", "/media/data/Programming/Projects/rust/svgparser/src/attribute_value.rs", "/media/data/Programming/Projects/rust/svgdom/src/write/length.rs", "/media/data/Programming/Projects/rust/svgparser/src/length.rs", "/media/data/Programming/Projects/rust/svgdom/src/write/depth.rs", "/media/data/Programming/Projects/rust/svgparser/src/svg.rs", "/media/data/Programming/Projects/rust/svgparser/src/error.rs", "/media/data/Programming/Projects/rust/svgparser/src/style.rs", "/media/data/Programming/Projects/rust/svgdom/TODO.txt", "/media/data/Programming/Projects/rust/svgparser/src/value_id.rs", "/media/data/Programming/Projects/rust/svgparser/src/color.rs", "/media/data/Programming/Projects/rust/svgparser/src/attribute.rs", "/home/razr/.cargo/registry/src/github.com-1ecc6299db9ec823/ascii-0.7.0/src/ascii_string.rs", "/home/razr/.cargo/registry/src/github.com-1ecc6299db9ec823/ascii-0.7.0/src/ascii_char.rs", "/media/data/Programming/Projects/rust/svgdom/src/", "/media/data/Programming/Projects/rust/svgdom/src/write/predefvalue.rs", "/media/data/Programming/Projects/rust/svgparser/src/lib.rs", "/media/data/Programming/Projects/rust/svgparser/src/transform.rs", "/media/data/Programming/Projects/rust/svgdom/src/write/color.rs", "/media/data/Stuff/home/rustc-1.10.0/src/libcore/option.rs", "/home/razr/.multirust/toolchains/stable/src/src/libcollections/string.rs", "/media/data/Programming/Projects/rust/svgdom/src/write/path.rs", "/media/data/Programming/Projects/rust/svgdom/src/write/transform.rs", "/home/razr/.multirust/toolchains/stable/src/src/libcollections/vec.rs", "/home/razr/.multirust/toolchains/stable/src/src/liballoc/rc.rs", "/home/razr/.multirust/toolchains/stable/src/src/libcore/iter.rs", "/home/razr/.multirust/toolchains/stable/src/src/libcore/option.rs", "/media/data/Programming/Projects/rust/svgdom/src/transform.rs", "/home/razr/.multirust/toolchains/stable/cargo/registry/src/github.com-88ac128001ac3a9a/ascii-0.6.0/src/lib.rs", "/media/data/Programming/Projects/rust/svgdom/src/", "/home/razr/.multirust/toolchains/stable/src/src/libcore/cell.rs", "/media/data/Programming/Projects/rust/svgdom/tests/parser.rs:14:5: 14:26/media/data/Programming/Projects/rust/svgdom/tests/generator.rs", "/home/razr/.multirust/toolchains/stable/src/src/libstd/collections/hash/map.rs", "/home/razr/.config/sublime-text-3/Packages/User/Preferences.sublime-settings", "/media/data/Programming/Projects/rust/svgdom/src/write/transform.rs:15:5: 15:17/media/data/Programming/Projects/rust/svgdom/src/write/transform.rs", "/media/data/Programming/Projects/rust/svgdom/src/generator.rs", "/media/data/Programming/Projects/rust/svgparser/tests/stream.rs", "/media/data/Programming/Projects/rust/svgdom/src/generator/mod.rs", "/media/data/Programming/Projects/rust/svgdom/src/generator/number.rs", "/media/data/Programming/Projects/rust/svgdom/tests/transform.rs", "/media/data/Programming/Projects/rust/svgdom/src/parser.rs:238:51: 238:52parser.rs", "/media/data/Programming/Projects/rust/svgdom/src/dom.rs:16:5: 16:16dom.rs", "/media/data/Programming/Projects/rust/svgparser/tests/svg.rs", "/media/data/Programming/Projects/rust/svgparser/tests/content.rs", "/media/data/Programming/Projects/rust/svgparser/src/attribute.rs:602:43: 602:69attribute.rs", "/media/data/Programming/Projects/rust/svgdom/src/parser.rs:474:26: 474:29parser.rs", "/media/data/Programming/Projects/rust/svgparser/src/raw.rs", "/media/data/Programming/Projects/rust/svgdom/src/length.rs", "/media/data/Programming/Projects/rust/svgdom/src/main.rs", "/media/data/Programming/Projects/rust/svgdom/src/element.rs", "/media/data/Programming/Projects/rust/svgdom/src/parser.rs:13:5: 13:34parser.rs", "/home/razr/.multirust/toolchains/stable/src/src/libcore/result.rs", "/media/data/Programming/Projects/rust/svgdom/spec/attributes.txt", "/media/data/Programming/Projects/rust/svgparser/src/paint.rs", "/media/data/Programming/Projects/rust/svgdom/tests/", "/media/data/Programming/Projects/rust/svgdom/src/domapi.rs", "/home/razr/.multirust/toolchains/stable/src/src/libstd/path.rs", "/media/data/Programming/Projects/rust/svgdom/target/debug/build/svgdom-abdefe845244cf7c/out/attrs_phash.rs", "/media/data/Programming/Projects/rust/svgdom/spec/elements.txt", "/media/data/Programming/Projects/rust/svgdom/build.rs", "/home/razr/.multirust/toolchains/stable/cargo/registry/src/github.com-88ac128001ac3a9a/vec_map-0.6.0/src/lib.rs", "/home/razr/.multirust/toolchains/stable/src/src/libcore/convert.rs" ], "find": { "height": 36.0 }, "find_in_files": { "height": 96.0, "where_history": [ "" ] }, "find_state": { "case_sensitive": false, "find_history": [ "InvalidAdvance", "# Examples", "svgparser", "curr_char", "char_at", "get_char_raw", "slice_next_raw", "gen_end_of_stream_error", "back", "InvalidIdent", "consume_char", "InvalidChar", "UnexpectedToken", "CloseBlock", "OpenBlock", "consume_char", "InvalidChar", "consume_ident", ";;", "simplecss::", "use svgparser::", "advance", "use svgparser::Stream;", "parse_css", "pub fn", "\"file_regex\": \"^(.*?):([0-9]+):([0-9]+):\\\\s[0-9]+:[0-9]+\\\\s(.*)$\",", "parse_style_attribute", "styles", "has_children(", "has_children", "children_all", "_all", "first_element_child", "childre", "children(", ".children()", "children(", "reference", "children(", "parse_svg_attribute", "entitis", "parse_svg_attribute", "post_link_data", ">>,\n", "ParseOptions", "parse_svg_attribute", "parse_style_attribute", "parse_svg_attribute", "Document", "resolve_css", "Document", "is_element()", "Selector", "post_attrs", "style", "doc.to_string()", "\\\"", "style", "prin", ":Link", "parse_iri_1", "set_li", "links_2", "abs: true,", " ", "to_absolute_", "test_to_absolute", "test_to_relative", "join_arc_to_flags", "attributes_types_1", "insert(", "insert", "detach()", "detach", "remove_attribute", "_mut", "values", "attribute(", "has_attribute", "has_attributes", "has_children", "iter", "children", "has_pare", "svgparser", "Warning:", "rustfmt", "id.clone()", "a SVG", "color", "append", "pop(", "process_text", "descendants_iter_1", "libsvgdom", "allow", "from_stream", "missing_docs", "InvalidCSS", "id.clone()", ".unwrap()", "attribute_value", ".attribute(", "LinkAttributes", "linked_nodes", "WeakLink", "same_rc", "child_by", "is_element", "is_tag_name", "child_by_tag_name", "ElementId", "AttributeId", ".clone()", "WriteToString", "create_element_node", "create_text_node", "create_node", "create_text_node", "create_node", "WriteBuffer", "svgparser::", "ParseError", "SvgParserError", "u8_to_astring", "AsciiString", "Attributes", "out" ], "highlight": true, "in_selection": false, "preserve_case": false, "regex": false, "replace_history": [ "UnknownToken", "BlockEnd", "BlockStart", "use simplecss::;", "use simplecss::Stream;", "fn", "\"file_regex\": \"(?|, ([^,<\\n]*\\\\.[A-z]{2}):([0-9]+)|[ \\t]*-->[ \\t]*([^<\\n]*):([0-9]+):([0-9]+))\",", "children_nodes", ".children_all()", "is_svg_element()", "doc.to_string_with_opt(&write_opt_for_tests!())", "'", "absolute: true,", " ", "", "test", "id", "attributes().get_value", ".attribute_value(", "create_element", "create_node", "create_element_node", "create_node", "create_element_node", "Error", "ParseError", "u8_to_string", "buf", "Segment", "svg::ElementEnd::", "svg::Token", "u8_to_str", "some!", "some", "AttributeId::", "buf", "doc.to_string", "parser::Error", "WriteOptions", "dom_to_string", "", "LengthUnit", "test_number", "is_char_eq", "", "parse_css_", "\\\"", "", "clr!(", "test_parse", "", ",", "", "\")", ", \"", ".entry(", "Node", "NodeData", "", "NodeRef", "Node", "Link", "WeakLink", "<'a>", "Node<'a>", "s", "pathsegment", "s", "));", ")", "Color::new", "m.insert(", "self.", "s.curr_char()", "curr_char", "s", "Tokenizer", "svg::Tokenizer", "svg::Parser::", "Parser", "Error", "self.stream.pos()", "self.stream.skip_spaces", "self.stream.left", "self.stream.curr_char", "self.stream.char_at", "self.stream.jump_to", "self.stream.advance", "self.stream.len_to", "self.stream.substr2", "self.stream.starts_with", "StreamError", "Tokenizer", "Parser", "(b\"", "", ",", "", "::F", "::C", "::A", "\", \"", ".entry(\"path, Element::path\");\n .entry(\"linearGradient, Element::linearGradient\");\n .entry(\"stop, Element::stop\");\n .entry(\"g, Element::g\");\n .entry(\"radialGradient, Element::radialGradient\");\n .entry(\"rect, Element::rect\");\n .entry(\"polygon, Element::polygon\");\n .entry(\"title, Element::title\");\n .entry(\"filter, Element::filter\");\n .entry(\"feGaussianBlur, Element::feGaussianBlur\");\n .entry(\"polyline, Element::polyline\");\n .entry(\"line, Element::line\");\n .entry(\"svg, Element::svg\");\n .entry(\"a, Element::a\");\n .entry(\"altGlyph, Element::altGlyph\");\n .entry(\"altGlyphDef, Element::altGlyphDef\");\n .entry(\"altGlyphItem, Element::altGlyphItem\");\n .entry(\"animate, Element::animate\");\n .entry(\"animateColor, Element::animateColor\");\n .entry(\"animateMotion, Element::animateMotion\");\n .entry(\"animateTransform, Element::animateTransform\");\n .entry(\"circle, Element::circle\");\n .entry(\"clipPath, Element::clipPath\");\n .entry(\"color-profile, Element::color_profile\");\n .entry(\"cursor, Element::cursor\");\n .entry(\"defs, Element::defs\");\n .entry(\"desc, Element::desc\");\n .entry(\"ellipse, Element::ellipse\");\n .entry(\"feBlend, Element::feBlend\");\n .entry(\"feColorMatrix, Element::feColorMatrix\");\n .entry(\"feComponentTransfer, Element::feComponentTransfer\");\n .entry(\"feComposite, Element::feComposite\");\n .entry(\"feConvolveMatrix, Element::feConvolveMatrix\");\n .entry(\"feDiffuseLighting, Element::feDiffuseLighting\");\n .entry(\"feDisplacementMap, Element::feDisplacementMap\");\n .entry(\"feDistantLight, Element::feDistantLight\");\n .entry(\"feFlood, Element::feFlood\");\n .entry(\"feImage, Element::feImage\");\n .entry(\"feMerge, Element::feMerge\");\n .entry(\"feMergeNode, Element::feMergeNode\");\n .entry(\"feMorphology, Element::feMorphology\");\n .entry(\"feOffset, Element::feOffset\");\n .entry(\"fePointLight, Element::fePointLight\");\n .entry(\"feSpecularLighting, Element::feSpecularLighting\");\n .entry(\"feSpotLight, Element::feSpotLight\");\n .entry(\"feTile, Element::feTile\");\n .entry(\"feTurbulence, Element::feTurbulence\");\n .entry(\"font, Element::font\");\n .entry(\"font-face, Element::font_face\");\n .entry(\"font-face-format, Element::font_face_format\");\n .entry(\"font-face-name, Element::font_face_name\");\n .entry(\"font-face-src, Element::font_face_src\");\n .entry(\"font-face-uri, Element::font_face_uri\");\n .entry(\"foreignObject, Element::foreignObject\");\n .entry(\"glyph, Element::glyph\");\n .entry(\"glyphRef, Element::glyphRef\");\n .entry(\"hkern, Element::hkern\");\n .entry(\"image, Element::image\");\n .entry(\"marker, Element::marker\");\n .entry(\"mask, Element::mask\");\n .entry(\"metadata, Element::metadata\");\n .entry(\"missing-glyph, Element::missing_glyph\");\n .entry(\"mpath, Element::mpath\");\n .entry(\"pattern, Element::pattern\");\n .entry(\"script, Element::script\");\n .entry(\"set, Element::set\");\n .entry(\"style, Element::style\");\n .entry(\"switch, Element::switch\");\n .entry(\"symbol, Element::symbol\");\n .entry(\"text, Element::text\");\n .entry(\"textPath, Element::textPath\");\n .entry(\"tref, Element::tref\");\n .entry(\"flowRoot, Element::flowRoot\");\n .entry(\"flowRegion, Element::flowRegion\");\n .entry(\"flowPara, Element::flowPara\");\n .entry(\"flowSpan, Element::flowSpan\");\n .entry(\"tspan, Element::tspan\");\n .entry(\"use, Element::use\");\n .entry(\"view, Element::view\");\n .entry(\"vkern, Element::vkern\");", "", "Element", "advance", "zero_after_point", "decimal_point_pos", "tmp_value", "test_parse" ], "reverse": false, "show_context": true, "use_buffer2": true, "whole_word": false, "wrap": true }, "groups": [ { "selected": 1, "sheets": [ { "buffer": 0, "file": "src/lib.rs", "semi_transient": false, "settings": { "buffer_size": 2837, "regions": { }, "selection": [ [ 1957, 1957 ] ], "settings": { "spell_check": false, "syntax": "Packages/Rust Enhanced/Rust.sublime-syntax" }, "translation.x": 0.0, "translation.y": 638.0, "zoom_level": 1.0 }, "stack_index": 1, "type": "text" }, { "buffer": 1, "file": "src/tokenizer.rs", "semi_transient": false, "settings": { "buffer_size": 11542, "regions": { }, "selection": [ [ 2494, 2494 ] ], "settings": { "spell_check": false, "syntax": "Packages/Rust Enhanced/Rust.sublime-syntax" }, "translation.x": 0.0, "translation.y": 1320.0, "zoom_level": 1.0 }, "stack_index": 0, "type": "text" }, { "buffer": 2, "file": "tests/css.rs", "semi_transient": false, "settings": { "buffer_size": 16065, "regions": { }, "selection": [ [ 15498, 15498 ] ], "settings": { "syntax": "Packages/Rust Enhanced/Rust.sublime-syntax", "tab_size": 4, "translate_tabs_to_spaces": true }, "translation.x": 0.0, "translation.y": 0.0, "zoom_level": 1.0 }, "stack_index": 2, "type": "text" } ] } ], "incremental_find": { "height": 28.0 }, "input": { "height": 36.0 }, "layout": { "cells": [ [ 0, 0, 1, 1 ] ], "cols": [ 0.0, 1.0 ], "rows": [ 0.0, 1.0 ] }, "menu_visible": true, "output.exec": { "height": 256.0 }, "output.find_results": { "height": 0.0 }, "pinned_build_system": "", "project": "simplecss.sublime-project", "replace": { "height": 66.0 }, "save_all_on_build": true, "select_file": { "height": 0.0, "last_filter": "", "selected_items": [ ], "width": 0.0 }, "select_project": { "height": 500.0, "last_filter": "", "selected_items": [ ], "width": 380.0 }, "select_symbol": { "height": 392.0, "last_filter": "", "selected_items": [ ], "width": 392.0 }, "selected_group": 0, "settings": { }, "show_minimap": true, "show_open_files": false, "show_tabs": true, "side_bar_visible": true, "side_bar_width": 459.0, "status_bar_visible": true, "template_settings": { } }