Closed GoogleCodeExporter closed 9 years ago
Original comment by erights
on 25 Dec 2009 at 5:44
Added in r86.
Example input:
"use strict";
'use test';
'use\ strict';
Output:
["Program",
{},
["PrologueDecl",
{
"directive":"use strict"
}
],
["PrologueDecl",
{
"directive":"use test"
}
],
["LiteralExpr",
{
"type":"string",
"value":"use strict"
}
]
]
Original comment by to...@google.com
on 7 Jan 2010 at 7:58
After realizing that PrologueDecl nodes also have a runtime semantics (during
which
they behave as StringLiterals), I added a 'value:' attribute to these nodes. The
evaluator can then use the 'directive' attribute to access the raw string
value, and
the 'value' attribute to return upon evaluation. The above example now parses
as:
["Program",
{},
["PrologueDecl",
{
"value":"use strict",
"directive":"use strict"
}
],
["PrologueDecl",
{
"value":"use test",
"directive":"use test"
}
],
["PrologueDecl",
{
"value":"use strict",
"directive":"use\\ strict"
}
]
]
Note also that the third string now parses correctly as a PrologueDecl.
Previously, I
thought PrologueDecls were not allowed to contain escape sequences. Apparently
they
are allowed to contain escape sequences. It's just that a Use Strict directive
in
particular does not allow them.
Original comment by to...@google.com
on 8 Jan 2010 at 12:38
Original issue reported on code.google.com by
erights
on 25 Dec 2009 at 1:18