If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

abstract out scanning and error reporting in parser

Assigned to



JavaScript Engine
8 years ago
8 years ago


(Reporter: dherman, Assigned: dherman)


Firefox Tracking Flags

(Not tracked)




8 years ago
A number of common patterns in the parser could be abstracted out at probably zero performance cost with a few inline function definitions:

- js_MatchToken, js_PeekToken, js_GetToken, js_UngetToken
- js_ReportCompilerErrorNumber, js_ReportErrorNumber

This should improve readability and maintainability.

Is this a duplicate of bug 549658?

We might be able to clean up error reporting more, but I think it's a method of the token stream after that patch, which isn't too bad.

Comment 2

8 years ago
Intended to add a few additional abstractions, e.g. replacing patterns like:

    tokenStream.flags |= TCF_OPERAND;
    tt = js_PeekToken(&tokenStream);
    tokenStream.flags &= ~TCF_OPERAND;

with e.g.:


But some of these (such as the above) belong in jsscan so I'll wait on this till you and I have a chance to sync up and merge our work.

Feel free to strip TCF_ and similar prefixes by moving enums into classes or structs, as we do elsewhere now that C++ is here to stay.

You need to log in before you can comment on or make changes to this bug.