Ò»¸ö¼òµ¥µÄÓïÑÔµÄÓï·¨£¨Èý£©£º×öЩСµ÷Õû£¬²¢½«Éú³ÉÄ¿±ê»»µ½CSharp2 - ±à³ÌÈëÃÅÍø
Ò»¸ö¼òµ¥µÄÓïÑÔµÄÓï·¨£¨Èý£©£º×öЩСµ÷Õû£¬²¢½«Éú³ÉÄ¿±ê»»µ½CSharp2ʱ¼ä:2011-10-07 javaeye RednaxelaFXΪÁ˺óÃæµÄtree grammar¸ü¼ò½à£¬±¾Æª¶ÔÉÏһƪµÄÊ÷ÖØд¹æÔòºÍһЩÓ﷨ϸ½Ú×öÁËЩµ÷Õû¡£²¢ÇÒ£¬½« Éú³ÉµÄlexerºÍparserµÄÔ´ÂëÄ¿±ê»»µ½ÁËCSharp2£¬ÒÔ±ãºóÃæÄÜʹÓÃһЩ.NETµÄ¿â¡£ ҪʹÓÃCSharp2µÄÄ¿±ê£¬ÐèÒª´Ó¹ÙÍøÏÂÔØÏàÓ¦µÄÔËÐÐʱ¿â¡£µ±Ç°µÄ×îаæÊÇ3.1.1£¬¿ÉÒÔ´ÓÕâÀï»ñÈ¡¡£ CSharp/CSharp2Ä¿±êµÄÏêϸÇé¿ö£¬¿ÉÒÔ²éÔĹÙÍøÉϵÄÎĵµ¡£ÒÔÉÏһƪµÄÓ﷨Ϊ»ù´¡£¬Òª»»µ½CSharp2Ä¿±ê Ö»Òª°Ñ¼¸¸öǶÈ붯×÷ÀïµÄSystem.out.println»»³ÉConsole.WriteLine£¬°ÑtoStringTree»»³É ToStringTree£¬°Ñclear»»³ÉClear¾Í¿ÉÒÔÁË¡£±àÒëµÄʱºòÖÁÉÙÐèÒªÒýÓÃAntlr3.Runtime.dll¡£ ÄÇô³ýÈ¥¸ü»»Éú³ÉÄ¿±ê´øÀ´µÄÓ°Ï죬Õâ´Î×öÁËЩÔõÑùµÄÐÞ¸ÄÄØ£¿ Ê×ÏÈ£¬Óï·¨×öÁËЩϸ΢µÄµ÷Õû¡£ÀýÈç˵£¬program¹æÔò´ÓÔ±¾ÔÊÐíûÓÐÓï¾äµ½ÏÖÔÚÒªÇóÖÁÉÙÓÐÒ»ÌõÓï¾ä £»blockStatementΪ¿ÕblockдÁËÌõרÃŵķÖÖ§£»expressionStatementÒ²Ìí¼ÓÁËÒ»¸öEXPR_STMTµÄÐé¹¹ tokenΪ¸ù½Úµã£¬µÈµÈ¡£ ±ä»¯×î´óµÄ»¹ÊÇvariableDeclaration¼°Ïà¹Ø¹æÔò¡£ÉÏһƪÀïÕâÌõ¹æÔòµÄÖØд¹æÔò²¢²»Çø·ÖÓгõʼ»¯Óë ÎÞ³õʼ»¯¡¢¼òµ¥ÀàÐÍÓëÊý×éÀàÐ͵ÄÇø±ð£»±¾ÆªÀïÔò½«ÕâÁ½¸öÇø±ð¶¼Ã÷È·µÄдÔÚÁËÖØд¹æÔòÀÒÔ²»Í¬µÄÐé ¹¹tokenÀ´×÷ΪÉú³ÉµÄÊ÷µÄ¸ù½Úµã¡£ÕâÑù£¬µ****óÃæµÄtree grammarµÄʱºò£¬ÐèÒªµÄlookaheadÊý¾Í¿ÉÒÔ¼õ ÉÙ¡£ ANTLRËùÉú³ÉµÄAST£¬ÒÔÉî¶ÈÓÅÏȵķ½Ê½±éÀú£¬¿ÉÒÔ¿´×öÒ»¸öһάµÄÁ÷£ºÃ¿Ò»²ã¸¸×Ó¹Øϵ¶¼¿ÉÒÔ±íʾΪ £º root -> "down" -> element1 -> element2 -> ... -> elementN -> "up" -> ... ÆäÖÐ"down"ºÍ"up"ÊÇANTLR²åÈëµÄÐé¹¹token£¬ÓÃÓÚÖ¸¶¨Ê÷µÄ²ã´Î¡£ ÕâÑù£¬ºóÃæʹÓÃtree grammarÀ´±éÀúASTʱ£¬Êµ¼ÊÉϱéÀúµÄ¾ÍÊÇÕâÑùÒ»¸öһάµÄÁ÷ £¨CommonTreeNodeStream£©¡£ËùÒÔÎÒÃÇÒ²¿ÉÒÔ°Ñtree grammar¿´×öÊÇÒþº¬ÁË"down"ºÍ"up"Ðé¹¹tokenµÄÆÕ Í¨parser grammar¡£ÄÇô£¬tree grammarÖÐÐèÒªµÄlookahead¸öÊýµÄ·ÖÎö£¬Ò²¾Í¸úparser grammarµÄÒ»Ñù ¡£ ¿´¿´ÏÂÃæµÄÀý×Ó¡£¶ÔÓÚÉÏһƪvariableDeclarationµÄÖØд¹æÔòÖгöÏֵıäÁ¿ÉùÃ÷µÄÀàÐÍ£¬¿ÉÒÔÓÃÕâÑù µÄtree grammarÀ´Æ¥Å䣺 Java´úÂë type : ^( SIMPLE_TYPE INT ) | ^( SIMPLE_TYPE REAL ) | ^( ARRAY_TYPE INT Integer+ ) | ^( ARRAY_TYPE REAL Integer+ ) ; Ê÷Óï·¨µÄ^( ... )¾ÍÒþº¬ÁË"down"ºÍ"up"ÕâÁ½¸öÐé¹¹token¡£Êµ¼ÊÉÏÕâÌõ¹æÔòÆ¥ÅäµÄÊÇ£º Ò»¸ö¼òµ¥µÄÓïÑÔµÄÓï·¨£¨Èý£©£º×öЩСµ÷Õû£¬²¢½«Éú³ÉÄ¿±ê»»µ½CSharp2(2)ʱ¼ä:2011-10-07 javaeye RednaxelaFX¿ÉÒÔºÜÇå³þµÄ¿´µ½"down"ºÍ"up"ÔÚ¹æÔòÖеÄλÖᣠÔÚ½øÈëÕâÌõ¹æÔòÖ®ºó£¬ÐèÒª¶àÉÙ¸ölookahead²Å×ãÒÔÅжÏÓ¦¸ÃÑ¡ÔñÄÄÌõ·ÖÖ§ÄØ£¿ ÏòÇ°¿´Ò»Î»£ºÖ»ÄÜÅųýµôÁ½¸ö·ÖÖ§£¬»¹ÓÐÁ½¸ö£¬²»¹»£» ÏòÇ°¿´Á½Î»£ºµÚ¶þλÊÇʲôÄØ£¿Ëĸö·ÖÖ§ÀïµÚ¶þλ¶¼ÊÇ"down"½Úµã£¬¶ÔÅжϷÖ֧û°ïÖú£¬»¹ÊDz»¹»Óà £» ÏòÇ°¿´Èýλ£ºSIMPLEºÍARRAY¡¢INTºÍREAL¶¼ÄÜ·Ö¿ªÁË£¬×ã¹»¡£ ÄÇô¶ÔÕâÌõ¹æÔò¶øÑÔ£¬ÐèÒª2¸ölookahead¡£ÔĶÁANTLRÉú³ÉµÄÔ´Â룬¿ÉÒÔ¿´µ½input.LA(3)ÕâÑùµÄµ÷Óà £¬±íʾÏòÇ°¿´µÚÈýλµÄtoken¡£Ã¿¶àÒ»¸ölookahead£¬Éú³ÉµÄ´úÂë¾ÍµÃ¶àÒÔ²ãǶÌ×µÄif-else£¬ºÜÊÇÂé·³¡£ Èç¹ûÄܵ÷ÕûÒ»ÏÂparserÕâ±ßÉú³ÉµÄASTµÄ½á¹¹£¬ÈÃtree grammarÄDZßÄÜд³É£º Java´úÂë simpleType : INT | REAL ; arrayType : ^( INT Integer+ ) | ^( REAL Integer+ ) ; ÄÇôÕâÁ½Ìõ¹æÔò¶¼Ö»ÐèÒª1¸ölookahead¾Í×ãÒÔÅжϷÖÖ§ÁË£¬±ÈÔ±¾µÄд·¨Òª¼òµ¥£¬Ò²»áÉÔ΢¿ìһЩ¡£ дÁ˸öRuby½Å±¾À´¼ì²éÉú³ÉµÄÔ´ |
ÁèÖڿƼ¼×¨ÒµÌṩ·þÎñÆ÷×âÓᢷþÎñÆ÷Íйܡ¢ÆóÒµÓʾ֡¢ÐéÄâÖ÷»úµÈ·þÎñ£¬¹«Ë¾ÍøÕ¾£ºhttp://www.lingzhong.cn ΪÁ˸ø¹ã´ó¿Í»§Á˽â¸ü¶àµÄ¼¼ÊõÐÅÏ¢£¬±¾¼¼ÊõÎÄÕÂÊÕ¼¯À´Ô´ÓÚÍøÂç,ÁèÖڿƼ¼×ðÖØÎÄÕÂ×÷ÕߵİæȨ£¬Èç¹ûÓÐÉæ¼°ÄãµÄ°æȨÓбØҪɾ³ýÄãµÄÎÄÕ£¬ÇëºÍÎÒÃÇÁªÏµ¡£ÒÔÉÏÐÅÏ¢ÓëÎÄÕÂÕýÎÄÊDz»¿É·Ö¸îµÄÒ»²¿·Ö,Èç¹ûÄúҪתÔر¾ÎÄÕÂ,Çë±£ÁôÒÔÉÏÐÅÏ¢£¬Ð»Ð»! |
- ÔÚAppletÖÐÏÔʾͼÏóµÄ·½·¨ - ±à³ÌÈëÃÅÍø
- PhotoshopÖÆ×÷ÂÌÉ«·ç¸ñÍøÕ¾Ê×ҳģ°å
- PS½Ì³Ì:ÈËÎï·ç¾°ÕÕƬµÄ·ç¾°±³¾°´¦Àí
- ʹÓÃ.ashxÎļþ´¦ÀíIHttpHandlerʵÏÖ·¢ËÍÎı¾¼°¶þ½øÖÆÊý¾ÝµÄ·½·¨
- ʹÓÃActionsÃæ°å(2)
- dzÎöWEB±íµ¥Éè¼Æ
- Flash MX2004ÈëÃÅÓë½ø½×ʵÀý¡ª¡ª¶¯×÷½Å±¾½ø½×(6)
- LinuxϵͳÏ´VNCÔ¶³Ì¿ØÖÆÈí¼þ
- Linuxѧϰ±Ê¼Ç£ºsamba·þÎñµÄÅäÖò¹³ä×ÊÁÏ£¨Ê¹ÓÃswat£©
- PSÖÆ×÷ÈÂ×ÅÀÙË¿±ßµÄË®¾§»¨¶ä