#	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.

# output-control SHOULD NOT include \n at end.
# output-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-embolden 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
# since multiple names can be removed, call remove-names many times to allow
# up to 99 names.
req rm parse-names eol \
	remove-names n $1 $2 $3 $4 $5 $6 $7 $8 $9 \
	remove-names n $10 $11 $12 $13 $14 $15 $16 $17 $18 \
	remove-names n $19 $20 $21 $22 $23 $24 $25 $26 $27 \
	remove-names n $28 $29 $30 $31 $32 $33 $34 $35 $36 \
	remove-names n $37 $38 $39 $40 $41 $42 $43 $44 $45 \
	remove-names n $46 $47 $48 $49 $50 $51 $52 $53 $54 \
	remove-names n $55 $56 $57 $58 $59 $60 $61 $62 $63 \
	remove-names n $64 $65 $66 $67 $68 $69 $70 $71 $72 \
	remove-names n $73 $74 $75 $76 $77 $78 $79 $80 $81 \
	remove-names n $82 $83 $84 $85 $86 $87 $88 $89 $90 \
	remove-names n $91 $92 $93 $94 $95 $96 $97 $98 $99
req rn parse-name parse-name eol rename $1 $2
req di parse-name eol diversion-begin $1
req da parse-name eol diversion-append $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
# since multiple names can be removed, call remove-names many times to allow
# up to 99 names.
req rr parse-names eol \
	remove-names y $1 $2 $3 $4 $5 $6 $7 $8 $9 \
	remove-names y $10 $11 $12 $13 $14 $15 $16 $17 $18 \
	remove-names y $19 $20 $21 $22 $23 $24 $25 $26 $27 \
	remove-names y $28 $29 $30 $31 $32 $33 $34 $35 $36 \
	remove-names y $37 $38 $39 $40 $41 $42 $43 $44 $45 \
	remove-names y $46 $47 $48 $49 $50 $51 $52 $53 $54 \
	remove-names y $55 $56 $57 $58 $59 $60 $61 $62 $63 \
	remove-names y $64 $65 $66 $67 $68 $69 $70 $71 $72 \
	remove-names y $73 $74 $75 $76 $77 $78 $79 $80 $81 \
	remove-names y $82 $83 $84 $85 $86 $87 $88 $89 $90 \
	remove-names y $91 $92 $93 $94 $95 $96 $97 $98 $99

# 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 title $1 $2 $3
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-name 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

# --------------------------------------------------------------------------
# groff-like stuff.

req cp parse-num x eol set-compatibility $1
req mso parse-filename eol push-macro-file $1
req shift parse-num x eol shift-args $1
req do process-do eol
req als parse-name parse-name eol alias-macro $1 $2
req aln parse-name parse-name eol alias-register $1 $2

# At the moment, these special characters are just the ones that I've
# seen troffcvt complain about not knowing.  There are lots of others
# that I simply haven't bothered to define.

imm special-char lq @quotedblleft
imm special-char rq @quotedblright

# --------------------------------------------------------------------------
# debugging stuff.  Uncomment the ones you want, to turn them on.

# imm dump-bad-requests 1
# req dump_stack eol dump-input-stack
# req db parse-num x eol debug-flag $1
# req dp parse-name eol dump-macro $1

# --------------------------------------------------------------------------
# tblcvt support

# Mostly all these do is use output-control to write out controls that
# correspond to the input requests.  This means we trust tblcvt not to
# write out-of-order requests, and to write correct values for the request
# arguments.

# The action lists for T*cell*begin and T*cell*end do generate output other
# than a \table-xxx control because cell font, point size, and vertical
# spacing information are part of the cell formatting that needs to be seen
# by troffcvt.

# T*table*begin rows cols header-rows align expand box allbox doublebox
req T*table*begin \
	parse-num x parse-num x parse-num x \
	parse-char parse-char parse-char parse-char parse-char eol \
	output-control "table-begin $1 $2 $3 $4 $5 $6 $7 $8"
req T*table*end eol \
	output-control "table-end"
# T*column*info width sep equal
req T*column*info \
	parse-num n parse-num n parse-char eol \
	output-control "table-column-info $1 $2 $3"
req T*row*begin eol \
	output-control "table-row-begin"
req T*row*end eol \
	output-control "table-row-end"
# T*cell*info type hspan vspan vspantop border
req T*cell*info \
	parse-char parse-num x parse-num x \
	parse-char parse-num x eol \
	output-control "table-cell-info $1 $2 $3 $4 $5"
# T*cell*begin font ptsize vspace
# The font, ptsize, and vspace arguments are processed by troffcvt
# Save the current font, size, and spacing before changing them.
req T*cell*begin \
	parse-name parse-num x parse-num x eol \
	output-control "table-cell-begin" \
	push-string ".nr T*cell*ft \\n(.f\n.if !'$1'0' .ft $1\n" \
	push-string ".nr T*cell*ps \\n(.s\n.if !'$2'0' .ps $2\n" \
	push-string ".nr T*cell*vs \\n(.v\n.if !'$3'0' .vs $3\n"
# Restore initial font, point size, and vertical spacing
req T*cell*end eol \
	push-string ".ft \\n[T*cell*ft]\n" \
	push-string ".ps \\n[T*cell*ps]\n" \
	push-string ".vs \\n[T*cell*vs]u\n" \
	output-control "table-cell-end"
req T*row*line \
	parse-num x eol \
	output-control "table-row-line $1"
req T*cell*line \
	parse-num x eol \
	output-control "table-cell-line $1"
req T*spanned*cell eol \
	output-control "table-spanned-cell"
req T*empty*cell eol \
	output-control "table-empty-cell"

# General setup stuff

# special characters - define in immediate mode

imm special-char em @emdash
imm special-char hy @hyphen
imm special-char bu @bullet
imm special-char sq @square
imm special-char ru @ru
imm special-char 14 @onequarter
imm special-char 12 @onehalf
imm special-char 34 @threequarters
imm special-char fi @fi
imm special-char fl @fl
imm special-char ff @ff
imm special-char Fi @ffi
imm special-char Fl @ffl
imm special-char de @degree
imm special-char dg @dagger
# footmark
imm special-char fm @minute
imm special-char ct @cent
imm special-char rg @registered
imm special-char co @copyright

imm special-char pl @plusmath
imm special-char mi @minusmath
imm special-char eq @equalmath
imm special-char ** @asteriskmath
imm special-char sc @section
imm special-char aa @acute
imm special-char ga @grave
imm special-char .. @umlaut
imm special-char ul @ul
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 +h @theta1
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 @sigma1
imm special-char *t @tau
imm special-char *u @upsilon
imm special-char *f @phi
imm special-char +f @phi1
imm special-char *x @chi
imm special-char *q @psi
imm special-char *w @omega
imm special-char +p @omega1

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 @radical
imm special-char rn @radicalex
imm special-char >= @greaterequal
imm special-char <= @lessequal
imm special-char == @equivalence
imm special-char ~= @approxequal
imm special-char ap @similar
imm special-char != @notequal
imm special-char -> @arrowright
imm special-char <- @arrowleft
imm special-char ua @arrowup
imm special-char da @arrowdown
imm special-char mu @multiply
imm special-char di @divide
imm special-char +- @plusminus
imm special-char cu @union
imm special-char ca @intersection
imm special-char sb @propersubset
imm special-char sp @propersuperset
imm special-char ib @reflexsubset
imm special-char ip @reflexsuperset
imm special-char if @infinity
imm special-char pd @partialdiff
imm special-char gr @gradient
imm special-char no @logicalnot
imm special-char is @integral
imm special-char pt @proportional
imm special-char es @emptyset
imm special-char mo @element
imm special-char br @br
imm special-char dd @daggerdbl
imm special-char rh @handright
imm special-char lh @handleft
imm special-char bs @bell
imm special-char or @bar
imm special-char ci @circle
imm special-char bv @bv
imm special-char lt @bracelefttp
imm special-char lb @braceleftbt
imm special-char rt @bracerighttp
imm special-char rb @bracerightbt
imm special-char lk @braceleftmid
imm special-char rk @bracerightmid
imm special-char lf @bracketleftbt
imm special-char rf @bracketrightbt
imm special-char lc @bracketlefttp
imm special-char rc @bracketrighttp

imm special-char /o @oslash
imm special-char "'A" @Aacute
imm special-char "'E" @Eacute
imm special-char "'I" @Iacute
imm special-char "'O" @Oacute
imm special-char "'U" @Uacute
imm special-char "'Y" @Yacute
imm special-char "'a" @aacute
imm special-char "'e" @eacute
imm special-char "'i" @iacute
imm special-char "'o" @oacute
imm special-char "'u" @uacute
imm special-char "'y" @yacute
imm special-char "`A" @Agrave
imm special-char "`E" @Egrave
imm special-char "`I" @Igrave
imm special-char "`O" @Ograve
imm special-char "`U" @Ugrave
imm special-char "`a" @agrave
imm special-char "`e" @egrave
imm special-char "`i" @igrave
imm special-char "`o" @ograve
imm special-char "`u" @ugrave
imm special-char :a @adieresis
imm special-char :e @edieresis
imm special-char :i @idieresis
imm special-char :o @odieresis
imm special-char :u @udieresis
imm special-char :y @ydieresis
imm special-char :A @Adieresis
imm special-char :E @Edieresis
imm special-char :I @Idieresis
imm special-char :O @Odieresis
imm special-char :U @Udieresis
imm special-char :Y @Ydieresis
imm special-char ~n @ntilde

imm special-char "'C" @Cacute
imm special-char "'c" @cacute
imm special-char %0 @perthousand
imm special-char 'a"' @hungarumlaut
imm special-char ,C @Ccedilla
imm special-char ,c @ccedilla
imm special-char -+ @minusplus
imm special-char -D @Eth
imm special-char -h @hbar
imm special-char .i @dotlessi
imm special-char .j @dotlessj
imm special-char /L @Lslash
imm special-char /O @Oslash
imm special-char /_ @angle
imm special-char /l @lslash
imm special-char 3d @therefore
imm special-char << @muchless
imm special-char <> @arrowboth
imm special-char =~ @congruent
imm special-char >> @muchgreater
imm special-char AE @AE
imm special-char AN @logicaland
imm special-char Ah @aleph
imm special-char Bq @quotedblbase
imm special-char CL @club
imm special-char CR @carriagereturn
imm special-char Cs @currency
imm special-char DI @diamond
imm special-char Do @dollar
imm special-char Fc @guillemotright
imm special-char Fn @florin
imm special-char Fo @guillemotleft
imm special-char HE @heart
imm special-char IJ @IJ
imm special-char Im @Ifraktur
imm special-char OE @OE
imm special-char OK @checkmark
imm special-char OR @logicalor
imm special-char Of @ordfeminine
imm special-char Om @ordmasculine
imm special-char Po @sterling
imm special-char Re @Rfraktur
imm special-char S1 @onesuperior
imm special-char S2 @twosuperior
imm special-char S3 @threesuperior
imm special-char SP @spade
imm special-char Sd @eth
imm special-char TP @Thorn
imm special-char Tp @thorn
imm special-char Ye @yen
imm special-char ^A @Acircumflex
imm special-char ^E @Ecircumflex
imm special-char ^I @Icircumflex
imm special-char ^O @Ocircumflex
imm special-char ^U @Ucircumflex
imm special-char ^a @acircumflex
imm special-char ^e @ecircumflex
imm special-char ^i @icircumflex
imm special-char ^o @ocircumflex
imm special-char ^u @ucircumflex
imm special-char a- @macron
imm special-char a. @dotaccent
imm special-char a^ @circumflex
imm special-char ab @breve
imm special-char ac @cedilla
imm special-char ad @dieresis
imm special-char ae @ae
imm special-char ah @caron
imm special-char an @arrowhorizex
imm special-char ao @ring
imm special-char aq @quotesingle
imm special-char at @at
imm special-char a~ @tilde
imm special-char ba @bar
imm special-char bb @brokenbar
imm special-char bq @quotesinglbase
imm special-char c* @circlemultiply
imm special-char c+ @circleplus
imm special-char dA @arrowdbldown
imm special-char en @endash
imm special-char f/ @fraction
imm special-char fa @universal
imm special-char fc @guilsinglright
imm special-char fo @guilsinglleft
imm special-char hA @arrowdblboth
imm special-char ha @asciicircum
imm special-char ho @ogonek
imm special-char ij @ij
imm special-char lA @arrowdblleft
imm special-char lB @bracketleft
imm special-char lC @braceleft
imm special-char la @angleleft
imm special-char lz @lozenge
imm special-char md @dotmath
imm special-char nb @notsubset
imm special-char nc @notpropersuperset
imm special-char ne @notequivalence
imm special-char nm @notelement
imm special-char oA @Aring
imm special-char oa @aring
imm special-char oe @oe
imm special-char oq @quoteleft
imm special-char pp @perpendicular
imm special-char ps @paragraph
imm special-char r! @exclamdown
imm special-char r? @questiondown
imm special-char rA @arrowdblright
imm special-char rB @bracketright
imm special-char rC @braceright
imm special-char ra @angleright
imm special-char rs @backslash
imm special-char sd @second
imm special-char sh @numbersign
imm special-char ss @germandbls
imm special-char st @suchthat
imm special-char te @existential
imm special-char tf @therefore
imm special-char ti @asciitilde
imm special-char tm @trademark
imm special-char uA @arrowdblup
imm special-char vA @arrowdblvert
imm special-char vS @Scaron
imm special-char vZ @Zcaron
imm special-char va @arrowvertboth
imm special-char vs @scaron
imm special-char vz @zcaron
imm special-char wp @weierstrass
imm special-char ~A @Atilde
imm special-char ~N @Ntilde
imm special-char ~O @Otilde
imm special-char ~a @atilde
imm special-char ~o @otilde
imm special-char ~~ @approxequal

# 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
