小编Arj*_*uha的帖子

ocamlyacc解析错误:什么令牌?

我正在使用ocamlyacc和ocamllex.我的语法中出现错误,表示自定义异常.到目前为止,我可以让它报告错误位置:

| error { raise (Parse_failure (string_of_position (symbol_start_pos ()))) }
Run Code Online (Sandbox Code Playgroud)

但是,我也想知道读了哪个令牌.必须有办法---任何人都知道吗?

谢谢.

ocaml ocamlyacc

15
推荐指数
2
解决办法
6853
查看次数

gdb:为SIGBUS处理程序设置断点

我正在尝试使用GDB调试一个简单的停止和复制垃圾收集器(用C语言编写).GC通过处理SIGBUS来工作.我在SIGBUS信号处理程序的顶部设置了一个断点.我告诉GDB将SIGBUS传递给我的程序.但是,它似乎不起作用.

以下程序(内联解释)显示了我的问题的本质:

#include <stdio.h>
#include <sys/mman.h>
#include <assert.h>
#include <signal.h>

#define HEAP_SIZE 4096

unsigned long int *heap;

void gc(int n) {
  signal(SIGBUS, SIG_DFL); // just for debugging
  printf("GC TIME\n");
}

int main () {

  // Allocate twice the required heap size (two semi-spaces)
  heap = mmap(NULL, HEAP_SIZE * 2, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED,
              -1, 0);
  assert (heap != MAP_FAILED);
  // 2nd semi-space is unreadable. Using "bump-pointer allocation", a SIGBUS
  // tells us we are out of space and …
Run Code Online (Sandbox Code Playgroud)

c garbage-collection gdb

9
推荐指数
2
解决办法
3783
查看次数

自定义Prelude模块 - 糟糕的主意?

我刚刚意识到我可以定义自己的Prelude模块并小心地控制它的输出.这被认为是不好的做法吗?

好处:

  • 无需在大型项目中重复导入"Common"模块.

  • 无需编写"import Prelude hidden(catch)".

haskell

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

标签 统计

c ×1

garbage-collection ×1

gdb ×1

haskell ×1

ocaml ×1

ocamlyacc ×1