fsyacc:允许用语言定义运算符

问题描述

fsyacc是否可以处理解析时引入的运算符?我正在尝试为万花筒构建一个解析器,这是一种玩具语言,用作LLVM教程的示例。万花筒允许将操作员与优先级一起定义。例如:
# Logical unary not.
def unary!(v)
  if v then
    0
  else
    1;

# Define > with the same precedence as <.
def binary> 10 (LHS RHS)
  RHS < LHS;

# Binary \"logical or\",(note that it does not \"short circuit\")
def binary| 5 (LHS RHS)
  if LHS then
    1
  else if RHS then
    1
  else
    0;

# Define = with slightly lower precedence than relationals.
def binary= 9 (LHS RHS)
  !(LHS < RHS | LHS > RHS);
    

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)