小编Ste*_*rus的帖子

在 Lex 和 Yacc 中创建注释

如何在 Lex 和 Yacc 中发表评论?

到目前为止,我还没有尝试过 Yacc,但在 Lex 中我已经尝试过/* comment */and // comment,但这些都无法编译。我在 Mac 上,使用内置的 Lex 和 Yacc 编译器(或者可能是 X-Code 编译器,我不知道)。Lex 或 Yacc 或最好两者中注释的正确语法是什么?

yacc lex bison flex-lexer

8
推荐指数
2
解决办法
1万
查看次数

什么int值与C中的exit()相关?

TutorialsPoint.com上,退出传递值0,而人们经常传递它1.我甚至见过exit(3);

不同的值意味着什么?

c exit

7
推荐指数
2
解决办法
777
查看次数

在结构中设置void*的第n个成员(以及结构名称用法与typedef)

对于类似风险的游戏,我有一个每个区域的结构,每个区域都需要有一个部队可以从母区移入的相关区域列表.

从理论上讲,它看起来像

typedef struct {
    char* name;
    region_t* connections;
} region_t;
Run Code Online (Sandbox Code Playgroud)

但是,这当然是不可能的,因为在解析器到达类型region_t*之前region_t不存在.因此我选择使用void*代替region_t*.

typedef struct {
    char* name;
    void* connections;
} region_t;

MiddleEast.connections = malloc(6 * sizeof(void*));
MiddleEast.connections = &SouthernEurope;
MiddleEast.(connections + 1) = &Egypt;
Run Code Online (Sandbox Code Playgroud)

使用region_ts MiddleEast,SouthernEuropeEgypt,我可以Southern Europe成功设置第一个连接,但是当我尝试设置为时.(connections + 1),&Egypt我得到了编译器错误

error: expected identifier before ‘(’ token

如何正确访问下一个内存地址?

c struct void-pointers

3
推荐指数
1
解决办法
64
查看次数

来自 listp 的意外结果

我有一个结构蜘蛛:

(defstruct spider omegas values k)
Run Code Online (Sandbox Code Playgroud)

和一个实例蜘蛛

(set '*spider* (make-spider
  :omegas '()
  :values (list *input*)
  :k '(#'omegashift #'dec #'dupval '((0 . #'dec) (1 . #'inc) (2 . #'dec)))))
Run Code Online (Sandbox Code Playgroud)

但是当我运行表达式时:(listp (car (spider-k *spider*))在 Emacs 和 SBCL 上(并且涉及 SLIME,但我不确定它是什么。)REPL 返回T. 这显然令人困惑,因为(car (spider-k *spider*)正确返回#'OMEGASHIFT(listp (function OMEGASHIFT))正确返回NIL

为什么是(listp (car (spider-k *spider*))真的?不应该是假的吗?

lisp predicate common-lisp

1
推荐指数
1
解决办法
40
查看次数

标签 统计

c ×2

bison ×1

common-lisp ×1

exit ×1

flex-lexer ×1

lex ×1

lisp ×1

predicate ×1

struct ×1

void-pointers ×1

yacc ×1