source: trunk/athena/etc/track/input.l @ 1471

Revision 1471, 1.7 KB checked in by don, 36 years ago (diff)
bellcore copyright.
Line 
1#include "bellcore-copyright.h"
2#include "mit-copyright.h"
3%%
4
5GLOBAL          {
6                        strncat(linebuf,yytext,yyleng);
7                        return(GEXCEPT);
8                }
9"->"            {
10                        strncat(linebuf,yytext,yyleng);
11                        return(ARROW);
12                }
13\\[\t ]*#[\t\40-\176]*\n       
14                {
15                        strcat(linebuf,"\n");
16                        return(BACKNEW);
17                }
18#[\t\40-\176]*$ ;
19[ \t]+          {
20                        strncat(linebuf,yytext,yyleng);
21                        return(WHITESPACE);
22                }
23[\42\44-\71\73-\133\135-\176]+  { /* everything except # : ! and \  */
24                        strncat(linebuf,yytext,yyleng);
25                        for ( wordp = yytext;
26                             *wordp == '/' && wordp[1];
27                              wordp++);
28                        strcpy(wordbuf, wordp);
29                        return(WORD);
30                }
31":"             {
32                        strncat(linebuf,yytext,yyleng);
33                        return(COLON);
34                }
35"!"             {
36                        strncat(linebuf,yytext,yyleng);
37                        return(BANG);
38                }
39"\\"            {
40                        strncat(linebuf,yytext,yyleng);
41                        return(BACKSLASH);
42                }
43"\n"            {
44                        strncat(linebuf,yytext,yyleng);
45                        return(NEWLINE);
46                }
47"\\\n"          {
48                        strcat(linebuf,"\n");
49                        return(BACKNEW);
50                }
51"\177"          {
52                        strcat(linebuf,"\n");
53                        return(NEWLINE);
54                }
55%%
56#undef input
57/* this version of input() is identical to yylex' original,
58 * except for the expression "endchar^='\177'", which is
59 * returned at end-of-file, and which is 0 in the original version.
60 * this expression will return '\177' on the 1st detection of EOF,
61 * and 0 (as usually happens at EOF) at the next invocation of input().
62 * our version allows yylex() to tokenize EOF, and yyparse() to parse it,
63 * so that an entry's command-field can optionally end without a newline.
64 * track supports this possibility, because emacs doesn't automatically
65 * terminate a file's last line with a newline.
66 */
67static unsigned char endchar = '\0';
68# define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?\
69(yylineno++,yytchar):yytchar)==EOF?(endchar^='\177'):yytchar)
Note: See TracBrowser for help on using the repository browser.