<gh_stars>0
"""
Define the default initial mapping of control sequences (literal strings such
as 'input' that the user can type), to internal instructions (such as 'input a
file'), parameters (such as 'the page width') and special values (such as 'the
desired height of this page').
"""
from typing import Dict

from .instructions import Instructions
from .parameters import Parameters
from .specials import Specials


# Control sequence to instruction map.
primitive_control_sequences: Dict[str, Instructions] = {
    'relax': Instructions.relax,
    'begingroup': Instructions.begin_group,
    'endgroup': Instructions.end_group,
    'show': Instructions.show_token,
    'showbox': Instructions.show_box,
    'showlists': Instructions.show_lists,
    'showthe': Instructions.show_the,
    'shipout': Instructions.ship_out,
    'ignorespaces': Instructions.ignore_spaces,
    'afterassignment': Instructions.after_assignment,
    'aftergroup': Instructions.after_group,
    'uppercase': Instructions.upper_case,
    'lowercase': Instructions.lower_case,
    'message': Instructions.message,
    'errmessage': Instructions.error_message,
    'immediate': Instructions.immediate,
    'openin': Instructions.open_input,
    'closein': Instructions.close_input,
    'openout': Instructions.open_output,
    'closeout': Instructions.close_output,
    'read': Instructions.read,
    'write': Instructions.write,

    'special': Instructions.special,
    'penalty': Instructions.add_penalty,
    'kern': Instructions.kern,
    'mkern': Instructions.math_kern,
    'unpenalty': Instructions.un_penalty,
    'unkern': Instructions.un_kern,
    'unskip': Instructions.un_glue,
    'mark': Instructions.mark,
    'insert': Instructions.insert,
    'vadjust': Instructions.v_adjust,
    'vskip': Instructions.v_skip,
    'vfil': Instructions.v_fil,
    'vfill': Instructions.v_fill,
    'vss': Instructions.v_stretch_or_shrink,
    'vfilneg': Instructions.v_fil_neg,
    'leaders': Instructions.leaders,
    'cleaders': Instructions.centered_leaders,
    'xleaders': Instructions.expanded_leaders,
    'box': Instructions.box,
    'copy': Instructions.copy,
    'lastbox': Instructions.last_box,
    'vsplit': Instructions.v_split,
    'hbox': Instructions.h_box,
    'vbox': Instructions.v_box,
    'vtop': Instructions.v_top,
    'moveleft': Instructions.move_left,
    'moveright': Instructions.move_right,
    'unvbox': Instructions.un_v_box,
    'unvcopy': Instructions.un_v_copy,
    'hrule': Instructions.h_rule,
    'halign': Instructions.h_align,
    'indent': Instructions.indent,
    'noindent': Instructions.no_indent,
    'par': Instructions.par,
    'end': Instructions.end,
    'dump': Instructions.dump,
    'hskip': Instructions.h_skip,
    'hfil': Instructions.h_fil,
    'hfill': Instructions.h_fill,
    'hss': Instructions.h_stretch_or_shrink,
    'hfilneg': Instructions.h_fil_neg,
    ' ': Instructions.control_space,
    'raise': Instructions.raise_box,
    'lower': Instructions.lower_box,
    'unhbox': Instructions.un_h_box,
    'unhcopy': Instructions.un_h_copy,
    'vrule': Instructions.v_rule,
    'char': Instructions.char,
    'accent': Instructions.accent,
    '/': Instructions.italic_correction,
    'discretionary': Instructions.discretionary,
    '-': Instructions.discretionary_hyphen,

    'setbox': Instructions.set_box,
    'count': Instructions.count,
    'dimen': Instructions.dimen,
    'skip': Instructions.skip,
    'muskip': Instructions.mu_skip,
    'toks': Instructions.toks,
    'ht': Instructions.box_dimen_height,
    'wd': Instructions.box_dimen_width,
    'dp': Instructions.box_dimen_depth,

    'advance': Instructions.advance,
    'multiply': Instructions.multiply,
    'divide': Instructions.divide,

    'catcode': Instructions.cat_code,
    'mathcode': Instructions.math_code,
    'uccode': Instructions.upper_case_code,
    'lccode': Instructions.lower_case_code,
    'sfcode': Instructions.space_factor_code,
    'delcode': Instructions.delimiter_code,

    'let': Instructions.let,
    'futurelet': Instructions.future_let,

    'textfont': Instructions.text_font,
    'scriptfont': Instructions.script_font,
    'scriptscriptfont': Instructions.script_script_font,

    'parshape': Instructions.par_shape,

    'fontdimen': Instructions.font_dimen,
    'hyphenchar': Instructions.hyphen_char,
    'skewchar': Instructions.skew_char,

    'hyphenation': Instructions.hyphenation,
    'patterns': Instructions.patterns,

    'errorstopmode': Instructions.error_stop_mode,
    'scrollmode': Instructions.scroll_mode,
    'nonstopmode': Instructions.non_stop_mode,
    'batchmode': Instructions.batch_mode,

    'def': Instructions.def_,
    'gdef': Instructions.g_def,
    'edef': Instructions.e_def,
    'xdef': Instructions.x_def,

    'chardef': Instructions.char_def,
    'mathchardef': Instructions.math_char_def,
    'countdef': Instructions.count_def,
    'dimendef': Instructions.dimen_def,
    'skipdef': Instructions.skip_def,
    'muskipdef': Instructions.mu_skip_def,
    'toksdef': Instructions.toks_def,

    'global': Instructions.global_mod,
    'long': Instructions.long_mod,
    'outer': Instructions.outer_mod,

    'font': Instructions.font,

    # If's.
    'ifnum': Instructions.if_num,
    'ifdim': Instructions.if_dimen,
    'ifodd': Instructions.if_odd,
    'ifvmode': Instructions.if_v_mode,
    'ifhmode': Instructions.if_h_mode,
    'ifmmode': Instructions.if_m_mode,
    'ifinner': Instructions.if_inner_mode,
    'if': Instructions.if_char,
    'ifcat': Instructions.if_cat,
    'ifx': Instructions.if_token,
    'ifvoid': Instructions.if_void,
    'ifhbox': Instructions.if_h_box,
    'ifvbox': Instructions.if_v_box,
    'ifeof': Instructions.if_end_of_file,
    'iftrue': Instructions.if_true,
    'iffalse': Instructions.if_false,
    'ifcase': Instructions.if_case,

    'else': Instructions.else_,
    'fi': Instructions.end_if,
    'or': Instructions.or_,

    # Expanded tokens (usually banisher-handled).
    'number': Instructions.number,
    'romannumeral': Instructions.roman_numeral,
    'string': Instructions.string,
    'jobname': Instructions.job_name,
    'fontname': Instructions.font_name,
    'meaning': Instructions.meaning,
    'csname': Instructions.cs_name,
    'endcsname': Instructions.end_cs_name,
    'expandafter': Instructions.expand_after,
    'noexpand': Instructions.no_expand,
    'topmark': Instructions.top_mark,
    'firstmark': Instructions.first_mark,
    'botmark': Instructions.bottom_mark,
    'splitfirstmark': Instructions.split_first_mark,
    'splitbotmark': Instructions.split_bottom_mark,
    'input': Instructions.input,
    'endinput': Instructions.end_input,
    'the': Instructions.the,

    'cr': Instructions.cr,
    'undefined': Instructions.undefined,
}

# Control sequence to parameter map.
param_control_sequences: Dict[str, Parameters] = {
    'pretolerance': Parameters.pre_tolerance,
    'tolerance': Parameters.tolerance,
    'hbadness': Parameters.h_badness,
    'vbadness': Parameters.v_badness,
    'linepenalty': Parameters.line_penalty,
    'hyphenpenalty': Parameters.hyphen_penalty,
    'exhyphenpenalty': Parameters.ex_hyphen_penalty,
    'binoppenalty': Parameters.bin_op_penalty,
    'relpenalty': Parameters.rel_penalty,
    'clubpenalty': Parameters.club_penalty,
    'widowpenalty': Parameters.widow_penalty,
    'displaywidowpenalty': Parameters.display_widow_penalty,
    'brokenpenalty': Parameters.broken_penalty,
    'predisplaypenalty': Parameters.pre_display_penalty,
    'postdisplaypenalty': Parameters.post_display_penalty,
    'interlinepenalty': Parameters.inter_line_penalty,
    'floatingpenalty': Parameters.floating_penalty,
    'outputpenalty': Parameters.output_penalty,
    'doublehyphendemerits': Parameters.double_hyphen_demerits,
    'finalhyphendemerits': Parameters.final_hyphen_demerits,
    'adjdemerits': Parameters.adj_demerits,
    'looseness': Parameters.looseness,
    'pausing': Parameters.pausing,
    'holdinginserts': Parameters.holding_inserts,
    'tracingonline': Parameters.tracing_on_line,
    'tracingmacros': Parameters.tracing_macros,
    'tracingstats': Parameters.tracing_stats,
    'tracingparagraphs': Parameters.tracing_paragraphs,
    'tracingpages': Parameters.tracing_pages,
    'tracingoutput': Parameters.tracing_output,
    'tracinglostchars': Parameters.tracing_lostchars,
    'tracingcommands': Parameters.tracing_commands,
    'tracingrestores': Parameters.tracing_restores,
    'language': Parameters.language,
    'uchyph': Parameters.uc_hyph,
    'lefthyphenmin': Parameters.left_hyphen_min,
    'righthyphenmin': Parameters.right_hyphen_min,
    'globaldefs': Parameters.global_defs,
    'maxdeadcycles': Parameters.max_dead_cycles,
    'hangafter': Parameters.hang_after,
    'fam': Parameters.fam,
    'mag': Parameters.mag,
    'escapechar': Parameters.escape_char,
    'defaulthyphenchar': Parameters.default_hyphen_char,
    'defaultskewchar': Parameters.default_skew_char,
    'endlinechar': Parameters.end_line_char,
    'newlinechar': Parameters.new_line_char,
    'delimiterfactor': Parameters.delimiter_factor,
    # THESE TIME ONES WILL BE SET IN Parameters
    'time': Parameters.time,
    'day': Parameters.day,
    'month': Parameters.month,
    'year': Parameters.year,
    'showboxbreadth': Parameters.show_box_breadth,
    'showboxdepth': Parameters.show_box_depth,
    'errorcontextlines': Parameters.error_context_lines,

    'hfuzz': Parameters.h_fuzz,
    'vfuzz': Parameters.v_fuzz,
    'overfullrule': Parameters.over_full_rule,
    'hsize': Parameters.h_size,
    'vsize': Parameters.v_size,
    'maxdepth': Parameters.max_depth,
    'splitmaxdepth': Parameters.split_max_depth,
    'boxmaxdepth': Parameters.box_max_depth,
    'lineskiplimit': Parameters.line_skip_limit,
    'delimitershortfall': Parameters.delimiter_short_fall,
    'nulldelimiterspace': Parameters.null_delimiter_space,
    'scriptspace': Parameters.script_space,
    'mathsurround': Parameters.math_surround,
    'predisplaysize': Parameters.pre_display_size,
    'displaywidth': Parameters.display_width,
    'displayindent': Parameters.display_indent,
    'parindent': Parameters.par_indent,
    'hangindent': Parameters.hang_indent,
    'hoffset': Parameters.h_offset,
    'voffset': Parameters.v_offset,

    'baselineskip': Parameters.base_line_skip,
    'lineskip': Parameters.line_skip,
    'parskip': Parameters.par_skip,
    'abovedisplayskip': Parameters.above_display_skip,
    'abovedisplayshortskip': Parameters.above_display_short_skip,
    'belowdisplayskip': Parameters.below_display_skip,
    'belowdisplayshortskip': Parameters.below_display_short_skip,
    'leftskip': Parameters.left_skip,
    'rightskip': Parameters.right_skip,
    'topskip': Parameters.top_skip,
    'splittopskip': Parameters.split_top_skip,
    'tabskip': Parameters.tab_skip,
    'spaceskip': Parameters.space_skip,
    'xspaceskip': Parameters.x_space_skip,
    'parfillskip': Parameters.par_fill_skip,

    'thinmuskip': Parameters.thin_mu_skip,
    'medmuskip': Parameters.med_mu_skip,
    'thickmuskip': Parameters.thick_mu_skip,

    'output': Parameters.output,
    'everypar': Parameters.every_par,
    'everymath': Parameters.every_math,
    'everydisplay': Parameters.every_display,
    'everyhbox': Parameters.every_h_box,
    'everyvbox': Parameters.every_v_box,
    'everyjob': Parameters.every_job,
    'everycr': Parameters.every_cr,
    'errhelp': Parameters.err_help,
}

# Control sequence to special value map.
special_control_sequences: Dict[str, Specials] = {
    'spacefactor': Specials.space_factor,
    'prevgraf': Specials.prev_graf,
    'deadcycles': Specials.dead_cycles,
    'insertpenalties': Specials.insert_penalties,
    'prevdepth': Specials.prev_depth,
    'pagegoal': Specials.page_goal,
    'pagetotal': Specials.page_total,
    'pagestretch': Specials.page_stretch,
    'pagefilstretch': Specials.page_fil_stretch,
    'pagefillstretch': Specials.page_fill_stretch,
    'pagefilllstretch': Specials.page_filll_stretch,
    'pageshrink': Specials.page_shrink,
    'pagedepth': Specials.page_depth,
}
