diff options
Diffstat (limited to 'modelica-parser-lalrpop/src')
-rw-r--r-- | modelica-parser-lalrpop/src/lib.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/modelica-parser-lalrpop/src/lib.rs b/modelica-parser-lalrpop/src/lib.rs index b515d73..ed07ca2 100644 --- a/modelica-parser-lalrpop/src/lib.rs +++ b/modelica-parser-lalrpop/src/lib.rs @@ -2,6 +2,7 @@ extern crate lalrpop_util; extern crate colored; extern crate regex; +#[macro_use] extern crate lazy_static; mod parser; mod ast; @@ -20,12 +21,12 @@ pub use parser::{ }; pub fn strip_comments(raw: &str) -> String { - // TODO: shouldn't recompile regex on every function call - // Match on comments: // (?m) sets multi-line mode - let comment_re = Regex::new(r"(?m)(//.*)$").unwrap(); - comment_re.replace_all(&raw, "") + lazy_static! { + static ref RE: Regex = Regex::new(r"(?m)(//.*)$").unwrap(); + } + RE.replace_all(&raw, "") } fn pp_segment(raw: &str, start: usize, end: usize) -> String { |