私はShunting-yard algorithmの後にC++で式パーサーを実装しましたが、wikipediaの説明については問題があります。それは詳細にアルゴリズム "に一部です:Shunting-yardアルゴリズムに関する質問
If the token is an operator, o1, then: while there is an operator token o2, at the top of the operator stack and either o1 is left-associative and its precedence is less than or equal to that of o2, or o1 is right associative, and has precedence less than that of o2, pop o2 off the operator stack, onto the output queue; at the end of iteration push o1 onto the operator stack.
それは私のundetstandingによる "while there is an operator token o2
" は、 "while there is an operator or function token o2
" であると言います。
関数は演算子として扱われ、すべての従来の演算子よりも優先順位が高くなければなりません。
これは実装しようとしている言語によって異なります。また、実際の関数名は実際には「呼び出し演算子」か、かっこは開きますか?そして、「機能トークン」は何ですか?どのように "関数トークン"と他の記号的な名前トークン(変数など)の違いはありますか?そして最後に、 "関数呼び出し演算子"(それがどんな形式であっても)*演算子*ではありませんか? –
@JoachimPileborg「C」言語を実装していたとしましょう。私はちょうどwikipediaの細部に従ってシャントヤードアルゴリズムを実装しようとしていました。そして、ウィキペディアの説明には、「オペレータ」以外の「機能」があります。私の理解は、ここの「演算子」はおそらくCやC++言語のような伝統的な演算子を意味し、「関数」は 'func(arg1、arg2 ...)'のような形式を意味します。 –
@JoachimPileborg私のコードは、私の質問で詳細が変更されました。だから、私はウィキペディアの説明が十分にはっきりしているとは思わない。 –