diff --git a/Cargo.lock b/Cargo.lock index e19323b..8bc9c77 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -67,7 +67,7 @@ checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" [[package]] name = "as3_parser" -version = "1.0.0" +version = "1.0.1" dependencies = [ "bitflags", "by_address", diff --git a/crates/parser/Cargo.toml b/crates/parser/Cargo.toml index bf5913a..439f51c 100644 --- a/crates/parser/Cargo.toml +++ b/crates/parser/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "as3_parser" -version = "1.0.0" +version = "1.0.1" edition = "2021" authors = ["hydroper "] repository = "https://github.com/hydroper/as3parser" diff --git a/crates/parser/compilation_unit.rs b/crates/parser/compilation_unit.rs index 4041f51..93b1777 100644 --- a/crates/parser/compilation_unit.rs +++ b/crates/parser/compilation_unit.rs @@ -1,10 +1,8 @@ -//! Defines the compilation unit, compiler options, comments, and source locations. +//! Defines the compilation unit, comments, and source locations. mod compilation_unit; pub use compilation_unit::*; mod comment; pub use comment::*; mod location; -pub use location::*; -mod compiler_options; -pub use compiler_options::*; \ No newline at end of file +pub use location::*; \ No newline at end of file diff --git a/crates/parser/compilation_unit/compilation_unit.rs b/crates/parser/compilation_unit/compilation_unit.rs index ec8bce4..b980d6b 100644 --- a/crates/parser/compilation_unit/compilation_unit.rs +++ b/crates/parser/compilation_unit/compilation_unit.rs @@ -11,7 +11,6 @@ pub struct CompilationUnit { pub(crate) error_count: Cell, pub(crate) warning_count: Cell, pub(crate) invalidated: Cell, - pub(crate) compiler_options: Rc, pub(crate) comments: RefCell>>, pub(crate) included_from: RefCell>>, pub(crate) nested_compilation_units: RefCell>>, @@ -26,7 +25,6 @@ impl Default for CompilationUnit { invalidated: Cell::new(false), error_count: Cell::new(0), warning_count: Cell::new(0), - compiler_options: CompilerOptions::default(), comments: RefCell::new(vec![]), nested_compilation_units: RefCell::new(vec![]), included_from: RefCell::new(None), @@ -36,7 +34,7 @@ impl Default for CompilationUnit { impl CompilationUnit { /// Constructs a source file in unparsed and non verified state. - pub fn new(file_path: Option, text: String, compiler_options: &Rc) -> Rc { + pub fn new(file_path: Option, text: String) -> Rc { Rc::new(Self { file_path, source_text: SourceText::new(text), @@ -44,7 +42,6 @@ impl CompilationUnit { invalidated: Cell::new(false), error_count: Cell::new(0), warning_count: Cell::new(0), - compiler_options: compiler_options.clone(), comments: RefCell::new(vec![]), nested_compilation_units: RefCell::new(vec![]), included_from: RefCell::new(None), @@ -61,11 +58,6 @@ impl CompilationUnit { &self.source_text.contents } - /// Compiler options. - pub fn compiler_options(&self) -> Rc { - self.compiler_options.clone() - } - /// Whether the source contains any errors after parsing /// and/or verification. pub fn invalidated(&self) -> bool { diff --git a/crates/parser/compilation_unit/compiler_options.rs b/crates/parser/compilation_unit/compiler_options.rs deleted file mode 100644 index 9af0015..0000000 --- a/crates/parser/compilation_unit/compiler_options.rs +++ /dev/null @@ -1,10 +0,0 @@ -use std::rc::Rc; - -/// Defines compiler options used within the parser. -pub struct CompilerOptions {} - -impl CompilerOptions { - pub fn default() -> Rc { - Rc::new(Self {}) - } -} \ No newline at end of file diff --git a/crates/parser/parser/parser.rs b/crates/parser/parser/parser.rs index c51bcfa..6a98f1c 100644 --- a/crates/parser/parser/parser.rs +++ b/crates/parser/parser/parser.rs @@ -3535,22 +3535,22 @@ impl<'input> Parser<'input> { self.add_syntax_error(&source_path_location.clone(), DiagnosticKind::CircularIncludeDirective, vec![]); // Use a placeholder compilation unit - nested_compilation_unit = CompilationUnit::new(None, "".into(), &self.tokenizer.compilation_unit().compiler_options); + nested_compilation_unit = CompilationUnit::new(None, "".into()); } else { if let Ok(content) = std::fs::read_to_string(&sub_file_path) { - nested_compilation_unit = CompilationUnit::new(Some(sub_file_path.clone()), content, &self.tokenizer.compilation_unit().compiler_options); + nested_compilation_unit = CompilationUnit::new(Some(sub_file_path.clone()), content); } else { self.add_syntax_error(&source_path_location.clone(), DiagnosticKind::FailedToIncludeFile, vec![]); // Use a placeholder compilation unit - nested_compilation_unit = CompilationUnit::new(None, "".into(), &self.tokenizer.compilation_unit().compiler_options); + nested_compilation_unit = CompilationUnit::new(None, "".into()); } } } else { self.add_syntax_error(&source_path_location.clone(), DiagnosticKind::ParentSourceIsNotAFile, vec![]); // Use a placeholder compilation unit - nested_compilation_unit = CompilationUnit::new(None, "".into(), &self.tokenizer.compilation_unit().compiler_options); + nested_compilation_unit = CompilationUnit::new(None, "".into()); } // Let it be such that the sub compilation unit is subsequent of diff --git a/crates/parser_test/main.rs b/crates/parser_test/main.rs index b543b8e..6abee8f 100644 --- a/crates/parser_test/main.rs +++ b/crates/parser_test/main.rs @@ -29,7 +29,7 @@ fn main() -> io::Result<()> { let source_path_ast_json = FlexPath::new_native(&source_path).change_extension(".tree").to_string_with_flex_separator(); let source_path_diagnostics = FlexPath::new_native(&source_path).change_extension(".diag").to_string_with_flex_separator(); let source_content = fs::read_to_string(&source_path)?; - let compilation_unit = CompilationUnit::new(Some(source_path), source_content, &CompilerOptions::default()); + let compilation_unit = CompilationUnit::new(Some(source_path), source_content); if arguments.mxml { let document = ParserFacade(&compilation_unit, default()).parse_mxml(); if arguments.file_log { diff --git a/demo/src/lib.rs b/demo/src/lib.rs index ab66b92..80e49c8 100644 --- a/demo/src/lib.rs +++ b/demo/src/lib.rs @@ -22,7 +22,7 @@ struct ParserDiagnosticResult { #[wasm_bindgen] pub fn parse(input: &str, source_type: &str) -> String { - let compilation_unit = CompilationUnit::new(None, input.to_owned(), &CompilerOptions::default()); + let compilation_unit = CompilationUnit::new(None, input.to_owned()); let mut program: Option> = None; let mut mxml: Option> = None; diff --git a/docs/getting-started.md b/docs/getting-started.md index d84514e..d643dcd 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -19,7 +19,7 @@ Parse programs or expressions through the `ParserFacade` structure of the `as3_p use as3_parser::ns::*; // Create compilation unit -let compilation_unit = CompilationUnit::new(None, "x ** y".into(), &CompilerOptions::default()); +let compilation_unit = CompilationUnit::new(None, "x ** y".into()); // Parser options let parser_options = ParserOptions::default(); diff --git a/docs/working-with-css.md b/docs/working-with-css.md index dc4ca81..41fdfe3 100644 --- a/docs/working-with-css.md +++ b/docs/working-with-css.md @@ -16,7 +16,7 @@ let text = r#" } "#; -let compilation_unit = CompilationUnit::new(None, text.into(), &CompilerOptions::default()); +let compilation_unit = CompilationUnit::new(None, text.into()); let document: Rc = CssParserFacade(&compilation_unit, ParserOptions::default()).parse_document(); ``` \ No newline at end of file diff --git a/docs/working-with-mxml.md b/docs/working-with-mxml.md index dc52919..37a3515 100644 --- a/docs/working-with-mxml.md +++ b/docs/working-with-mxml.md @@ -17,7 +17,7 @@ let text = r#" creationComplete="initialize()"> "#; -let compilation_unit = CompilationUnit::new(None, text.into(), &CompilerOptions::default()); +let compilation_unit = CompilationUnit::new(None, text.into()); let parser_options = ParserOptions { // Ignore whitespace chunks in a node list when at least one diff --git a/examples/asdoc/example.rs b/examples/asdoc/example.rs index 8d57b3b..2e10ca1 100644 --- a/examples/asdoc/example.rs +++ b/examples/asdoc/example.rs @@ -9,7 +9,7 @@ fn main() { let source_content = include_str!("Example.as").to_owned(); // Create compilation unit - let compilation_unit = CompilationUnit::new(Some(source_path), source_content, &CompilerOptions::default()); + let compilation_unit = CompilationUnit::new(Some(source_path), source_content); // Parse program let program = ParserFacade(&compilation_unit, default()).parse_program();