身份表达,因素和术语? [英] Identity expression, factor, and term?

查看:86
本文介绍了身份表达,因素和术语?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习与上下文无关的语法,而且我不了解如何用C或C ++这样的编程语言来标识表达,因子和术语。

I am learning context-free grammar, and I don't understand how to identity expression, factor and term in a programming language like C or C++.

假设我们有一个赋值语句 id:= E ,其中E是任何算术表达式。

Suppose we have an assignment statement, id := E, where E is any arithmetic expression.

术语是什么?什么是表情?而实际代码中的因素是什么?

What is a term? What is an expression? and What is a factor in an actual piece of code?

我们可以拥有

int i = 3, j = 14
int i = 3 + j * 14;

非常感谢。

推荐答案

因数,项和表达式概念来自数学,与编程语言并没有真正的联系。

The "factor", "term" and "expression" concepts come from math and don't really have to do with programming languages.

因素就是您要乘的东西:

Factors are things you multiply:

1*2*(3+4)

添加的术语是:

1 + 2 + (3*4)

表达式是整个结果

1 + 3 * 7

在无上下文的语言解析中,您可以使用这些区别来组织运算符之间的优先级。因此,表达式由项的总和组成,而项由因子的乘积组成,并且因子可以是数字或带括号的子表达式。

In context-free language parsing you use these distinctions to organize the precedences between operators. So an expression is made of a sum of terms and a term is made of a product of factors and a factor is either a number or a parenthesized subexpression.

这篇关于身份表达,因素和术语?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆