<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    VIRGIN FOREST OF JAVA
    不要埋頭苦干,要學習,學習,再學習。。。。。
    powered by R.Zeus
    Author Terence Parr ?PREMIUM

    ?????????????????????????????????Created?? Sep 3, 1999


    ?

    ?

    Answer
    A lexer is a TokenStream source that merely spits out a stream of Token objects to the parser (or another stream consumer). As such, a lexer implements method nextToken() to satisfy interface TokenStream. The parser repeatedly calls yourlexer.nextToken() to get tokens.

    What token definitions result in token objects that get sent to the parser? The answer you'd expect or the one you're used to is, "You get a Token object for every lexical rule in your lexer grammar." This is indeed the default case for ANTLR's lexer grammars.

    What if you want to break up the definition of a complicated rule into multiple rules? Surely you don't want every rule to result in a complete Token object in this case. Some rules are only around to help other rules construct tokens. To distinguish these "helper" rules from rules that result in tokens, use the protected modifier. This overloading of the access-visibility Java term occurs because if the rule is not visible, it cannot be "seen" by the parser.

    Another, more practical, way to look at this is to note that only non-protected rules get called by nextToken() and, hence, only non-protected rules can generate tokens that get shoved down the TokenStream pipe to the parser.

    I now recognize this approach as a mistake. I have a number of other proposals to fix this, none that seems to satisfy everyone.

    								class L extends Lexer;
    
    /** This rule is "visible" to the parser
     *  and a Token object is sent to the
     *  parser when an INT is matched.
     */
    INT : (DIGIT)+ ;
    
    
    /** This rule does not result in a token
     *  object that is passed to the parser.
     *  It merely recognizes a portion of INT.
     */
    protected
    DIGIT : '0'..'9' ;
    
    						

    By definition, all lexical rules return Token objects (ANTLR optimizes away many of these object creations, however), but only the Token objects of non-protected rules get pulled out of the lexer itself

    posted on 2006-09-06 17:18 R.Zeus 閱讀(334) 評論(0)  編輯  收藏 所屬分類: ANTLR
    主站蜘蛛池模板: 亚洲动漫精品无码av天堂| 亚洲一区二区三区高清不卡| 亚洲AV无码欧洲AV无码网站| 亚洲男同gay片| 24小时日本电影免费看| 亚洲av再在线观看| 亚洲乱码在线视频| 99国产精品视频免费观看| www.亚洲一区| 三级片免费观看久久| 成全视频在线观看免费高清动漫视频下载| 亚洲国产AV无码专区亚洲AV| 91在线品视觉盛宴免费| 亚洲黄色免费在线观看| 丁香花在线视频观看免费| 亚洲精品视频免费观看| 男人免费视频一区二区在线观看| 性做久久久久免费观看| 国产成人精品亚洲日本在线| 亚洲最大av无码网址| ww在线观视频免费观看w| 亚洲国产精品无码久久九九 | 人人玩人人添人人澡免费| 亚洲va久久久噜噜噜久久狠狠| 成人性生交大片免费看无遮挡 | 你是我的城池营垒免费观看完整版| 国产无遮挡吃胸膜奶免费看视频| 亚洲精华国产精华精华液好用| 免费黄色app网站| 久久水蜜桃亚洲AV无码精品| 免费一级毛片正在播放| 一级视频免费观看| 久久亚洲国产最新网站| 国产精品国产午夜免费福利看| 99视频在线看观免费| 黄视频在线观看免费| 亚洲综合在线观看视频| 国产高清免费视频| 亚洲日韩国产二区无码| 亚洲精品视频在线免费| 好大好深好猛好爽视频免费|