瀏覽代碼

? expression

main
leo 4 年之前
父節點
當前提交
93ff7e031d
共有 1 個文件被更改,包括 5 次插入3 次删除
  1. +5
    -3
      lexer.c

+ 5
- 3
lexer.c 查看文件

@ -56,6 +56,7 @@ struct Node
char *stringValue; char *stringValue;
Node *children[2]; Node *children[2];
}; };
struct String { enum opcode type; char *stringValue; int len;}
}; };
@ -70,7 +71,8 @@ Node *mkNode(enum opcode type)
Node *mkString(char *value) Node *mkString(char *value)
{ {
Node *node= mkNode(STRING); Node *node= mkNode(STRING);
node->stringValue= value;
node->String.stringValue= value;
node->String.len=strlen(value);
return node; return node;
} }
@ -108,9 +110,9 @@ int execute(Node *node, Exploration *in)
{ {
switch (node->type) { switch (node->type) {
case STRING: { case STRING: {
for (int i=0; i < strlen(node->stringValue);i++)
for (int i=0; i < node->String.len);i++)
{ {
if (advance(in) != node->stringValue[i])
if (advance(in) != node->String.stringValue[i])
{ {
return 0; return 0;
} }

Loading…
取消
儲存