Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion doc/dart-target.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,17 @@ The expected output is:
{"a":1}
"a":1
1
```
```

### Debug

We have some logs in place that can ease the debugging process, in order to turn these logs on you can enable the following environment declarations:

- ANTLR_LEXER_DEBUG
- ANTLR_LEXER_DFA_DEBUG
- ANTLR_PARSER_DEBUG
- ANTLR_PARSER_LIST_ATN_DECISIONS_DEBUG
- ANTLR_PARSER_DFA_DEBUG
- ANTLR_PARSER_RETRY_DEBUG

If you're using flutter, you can define these variables by adding an `--dart-define` arguments, eg. `flutter run --dart-define LEXER_DEBUG=false`
10 changes: 8 additions & 2 deletions runtime/Dart/lib/src/atn/src/lexer_atn_simulator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,14 @@ class SimState {

/// "dup" of ParserInterpreter */
class LexerATNSimulator extends ATNSimulator {
static const bool debug = false;
static const bool dfa_debug = false;
static const bool debug = bool.fromEnvironment(
'ANTLR_LEXER_DEBUG',
defaultValue: false,
);
static const bool dfa_debug = bool.fromEnvironment(
'ANTLR_LEXER_DFA_DEBUG',
defaultValue: false,
);

static const int MIN_DFA_EDGE = 0;
static const int MAX_DFA_EDGE = 127; // forces unicode to stay in ATN
Expand Down
20 changes: 16 additions & 4 deletions runtime/Dart/lib/src/atn/src/parser_atn_simulator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,22 @@ import 'transition.dart';
/// both SLL and LL parsing. Erroneous input will therefore require 2 passes over
/// the input.</p>
class ParserATNSimulator extends ATNSimulator {
static const bool debug = false;
static const bool debug_list_atn_decisions = false;
static const bool dfa_debug = false;
static const bool retry_debug = false;
static const bool debug = bool.fromEnvironment(
'ANTLR_PARSER_DEBUG',
defaultValue: false,
);
static const bool debug_list_atn_decisions = bool.fromEnvironment(
'ANTLR_PARSER_LIST_ATN_DECISIONS_DEBUG',
defaultValue: false,
);
static const bool dfa_debug = bool.fromEnvironment(
'ANTLR_PARSER_DFA_DEBUG',
defaultValue: false,
);
static const bool retry_debug = bool.fromEnvironment(
'ANTLR_PARSER_RETRY_DEBUG',
defaultValue: false,
);

/// Just in case this optimization is bad, add an ENV variable to turn it off */
static const bool TURN_OFF_LR_LOOP_ENTRY_BRANCH_OPT =
Expand Down