aboutsummaryrefslogtreecommitdiffstats
path: root/modelica-parser-lalrpop/src
diff options
context:
space:
mode:
Diffstat (limited to 'modelica-parser-lalrpop/src')
-rw-r--r--modelica-parser-lalrpop/src/lib.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/modelica-parser-lalrpop/src/lib.rs b/modelica-parser-lalrpop/src/lib.rs
index a109607..0b94c35 100644
--- a/modelica-parser-lalrpop/src/lib.rs
+++ b/modelica-parser-lalrpop/src/lib.rs
@@ -1,13 +1,23 @@
extern crate lalrpop_util;
extern crate colored;
+extern crate regex;
pub mod parser;
pub mod ast;
use colored::*;
use lalrpop_util::ParseError;
+use regex::Regex;
+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, "")
+}
fn pp_segment(raw: &str, start: usize, end: usize) -> String {
let mut line_start = 0;