optabs.fun 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #import std
  2. #import nat
  3. #import pag
  4. #import lag
  5. #import ogl
  6. #import ops
  7. #import eto
  8. #import tbl
  9. #import fen
  10. #import pag
  11. #import pru
  12. # use this to regenerate the tables in Chapter 5 if any operators are added to the language
  13. # should work without modification after the compiler is rebuilt
  14. overb = ~&i&& ~&w/`.?(~&w/`|?('\verb-'--+ --'-','\verb|'--+ --'|'),'\verb.'--+ --'.')
  15. theoretical = (\/-=)~~~~ pru-default_rules
  16. actual = # should be the same as theoretical for valid arities
  17. ~&H\fen-parser(pru-default_rules,extra_tabular default_operators) ~&lr; "p". ruleset[
  18. inin: (~&rZ&& ~&l; ~&vthv)+ _token%dTwLLXMk+ "p"+ ~&iNC+ token$[lexeme: ~&]*+ <.'x'!,~&l,'y'!,~&r,'z'!>,
  19. prepost: (~&rZ&& ~&l; ~&vth)+ _token%dTwLLXMk+ "p"+ ~&iNC+ token$[lexeme: ~&]*+ <.~&l,'x'!,~&r>,
  20. prein: (~&rZ&& ~&l; ~&vth)+ _token%dTwLLXMk+ "p"+ ~&iNC+ token$[lexeme: ~&]*+ <.~&l,'x'!,~&r,'y'!>,
  21. inpost: (~&rZ&& ~&l; ~&vth)+ _token%dTwLLXMk+ "p"+ ~&iNC+ token$[lexeme: ~&]*+ <.'x'!,~&l,'y'!,~&r>]
  22. #output dot'tex' -+
  23. :/'\begin{tabular}{llllllllllllllllll}'+ --<'\end{tabular}'>,
  24. :/'\toprule'+ --<'\bottomrule'>,
  25. :^/~&h :/'\midrule'+ ~&t,
  26. * --'\\'+ mat`&+ * overb,
  27. ~&uF; ~&K7+ ^D(leql$^,~&); * ~&rS+ zipp0+-
  28. pec = ~&sS operator_classes extra_tabular default_operators
  29. #output-
  30. #output dot'tex' "ii". ~&H\pec %sLLMk; -+
  31. :/'\begin{tabular}{rllllllllllllllllll}'+ --<'\end{tabular}'>,
  32. :/'\toprule'+ --<'\bottomrule'>,
  33. ^|T(--<'\midrule'>+ ^lrNCT(~&y; :^\~&t :/`&+ ~&h,--'\\'+ ~&zy)+ * '\verb.'--+ --'.&',* --'\\'),
  34. ^/~&eS ~&iiK0; -+
  35. ^|T(overb,*= :/`&+ ~&i&& '$\bullet$'!)*,
  36. |=hll2rSXS&ll+ * ^/~&be (any "ii")+ %sWLMk+ ~&K0+-+-
  37. iip = ~inin theoretical
  38. ppp = ~prepost theoretical
  39. pip = ~prein theoretical
  40. ipp = ~inpost theoretical
  41. #output-
  42. #output dot'tex' label'atab'+ elongation'Operator arities and algebraic properties'+ table0
  43. atab =
  44. (
  45. <
  46. <'mnemonic'>^:<>,
  47. <'arity'>^: <<'prefix'>^:<>,<'infix'>^:<>,<'postfix'>^:<>,<'solo'>^:<>>,
  48. <'dyadicism'>^: <<'prefix'>^:<>,<'postfix'>^:<>,<'solo'>^:<>>>,
  49. ~&H\default_operators ~match.&Z*~; (dyadic:= ~dyadic|| mode&!)*; ~&K7+ * :^(~&h,~&t; * ~&i&& '$\bullet$'!)+ <.
  50. overb+ ~mnemonic,
  51. ~meanings.ogl-prefix,
  52. ~meanings.ogl-infix,
  53. ~meanings.ogl-postfix,
  54. ~meanings.ogl-solo,
  55. ~dyadic.ogl-prefix,
  56. ~dyadic.ogl-postfix,
  57. ~dyadic.ogl-solo>)