File tree Expand file tree Collapse file tree
packages/babel-parser/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11// @flow
2- /*:: declare var invariant; */
32
43import * as N from "../types" ;
54import { types as tt , type TokenType } from "../tokenizer/types" ;
@@ -857,8 +856,10 @@ export default class StatementParser extends ExpressionParser {
857856 while ( ! this . eat ( end ) ) {
858857 // Track octal literals that occur before a "use strict" directive.
859858 if ( ! parsedNonDirective && this . state . containsOctal ) {
860- /*:: invariant(this.state.octalPosition !== null) */
861- octalPositions . push ( this . state . octalPosition ) ;
859+ // This octal literal will always occur in a directive and will
860+ // therefore be escaped. Subtract two from the current position to
861+ // account for the "\" character.
862+ octalPositions . push ( this . state . pos - 2 ) ;
862863 }
863864
864865 const stmt = this . parseStatement ( null , topLevel ) ;
Original file line number Diff line number Diff line change @@ -225,7 +225,6 @@ export default class Tokenizer extends LocationParser {
225225 if ( ! curContext || ! curContext . preserveSpace ) this . skipSpace ( ) ;
226226
227227 this . state . containsOctal = false ;
228- this . state . octalPosition = null ;
229228 this . state . start = this . state . pos ;
230229 this . state . startLoc = this . state . curPosition ( ) ;
231230 if ( this . state . pos >= this . length ) {
@@ -1297,10 +1296,7 @@ export default class Tokenizer extends LocationParser {
12971296 } else if ( this . state . strict ) {
12981297 this . raise ( codePos , Errors . StrictOctalLiteral ) ;
12991298 } else if ( ! this . state . containsOctal ) {
1300- // These properties are only used to throw an error for an octal which occurs
1301- // in a directive which occurs prior to a "use strict" directive.
13021299 this . state . containsOctal = true ;
1303- this . state . octalPosition = codePos ;
13041300 }
13051301 }
13061302
Original file line number Diff line number Diff line change @@ -141,9 +141,9 @@ export default class State {
141141 // escape sequences must not be interpreted as keywords.
142142 containsEsc: boolean = false ;
143143
144- // TODO
144+ // Used to throw an error for an octal literal which occurs
145+ // in a directive which occurs prior to a "use strict" directive.
145146 containsOctal: boolean = false ;
146- octalPosition: number | null = null ;
147147
148148 // Names of exports store. `default` is stored as a name for both
149149 // `export default foo;` and `export { foo as default };`.
You can’t perform that action at this time.
0 commit comments