English 中文(简体)
在C++(而不是C)中建立简单计算器,采用之二和灵活法
原标题:Creating simple calculator with bison & flex in C++ (not C)

我愿采用 bis和灵活法,创建简单的C++计算器。 请指出创造教区的新鲜米。 我在之二/flex中已经发现几个例子,但所有例子都在C中撰写。

我的目标是制定C++代码,其中各年级将包括价值观、业务、遗体等节点,以创建海岸警卫队(评价将在创建整个海岸警卫队之后进行——从根基开始,然后进行)。

例如:

my_var = sqrt(9 ** 2 - 32) + 4 - 20 / 5
my_var * 3

如下:

        =
      /   
my_var     +
         /   
     sqrt     -
       |     / 
       -    4   /
      /       / 
    **   32   20  5
   /  
  9    2

和第二产业部门一样:

       *
      / 
my_var   3

接着,根据假体编码, AST:

ast_root = create_node( = , new_variable("my_var"), exp)

<exp>/em>:

exp = create_node(OPERATOR, val1, val2)

但NOT类似:

$$ = $1 OPERATOR $3

因此,我直接获得行动的价值,而不是创立诺德。

我认为,Node应当包含(运行)、val1(Node)、val2(Node)。 在某些情况下,如上文提及的sqrt那样,阀2为NUL,最后一种论点。 权利?

如果你能够就上述问题(包括建立中东区域局的档案)提出C++号施克尔顿(不作评估)的建议,帮助我了解如何在中世纪建立/保留 No。 法典可以被抹去,而让我得到想法。

如果你知道的话,请让我举一个现有的(可能是简单的)例子。

感谢大家的时间和帮助!

最佳回答
问题回答

暂无回答




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签