Skip to content

Commit 2550a24

Browse files
committed
fix build erros
1 parent ccf2c01 commit 2550a24

3 files changed

Lines changed: 48 additions & 9 deletions

File tree

src/compiler/lexer/scanner.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ static PxTokenType identifierType(Scanner *scanner) {
169169
if (scanner->current - scanner->start > 1) {
170170
switch (scanner->start[1]) {
171171
case 'b': return checkKeyword(scanner, 2, 6, "stract", TOKEN_ABSTRACT);
172+
case 'n': return checkKeyword(scanner, 2, 1, "d", TOKEN_AND);
172173
case 's':
173174
if (scanner->current - scanner->start == 2) return TOKEN_AS;
174175
return checkKeyword(scanner, 2, 3, "ync", TOKEN_ASYNC);
@@ -371,6 +372,7 @@ static PxTokenType identifierType(Scanner *scanner) {
371372
}
372373
}
373374
break;
375+
case 'd': return checkKeyword(scanner, 2, 6, "entity", TOKEN_IDENTITY);
374376
default: return checkKeyword(scanner, 2, 0, "", TOKEN_IN);
375377
}
376378
}
@@ -434,10 +436,12 @@ static PxTokenType identifierType(Scanner *scanner) {
434436
case 'a': return checkKeyword(scanner, 2, 4, "tive", TOKEN_NATIVE);
435437
case 'e': return checkKeyword(scanner, 2, 1, "w", TOKEN_NEW);
436438
case 'o': return checkKeyword(scanner, 2, 2, "de", TOKEN_NODE);
439+
case 'u': return checkKeyword(scanner, 2, 2, "ll", TOKEN_NULL);
437440
}
438441
}
439442
break;
440443
case 'N': return checkKeyword(scanner, 1, 2, "av", TOKEN_UI_NAV);
444+
case 'o': return checkKeyword(scanner, 1, 1, "r", TOKEN_OR);
441445
case 'O': return checkKeyword(scanner, 1, 5, "ption", TOKEN_UI_OPTION);
442446
case 'M': return checkKeyword(scanner, 1, 3, "ain", TOKEN_UI_MAIN);
443447
case 'p':
@@ -471,6 +475,21 @@ static PxTokenType identifierType(Scanner *scanner) {
471475
break;
472476
}
473477
}
478+
}
479+
break;
480+
case 'q':
481+
if (scanner->current - scanner->start > 1) {
482+
switch (scanner->start[1]) {
483+
case 'u':
484+
if (scanner->current - scanner->start > 2) {
485+
switch (scanner->start[2]) {
486+
case 'a': return checkKeyword(scanner, 3, 4, "ntum", TOKEN_QUANTUM);
487+
case 'b': return checkKeyword(scanner, 3, 2, "it", TOKEN_QUBIT);
488+
}
489+
}
490+
break;
491+
}
492+
}
474493
break;
475494
case 'r':
476495
if (scanner->current - scanner->start > 1) {
@@ -493,6 +512,7 @@ static PxTokenType identifierType(Scanner *scanner) {
493512
}
494513
break;
495514
case 'o': return checkKeyword(scanner, 2, 6, "llback", TOKEN_ROLLBACK);
515+
case 'e': return checkKeyword(scanner, 2, 5, "plica", TOKEN_REPLICA);
496516
}
497517
}
498518
break;
@@ -515,6 +535,7 @@ static PxTokenType identifierType(Scanner *scanner) {
515535
return checkKeyword(scanner, 2, 3, "per", TOKEN_SUPER);
516536
}
517537
break;
538+
case 'y': return checkKeyword(scanner, 2, 2, "nc", TOKEN_SYNC);
518539
case 'w': return checkKeyword(scanner, 2, 4, "itch", TOKEN_SWITCH);
519540
}
520541
}
@@ -539,6 +560,7 @@ static PxTokenType identifierType(Scanner *scanner) {
539560
if (scanner->start[2] == 'n') return checkKeyword(scanner, 3, 3, "sor", TOKEN_TENSOR);
540561
}
541562
break;
563+
case 'a': return checkKeyword(scanner, 2, 5, "inted", TOKEN_TAINTED);
542564
case 'h':
543565
if (scanner->current - scanner->start > 2) {
544566
switch (scanner->start[2]) {

src/compiler/parser/parser.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ static Expr *ternary(Parser *p) {
981981
static Expr *orExpr(Parser *p) {
982982
Expr *expr = andExpr(p);
983983

984-
while (match(p, 1, TOKEN_PIPE_PIPE)) {
984+
while (match(p, 2, TOKEN_PIPE_PIPE, TOKEN_OR)) {
985985
Token op = previous(p);
986986
char *opStr = tokenToString(op);
987987
Expr *right = andExpr(p);
@@ -995,7 +995,7 @@ static Expr *orExpr(Parser *p) {
995995
static Expr *andExpr(Parser *p) {
996996
Expr *expr = bitwiseOr(p);
997997

998-
while (match(p, 1, TOKEN_AMPERSAND_AMPERSAND)) {
998+
while (match(p, 2, TOKEN_AMPERSAND_AMPERSAND, TOKEN_AND)) {
999999
Token op = previous(p);
10001000
char *opStr = tokenToString(op);
10011001
Expr *right = bitwiseOr(p);

src/compiler/transpiler_ui.c

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,16 @@ static void transpileStmt(Stmt *stmt, FILE *html, FILE *js, int indent) {
199199
const char *rawKey = (props->items[i].key && props->items[i].key->type == EXPR_VARIABLE)
200200
? props->items[i].key->as.variable.name : NULL;
201201
const char *mappedKey = rawKey ? mapPropName(rawKey) : NULL;
202+
bool isVariableValue = (props->items[i].value && props->items[i].value->type == EXPR_VARIABLE);
202203

203204
fprintf(html, " ");
204205
if (mappedKey) {
205-
fprintf(html, "%s", mappedKey);
206+
// Reactive prefix for Alpine
207+
if (isVariableValue && (strcmp(mappedKey, "class") != 0)) {
208+
fprintf(html, ":%s", mappedKey);
209+
} else {
210+
fprintf(html, "%s", mappedKey);
211+
}
206212
} else {
207213
transpileExpr(props->items[i].key, html);
208214
}
@@ -249,6 +255,22 @@ static void transpileStmt(Stmt *stmt, FILE *html, FILE *js, int indent) {
249255
fprintf(js, ";\n");
250256
break;
251257

258+
case STMT_EXPRESSION:
259+
// Handle text content or JS expressions
260+
if (html) {
261+
if (stmt->as.expression.expression->type == EXPR_VARIABLE) {
262+
// Reactive text
263+
fprintf(html, "<span x-text=\"%s\"></span>", stmt->as.expression.expression->as.variable.name);
264+
} else {
265+
transpileExpr(stmt->as.expression.expression, html);
266+
}
267+
} else if (js) {
268+
printIndent(js, indent);
269+
transpileExpr(stmt->as.expression.expression, js);
270+
fprintf(js, ";\n");
271+
}
272+
break;
273+
252274
default:
253275
// Non-UI statements silently skipped in UI context
254276
break;
@@ -280,13 +302,8 @@ static void transpileExpr(Expr *expr, FILE *out) {
280302
break;
281303

282304
case EXPR_BINARY:
283-
// Handle string concat (+)
284305
transpileExpr(expr->as.binary.left, out);
285-
if (expr->as.binary.op == TOKEN_PLUS) {
286-
// no separator for style string concatenation
287-
} else {
288-
fprintf(out, " %c ", (char)expr->as.binary.op);
289-
}
306+
fprintf(out, " %s ", expr->as.binary.operator);
290307
transpileExpr(expr->as.binary.right, out);
291308
break;
292309

0 commit comments

Comments
 (0)