iris

small scheme interpreter
git clone git://git.2f30.org/iris.git
Log | Files | Refs | LICENSE

commit 6f2de90fbf55c527f3ffbd434db838ff888f6f78
parent 4569add3a27a58457e0fb0379932a98868ae9fe8
Author: sin <sin@2f30.org>
Date:   Tue May 13 16:23:20 +0100

Rename "State_" to S

Diffstat:
lexer.c | 100++++++++++++++++++++++++++++++++++++++++----------------------------------------
1 file changed, 50 insertions(+), 50 deletions(-)
diff --git a/lexer.c b/lexer.c @@ -6,22 +6,22 @@ #include "lexer.h" enum state { - State_Se, - State_Identifier, - State_Probable_Boolean, - State_Boolean, - State_Number, - State_Signed_Number, - State_Probable_Character, - State_Character, - State_Probable_String, - State_String, - State_Lparen, - State_Rparen, - State_Quote, - State_Dot, - State_Comment, - State_Illegal_Input, + SSe, + SIdentifier, + SProbable_Boolean, + SBoolean, + SNumber, + SSigned_Number, + SProbable_Character, + SCharacter, + SProbable_String, + SString, + SLparen, + SRparen, + SQuote, + SDot, + SComment, + SIllegal_Input, }; #define MAXTOKSIZE 256 @@ -45,38 +45,38 @@ gettok(FILE *in) int c; again: - state = State_Se; + state = SSe; s = e = buf; while ((c = getc(in)) != EOF && e < &buf[MAXTOKSIZE]) { *e = c; switch (state) { - case State_Se: + case SSe: if (*e == ' ' || *e == '\t' || *e == '\n') goto again; if (isalpha(*e) != 0) - state = State_Identifier; + state = SIdentifier; else if (*e == '#') - state = State_Probable_Boolean; + state = SProbable_Boolean; else if (isdigit(*e) != 0) - state = State_Number; + state = SNumber; else if (*e == '-' || *e == '+') - state = State_Signed_Number; + state = SSigned_Number; else if (*e == '"') - state = State_Probable_String; + state = SProbable_String; else if (*e == '(') - state = State_Lparen; + state = SLparen; else if (*e == ')') - state = State_Rparen; + state = SRparen; else if (*e == '\'') - state = State_Quote; + state = SQuote; else if (*e == '.') - state = State_Dot; + state = SDot; else if (*e == ';') - state = State_Comment; + state = SComment; else - state = State_Illegal_Input; + state = SIllegal_Input; break; - case State_Identifier: + case SIdentifier: if (delim(*e) != 0) { tok.type = TIdentifier; tok.s = s; @@ -91,11 +91,11 @@ again: return tok; } break; - case State_Probable_Boolean: + case SProbable_Boolean: if (*e == 'f' || *e == 't') - state = State_Boolean; + state = SBoolean; else if (*e == '\\') - state = State_Probable_Character; + state = SProbable_Character; else { tok.type = TError; tok.s = "not a boolean or a character"; @@ -103,7 +103,7 @@ again: return tok; } break; - case State_Boolean: + case SBoolean: if (delim(*e) != 0) { tok.type = TBoolean; tok.s = s; @@ -115,7 +115,7 @@ again: tok.s = "missing delimiter after boolean"; tok.e = NULL; return tok; - case State_Number: + case SNumber: if (delim(*e) != 0) { tok.type = TNumber; tok.s = s; @@ -130,18 +130,18 @@ again: return tok; } break; - case State_Signed_Number: + case SSigned_Number: if (isdigit(*e) == 0) { tok.type = TError; tok.s = "not a number"; tok.e = NULL; return tok; } - state = State_Number; + state = SNumber; break; - case State_Probable_Character: + case SProbable_Character: if (isalpha(*e) != 0) { - state = State_Character; + state = SCharacter; } else { tok.type = TError; tok.s = "expected character constant"; @@ -149,7 +149,7 @@ again: return tok; } break; - case State_Character: + case SCharacter: if (delim(*e) != 0) { tok.type = TCharacter; tok.s = s; @@ -161,45 +161,45 @@ again: tok.s = "missing delimiter after character constant"; tok.e = NULL; return tok; - case State_Probable_String: + case SProbable_String: if (*e == '"') - state = State_String; + state = SString; break; - case State_String: + case SString: tok.type = TString; tok.s = s; tok.e = e; ungetc(*e, in); return tok; - case State_Lparen: + case SLparen: tok.type = TLparen; tok.s = s; tok.e = e; ungetc(*e, in); return tok; - case State_Rparen: + case SRparen: tok.type = TRparen; tok.s = s; tok.e = e; ungetc(*e, in); return tok; - case State_Quote: + case SQuote: tok.type = TQuote; tok.s = s; tok.e = e; ungetc(*e, in); return tok; - case State_Dot: + case SDot: tok.type = TDot; tok.s = s; tok.e = e; ungetc(*e, in); return tok; - case State_Comment: + case SComment: if (*e == '\n') goto again; break; - case State_Illegal_Input: + case SIllegal_Input: tok.type = TError; tok.s = "illegal input"; tok.e = NULL; @@ -218,7 +218,7 @@ again: tok.e = NULL; return tok; } - if (state != State_Se) { + if (state != SSe) { tok.type = TError; tok.s = "unexpected EOF encountered"; tok.e = NULL;