1 /* $Id: LLlex.c,v 1.6 1994/06/24 10:42:02 ceriel Exp $ */
3 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4 * See the copyright notice in the ACK home directory, in the file "Copyright".
8 * Very simple lexical analyzer.
9 * Also contains LLmessage().
17 struct token dot; /* current token */
18 static struct token aside; /* to put currrent token aside, when a token
21 int newline, lineno; /* To keep track of linenumbers */
22 extern FILE *input; /* file descriptor of machine table */
27 if (aside.t_tokno) { /* A token was pushed aside, return it now */
32 if (newline) { /* delayed increment of lineno, needed to give
33 * correct line numbers in error messages
39 while (c == '/') { /* Could be a comment */
40 if ((c = getc(input)) == '*') {
41 /* Yes, it is a comment */
47 if (c == '\n') lineno++;
49 } while (c != '*' && c != EOF);
50 if (c != EOF) c = getc(input);
51 } while (c != '/' && c != EOF);
55 error("Unterminated comment");
69 if (isupper(c) || islower(c) || c == '_') {
79 dot.t_tokno = LINE_TERMINATOR;
80 return LINE_TERMINATOR;
82 dot.t_tokno = OPERAND_SEPARATOR;
83 return OPERAND_SEPARATOR;
84 case instruction_sep :
85 dot.t_tokno = INSTRUCTION_SEPARATOR;
86 return INSTRUCTION_SEPARATOR;
90 dot.t_tokno = PATTERN_SEPARATOR;
91 return PATTERN_SEPARATOR;
97 dot.t_tokno = OPEN_BRACKET;
100 dot.t_tokno = CLOSE_BRACKET;
101 return CLOSE_BRACKET;
113 /* Let the C-compiler find out what is illegal! */
120 static int savlineno;
122 if (savlineno != lineno) {
123 /* Only an error message if on another line number */
125 error("Syntax error");
128 /* "d" is the token to be inserted.
129 * This is the place to put the current token aside and
130 * give the inserted token an attribute ... but who cares