diff options
Diffstat (limited to 'Source/JavaScriptCore/parser/ParserTokens.h')
-rw-r--r-- | Source/JavaScriptCore/parser/ParserTokens.h | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/Source/JavaScriptCore/parser/ParserTokens.h b/Source/JavaScriptCore/parser/ParserTokens.h index 14191b95d..ed9780b52 100644 --- a/Source/JavaScriptCore/parser/ParserTokens.h +++ b/Source/JavaScriptCore/parser/ParserTokens.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2013 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,6 +27,8 @@ #define ParserTokens_h #include "ParserModes.h" +#include <limits.h> +#include <stdint.h> namespace JSC { @@ -38,6 +40,8 @@ enum { BinaryOpTokenPrecedenceShift = 8, BinaryOpTokenAllowsInPrecedenceAdditionalShift = 4, BinaryOpTokenPrecedenceMask = 15 << BinaryOpTokenPrecedenceShift, + ErrorTokenFlag = 1 << (BinaryOpTokenAllowsInPrecedenceAdditionalShift + BinaryOpTokenPrecedenceShift + 7), + UnterminatedErrorTokenFlag = ErrorTokenFlag << 1 }; #define BINARY_OP_PRECEDENCE(prec) (((prec) << BinaryOpTokenPrecedenceShift) | ((prec) << (BinaryOpTokenPrecedenceShift + BinaryOpTokenAllowsInPrecedenceAdditionalShift))) @@ -85,7 +89,6 @@ enum JSTokenType { SEMICOLON, COLON, DOT, - ERRORTOK, EOFTOK, EQUAL, PLUSEQUAL, @@ -133,28 +136,44 @@ enum JSTokenType { MINUS = 19 | BINARY_OP_PRECEDENCE(9) | UnaryOpTokenFlag, TIMES = 20 | BINARY_OP_PRECEDENCE(10), DIVIDE = 21 | BINARY_OP_PRECEDENCE(10), - MOD = 22 | BINARY_OP_PRECEDENCE(10) + MOD = 22 | BINARY_OP_PRECEDENCE(10), + ERRORTOK = 0 | ErrorTokenFlag, + UNTERMINATED_IDENTIFIER_ESCAPE_ERRORTOK = 0 | ErrorTokenFlag | UnterminatedErrorTokenFlag, + INVALID_IDENTIFIER_ESCAPE_ERRORTOK = 1 | ErrorTokenFlag, + UNTERMINATED_IDENTIFIER_UNICODE_ESCAPE_ERRORTOK = 2 | ErrorTokenFlag | UnterminatedErrorTokenFlag, + INVALID_IDENTIFIER_UNICODE_ESCAPE_ERRORTOK = 3 | ErrorTokenFlag, + UNTERMINATED_MULTILINE_COMMENT_ERRORTOK = 4 | ErrorTokenFlag | UnterminatedErrorTokenFlag, + UNTERMINATED_NUMERIC_LITERAL_ERRORTOK = 5 | ErrorTokenFlag | UnterminatedErrorTokenFlag, + INVALID_OCTAL_NUMBER_ERRORTOK = 6 | ErrorTokenFlag | UnterminatedErrorTokenFlag, + INVALID_NUMERIC_LITERAL_ERRORTOK = 7 | ErrorTokenFlag, + UNTERMINATED_STRING_LITERAL_ERRORTOK = 8 | ErrorTokenFlag | UnterminatedErrorTokenFlag, + INVALID_STRING_LITERAL_ERRORTOK = 9 | ErrorTokenFlag, }; union JSTokenData { - int intValue; + struct { + uint32_t line; + uint32_t offset; + uint32_t lineStartOffset; + }; double doubleValue; const Identifier* ident; }; struct JSTokenLocation { - JSTokenLocation() : line(0), column(0) { } + JSTokenLocation() : line(0), lineStartOffset(0), startOffset(0) { } JSTokenLocation(const JSTokenLocation& location) { line = location.line; + lineStartOffset = location.lineStartOffset; startOffset = location.startOffset; endOffset = location.endOffset; - column = location.column; } + int line; - int startOffset; - int endOffset; - int column; + unsigned lineStartOffset; + unsigned startOffset; + unsigned endOffset; }; struct JSToken { @@ -163,7 +182,6 @@ struct JSToken { JSTokenLocation m_location; }; -} - +} // namespace JSC #endif // ParserTokens_h |