0

次の文法規則があります。

pacman
  : section section map section
  ;

3 つの異なる を異なる方法で処理する、このルールの Java アクションを作成したいと考えていますsection。3 つの異なるインスタンスのハンドルは何ですか?


これは私が欲しいものを示す疑似コードです:

pacman
  : section section map section
  {
    processFirstSection($section[0]);
    if(checkSecondSection($section[1]))
    {
      //The if statement isn't important itself;
      //the point is that I do completely different
      //things with each section
      handleThirdSection($section[2]);
    }
  }
  ;
4

1 に答える 1

0
pacman
  : section1=section section2=section map section3=section
  {
    processFirstSection($section1);
    if(checkSecondSection($section2))
    {
      handleThirdSection($section3);
    }
  }

一般的に、ルール

 rule : name=Token otherName=rule

を使用してトークンにアクセスし、をToken使用$nameしてルールにアクセスできます。rule$otherName

于 2013-10-12T03:05:37.817 に答える