简体   繁体   中英

How can I understand this binary expression grammar?

I don't understand this binary expression grammar

expr -> expr '+' term
      | expr '-' term
      | term

term -> term '*' factor
      | term '/' factor
      | factor

factor -> '(' expr ')'
        | NUM 

In plain english:

An expr can be one of the following:

  • another expr followed by the character + followed by a term
  • another expr followed by the character - followed by a term
  • a term

A term can be one of the following:

  • another term followed by the character * followed by a factor
  • another term followed by the character / followed by a factor
  • a factor

A factor can be one of the following:

  • a character ( followed by and expr followed by a character )
  • a number

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM