1 #include "lexer.ih" 2 3 /* 4 Return the next token The matched text is in lp->d_text 5 Once d_lastchar is EOF it remains EOF until reset by lexer_end_eval() 6 7 lexer_push_file pushes a filename and sets a new cwd 8 l_pop reverts back to the previous path at EOR or at a file switch 9 */ 10 l_lex(register Lexer * lp)11LEXER_TOKEN l_lex(register Lexer *lp) 12 { 13 l_nextchar(lp); /* determine the next char */ 14 15 switch (lp->d_lastchar) 16 { 17 case EOF: 18 return TOKEN_EOF; 19 20 case EOR: 21 return l_pop(lp) == SUCCESS ? TOKEN_EOR : TOKEN_EOF; 22 23 case ' ': 24 case '\t': 25 return l_append(lp, TOKEN_SPACE); 26 27 case '(': 28 return l_append(lp, TOKEN_OPENPAR); 29 30 case ')': 31 return l_append(lp, TOKEN_CLOSEPAR); 32 33 case '\n': 34 return l_append(lp, TOKEN_NEWLINE); 35 36 case '+': 37 return l_append(lp, TOKEN_PLUS); 38 39 default: 40 return l_compound(lp); 41 } 42 } 43