Skip to content

Commit

Permalink
Remove compiler options from this project
Browse files Browse the repository at this point in the history
  • Loading branch information
hydroper committed Apr 28, 2024
1 parent 9037e20 commit ac97f48
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/parser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "as3_parser"
version = "1.0.0"
version = "1.0.1"
edition = "2021"
authors = ["hydroper <[email protected]>"]
repository = "https://github.com/hydroper/as3parser"
Expand Down
6 changes: 2 additions & 4 deletions crates/parser/compilation_unit.rs
Original file line number Diff line number Diff line change
@@ -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::*;
pub use location::*;
10 changes: 1 addition & 9 deletions crates/parser/compilation_unit/compilation_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ pub struct CompilationUnit {
pub(crate) error_count: Cell<u32>,
pub(crate) warning_count: Cell<u32>,
pub(crate) invalidated: Cell<bool>,
pub(crate) compiler_options: Rc<CompilerOptions>,
pub(crate) comments: RefCell<Vec<Rc<Comment>>>,
pub(crate) included_from: RefCell<Option<Rc<CompilationUnit>>>,
pub(crate) nested_compilation_units: RefCell<Vec<Rc<CompilationUnit>>>,
Expand All @@ -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),
Expand All @@ -36,15 +34,14 @@ impl Default for CompilationUnit {

impl CompilationUnit {
/// Constructs a source file in unparsed and non verified state.
pub fn new(file_path: Option<String>, text: String, compiler_options: &Rc<CompilerOptions>) -> Rc<Self> {
pub fn new(file_path: Option<String>, text: String) -> Rc<Self> {
Rc::new(Self {
file_path,
source_text: SourceText::new(text),
diagnostics: RefCell::new(vec![]),
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),
Expand All @@ -61,11 +58,6 @@ impl CompilationUnit {
&self.source_text.contents
}

/// Compiler options.
pub fn compiler_options(&self) -> Rc<CompilerOptions> {
self.compiler_options.clone()
}

/// Whether the source contains any errors after parsing
/// and/or verification.
pub fn invalidated(&self) -> bool {
Expand Down
10 changes: 0 additions & 10 deletions crates/parser/compilation_unit/compiler_options.rs

This file was deleted.

8 changes: 4 additions & 4 deletions crates/parser/parser/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion crates/parser_test/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion demo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Rc<Program>> = None;
let mut mxml: Option<Rc<Mxml>> = None;
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion docs/working-with-css.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<CssDocument> = CssParserFacade(&compilation_unit, ParserOptions::default()).parse_document();
```
2 changes: 1 addition & 1 deletion docs/working-with-mxml.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let text = r#"
creationComplete="initialize()">
</s:Application>
"#;
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
Expand Down
2 changes: 1 addition & 1 deletion examples/asdoc/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit ac97f48

Please sign in to comment.