src/javacodegen.c

changeset 46
534a4ef4143d
parent 45
1f3835182aeb
child 47
c39ecbbca7c0
equal deleted inserted replaced
45:1f3835182aeb 46:534a4ef4143d
39 "transient", "catch", "extends", "int", "short", "try", "char", "final", 39 "transient", "catch", "extends", "int", "short", "try", "char", "final",
40 "interface", "static", "void", "class", "finally", "long", "strictfp", 40 "interface", "static", "void", "class", "finally", "long", "strictfp",
41 "volatile", "const", "float", "native", "super", "while", NULL 41 "volatile", "const", "float", "native", "super", "while", NULL
42 }; 42 };
43 43
44 int check_jtype(char *word, size_t len) {
45 return isupper(word[0]);
46 }
47
48 int check_jdirective(char *word) {
49 return word[0] == '@';
50 }
51
52 #define memcpy_const(darr,doff,str) memcpy(&(darr[doff]), str, sizeof(str)-1); \ 44 #define memcpy_const(darr,doff,str) memcpy(&(darr[doff]), str, sizeof(str)-1); \
53 dp += sizeof(str)-1 45 dp += sizeof(str)-1
54 46
55 void jparseline(char *src, UcxBuffer *destbuf, highlighter_t *hltr) { 47 void jparseline(char *src, UcxBuffer *destbuf, HighlighterData *hltr) {
56 /* TODO: workaround for using old code with UcxBuffer */ 48 /* TODO: workaround for using old code with UcxBuffer */
57 char *dest = destbuf->space + destbuf->pos; 49 char *dest = destbuf->space + destbuf->pos;
58 50
59 memset(hltr->word, 0, WORDBUF_SIZE); 51 memset(hltr->word, 0, WORDBUF_SIZE);
60 size_t wp = 0, sp = (size_t)-1, dp = 0; 52 size_t wp = 0, sp = (size_t)-1, dp = 0;
117 dp = writeescapedchar(dest, dp, c); 109 dp = writeescapedchar(dest, dp, c);
118 } else if (!iswordcharacter(c)) { 110 } else if (!iswordcharacter(c)) {
119 /* interpret word int_t */ 111 /* interpret word int_t */
120 if (wp > 0 && wp < WORDBUF_SIZE) { 112 if (wp > 0 && wp < WORDBUF_SIZE) {
121 int closespan = 1; 113 int closespan = 1;
122 if (check_keyword(hltr->word, hltr->keywords)) { 114 if (check_keyword(hltr->word, jkeywords)) {
123 memcpy_const(dest, dp, 115 memcpy_const(dest, dp,
124 "<span class=\"c2html-keyword\">"); 116 "<span class=\"c2html-keyword\">");
125 } else if (hltr->istype(hltr->word, wp)) { 117 } else if (isupper(hltr->word[0])) {
126 memcpy_const(dest, dp, 118 memcpy_const(dest, dp,
127 "<span class=\"c2html-type\">"); 119 "<span class=\"c2html-type\">");
128 } else if (hltr->isdirective(hltr->word)) { 120 } else if (hltr->word[0] == '@') {
129 memcpy_const(dest, dp, 121 memcpy_const(dest, dp,
130 "<span class=\"c2html-directive\">"); 122 "<span class=\"c2html-directive\">");
131 } else if (check_capsonly(hltr->word, wp)) { 123 } else if (check_capsonly(hltr->word, wp)) {
132 memcpy_const(dest, dp, 124 memcpy_const(dest, dp,
133 "<span class=\"c2html-macroconst\">"); 125 "<span class=\"c2html-macroconst\">");

mercurial