/* this is an example formatted token file for a pascal to test the
 * prettyprinting scanner generator. It was oiginally aimed to produce
 * TeX code to be formatted with the cwebmac package.
 */

%{
#define PSCAN_NAME pascan
#define PSCAN_INIT_NAME pascan_init
%}



%%

"<>"       MATH     { "$\\neq$" }         // not equal sign
"<="       MATH     { "$\\leq$" }          // less or equal
">="       MATH     { "$\\geq$" }          // greater or equal
":="       MATH     { "\\hbox{${}\\mathrel{:=}{}$}" }   // assignment
'([^']|'')*'    SIMP  { "\\.{" + ** + "}" }   // strings
"("        OPEN
")"        CLOSE    [int i;]
			{ [ in_table(yytext) ? create("it") :
			create("bf") ]  }
		    [ return(a[i\]); ]

"["        OPEN
"]"        CLOSE
"*"        MATH     { "$\\ast$" }
","        MATH     { ** + opt9 }
".."       MATH
"."        SIMP
":"        COLON
";"        SEMI
"="        MATH
"+"        MATH
"-"        MATH
"<"        MATH     { "$<$" }
">"        MATH     { "$>$" }
"/"        MATH
                 // this to allow underscores in identifiers:
"_"[a-zA-Z0-9]*    ID_TYPE    {"\\" + ** }

[0-9]+             SIMP
[0-9]*"."[0-9]+    SIMP

and        MATH     {"\\AND "}
array      ALPHA    {"\\&{array}"}
begin      BEG      {force + "\n" + "\\&{begin}" }
boolean    SIMP     {"\\&{boolean}"}
case       CASE     {force + "\\&{case}" + cancel }
const      INTRO    {force + backup + "\\&{const}"}
div        MATH     {" \\&{div} "}
do         OMEGA    {"\\&{do}"}
downto     MATH     {"\\&{downto}"}
else       ELSE     {"\\&{else}" }
end        END      {"\\&{end}" }
for        ALPHA    {"\\&{for}" }
function   PROC     {big_force + backup + "\\&{function} " }
if         ALPHA    {"\\&{if}" }
integer    SIMP     {"\\&{integer}"}
mod        MATH     {"\\&{mod}"}
not        MATH     {"\\neg "}
of         OMEGA    {"\\&{of} " + cancel }
or         MATH     {"\\V "}
procedure  PROC     {big_force + backup + "\\&{procedure} " }
program    PROC     {big_force + backup + "\\&{program} "}
readln     SIMP     {"\\&{readln}"}
real       SIMP     {"\\&{real}"}
record     RECORD   {"\\&{record}"}
repeat     BEG      {force + "\\&{repeat}" }
then       OMEGA    {"\\&{then}" }
to         MATH     {" \\&{to} "}
type       INTRO    {force + backup + "\\&{type}" }
until      UNTIL    {force + "\\&{until}" }
var        INTRO    {force + backup + "\\&{var} "  }
while      ALPHA    {force + "\\&{while}" }
with       ALPHA    {force + "\\&{with}"}
write      SIMP     {"\\&{write}"}
writeln    SIMP     {"\\&{writeln}"}


"{"[^}]*"}"    COMMENT    { "\\hbox{$\\{$\\.{" + ** + "}$\\}$}" }   // comments

[a-zA-Z][a-zA-Z0-9]*    ID_TYPE    // identifiers

[\t\ \n]          // eat up whitespace

.                 // eat up other non matching characters
