Pristine Ack-5.5
[Ack-5.5.git] / util / opt / scan.l
1 %{
2 #ifndef NORCSID
3 static char rcsid2[] = "$Id: scan.l,v 2.6 1994/06/24 10:40:58 ceriel Exp $";
4 #endif
5
6 /*
7  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
8  * See the copyright notice in the ACK home directory, in the file "Copyright".
9  *
10  * Author: Hans van Staveren
11  */
12
13 extern long atol();
14 %}
15 %%
16 \"[^"]*\"       { strncpy(patid,yytext,sizeof(patid)); return(STRING); }
17 notreg          return(NOTREG);
18 sfit            return(SFIT);
19 ufit            return(UFIT);
20 rotate          return(ROTATE);
21 p               return(PSIZE);
22 w               return(WSIZE);
23 defined         return(DEFINED);
24 samesign        return(SAMESIGN);
25 rom             return(ROM);
26 [a-zA-Z]{3}     {
27                 int m;
28                 m = mlookup(yytext);
29                 if (m==0) {
30                         yyless(1);
31                         return yytext[0];
32                 } else {
33                         yylval.y_int = m;
34                         return(MNEM);
35                 }
36                 }
37 "&&"            return(AND2);
38 "||"            return(OR2);
39 "&"             return(AND1);
40 "|"             return(OR1);
41 "^"             return(XOR1);
42 "+"             return(ARPLUS);
43 "-"             return(ARMINUS);
44 "*"             return(ARTIMES);
45 "/"             return(ARDIVIDE);
46 "%"             return(ARMOD);
47 "=="            return(CMPEQ);
48 "!="            return(CMPNE);
49 "<"             return(CMPLT);
50 "<="            return(CMPLE);
51 ">"             return(CMPGT);
52 ">="            return(CMPGE);
53 "!"             return(NOT);
54 "~"             return(COMP);
55 "<<"            return(LSHIFT);
56 ">>"            return(RSHIFT);
57 [0-9]+          { long l= atol(yytext);
58                   if (l>32767) yyerror("Number too big");
59                   yylval.y_int= (int) l;
60                   return(NUMBER);
61                 }
62 [ \t]           ;
63 .               return(yytext[0]);
64 \n              { lino++; return(yytext[0]); }
65 :[ \t]*\n[ \t]+ { lino++; return(':'); }
66 ^"# "[0-9]+.*\n { lino=atoi(yytext+2); }
67 ^\#.*\n         { lino++; }