#	Requests begin with an argument parsing action section
#	(possibly empty), then eol (mandatory), then a non-parsing
#	action section (possibly empty).  Immediates have only a
#	non-parsing action section.

#	If you list immediate actions, be aware that most parameters are
#	uninitialized.  You should set spacing to initialize how big v's
#	are, and point-size to initialize how big m's and n's are.

# write-control SHOULD NOT include \n at end.
# write-text output SHOULD include \n at end, but regular text output
# may or may not - but there is the problem of whether to flush or not.  Ick.

# 2. font and character size control

req ps parse-absrel-num x point-size eol point-size $1
req ss parse-num x eol space-size $1
req cs parse-name parse-num x parse-num x eol constant-width $1 $2 $3
req bd parse-s parse-name parse-num x eol embolden $1 $2 $3
req ft parse-name eol font $1
req fp parse-num x parse-name eol font-position $1 $2

# 3. page control (not implemented: pn ne mk rt)

req pl parse-absrel-num v page-length eol page-length $1
# no way to know current page number; so sorry...
req bp parse-absrel-num u 0 eol break begin-page $1
req pn parse-absrel-num u 0 eol page-number $1
req po parse-absrel-num m offset eol offset $1
req ne parse-num v eol need $1
req mk parse-name eol
req rt parse-absrel-num v 0 eol

# 4. text filling, adjusting and centering

req br eol break
req fi eol break fill
req nf eol break nofill
req ad parse-char eol adjust $1
req na eol noadjust
req ce parse-num x eol break center $1

# 5. vertical spacing (not implemented: sv os ns rs)

# seems odd, but vs and ls don't allow parse-absrel-num?
req vs parse-num p eol spacing $1
req ls parse-num x eol line-spacing $1
req sp parse-num v eol break space $1
req sv parse-num v eol
req os eol
req ns eol no-space n
req rs eol no-space y

# 6. line length and indenting

req ll parse-absrel-num m line-length eol line-length $1
req in parse-absrel-num m indent eol break indent $1
# temp indent interpreted relative to indent if +/-
req ti parse-absrel-num m indent eol break temp-indent $1

# 7. macros, strings, diversion, and position traps
# (not implemented: wh ch dt)

req de parse-name parse-name eol define-macro $1 $2
req am parse-name parse-name eol append-macro $1 $2
req ds parse-name parse-string-value y eol define-string $1 $2
req as parse-name parse-string-value y eol append-string $1 $2
req rm parse-removelist n eol
req rn parse-name parse-name eol rename $1 $2
req di parse-name eol begin-diversion $1
req da parse-name eol append-diversion $1
req wh parse-num v parse-name eol
req ch parse-name parse-num v eol
req dt parse-num v parse-name eol
req it parse-num x parse-name eol input-trap $1 $2
req em parse-name eol end-macro $1

# 8. number registers

req nr parse-name parse-absrel-num u \\$1 parse-num x eol \
		define-register $1 $2 $3
# this isn't quite right, because second arg can be 01, 001, etc.
# (fix this sometime!)
req af parse-name parse-char eol register-format $1 $2
req rr parse-removelist y eol

# 9. tabs, leaders and fields

req ta parse-tab-stops eol
req tc parse-char eol set-tab $1
req lc parse-char eol set-leader $1
req fc parse-char parse-char eol set-field $1 $2

# 10. input and output conventions and character translations
# not implemented: lg tr

# 10.1. input character translations

req ec parse-char eol set-escape $1
req eo eol noescape

# 10.2. ligatures

req lg parse-num u eol

# 10.3 backspacing, underlining, overstriking, etc.

req ul parse-num x eol underline $1
req cu parse-num x eol continuous-underline $1
req uf parse-name eol underline-font $1

# 10.4. control characters

req cc parse-char eol set-control $1
req c2 parse-char eol set-control2 $1

# 10.5. output translations

req tr parse-transliteration eol transliterate $1

# 13. hyphenation (not implemented nh hy hc hw)

req nh eol hyphenate 0
req hy parse-num x eol hyphenate $1
req hc parse-char eol hyphen-char $1
req hw eol

# 14. three part titles (not implemented properly: tl)

req tl parse-title eol
req pc parse-char eol page-num-char $1
req lt parse-absrel-num m title-length eol title-length $1

# 15. output line numbering (not implemented: nm nn)

# not really right because last three arguments can be non-numeric
req nm parse-num u parse-num u parse-num u parse-num u eol
req nn parse-num u eol

# 16. conditional acceptance of input

req if parse-condition n eol
req ie parse-condition y eol
req el process-condition eol

# 17. environment switching

req ev parse-num x eol environment $1

# 18. insertions from the standard input (not implemented: rd)

req rd eol
req ex eol end-input

# 19. input/output file switching (not implemented: pi)

req so parse-filename eol push-file $1
req nx parse-filename eol switch-file $1
req pi eol

# 20. miscellaneous (not implemented: mc pm fl)

req mc parse-char parse-num m eol
req tm parse-string-value n eol echo $1
req ab parse-string-value n eol abort $1
req ig parse-name eol ignore $1
req pm parse-char eol
req fl eol

####
# special fake debugging commands
# (uncomment to allow them)

# req db parse-num x eol debug-flag $1
# req dp parse-name eol dump-macro $1

# General setup stuff

# special characters - define in immediate mode

imm special-char em @em-dash
imm special-char hy @hyphen
imm special-char bu @bullet
imm special-char sq @square
imm special-char ru @rule
imm special-char 14 @one-fourth
imm special-char 12 @one-half
imm special-char 34 @three-fourths
imm special-char fi @ligature-fi
imm special-char fl @ligature-fl
imm special-char ff @ligature-ff
imm special-char Fi @ligature-ffi
imm special-char Fl @ligature-ffl
imm special-char de @degree
imm special-char dg @dagger
imm special-char fm @footmark
imm special-char ct @cent
imm special-char rg @registered
imm special-char co @copyright

imm special-char pl @math-plus
imm special-char mi @math-minus
imm special-char eq @math-equals
imm special-char ** @math-star
imm special-char sc @section
imm special-char aa @acute-accent
imm special-char ga @grave-accent
imm special-char ul @underrule
imm special-char sl @slash

imm special-char *a @alpha
imm special-char *b @beta
imm special-char *g @gamma
imm special-char *d @delta
imm special-char *e @epsilon
imm special-char *z @zeta
imm special-char *y @eta
imm special-char *h @theta
imm special-char *i @iota
imm special-char *k @kappa
imm special-char *l @lambda
imm special-char *m @mu
imm special-char *n @nu
imm special-char *c @xi
imm special-char *o @omicron
imm special-char *p @pi
imm special-char *r @rho
imm special-char *s @sigma
imm special-char ts @terminal-sigma
imm special-char *t @tau
imm special-char *u @upsilon
imm special-char *f @phi
imm special-char *x @chi
imm special-char *q @psi
imm special-char *w @omega

imm special-char *A @Alpha
imm special-char *B @Beta
imm special-char *G @Gamma
imm special-char *D @Delta
imm special-char *E @Epsilon
imm special-char *Z @Zeta
imm special-char *Y @Eta
imm special-char *H @Theta
imm special-char *I @Iota
imm special-char *K @Kappa
imm special-char *L @Lambda
imm special-char *M @Mu
imm special-char *N @Nu
imm special-char *C @Xi
imm special-char *O @Omicron
imm special-char *P @Pi
imm special-char *R @Rho
imm special-char *S @Sigma
imm special-char *T @Tau
imm special-char *U @Upsilon
imm special-char *F @Phi
imm special-char *X @Chi
imm special-char *Q @Psi
imm special-char *W @Omega

imm special-char sr @square-root
imm special-char rn @root-extender
imm special-char >= @greater-equal
imm special-char <= @less-equal
imm special-char == @identically-equal
imm special-char ~= @approximately-equal
imm special-char ap @approximates
imm special-char != @not-equal
imm special-char -> @right-arrow
imm special-char <- @left-arrow
imm special-char ua @up-arrow
imm special-char da @down-arrow
imm special-char mu @multiply
imm special-char di @divide
imm special-char +- @plus-minus
imm special-char cu @cup
imm special-char ca @cap
imm special-char sb @subset
imm special-char sp @superset
imm special-char ib @improper-subset
imm special-char ip @improper-superset
imm special-char if @infinity
imm special-char pd @partial-derivative
imm special-char gr @gradient
imm special-char no @not
imm special-char is @integral
imm special-char pt @proportional
imm special-char es @empty-set
imm special-char mo @member-of
imm special-char br @box-vertical-rule
imm special-char dd @double-dagger
imm special-char rh @right-hand
imm special-char lh @left-hand
imm special-char bs @bell-system-logo
imm special-char or @or
imm special-char ci @circle
imm special-char lt @left-top-bracket
imm special-char lb @left-bottom-bracket
imm special-char rt @right-top-bracket
imm special-char rb @right-bottom-bracket
imm special-char lk @left-center-bracket
imm special-char rk @right-center-bracket
imm special-char bv @bold-vertical
imm special-char lf @left-floor-bracket
imm special-char rf @right-floor-bracket
imm special-char lc @left-ceiling-bracket
imm special-char rc @right-ceiling-bracket

# initial page layout

imm page-length 11i
imm offset 1i
imm line-length 6.5i
imm indent 0
imm temp-indent 0
imm title-length 6.5i
imm fill
imm adjust b
imm point-size 10
imm spacing 12p
imm line-spacing 1
imm font R
