tex1.rig 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. -- Now TEX scaner is available.
  2. -- T+ defines LaTeX lexical rules
  3. -- and value of new "tex_lexics" boolean variable
  4. -- @+ defines (additionaly to T+) .sty - file mode of LaTeX,
  5. -- when @ characters are allowed in command names
  6. -- .TEX file have to be with 'P-U-p-A-T+'
  7. -- .STY file have to be with 'P-U-p-A-T+@+'
  8. #E
  9. OPEN S 'S2.LST';
  10. $L:=#CALL_PAS(35 'sample.TEX' 'P-U-p-A-T+');
  11. PRINT $L;
  12. $L:= #CONV($L);
  13. PRINT $L;
  14. #STAT($L);
  15. #CALL_PAS(1);
  16. FORALL $E IN $L DO S<]@$E; IF NOT $E->S<<;S<<;FI;OD;
  17. ##
  18. #CONV
  19. (. (* ( ( '%' (* S'($$) *) NULL ) -- removes all comments
  20. ! ( $X!.:=' ' (* ' ' *) ) -- removes all spaces but one
  21. ! ( NULL (+ NULL +) / $X!.:=NULL / ) -- leave one NULL if many
  22. ! ( NULL / $X!. :=' '/) -- removes single NULLs,
  23. -- changing them to spaces
  24. ! $X!.:=$E
  25. )
  26. *)
  27. .)
  28. /RETURN $X/
  29. ##
  30. #STAT
  31. (. (* ( $IDENT!.:=#IDENT
  32. ! $KEYS!.:=#_KEYWORD
  33. ! $NULLS!.:=NULL
  34. ! $ATOMS!.:=$ANY
  35. )
  36. *)
  37. .)
  38. /
  39. PRINT (. IDENTIFIERS $IDENT .);
  40. PRINT (. KEYWORDs $KEYS .);
  41. PRINT (. NULLs $NULLS .);
  42. PRINT (. OTHER GOOD THINGS $ATOMS .);
  43. /
  44. ##