11 return !strchr("\n \t#;&|^$=`'{}()<>", c) && c!=EOF;
19 * return 'a'<=c && c<='z' || 'A'<=c && c<='Z' || '0'<=c && c<='9'
20 * || c=='_' || c=='*';
22 return c>' ' && !strchr("!\"#$%&'()+,-./:;<=>?@[\\]^`{|}~", c);
29 * Look ahead in the input stream
40 * Consume the lookahead character.
52 * read a character from the input stream
59 static int peekc = EOF;
69 c = rchr(runq->cmdfd);
70 if(!inquote && c=='\\'){
71 c = rchr(runq->cmdfd);
72 if(c=='\n' && !incomm){ /* don't continue a comment */
81 doprompt = doprompt || c=='\n' || c==EOF;
84 else if(flag['V'] || ndot>=2 && flag['v']) pchr(err, c);
95 prompt = vlook("prompt");
96 if(prompt->val && prompt->val->next)
97 promptstr = prompt->val->next->word;
111 /* Why did this used to be if(!inquote && c=='#') ?? */
116 if(c=='\n' || c==EOF) {
123 if(c==' ' || c=='\t')
153 addtok(char *p, int val)
159 yyerror("token buffer too short");
167 addutf(char *p, int c)
170 if(twobyte(c)) /* 2-byte escape */
171 return addtok(p, advance());
172 if(threebyte(c)){ /* 3-byte escape */
173 p = addtok(p, advance());
174 return addtok(p, advance());
178 int lastdol; /* was the last token read '$' or '$#' or '"'? */
179 int lastword; /* was the last token read a word or compound word terminator? */
189 * Embarassing sneakiness: if the last token read was a quoted or unquoted
190 * WORD then we alter the meaning of what follows. If the next character
191 * is `(', we return SUB (a subscript paren) and consume the `('. Otherwise,
192 * if the next character is the first character of a simple or compound word,
193 * we insert a `^' before it.
199 strcpy(tok, "( [SUB]");
202 if(wordchr(d) || d=='\'' || d=='`' || d=='$' || d=='"'){
209 switch(c = advance()){
246 * funny redirection tokens:
247 * redir: arrow | arrow '[' fd ']'
248 * arrow: '<' | '<<' | '>' | '>>' | '|'
249 * fd: digit | digit '=' | digit '=' digit
250 * digit: '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'
251 * some possibilities are nonsensical and get a message.
267 else t->rtype = WRITE;
275 } else if (nextis('>')){
278 } else t->rtype = READ;
289 yyerror(t->type==PIPE?"pipe syntax"
290 :"redirection syntax");
295 t->fd0 = t->fd0*10+c-'0';
298 }while('0'<=c && c<='9');
304 if('0'<=c && c<='9'){
309 t->fd0 = t->fd0*10+c-'0';
312 }while('0'<=c && c<='9');
321 || t->type==DUP && (t->rtype==HERE || t->rtype==APPEND))
347 t = token(tok, WORD);
359 /* next line should have (char)c==GLOB, but ken's compiler is broken */
360 if(c=='*' || c=='[' || c=='?' || c==(unsigned char)GLOB)
364 if(lastdol?!idchr(c):!wordchr(c)) break;