#STRUSCAN
 -- Structured scaner is very useful if your input is not from
 -- a textual representation but from some code generated by
 -- another program, that can output both text and special characters.

 -- You can create any RIGAL data simply by reading such code.
 -- You can also create such code from RIGAL.

 -- The special characters have code chr(21) .. chr(25).
 -- Reads "strusca1.inp" and prints it.
 -- Note chr(21) and chr(22) there 
 
 -- Reads "strusca2.inp" and prints it.
 -- Note chr(21) ... chr(25) there
 
 $T:=#CALL_PAS(35 'strusca1.inp'); 
 PRINT $T;
 
 $T:=#CALL_PAS(35 'strusca2.inp');
 PRINT $T;
 OPEN S 'strusca3.out';
 #emit_spec($T);
 CLOSE S;
 $K:=#CALL_PAS(35 'strusca3.out');
 PRINT $K;

 -- Not all text editors support editing of files with
 -- special characters. Usually it is posible to enter
 -- them (in PC) by holding the ALT-key and entering,e.g., 0 2 1
 -- in right, numeric keyboard.

##  
#emit_spec
 -- This rule creates code that can be read again by
 -- the structured scaner. 

 NULL / S <] #CHR(21) #CHR(22) / ;; -- 
 $LABEL::(.
 / IF $LABEL -> S<] #CHR(25); #emit_spec($LABEL); FI;
   S<] #CHR(21)/
  (* #emit_spec *)
   .)     / S <] #CHR(22);S<<; /
 ;;
 $LABEL :: <* $SEL :
 / IF $LABEL -> S<] #CHR(25); #emit_spec($LABEL);$LABEL:=NULL; FI;
   IF NOT $START-> S<] #CHR(23);$START:=T; FI;
   #emit_spec($SEL)
 / #emit_spec
  *>
  / S<] #CHR(24);S<< /
;;
 $ATOM / S <] ' ' $ATOM ' ' / 
##  


   
 
   




