private void addLexerActions() {
		if (atn.grammarType == ATNType.LEXER) {
			data.add(atn.lexerActions.length);
			for (LexerAction action : atn.lexerActions) {
				data.add(action.getActionType().ordinal());
				switch (action.getActionType()) {
				case CHANNEL:
					int channel = ((LexerChannelAction)action).getChannel();
					data.add(channel);
					data.add(0);
					break;

				case CUSTOM:
					int ruleIndex = ((LexerCustomAction)action).getRuleIndex();
					int actionIndex = ((LexerCustomAction)action).getActionIndex();
					data.add(ruleIndex);
					data.add(actionIndex);
					break;

				case MODE:
					int mode = ((LexerModeAction)action).getMode();
					data.add(mode);
					data.add(0);
					break;

				case MORE:
					data.add(0);
					data.add(0);
					break;

				case POP_MODE:
					data.add(0);
					data.add(0);
					break;

				case PUSH_MODE:
					mode = ((LexerPushModeAction)action).getMode();
					data.add(mode);
					data.add(0);
					break;

				case SKIP:
					data.add(0);
					data.add(0);
					break;

				case TYPE:
					int type = ((LexerTypeAction)action).getType();
					data.add(type);
					data.add(0);
					break;

				default:
					String message = String.format(Locale.getDefault(), "The specified lexer action type %s is not valid.", action.getActionType());
					throw new IllegalArgumentException(message);
				}
			}
		}
	}
Serialize state descriptors, edge descriptors, and decision&rarr;state map
 into list of ints.  Likely out of date, but keeping as it could be helpful:

     SERIALIZED_VERSION
     UUID (2 longs)
		grammar-type, (ANTLRParser.LEXER, ...)
 	max token type,
 	num states,
 	state-0-type ruleIndex, state-1-type ruleIndex, ... state-i-type ruleIndex optional-arg ...
 	num rules,
 	rule-1-start-state rule-1-args, rule-2-start-state  rule-2-args, ...
 	(args are token type,actionIndex in lexer else 0,0)
     num modes,
     mode-0-start-state, mode-1-start-state, ... (parser has 0 modes)
     num unicode-bmp-sets
     bmp-set-0-interval-count intervals, bmp-set-1-interval-count intervals, ...
     num unicode-smp-sets
     smp-set-0-interval-count intervals, smp-set-1-interval-count intervals, ...
	num total edges,
     src, trg, edge-type, edge arg1, optional edge arg2 (present always), ...
     num decisions,
     decision-0-start-state, decision-1-start-state, ...

 Convenient to pack into unsigned shorts to make as Java string.
runtime/Java/src/org/antlr/v4/runtime/atn/ATNSerializer.java