0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

BNFで表現されたあるプログラム言語の構文

Last updated at Posted at 2020-08-22

応用情報技術者平成30年秋期 午前問4

次に示す記述は,BNFで表現されたあるプログラム言語の構文の一部である。次に示す記述は,BNFで表現されたあるプログラム言語の構文の一部である。<パラメタ指定>として,正しいものはどれか。

  <パラメタ指定>::=<パラメタ>|(<パラメタ指定>,<パラメタ>)
  <パラメタ>::=<英字>|<パラメタ><英字>
  <英字>::=a|b|c|d|e|f|g|h|i

image.png

ロジックとしては、
<パラメタ指定>::=(<パラメタ指定>,<パラメタ>)
→ ((<パラメタ指定>,<パラメタ>),<パラメタ>)
→ (((<パラメタ指定>,<パラメタ>),<パラメタ>),<パラメタ>)

のように、
 ((((<パラメタ>,<パラメタ>),<パラメタ>),<パラメタ>),<パラメタ>)
の構文が適切となる。

つまり、「( )」、「,」が必須ですね。且つ、イのような二重括弧もだめですね。括弧中でも「パラメタ指定」なので、「( )」、「,」も必須ですね。
よって、イウエは間違い、アが正しいだろうな。

ーーーーーーーーーーーーーーーーーーーーーーーーーー
補足
次の規則から生成することができる式はどれか。

〔規則〕
  <式> ::=<変数>|(<式>+<式>)|<式>*<式>
  <変数> ::=A|B|C|D

 ア、A+(B+C)*D      イ、(A+B)+(C+D)
 ウ、(A+B)*(C+D)     エ、(A*B)+(C*D)

答えにつきまして、
+の場合は、両側が「( )」 が必要であること。
よって、ア、イ、エは間違いですね。

参照:

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?