| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library fasta.parser.parser; | 5 library fasta.parser.parser; |
| 6 | 6 |
| 7 import '../scanner.dart' show | 7 import '../scanner.dart' show |
| 8 ErrorToken; | 8 ErrorToken; |
| 9 | 9 |
| 10 import '../scanner/recover.dart' show | 10 import '../scanner/recover.dart' show |
| (...skipping 1852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1863 listener.handleAsyncModifier(async, star); | 1863 listener.handleAsyncModifier(async, star); |
| 1864 return token; | 1864 return token; |
| 1865 } | 1865 } |
| 1866 | 1866 |
| 1867 int statementDepth = 0; | 1867 int statementDepth = 0; |
| 1868 Token parseStatement(Token token) { | 1868 Token parseStatement(Token token) { |
| 1869 if (statementDepth++ > 500) { | 1869 if (statementDepth++ > 500) { |
| 1870 // This happens for degenerate programs, for example, a lot of nested | 1870 // This happens for degenerate programs, for example, a lot of nested |
| 1871 // if-statements. The language test deep_nesting2_negative_test, for | 1871 // if-statements. The language test deep_nesting2_negative_test, for |
| 1872 // example, provokes this. | 1872 // example, provokes this. |
| 1873 reportRecoverableError( | 1873 return reportUnrecoverableError(token, ErrorKind.StackOverflow); |
| 1874 token, ErrorKind.Unspecified, {'text': 'Stack overflow'}); | |
| 1875 return skipToEof(token); | |
| 1876 } | 1874 } |
| 1877 Token result = parseStatementX(token); | 1875 Token result = parseStatementX(token); |
| 1878 statementDepth--; | 1876 statementDepth--; |
| 1879 return result; | 1877 return result; |
| 1880 } | 1878 } |
| 1881 | 1879 |
| 1882 Token parseStatementX(Token token) { | 1880 Token parseStatementX(Token token) { |
| 1883 final value = token.stringValue; | 1881 final value = token.stringValue; |
| 1884 if (identical(token.kind, IDENTIFIER_TOKEN)) { | 1882 if (identical(token.kind, IDENTIFIER_TOKEN)) { |
| 1885 return parseExpressionStatementOrDeclaration(token); | 1883 return parseExpressionStatementOrDeclaration(token); |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2183 } | 2181 } |
| 2184 return token; | 2182 return token; |
| 2185 } | 2183 } |
| 2186 | 2184 |
| 2187 int expressionDepth = 0; | 2185 int expressionDepth = 0; |
| 2188 Token parseExpression(Token token) { | 2186 Token parseExpression(Token token) { |
| 2189 if (expressionDepth++ > 500) { | 2187 if (expressionDepth++ > 500) { |
| 2190 // This happens in degenerate programs, for example, with a lot of nested | 2188 // This happens in degenerate programs, for example, with a lot of nested |
| 2191 // list literals. This is provoked by, for examaple, the language test | 2189 // list literals. This is provoked by, for examaple, the language test |
| 2192 // deep_nesting1_negative_test. | 2190 // deep_nesting1_negative_test. |
| 2193 reportRecoverableError( | 2191 return reportUnrecoverableError(token, ErrorKind.StackOverflow); |
| 2194 token, ErrorKind.Unspecified, {'text': 'Stack overflow'}); | |
| 2195 return token.next; | |
| 2196 } | 2192 } |
| 2197 listener.beginExpression(token); | 2193 listener.beginExpression(token); |
| 2198 Token result = optional('throw', token) | 2194 Token result = optional('throw', token) |
| 2199 ? parseThrowExpression(token, true) | 2195 ? parseThrowExpression(token, true) |
| 2200 : parsePrecedenceExpression(token, ASSIGNMENT_PRECEDENCE, true); | 2196 : parsePrecedenceExpression(token, ASSIGNMENT_PRECEDENCE, true); |
| 2201 expressionDepth--; | 2197 expressionDepth--; |
| 2202 return result; | 2198 return result; |
| 2203 } | 2199 } |
| 2204 | 2200 |
| 2205 Token parseExpressionWithoutCascade(Token token) { | 2201 Token parseExpressionWithoutCascade(Token token) { |
| (...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3316 break; | 3312 break; |
| 3317 } | 3313 } |
| 3318 if (isRecoverable) { | 3314 if (isRecoverable) { |
| 3319 listener.handleRecoverableError(token, kind, arguments); | 3315 listener.handleRecoverableError(token, kind, arguments); |
| 3320 return null; | 3316 return null; |
| 3321 } else { | 3317 } else { |
| 3322 return listener.handleUnrecoverableError(token, kind, arguments); | 3318 return listener.handleUnrecoverableError(token, kind, arguments); |
| 3323 } | 3319 } |
| 3324 } | 3320 } |
| 3325 } | 3321 } |
| OLD | NEW |