swc_ecma_parser:
 - fix lexer
 - better error reporting for jsx reference test

swc_ecma_codegen:
 - Update references
This commit is contained in:
강동윤 2019-02-13 16:03:38 +09:00 committed by GitHub
parent fedfea4e09
commit c647cf1bc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
228 changed files with 714 additions and 270 deletions

View File

@ -1,16 +1,13 @@
{
;
}
a();
}a();
{
}
;
};
{
{
}
;
}
;
};
b();
{
}

View File

@ -1,4 +1,3 @@
a.in;
{
}
/foo/;
}/foo/;

View File

@ -1,4 +1,3 @@
a++;
{
}
/foo/;
}/foo/;

View File

@ -2,7 +2,6 @@
{
a;
}
}
{
}{
b;
}

View File

@ -1,3 +1,2 @@
{
}
/foo/;
}/foo/;

View File

@ -3,7 +3,6 @@ function a() {
}
a();
{
}
function a() {
}function a() {
b.c('e');
}

View File

@ -1,3 +1,2 @@
{
}
/=/;
}/=/;

View File

@ -1,4 +1,3 @@
{
[1];
}
/foo/;
}/foo/;

View File

@ -99,7 +99,7 @@ impl<'a, I: Input> Lexer<'a, I> {
impl<'a, I: Input> Iterator for Lexer<'a, I> {
type Item = TokenAndSpan;
fn next(&mut self) -> Option<Self::Item> {
let start = self.cur_pos();
let mut start = self.cur_pos();
let res = (|| -> Result<Option<_>, _> {
if self.state.is_first {
@ -119,6 +119,7 @@ impl<'a, I: Input> Iterator for Lexer<'a, I> {
}
_ => {}
}
start = self.input.cur_pos();
};
let c = match self.input.cur() {
@ -311,7 +312,7 @@ impl State {
// ${} in template
if out == TokenContext::TplQuasi {
return true;
return false;
}
// expression cannot follow expression

View File

@ -904,6 +904,36 @@ fn empty() {
assert_eq!(lex_tokens(::Syntax::default(), "",), vec![]);
}
#[test]
fn issue_191() {
assert_eq!(
lex_tokens(
::Syntax::Es(::EsConfig {
jsx: true,
..Default::default()
}),
"`${foo}<bar>`"
),
vec![
tok!('`'),
Token::Template {
raw: "".into(),
cooked: "".into(),
has_escape: false,
},
tok!("${"),
Token::Word(Word::Ident("foo".into())),
tok!('}'),
Token::Template {
raw: "<bar>".into(),
cooked: "<bar>".into(),
has_escape: false,
},
tok!('`')
]
);
}
#[bench]
fn lex_colors_js(b: &mut Bencher) {
b.bytes = include_str!("../../colors.js").len() as _;

View File

@ -153,7 +153,7 @@ fn reference_tests(tests: &mut Vec<TestDescAndFn>) -> Result<(), io::Error> {
let path = dir.join(&file_name);
// Parse source
let module = parse_module(cm, handler, &path).expect("should be parsed");
let module = parse_module(cm, handler, &path)?;
if StdErr::from(format!("{:#?}", module))
.compare_to_file(format!("{}.stdout", path.display()))

View File

@ -58,5 +58,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -104,5 +104,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -102,5 +102,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -147,5 +147,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -255,5 +255,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -122,5 +122,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -158,5 +158,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -101,5 +101,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -88,5 +88,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -136,5 +136,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -212,5 +212,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -121,5 +121,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -438,5 +438,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -194,5 +194,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -323,5 +323,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -251,5 +251,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -58,5 +58,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -86,5 +86,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -163,5 +163,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -209,5 +209,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -159,5 +159,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -0,0 +1 @@
`${foo} <bar>`

View File

@ -0,0 +1,131 @@
Module {
span: Span {
lo: BytePos(
0
),
hi: BytePos(
14
),
ctxt: #0
},
body: [
Stmt(
Expr(
Tpl(
Tpl {
span: Span {
lo: BytePos(
0
),
hi: BytePos(
14
),
ctxt: #0
},
exprs: [
Ident(
Ident {
sym: foo,
span: Span {
lo: BytePos(
3
),
hi: BytePos(
6
),
ctxt: #0
},
type_ann: None,
optional: false
}
)
],
quasis: [
TplElement {
span: Span {
lo: BytePos(
1
),
hi: BytePos(
1
),
ctxt: #0
},
tail: false,
cooked: Some(
Str {
span: Span {
lo: BytePos(
1
),
hi: BytePos(
1
),
ctxt: #0
},
value: Atom('' type=static),
has_escape: false
}
),
raw: Str {
span: Span {
lo: BytePos(
1
),
hi: BytePos(
1
),
ctxt: #0
},
value: Atom('' type=static),
has_escape: false
}
},
TplElement {
span: Span {
lo: BytePos(
7
),
hi: BytePos(
13
),
ctxt: #0
},
tail: true,
cooked: Some(
Str {
span: Span {
lo: BytePos(
7
),
hi: BytePos(
13
),
ctxt: #0
},
value: Atom(' <bar>' type=inline),
has_escape: false
}
),
raw: Str {
span: Span {
lo: BytePos(
7
),
hi: BytePos(
13
),
ctxt: #0
},
value: Atom(' <bar>' type=inline),
has_escape: false
}
}
]
}
)
)
)
],
shebang: None
}

View File

@ -0,0 +1 @@
`${foo}<bar>`

View File

@ -693,5 +693,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -667,5 +667,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -104,5 +104,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -102,5 +102,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -49,5 +49,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -65,5 +65,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -293,5 +293,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -223,5 +223,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -253,5 +253,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -177,5 +177,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -86,5 +86,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -183,5 +183,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -102,5 +102,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -102,5 +102,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -155,5 +155,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -118,5 +118,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -102,5 +102,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -170,5 +170,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -191,5 +191,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -141,5 +141,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -141,5 +141,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -118,5 +118,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -122,5 +122,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -111,5 +111,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -191,5 +191,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -191,5 +191,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -118,5 +118,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -158,5 +158,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -316,5 +316,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -90,5 +90,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -128,5 +128,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -117,5 +117,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -290,5 +290,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -72,5 +72,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -106,5 +106,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -74,5 +74,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -74,5 +74,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -63,5 +63,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -74,5 +74,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -42,5 +42,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -86,5 +86,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -101,5 +101,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -86,5 +86,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -56,5 +56,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -29,5 +29,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -201,5 +201,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -269,5 +269,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -430,5 +430,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -370,5 +370,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -442,5 +442,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -260,5 +260,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -186,5 +186,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -286,5 +286,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -219,5 +219,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -128,5 +128,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -184,5 +184,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -170,5 +170,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -141,5 +141,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -221,5 +221,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -384,5 +384,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -131,5 +131,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -275,5 +275,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -583,5 +583,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -181,5 +181,6 @@ Module {
)
)
)
]
],
shebang: None
}

View File

@ -142,5 +142,6 @@ Module {
)
)
)
]
],
shebang: None
}

Some files were not shown because too many files have changed in this diff Show More