问题标签 [ocamlyacc]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
parsing - 转移表溢出,自动机太大
我想在Excel 公式的词法分析器和解析器中添加对带有 Excel 表的结构化引用的支持。
我将以下正则表达式添加到lexer_structref.mll
:
在lexer_e.mll
中,我添加了如下标识符。并将parser_e.mly
调用Parser_structref.mly
which 解析结构化引用。
但是,编译整个程序给了我以下错误:
| lex_Column'
从中删除let lex_structref
使编译工作。
有什么我写错了,还是因为我以前的词法分析器和解析器(工作正常)已经很大并且添加了一些东西会爆炸?我怎么能诊断呢?
parsing - Set a rule based on the value of a global variable
In my lexer & parser by ocamllex and ocamlyacc, I have a .mly
as follows:
In params.ml
, a variable separator
is defined. Its value is either ;
or ,
and set by the upstream system.
In the .mly
, I want the rule of expr_separators
to be defined based on the value of Params.separator
. For example, when params.separtor
is ;
, only [1;2;3]
is considered as expr
, whereas [1,2,3]
is not. When params.separtor
is ,
, only [1,2,3]
is considered as expr
, whereas [1;2;3]
is not.
Does anyone know how to amend the lexer and parser to realize this?
PS:
The value of Params.separator
is set before the parsing, it will not change during the parsing.
At the moment, in the lexer, ,
returns a token COMMA
and ;
returns SEMICOLON
. In the parser, there are other rules where COMMA
or SEMICOLON
are involved.
I just want to set a rule expr_separators
such that it considers ;
and ignores ,
(which may be parsed by other rules), when Params.separator
is ;
; and it considers ,
and ignore ;
(which may be parsed by other rules), when Params.separator
is ,
.
ocaml - OCaml:表示整数列表的简单赋值
您好,我正在学习 OCaml 语言并完成一项任务。
无限精度自然数可以表示为 0 到 9 之间的整数列表
编写一个函数,它接受一个整数并用一个 0 到 9 之间的整数列表表示它,其中列表的头部包含最低有效位,列表的最后一个元素表示最高有效位。如果输入为负,则返回 None。我们为您提供了一些用例:
例如:
我已经为它写了下面的代码。
我在第 4 行遇到语法错误。由于我是这种语言的新手,所以无法弄清问题所在。有人可以帮忙吗?
ocaml - OCaml:带有 int 列表的 pell 函数
我正在尝试在 OCaml 中编写一个简单的函数
编写之前的 pell 函数的无限精度版本
我为此编写了以下代码:
但仍然有一些语法错误。有人可以帮我解决这个问题吗?
list - 我在语言 OCaml 的两个问题上遇到困难
重要提示:我只被允许使用List.head
,List.tail
并且List.length
没有 List.map List.rev ......等
只有 List.hd、List.tl 和 List.length
仅当列表的长度为奇数时,如何在列表列表中复制列表的元素
这是我尝试过的代码:
举个例子:
返回
任何帮助将不胜感激
谢谢你们
parsing - 在 parser.mly 文件中列出标记是否有优先权?
就像我在解析器的开头列出了一些标记一样
是否有任何类型的优先级与此相关?或者这只是一个对订购没有特别重要意义的代币列表?
compiler-construction - ocaml解析器中的优先级重要吗?
例如,如果我正在编写一个类似 parser.mly 的文件,并且我为表达式编写了这个
这是否与
就像我想我问的是垂直列出的顺序在确定解析优先级时是否重要?
compiler-construction - 为生成 LLVM IR 而编写的 Ocaml 代码是做什么的?
我是 Ocaml 的新手,不明白这段代码在做什么
StringMap.t 具体是做什么的?还有什么?“global_vars : L.llvalue StringMap.t”有什么作用?
compiler-construction - 这是在 Ocaml 中进行铸造的一个例子,不清楚这条线在做什么?
我正在查看用于创建 LLVM IR 的 codegen.ml 文件。我对 Ocaml 不熟悉,所以只需要澄清一下
所以对于这条线
“->”后面的东西是干什么的?是否将 0.0 转换为浮点数?
function - OCaml 函数中的 `_ -> ()` 是什么意思?
我正在查看这段代码(前两行是上下文的伪代码)
所以我认为正在发生的事情是有一个名为的列表binds
,并且因为iter
在“”之后的括号内定义的函数List.iter
被应用于binds
.
但是我对函数本身感到困惑。这是我尝试单独写出函数的尝试
是什么_ -> ()
意思?