Revision: 18095
Author: [email protected]
Date: Wed Nov 27 09:41:41 2013 UTC
Log: Experimental scanner: keep track of which strings / identifiers
contain an escape.
BUG=
[email protected]
Review URL: https://codereview.chromium.org/91123002
http://code.google.com/p/v8/source/detail?r=18095
Modified:
/branches/experimental/parser/src/lexer/experimental-scanner.h
/branches/experimental/parser/src/lexer/lexer_py.re
/branches/experimental/parser/tools/lexer_generator/code_generator.jinja
=======================================
--- /branches/experimental/parser/src/lexer/experimental-scanner.h Tue Nov
26 17:56:14 2013 UTC
+++ /branches/experimental/parser/src/lexer/experimental-scanner.h Wed Nov
27 09:41:41 2013 UTC
@@ -188,8 +188,9 @@
// we need to decide if pos is counted in characters or in bytes.
virtual void SeekForward(int pos) = 0;
- // Scans the input as a regular expression pattern, previous
- // character(s) must be /(=). Returns true if a pattern is scanned.
+ // Scans the input as a regular expression pattern, previous
character(s) must
+ // be /(=). Returns true if a pattern is scanned. FIXME: this won't work
for
+ // utf-8 newlines.
virtual bool ScanRegExpPattern(bool seen_equal) = 0;
// Returns true if regexp flags are scanned (always since flags can
// be empty).
@@ -200,6 +201,7 @@
Token::Value token;
int beg_pos;
int end_pos;
+ bool has_escapes;
};
virtual void Scan() = 0;
=======================================
--- /branches/experimental/parser/src/lexer/lexer_py.re Mon Nov 25 09:05:44
2013 UTC
+++ /branches/experimental/parser/src/lexer/lexer_py.re Wed Nov 27 09:41:41
2013 UTC
@@ -196,9 +196,9 @@
<<DoubleQuoteString>>
"\\" line_terminator_sequence <||continue>
-/\\[x][:hex_digit:]{2}/ <||continue>
-/\\[u][:hex_digit:]{4}/ <||continue>
-/\\[^xu:line_terminator:]/ <||continue>
+/\\[x][:hex_digit:]{2}/ <set_has_escapes||continue>
+/\\[u][:hex_digit:]{4}/ <set_has_escapes||continue>
+/\\[^xu:line_terminator:]/ <set_has_escapes||continue>
"\\" <|token(ILLEGAL)|>
line_terminator <|token(ILLEGAL)|>
"\"" <|token(STRING)|>
@@ -208,9 +208,9 @@
<<SingleQuoteString>>
# TODO subgraph for '\'
"\\" line_terminator_sequence <||continue>
-/\\[x][:hex_digit:]{2}/ <||continue>
-/\\[u][:hex_digit:]{4}/ <||continue>
-/\\[^xu:line_terminator:]/ <||continue>
+/\\[x][:hex_digit:]{2}/ <set_has_escapes||continue>
+/\\[u][:hex_digit:]{4}/ <set_has_escapes||continue>
+/\\[^xu:line_terminator:]/ <set_has_escapes||continue>
"\\" <|token(ILLEGAL)|>
line_terminator <|token(ILLEGAL)|>
"'" <|token(STRING)|>
@@ -223,6 +223,7 @@
if (V8_UNLIKELY(!ValidIdentifierPart())) {
goto default_action;
}
+ next_.has_escapes = true;
}|token(IDENTIFIER)|continue>
<<SingleLineComment>>
=======================================
---
/branches/experimental/parser/tools/lexer_generator/code_generator.jinja
Tue Nov 26 13:37:30 2013 UTC
+++
/branches/experimental/parser/tools/lexer_generator/code_generator.jinja
Wed Nov 27 09:41:41 2013 UTC
@@ -113,6 +113,8 @@
goto code_after_entry_{{value[3]}};
{% elif type == 'set_marker' %}
marker_ = cursor_ - {{value}};
+ {% elif type == 'set_has_escapes' %}
+ next_.has_escapes = true;
{% else %}
uncompilable code for {{type}}
{% endif -%}
@@ -286,6 +288,7 @@
namespace internal {
template<>
void ExperimentalScanner<{{char_type}}>::Scan() {
+ next_.has_escapes = false;
// Setup environment.
Token::Value stored_token;
{{char_type}} primary_char;
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.