summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2007-10-11 22:38:46 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2007-10-11 22:38:46 +0800
commit556e233ad80f4c8230e512662be235d2cfb2c95b (patch)
tree6d68476bda34e2c945618fc747a68d4d30b32269 /src
parent[ARITH] Add assignment and intmax_t support (diff)
downloaddash-556e233ad80f4c8230e512662be235d2cfb2c95b.tar.gz
dash-556e233ad80f4c8230e512662be235d2cfb2c95b.zip
[ARITH] Size optimisations in arithmetic lexer
Use += instead of straight assignment for token value.
Diffstat (limited to 'src')
-rw-r--r--src/arith_yylex.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/src/arith_yylex.c b/src/arith_yylex.c
index 0f46990..2c15657 100644
--- a/src/arith_yylex.c
+++ b/src/arith_yylex.c
@@ -56,7 +56,8 @@ yylex()
 	const char *p;
 
 	for (;;) {
-		switch (*buf) {
+		value = *buf;
+		switch (value) {
 		case ' ':
 		case '\t':
 		case '\n':
@@ -137,7 +138,7 @@ yylex()
 			value = ARITH_VAR;
 			goto out;
 		case '=':
-			value = ARITH_ASS;
+			value += ARITH_ASS - '=';
 checkeq:
 			if (*++buf != '=')
 				goto out;
@@ -146,85 +147,84 @@ checkeq:
 		case '>':
 			switch (*++buf) {
 			case '=':
-				value = ARITH_GE;
+				value += ARITH_GE - '>';
 				break;
 			case '>':
-				value = ARITH_RSHIFT;
+				value += ARITH_RSHIFT - '>';
 				goto checkeq;
 			default:
-				value = ARITH_GT;
+				value += ARITH_GT - '>';
 				goto out;
 			}
 			break;
 		case '<':
 			switch (*++buf) {
 			case '=':
-				value = ARITH_LE;
+				value += ARITH_LE - '<';
 				break;
 			case '<':
-				value = ARITH_LSHIFT;
+				value += ARITH_LSHIFT - '<';
 				goto checkeq;
 			default:
-				value = ARITH_LT;
+				value += ARITH_LT - '<';
 				goto out;
 			}
 			break;
 		case '|':
 			if (*++buf != '|') {
-				value = ARITH_BOR;
+				value += ARITH_BOR - '|';
 				goto checkeq;
 			}
-			value = ARITH_OR;
+			value += ARITH_OR - '|';
 			break;
 		case '&':
 			if (*++buf != '&') {
-				value = ARITH_BAND;
+				value += ARITH_BAND - '&';
 				goto checkeq;
 			}
-			value = ARITH_AND;
+			value += ARITH_AND - '&';
 			break;
 		case '!':
 			if (*++buf != '=') {
-				value = ARITH_NOT;
+				value += ARITH_NOT - '!';
 				goto out;
 			}
-			value = ARITH_NE;
+			value += ARITH_NE - '!';
 			break;
 		case 0:
-			value = 0;
 			goto out;
 		case '(':
-			value = ARITH_LPAREN;
+			value += ARITH_LPAREN - '(';
 			break;
 		case ')':
-			value = ARITH_RPAREN;
+			value += ARITH_RPAREN - ')';
 			break;
 		case '*':
-			value = ARITH_MUL;
+			value += ARITH_MUL - '*';
 			goto checkeq;
 		case '/':
-			value = ARITH_DIV;
+			value += ARITH_DIV - '/';
 			goto checkeq;
 		case '%':
-			value = ARITH_REM;
+			value += ARITH_REM - '%';
 			goto checkeq;
 		case '+':
-			value = ARITH_ADD;
+			value += ARITH_ADD - '+';
 			goto checkeq;
 		case '-':
-			value = ARITH_SUB;
+			value += ARITH_SUB - '-';
 			goto checkeq;
 		case '~':
-			value = ARITH_BNOT;
+			value += ARITH_BNOT - '~';
 			break;
 		case '^':
-			value = ARITH_BXOR;
+			value += ARITH_BXOR - '^';
 			goto checkeq;
 		case '?':
-			value = ARITH_QMARK;
+			value += ARITH_QMARK - '?';
 			break;
 		case ':':
-			value = ARITH_COLON;
+			value += ARITH_COLON - ':';
 			break;
 		}
 		break;
ttps://github.com/neovim/neovim/pull/9633> is merged and appears in a release. 2019-02-18Use hi -o anchor in upJune McEnroe 2019-02-18Don't match nested parentheses in Tag for CJune McEnroe Fixes mistaken highlight of: pngWrite(file, (uint8_t []) { 0, 0, 0 }, 3); 2019-02-18Match whitespace between * [] {}June McEnroe 2019-02-18Fix function-like #define regexJune McEnroe A define like #define FOO (1) is not function-like. 2019-02-18Match Tag in RustJune McEnroe 2019-02-18Match sh functions as TagJune McEnroe 2019-02-18Match Sh and Ss as Tag in mdocJune McEnroe 2019-02-18Match statics and typedefs as TagJune McEnroe 2019-02-18Clean up htmlHeaderJune McEnroe 2019-02-18Remove hi line numberingJune McEnroe Tags are much better for referring to specific parts of a file and line numbering is better done by a post-processing tool such as cat -n or producing a two-column HTML <table>. 2019-02-18Add Tag class to hiJune McEnroe 2019-02-17Generate HTML with hi -n -f html -o anchorJune McEnroe Running hi twice to insert stuff between the head and the content is a bit of a hack but oh well. 2019-02-17Add hi -f html -o anchor for line number linksJune McEnroe 2019-02-17Simplify temp trap in upJune McEnroe 2019-02-17Add line numbers to hiJune McEnroe Renames previous -n option to -m to stay consistent with cat -n. Prefixing lines with line numbers affects where the first tab indent ends up relative to the text above it. Not sure if it's worth fixing somehow. 2019-02-17Always split spans after newlinesJune McEnroe Simplifies ANSI and IRC output code, and prepares for line numbered output. 2019-02-15Color format specifiers light cyan in vimJune McEnroe 2019-02-15Highlight Interp as yellowJune McEnroe 2019-02-15Highlight strings in sh command substitutionsJune McEnroe 2019-02-15Add nmap gpJune McEnroe 2019-02-14Avoid newline when copying URL to pasteboardJune McEnroe 2019-02-13Add forgotten "sixth" book of H2G2June McEnroe