Rust编写的JavaScript引擎,该项目是一个试验性质的项目。
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
#![no_main]
|
|
|
|
|
|
|
|
mod common;
|
|
|
|
|
|
|
|
use crate::common::FuzzSource;
|
|
|
|
use boa_engine::Context;
|
|
|
|
use boa_parser::Parser;
|
|
|
|
use libfuzzer_sys::{fuzz_target, Corpus};
|
|
|
|
use std::io::Cursor;
|
|
|
|
|
|
|
|
fn do_fuzz(original: FuzzSource) -> Corpus {
|
|
|
|
let mut ctx = Context::builder()
|
|
|
|
.interner(original.interner)
|
|
|
|
.instructions_remaining(0)
|
|
|
|
.build();
|
|
|
|
let mut parser = Parser::new(Cursor::new(&original.source));
|
Module parsing (#2411)
I'm creating this draft PR, since I wanted to have some early feedback, and because I though I would have time to finish it last week, but I got caught up with other stuff. Feel free to contribute :)
The main thing here is that I have divided `eval()`, `parse()` and similar functions so that they can decide if they are parsing scripts or modules. Let me know your thoughts.
Then, I was checking the import & export parsing, and I noticed we are using `TokenKind::Identifier` for `IdentifierName`, so I changed that name. An `Identifier` is an `IdentifierName` that isn't a `ReservedWord`. This means we should probably also adapt all `IdentifierReference`, `BindingIdentifier` and so on parsing. I already created an `Identifier` parser.
Something interesting there is that `await` is not a valid `Identifier` if the goal symbol is `Module`, as you can see in the [spec](https://tc39.es/ecma262/#prod-LabelIdentifier), but currently we don't have that information in the `InputElement` enumeration, we only have `Div`, `RegExp` and `TemplateTail`. How could we approach this?
Co-authored-by: jedel1043 <jedel0124@gmail.com>
2 years ago
|
|
|
if let Ok(parsed) = parser.parse_script(ctx.interner_mut()) {
|
|
|
|
let _ = ctx.compile(&parsed);
|
|
|
|
Corpus::Keep
|
|
|
|
} else {
|
|
|
|
Corpus::Reject
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fuzz_target!(|original: FuzzSource| -> Corpus { do_fuzz(original) });
|