=== modified file 'src/com/goldencode/p2j/uast/ProgressParserATNSimulator.java'
--- old/src/com/goldencode/p2j/uast/ProgressParserATNSimulator.java
+++ new/src/com/goldencode/p2j/uast/ProgressParserATNSimulator.java
@@ -30,6 +30,11 @@
 **     PMP 20261110 A custom prediction which finds no alternative for a mandatory block now falls back to
 **                  the default prediction instead of matching nothing (an endless loop inside a loop body).
 **     PMP 20261111 Added custom prediction for the ON statement trigger.
+**     PMP 20261113 Matched the custom predictions to the decisions of the generated parser by rule, index in
+**                  the rule and a fingerprint of the alternatives when the class is loaded, so that a shift
+**                  of the decision numbers needs no change here. The constructor throws when a row no longer
+**                  matches or its decision became LL(1), listing every such row and the rule's decisions.
+**                  Added main(), which prints a rule's decisions as table rows.
 */
 
 /*
@@ -87,31 +92,196 @@
 
 package com.goldencode.p2j.uast;
 
+import java.util.*;
 import org.antlr.v4.runtime.NoViableAltException;
 import org.antlr.v4.runtime.ParserRuleContext;
 import org.antlr.v4.runtime.Token;
 import org.antlr.v4.runtime.TokenStream;
-import org.antlr.v4.runtime.atn.ATN;
-import org.antlr.v4.runtime.atn.BlockStartState;
-import org.antlr.v4.runtime.atn.DecisionState;
-import org.antlr.v4.runtime.atn.LL1Analyzer;
-import org.antlr.v4.runtime.atn.ParserATNSimulator;
-import org.antlr.v4.runtime.atn.PredictionContextCache;
+import org.antlr.v4.runtime.atn.*;
 import org.antlr.v4.runtime.dfa.DFA;
+import org.antlr.v4.runtime.misc.IntervalSet;
 
 public class ProgressParserATNSimulator 
 extends ParserATNSimulator
 implements ProgressParserTokenTypes
 {
-   // The progress parser
-   private final ProgressParser parser;
-   
    /**
-    * Signed adjustment applied to selected decision numbers before dispatching to the
-    * custom prediction handlers. Keep this value at {@code 0} when the generated
-    * ANTLR decision numbers are already aligned with the switch cases below.
+    * The decisions which have a custom prediction, one row per switch key of {@link #predictWorker}:
+    * the key, the rule which owns the decision, the index of the decision among the decisions of that
+    * rule (in ATN order, LL(1) decisions included) and the fingerprint of the decision (see
+    * {@link #fingerprint}). Every {@code case} of {@link #predictWorker} needs a row and every row a
+    * {@code case}: a {@code case} without a row is never reached, a row without a {@code case} is
+    * predicted by ANTLR.
+    * <p>
+    * A key is the decision number the generated parser had when the prediction was written, and the
+    * {@code Alt__<n>} suffix of the predictor names refers to it. The generated numbers shift when a
+    * decision is added or removed anywhere before in the grammar, so the keys are matched to the
+    * current decisions by rule and index, see {@link #mapDecisions}. The constructor throws when a row
+    * no longer matches: the rule has fewer decisions, the decision at that index has another
+    * fingerprint (another state type, number of alternatives, or first symbol of an alternative, for
+    * example after a decision was added before it in the same rule), two rows match the same decision,
+    * or the decision became LL(1) (the generated parser predicts it from the lookahead token and never
+    * calls {@link #adaptivePredict} for it). The predictor must then be reviewed, because the
+    * alternative numbers it returns belong to the decision. The error lists the current decisions of
+    * each affected rule, and {@link #main} prints them as rows of this table.
+    * <p>
+    * Not detected: a change of an alternative after its first symbol, and the LL(1) decisions which
+    * {@link LL1Analyzer} does not recognize as such (it can miss some which ANTLR generates as LL(1)).
+    */
+   private static final int[][] CUSTOM_DECISIONS =
+   {
+      {   1, ProgressParser.RULE_pre_scan_class,                    1, 0x17BD2E4B },
+      {   3, ProgressParser.RULE_pre_scan_class,                    3, 0x5EA5CB06 },
+      {   4, ProgressParser.RULE_pre_scan_class,                    4, 0x28CDAE3F },
+      {   8, ProgressParser.RULE_block,                             0, 0x5E772712 },
+      {   9, ProgressParser.RULE_single_block,                      0, 0x17657236 },
+      {  20, ProgressParser.RULE_procedure,                         1, 0x024E27F7 },
+      {  49, ProgressParser.RULE_using_stmt,                        0, 0x172B60CF },
+      {  53, ProgressParser.RULE_constructor,                       0, 0xE621B83B },
+      {  56, ProgressParser.RULE_user_defined_method,               0, 0xE621B83B },
+      {  66, ProgressParser.RULE_function,                          0, 0xE621B83B },
+      {  87, ProgressParser.RULE_define_stmt,                       6, 0x53C3E963 },
+      {  98, ProgressParser.RULE_def_parm_stmt,                     0, 0xAD558BB2 },
+      { 101, ProgressParser.RULE_def_browse_stmt,                   2, 0xCD1470D8 },
+      { 102, ProgressParser.RULE_def_browse_stmt,                   3, 0xE5261C8C },
+      { 104, ProgressParser.RULE_def_browse_stmt,                   5, 0x36447939 },
+      { 106, ProgressParser.RULE_def_query_stmt,                    1, 0x7C4C26A0 },
+      { 107, ProgressParser.RULE_for_record_spec,                   0, 0x840AC948 },
+      { 108, ProgressParser.RULE_for_record_spec,                   1, 0x840AC948 },
+      { 109, ProgressParser.RULE_for_record_spec,                   2, 0x85FA1C50 },
+      { 110, ProgressParser.RULE_simple_for_record_spec,            0, 0x2E50908C },
+      { 112, ProgressParser.RULE_def_buf_stmt,                      1, 0xB2F8C2AB },
+      { 113, ProgressParser.RULE_def_buf_stmt,                      2, 0x08876AEA },
+      { 119, ProgressParser.RULE_def_dataset_stmt,                  3, 0x29E6B215 },
+      { 128, ProgressParser.RULE_for_data_relation_spec,            1, 0x89B2C1D2 },
+      { 132, ProgressParser.RULE_nested_clause,                     0, 0x8146CFCB },
+      { 139, ProgressParser.RULE_def_menu_stmt,                     4, 0x9BBE6662 },
+      { 142, ProgressParser.RULE_submenu_descriptor,                1, 0xEE51CAFE },
+      { 144, ProgressParser.RULE_menu_item_phrase,                  1, 0x50F48775 },
+      { 147, ProgressParser.RULE_def_button_stmt,                   2, 0x022A3C5F },
+      { 149, ProgressParser.RULE_def_rect_stmt,                     1, 0x494D0491 },
+      { 151, ProgressParser.RULE_def_image_stmt,                    1, 0xBE98C96E },
+      { 154, ProgressParser.RULE_def_frame_stmt,                    1, 0x3839D624 },
+      { 155, ProgressParser.RULE_def_frame_stmt,                    2, 0x119D161F },
+      { 157, ProgressParser.RULE_form_stmt,                         1, 0x2216A048 },
+      { 161, ProgressParser.RULE_form_item,                         0, 0x4E4BCC80 },
+      { 173, ProgressParser.RULE_set_or_update_or_prompt_for_stmt,  3, 0xE3476A07 },
+      { 192, ProgressParser.RULE_format_phrase,                     4, 0x32828013 },
+      { 195, ProgressParser.RULE_aggregate_phrase,                  2, 0x20F901F8 },
+      { 196, ProgressParser.RULE_aggregate_phrase,                  3, 0xFEA2B4C1 },
+      { 205, ProgressParser.RULE_frame_phrase,                      5, 0x8A56F1B7 },
+      { 206, ProgressParser.RULE_frame_phrase,                      6, 0x73BCCD7B },
+      { 212, ProgressParser.RULE_title_phrase,                      0, 0x12C02DB8 },
+      { 213, ProgressParser.RULE_title_phrase,                      1, 0xB0495C87 },
+      { 215, ProgressParser.RULE_color_stmt,                        1, 0x627E2C4A },
+      { 220, ProgressParser.RULE_display_color_clause,              0, 0xAC376778 },
+      { 224, ProgressParser.RULE_color_phrase,                      2, 0x551C8D28 },
+      { 225, ProgressParser.RULE_column_spec,                       0, 0x7CA23F6E },
+      { 227, ProgressParser.RULE_column_spec,                       2, 0x20C0DF3C },
+      { 228, ProgressParser.RULE_column_spec,                       3, 0x7B6041FE },
+      { 229, ProgressParser.RULE_column_spec,                       4, 0x323F21FE },
+      { 230, ProgressParser.RULE_column_spec,                       5, 0x9922794A },
+      { 231, ProgressParser.RULE_browse_enable_phrase,              0, 0x8B6CDF8C },
+      { 238, ProgressParser.RULE_column_format_phrase,              2, 0x1C7CC322 },
+      { 242, ProgressParser.RULE_browse_options_phrase,             3, 0x7A0F06FB },
+      { 243, ProgressParser.RULE_browse_options_phrase,             4, 0x1E89D7BD },
+      { 246, ProgressParser.RULE_table_parm,                        1, 0x3EAD0937 },
+      { 249, ProgressParser.RULE_table_parm,                        4, 0x8BFF2A14 },
+      { 251, ProgressParser.RULE_regular_parm,                      1, 0x7110BB10 },
+      { 254, ProgressParser.RULE_inner_block,                       1, 0xE621B83B },
+      { 260, ProgressParser.RULE_stmt_list,                         1, 0x2E4713DE },
+      { 265, ProgressParser.RULE_common_block_options,              1, 0x55E37AA3 },
+      { 271, ProgressParser.RULE_then_clause,                       0, 0x880C89A6 },
+      { 272, ProgressParser.RULE_else_clause,                       0, 0x880C89A6 },
+      { 274, ProgressParser.RULE_case_stmt,                         1, 0x4D583592 },
+      { 275, ProgressParser.RULE_case_stmt,                         2, 0x430898FC },
+      { 277, ProgressParser.RULE_end_stmt,                          0, 0x6114103D },
+      { 278, ProgressParser.RULE_end_stmt,                          1, 0x630C5649 },
+      { 409, ProgressParser.RULE_put_screen_stmt,                   0, 0x96CC2358 },
+      { 410, ProgressParser.RULE_put_screen_stmt,                   1, 0xFAEDA274 },
+      { 492, ProgressParser.RULE_on_stmt,                           8, 0x853012D4 },
+      { 493, ProgressParser.RULE_on_stmt,                           9, 0x30C9E990 },
+      { 494, ProgressParser.RULE_write_referencing_phrase,          0, 0x5537DF1D },
+      { 505, ProgressParser.RULE_query_reference,                   0, 0xC816A7D7 },
+      { 517, ProgressParser.RULE_malformed_symbol,                  0, 0x3BD76DC3 },
+      { 548, ProgressParser.RULE_combo_box_phrase,                  1, 0xB6AC150C },
+      { 551, ProgressParser.RULE_simple_widget_phrase,              2, 0x044F5F45 },
+      { 558, ProgressParser.RULE_radio_set_phrase,                  3, 0x65DEC16B },
+      { 561, ProgressParser.RULE_selection_list_phrase,             2, 0xF069D026 },
+      { 565, ProgressParser.RULE_radio_buttons_clause,              0, 0xFFE3E15B },
+      { 566, ProgressParser.RULE_radio_buttons_clause,              1, 0xFFE3E15B },
+      { 567, ProgressParser.RULE_radio_buttons_clause,              2, 0x85FA1C50 },
+      { 569, ProgressParser.RULE_list_items_clause,                 0, 0x85FA1C50 },
+      { 576, ProgressParser.RULE_def_var_stmt,                      2, 0xDD2DB7D1 },
+      { 590, ProgressParser.RULE_extent,                            0, 0xC4CDBDD0 },
+      { 598, ProgressParser.RULE_var_type,                          2, 0xA3D25968 },
+      { 600, ProgressParser.RULE_like_clause,                       1, 0xF46A66FB },
+      { 607, ProgressParser.RULE_no_focus_clause,                   0, 0x74F47C75 },
+      { 613, ProgressParser.RULE_label_reference,                   0, 0x3740D9DC },
+      { 628, ProgressParser.RULE_record_phrase,                     3, 0x31A31610 },
+      { 742, ProgressParser.RULE_def_temp_table_stmt,               2, 0xF3FBEE4A },
+      { 747, ProgressParser.RULE_add_temp_table_field,              3, 0x8606874C },
+      { 751, ProgressParser.RULE_temp_table_field_options,          1, 0x729C8ED3 },
+      { 753, ProgressParser.RULE_index_clause,                      1, 0x60F7A403 },
+      { 756, ProgressParser.RULE_is_clause,                         2, 0x5E3D15E9 },
+      { 757, ProgressParser.RULE_index_field_clause,                0, 0x7D1AB91B },
+      { 765, ProgressParser.RULE_field_list,                        1, 0x2534BD7C },
+      { 767, ProgressParser.RULE_where_clause,                      0, 0x1B88C3C5 },
+      { 773, ProgressParser.RULE_display_stmt,                      0, 0x29DCD60E },
+      { 775, ProgressParser.RULE_display_stmt,                      2, 0x11980AAC },
+      { 778, ProgressParser.RULE_display_stmt,                      5, 0xE00A73A3 },
+      { 779, ProgressParser.RULE_display_stmt,                      6, 0xA144D52C },
+      { 791, ProgressParser.RULE_put_stmt,                          0, 0xDA004D66 },
+      { 792, ProgressParser.RULE_put_stmt,                          1, 0x93C6EB6A },
+      { 811, ProgressParser.RULE_msg_stmt,                          0, 0xDE3735B3 },
+      { 825, ProgressParser.RULE_run_stmt,                          0, 0xDA27A52E },
+      { 827, ProgressParser.RULE_run_stmt,                          2, 0xC25E7E85 },
+      { 862, ProgressParser.RULE_filename,                          0, 0xC38E6F74 },
+      { 864, ProgressParser.RULE_return_core,                       1, 0x1B88C3C5 },
+      { 870, ProgressParser.RULE_expr,                              0, 0x60763FF0 },
+      { 871, ProgressParser.RULE_log_and_expr,                      0, 0xE120265F },
+      { 872, ProgressParser.RULE_bitwise_xor_expr,                  0, 0x51B3B8E3 },
+      { 873, ProgressParser.RULE_log_not_expr,                      0, 0xB4F1521F },
+      { 877, ProgressParser.RULE_compare_expr,                      3, 0x8371EBF6 },
+      { 878, ProgressParser.RULE_compare_expr,                      4, 0xD56D06B3 },
+      { 879, ProgressParser.RULE_compare_expr,                      5, 0xE8E8A108 },
+      { 880, ProgressParser.RULE_sum_expr,                          0, 0x53C5F765 },
+      { 881, ProgressParser.RULE_prod_expr,                         0, 0xAC276FE9 },
+      { 883, ProgressParser.RULE_un_type,                           1, 0x79EFC24F },
+      { 884, ProgressParser.RULE_chained_object_members,            0, 0xDFD215CA },
+      { 885, ProgressParser.RULE_chained_object_members,            1, 0x65C0B688 },
+      { 890, ProgressParser.RULE_chained_object_members,            6, 0x0F470D66 },
+      { 893, ProgressParser.RULE_primary_expr,                      1, 0xC0D25995 },
+      { 894, ProgressParser.RULE_primary_expr,                      2, 0x4EA34273 },
+      { 921, ProgressParser.RULE_attribute_or_method,               7, 0xC5547940 },
+      { 922, ProgressParser.RULE_attribute_or_method,               8, 0x419DD5C2 },
+      { 927, ProgressParser.RULE_com_property_or_method,            4, 0x2534BD7C },
+      { 932, ProgressParser.RULE_widget_qualifier,                  0, 0xF4937A60 },
+      { 937, ProgressParser.RULE_lvalue,                            4, 0x651F119E },
+      { 938, ProgressParser.RULE_lvalue,                            5, 0x853F9E26 },
+      { 939, ProgressParser.RULE_lvalue,                            6, 0x0ABEF8BF },
+      { 941, ProgressParser.RULE_subscript,                         1, 0x074171FA },
+      { 942, ProgressParser.RULE_likeSubscript,                     0, 0x403FE8C1 },
+      { 945, ProgressParser.RULE_super_function,                    0, 0xB08CD4ED },
+      { 948, ProgressParser.RULE_record_funcs,                      2, 0x6CA2BE21 },
+      { 953, ProgressParser.RULE_at_phrase,                         0, 0x9A666002 },
+      { 964, ProgressParser.RULE_command_token_list,                1, 0x0A25C9CC }
+   };
+
+   /** The decisions of each rule of the generated parser, indexed by rule, in ATN order. */
+   private static final List<List<DecisionState>> RULE_DECISIONS = decisionsByRule();
+
+   /**
+    * The switch key of each decision of the generated parser, or -1 for one without custom prediction.
+    * When {@link #CUSTOM_DECISIONS} does not match the grammar, only the rows which match are mapped.
+    */
+   private static final int[] DECISION_KEYS = new int[ProgressParser._ATN.getNumberOfDecisions()];
+
+   /**
+    * Why {@link #CUSTOM_DECISIONS} does not match the grammar, or {@code null} when it does. The class
+    * stays usable on a mismatch, so that {@link #main} can still print the rows. The constructor throws.
     */
-   private static final int DECISION_OFFSET = 0;
+   private static final String MAPPING_ERROR = mapDecisions(DECISION_KEYS);
 
    /** {@link #decisionKinds} value: not classified yet. */
    private static final byte KIND_UNKNOWN = 0;
@@ -128,12 +298,36 @@
     */
    private static final byte[] decisionKinds = new byte[ProgressParser._ATN.getNumberOfDecisions()];
 
+   /** The progress parser. */
+   private final ProgressParser parser;
+
+   /**
+    * Creates the simulator.
+    *
+    * @param    parser
+    *           The progress parser.
+    * @param    atn
+    *           The ATN of the generated parser.
+    * @param    decisionToDFA
+    *           The DFA of each decision.
+    * @param    sharedContextCache
+    *           The prediction context cache.
+    *
+    * @throws   IllegalStateException
+    *           if {@link #CUSTOM_DECISIONS} does not match the decisions of the generated parser.
+    */
    public ProgressParserATNSimulator(ProgressParser parser,
                                      ATN atn,
                                      DFA[] decisionToDFA,
                                      PredictionContextCache sharedContextCache)
    {
       super(parser, atn, decisionToDFA, sharedContextCache);
+
+      if (MAPPING_ERROR != null)
+      {
+         throw new IllegalStateException(MAPPING_ERROR);
+      }
+
       this.parser = parser;
    }
    
@@ -183,6 +377,261 @@
    }
 
    /**
+    * Maps each decision of the generated parser to the switch key of its custom prediction, from
+    * {@link #CUSTOM_DECISIONS}, and checks every row against the grammar.
+    *
+    * @param    keys
+    *           Receives the switch key of each decision, -1 for a decision without custom prediction.
+    *           A row which does not match the grammar is not mapped (except an LL(1) decision).
+    *
+    * @return   {@code null} when every row matches the grammar, otherwise a message with every row
+    *           which does not match and the current decisions of each affected rule.
+    */
+   private static String mapDecisions(int[] keys)
+   {
+      Arrays.fill(keys, -1);
+
+      LL1Analyzer   analyzer = new LL1Analyzer(ProgressParser._ATN);
+      StringBuilder problems = new StringBuilder();
+      Set<Integer>  rules    = new TreeSet<>();
+
+      for (int[] row : CUSTOM_DECISIONS)
+      {
+         int key      = row[0];
+         int rule     = row[1];
+         int index    = row[2];
+         int expected = row[3];
+
+         List<DecisionState> decisions = RULE_DECISIONS.get(rule);
+         DecisionState       state     = index < decisions.size() ? decisions.get(index) : null;
+
+         String problem = null;
+         if (state == null)
+         {
+            problem = "the rule has " + decisions.size() + " decisions";
+         }
+         else if (fingerprint(state) != expected)
+         {
+            problem = "decision " + state.decision + " is " + describe(state);
+         }
+         else if (keys[state.decision] != -1)
+         {
+            problem = "decision " + state.decision + " is already mapped to key " + keys[state.decision];
+         }
+         else
+         {
+            keys[state.decision] = key;
+
+            if (isLL1(analyzer, state))
+            {
+               problem = "decision " + state.decision + " is LL(1), the parser never calls " +
+                         "adaptivePredict() for it";
+            }
+         }
+
+         if (problem != null)
+         {
+            problems.append(String.format("%n   custom prediction %d, expected decision index %d of " +
+                                          "rule %s with fingerprint 0x%08X: %s",
+                                          key,
+                                          index,
+                                          ProgressParser.ruleNames[rule],
+                                          expected,
+                                          problem));
+            rules.add(rule);
+         }
+      }
+
+      if (problems.length() == 0)
+      {
+         return null;
+      }
+
+      StringBuilder msg = new StringBuilder();
+      msg.append("CUSTOM_DECISIONS no longer matches the grammar. Review each predictor listed and " +
+                 "update its row (ProgressParserATNSimulator.main() prints the rows of a rule):");
+      msg.append(problems);
+      for (int rule : rules)
+      {
+         List<DecisionState> decisions = RULE_DECISIONS.get(rule);
+
+         msg.append(String.format("%nDecisions of rule %s:", ProgressParser.ruleNames[rule]));
+         for (int i = 0; i < decisions.size(); i++)
+         {
+            DecisionState state = decisions.get(i);
+            msg.append(String.format("%n   index %d: decision %d, %s", i, state.decision, describe(state)));
+         }
+      }
+
+      return msg.toString();
+   }
+
+   /**
+    * Collects the decisions of each rule of the generated parser.
+    *
+    * @return   The decision states, indexed by rule, each list in ATN order.
+    */
+   private static List<List<DecisionState>> decisionsByRule()
+   {
+      ATN                       atn           = ProgressParser._ATN;
+      List<List<DecisionState>> ruleDecisions = new ArrayList<>();
+      for (int i = 0; i < atn.ruleToStartState.length; i++)
+      {
+         ruleDecisions.add(new ArrayList<>());
+      }
+
+      for (int d = 0; d < atn.getNumberOfDecisions(); d++)
+      {
+         DecisionState state = atn.getDecisionState(d);
+         ruleDecisions.get(state.ruleIndex).add(state);
+      }
+
+      return ruleDecisions;
+   }
+
+   /**
+    * Computes the fingerprint of a decision: a hash of its state type and, for each alternative in
+    * order, the set of symbols the alternative can start with inside the rule (see
+    * {@link #firstSymbols}). Only names enter the hash (token and rule names, not their numbers), so
+    * the fingerprint does not change when tokens, rules or decisions are added elsewhere in the
+    * grammar.
+    *
+    * @param    state
+    *           The decision state.
+    *
+    * @return   The fingerprint.
+    */
+   private static int fingerprint(DecisionState state)
+   {
+      StringBuilder text = new StringBuilder(ATNState.serializationNames.get(state.getStateType()));
+      for (int i = 0; i < state.getNumberOfTransitions(); i++)
+      {
+         Set<String> symbols = new TreeSet<>();
+         firstSymbols(state.transition(i).target, symbols, new HashSet<>());
+         text.append(" | ").append(String.join(" ", symbols));
+      }
+
+      return text.toString().hashCode();
+   }
+
+   /**
+    * Collects the symbols which can be matched first from the given ATN state, without leaving its
+    * rule: the display name of a token (prefixed by {@code ~} for a negated set), {@code .} for a
+    * wildcard, the name of a referenced rule (which is not entered), {@code ?} for a semantic
+    * predicate and {@code <end>} when the end of the rule can be reached. Actions are skipped.
+    *
+    * @param    state
+    *           The ATN state to start from.
+    * @param    symbols
+    *           Receives the symbols.
+    * @param    visited
+    *           The states already visited, to stop at loops.
+    */
+   private static void firstSymbols(ATNState state, Set<String> symbols, Set<ATNState> visited)
+   {
+      if (!visited.add(state))
+      {
+         return;
+      }
+
+      if (state instanceof RuleStopState)
+      {
+         symbols.add("<end>");
+         return;
+      }
+
+      for (int i = 0; i < state.getNumberOfTransitions(); i++)
+      {
+         Transition trans = state.transition(i);
+         if (trans instanceof RuleTransition)
+         {
+            symbols.add(ProgressParser.ruleNames[trans.target.ruleIndex]);
+         }
+         else if (trans.isEpsilon())
+         {
+            if (trans instanceof AbstractPredicateTransition)
+            {
+               symbols.add("?");
+            }
+
+            firstSymbols(trans.target, symbols, visited);
+         }
+         else if (trans instanceof WildcardTransition)
+         {
+            symbols.add(".");
+         }
+         else
+         {
+            String prefix = trans instanceof NotSetTransition ? "~" : "";
+            for (int type : trans.label().toList())
+            {
+               symbols.add(prefix + ProgressParser.VOCABULARY.getDisplayName(type));
+            }
+         }
+      }
+   }
+
+   /**
+    * Checks whether ANTLR generates a decision as LL(1), predicted from the lookahead token without
+    * {@link #adaptivePredict}: the lookahead sets of its alternatives are disjoint and none of them
+    * depends on a predicate. This is the test of the ANTLR tool, run on the runtime ATN, so it can miss
+    * a decision which the tool generates as LL(1).
+    *
+    * @param    analyzer
+    *           The analyzer of the parser's ATN.
+    * @param    state
+    *           The decision state.
+    *
+    * @return   {@code true} if the decision is LL(1).
+    */
+   private static boolean isLL1(LL1Analyzer analyzer, DecisionState state)
+   {
+      IntervalSet[] look = analyzer.getDecisionLookahead(state);
+      IntervalSet   seen = new IntervalSet();
+      for (IntervalSet alt : look)
+      {
+         if (alt == null || !alt.and(seen).isNil())
+         {
+            return false;
+         }
+
+         seen.addAll(alt);
+      }
+
+      return true;
+   }
+
+   /**
+    * Describes a decision state by its type, number of alternatives and fingerprint.
+    *
+    * @param    state
+    *           The decision state.
+    *
+    * @return   The description, for example
+    *           {@code "STAR_BLOCK_START with 12 alternatives, fingerprint 0x1A2B3C4D"}.
+    */
+   private static String describe(DecisionState state)
+   {
+      return String.format("%s with %d alternatives, fingerprint 0x%08X",
+                           ATNState.serializationNames.get(state.getStateType()),
+                           state.getNumberOfTransitions(),
+                           fingerprint(state));
+   }
+
+   /**
+    * Builds the rule column of a {@link #CUSTOM_DECISIONS} row, as printed by {@link #main}.
+    *
+    * @param    rule
+    *           The rule index.
+    *
+    * @return   The column text, for example {@code "ProgressParser.RULE_at_phrase,"}.
+    */
+   private static String ruleColumn(int rule)
+   {
+      return "ProgressParser.RULE_" + ProgressParser.ruleNames[rule] + ",";
+   }
+
+   /**
     * Checks whether a decision is a block which must match one of its alternatives: none of them can reach
     * the end of the block without matching a token. Loop decisions and optional blocks are not mandatory.
     *
@@ -234,7 +683,9 @@
     * This method contains the custom prediction dispatch used by this simulator. For selected
     * decisions, it applies specialized fast-path logic which avoids expensive generic ATN
     * prediction in known grammar hotspots. Decisions which are not handled explicitly are
-    * delegated to the superclass implementation.
+    * delegated to the superclass implementation. The switch is on the key the decision has in
+    * {@link #CUSTOM_DECISIONS}, which can differ from the decision number, while the superclass
+    * always gets the decision number.
     *
     * @param    input
     *           The token stream used by the parser.
@@ -248,11 +699,8 @@
     private int predictWorker(TokenStream input, int decision, ParserRuleContext outerContext)
     {
        int alt = -1;
-       int minAdjustedDecision = 0;
-       int maxAdjustedDecision = Integer.MAX_VALUE;
-       decision = adjustDecision(decision, minAdjustedDecision, maxAdjustedDecision);
-       
-       switch(decision)
+
+       switch (DECISION_KEYS[decision])
        {
           case 1:
              return parser.predictPreScanClassAlt__1(input);
@@ -731,31 +1179,85 @@
              return super.adaptivePredict(input, decision, outerContext);
        }
     }
-    
-    /**
-     * Adjusts a generated ANTLR decision number before it is used for custom prediction dispatch.
-     * <p>
-     * The superclass must still be called with the original decision number, because it indexes the
-     * generated ATN/DFA tables. The adjusted value is used only to match the stable switch cases in
-     * this class.
-     *
-     * @param    decision
-     *           The original generated ANTLR decision number.
-     * @param    minAdjustedDecision
-     *           The lowest decision number to which the configured offset should be applied.
-     * @param    maxAdjustedDecision
-     *           The highest decision number to which the configured offset should be applied.
-     *
-     * @return   The adjusted decision number when it is inside the configured range, otherwise the
-     *           original decision number.
-     */
-    private int adjustDecision(int decision, int minAdjustedDecision, int maxAdjustedDecision)
-    {
-       if (decision >= minAdjustedDecision && decision <= maxAdjustedDecision)
-       {
-          return decision + DECISION_OFFSET;
-       }
 
-       return decision;
-    }
+   /**
+    * Prints the decisions of the given rules as rows of {@link #CUSTOM_DECISIONS}, aligned as the table,
+    * to add a custom prediction or to repair the table after a grammar change. A decision which has a
+    * custom prediction (its row still matches) is printed with its key, any other with its current
+    * decision number as the key, and a comment after each row describes the decision. Also prints why the
+    * table does not match the grammar, if it does not. The exit status is 1 for a usage error, an
+    * unknown rule or a table which does not match the grammar.
+    * <p>
+    * Usage: {@code java -cp "build/lib/*" com.goldencode.p2j.uast.ProgressParserATNSimulator <rule>...}
+    *
+    * @param    args
+    *           The names of the parser rules, as in {@code ProgressParser.g4}.
+    */
+   public static void main(String[] args)
+   {
+      boolean failed = false;
+
+      if (MAPPING_ERROR != null)
+      {
+         System.err.println(MAPPING_ERROR);
+         System.err.println();
+         failed = true;
+      }
+
+      if (args.length == 0)
+      {
+         System.err.println("Usage: java -cp \"build/lib/*\" " + ProgressParserATNSimulator.class.getName() +
+                            " <rule>...");
+         System.exit(1);
+      }
+
+      // the width of the rule column, as in the table
+      int width = 0;
+      for (int[] row : CUSTOM_DECISIONS)
+      {
+         width = Math.max(width, ruleColumn(row[1]).length());
+      }
+
+      List<String> ruleNames = Arrays.asList(ProgressParser.ruleNames);
+      for (String name : args)
+      {
+         int rule = ruleNames.indexOf(name);
+         if (rule < 0)
+         {
+            System.err.println("Unknown rule: " + name);
+            failed = true;
+            continue;
+         }
+
+         List<DecisionState> decisions = RULE_DECISIONS.get(rule);
+         if (decisions.isEmpty())
+         {
+            System.out.println("Rule " + name + " has no decisions.");
+            continue;
+         }
+
+         String column = String.format("%-" + Math.max(width, ruleColumn(rule).length()) + "s",
+                                       ruleColumn(rule));
+         for (int i = 0; i < decisions.size(); i++)
+         {
+            DecisionState state  = decisions.get(i);
+            boolean       custom = DECISION_KEYS[state.decision] != -1;
+            int           key    = custom ? DECISION_KEYS[state.decision] : state.decision;
+
+            System.out.printf("      { %3d, %s %2d, 0x%08X },  // decision %d, %s%s%n",
+                              key,
+                              column,
+                              i,
+                              fingerprint(state),
+                              state.decision,
+                              describe(state),
+                              custom ? ", custom prediction" : "");
+         }
+      }
+
+      if (failed)
+      {
+         System.exit(1);
+      }
+   }
 }
