| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> perl >> gong neng feng fu de Perl:Perl6 yu fa he zheng ze biao da shi

gong neng feng fu de Perl:Perl6 yu fa he zheng ze biao da shi

2008-05-19 06:25:40 编辑來源:互联网 评论
 
 
 
本文为【功能丰富的Perl:Perl6语法和正则表达式】的拼音翻译版
  Perl 6 zhong yu ji jiang mian shi 。 zai ben wen zhong ,Ted jiang xiang nin jie shao Perl 6 yu yan de yu fa he zheng ze biao da shi , bing jiang ta men yu dang qian ke yong de Perl 5 Parse::RecDescent mo kuai jin xing dui bi 。 ren shi Perl zheng ze biao da shi de xin te xing , bing xue hui ru he ju ti shi yong xin qi er you gong neng qiang da de Perl jiao ben yu yan 。
  dui suo you Perl bian cheng ren yuan er yan ,Perl 6 xiang mu shi yi ge re men hua ti 。Perl yi zhi shi yi men bu duan fa zhan de yu yan , ji hu cong ren he ke yi xiang xiang de dao de jiao du dou ke yi que ding ,Perl 6 que shi shi you Perl 5 jin hua er lai ( bu guo , nin ye ke yi shuo ta men de qi yuan xiang tong )。Perl 6 jiang yun xing yu Parrot zhi shang ,Parrot shi yi zhong tong yong xu ni ji , bu dan ke yi jia zai he jie shi Perl 6 zi jie ma , huan ke yi jia zai he jie shi qi ta xu duo yu yan 。
  bu yao rang jiang lai de wen ti kun rao zhe nin 。 ru guo nin zeng jing yong le ji ge yue de shi jian lai guan cha mou ge jian zhu wu de jian zhu guo cheng , nin jiu hui zhi dao , xuan hao di ji hou yao jin xing wa jue , jin shu gu jia si hu zong shi chu li zhe 。 gong ren men lai lai wang wang , gong zuo yi zhi zai jin xing , dan shi biao mian kan dao de que zong shi chen jiu de 、 chou lou de 、 sheng xiu de jin shu 。 ran hou , ruo gan tian yi hou , tu ran jian , jian zhu wu jiu wan cheng le 。Perl 6 xiang mu dang qian zheng shi chu yu na ge chang qi de zhong jian jie duan , biao mian kan dao de zhi shi sheng xiu de jin shu , er gong ren men zheng zai shen ru di xia jin xing mu hou gong zuo 。 ru guo nin xiang dong xi xiang mu de jin zhan , na me ke yi qu cha kan zui xin de Parrot fa xing ban ben yi ji Perl 6 mei zhou de geng xin ( qing shen yue shen kao zi liao zhong de lian jie )。
  ben wen jiang xiang nin jie shao Perl 6 yu yan de yu fa he zheng ze biao da shi , bing jiang zhe xie yu dang qian ke yong de Perl 5 Parse::RecDescent mo kuai jin xing dui bi 。 ru guo yi qian dui Perl 5 you suo le jie , shu xi Parse::RecDescent, bing qie you ci fa fen xi (lexing) he ju fa fen xi (parsing) fang mian de jing yan , na me zhe xie hui dui nin zhang wo ben wen you hen da bang zhu , ci wai , ben wen shi wei na xie dui Perl 6 yu fa he zheng ze biao da shi gan xing qu de suo you Perl bian cheng ren yuan zhuan xie de 。
  Perl 6 zheng ze biao da shi he yu fa gai shu
  shou xian xu yao sheng ming yi jian shi :Perl jiang tong guo shi yong :p5 xiu shi fu lai zhi chi Perl 5 zheng ze biao da shi 。 dui yu na xie dui Perl 6 zheng ze biao da shi bu gan xing qu huo zhe bu xiang zhuan dao zhe fang mian lai de ren er yan , zhe shi yi ge fu yin 。 ci wai ,Perl 6 zheng ze biao da shi ke neng ( dan bu shi bi xu ) yu Perl 5 zhong dui ying de zheng ze biao da shi you ben zhi shang de qu bie 。
  zai xu yao shi ,Perl 6 zheng ze biao da shi ke yi bei fu yong 。 zai pi pei dan yi de ci shi , fu yong zheng ze biao da shi shi hen huang miu de ; dan zai jie xi pei zhi wen jian shi , ji hu bi xu yao fu yong zheng ze biao da shi ( zhe qu jue yu pei zhi wen fa de fu duo du 、 fa sheng xiu gai de pin lv deng )。
  zai Perl 5 zhong ,Regexp::Common mo kuai ( qing shen yue shen kao zi liao ) yi jing zai chang shi fu yong zheng ze biao da shi , dan shi , yin wei Perl 5 bu yuan xu fu yong zheng ze biao da shi , suo yi bu de bu jiang ta men feng zhuang zai yi ge mo kuai jie kou zhong 。 Perl 6 wan quan zhi chi zhe zhong fu yong 。
  jin guan nin ke yi bian xie lei si Perl 5 zheng ze biao da shi de mo hu er hui se de Perl 6 zheng ze biao da shi , dan zai mo ren qing kuang xia , yuan xu qi yong kong ge zhu jie ; suo yi , sui ran zai Perl 5 zhong nin ke yi yong “hello there” ben shen lai pi pei “hello there”, dan zai Perl 6 zhong , nin bi xu jiang qi gai wei /hello <sp there/。 zhe yang jiu ke yi zai zheng ze biao da zhong jiang tiao jian qing xi di fen li kai lai 。
  geng chong yao de shi , zai yu fa (grammars) nei bu shi yong zheng ze biao da shi shi ,Perl 6 zheng ze biao da shi bi xu bu na me hui se 。 bian cheng ren yuan hui fa xian ( wo xi wang ru ci , Larry Wall ye shi ), dui qing dan 2 de li jie yu wei hu yao bi dui qing dan 1 de rong yi de duo :
  qing dan 1. mei you yu fa de zheng ze biao da shi
  # note this is just a language example, not an accurate name matcher
  # Perl 6 <[A-Z] is equivalent to the Perl 5 [A-Z]
  # Perl 6 :w modifier surrounds all tokens with "automagic" whitespace,
  # which basically means it will match what most people would call
  # "words"
  $name = m:w/ <[A-Z]<[a-z]+ <[A-Z]<[a-z]+ /;
  qing dan 2. zai yu fa zhong zuo wei gui ze de zheng ze biao da shi
  # note this is just a language example, not an accurate name matcher
  grammar English
  {
  rule name :w { <singlename <singlename };
  rule singlename { <[A-Z]<[a-z]+ };
  };
  qing dan 2 bu jin geng rong yi du dong , er qie wei hu qi lai ye geng rong yi 。 li ru ,Perl 6 ben shen yi jing ding yi le <upper he <lower gui ze , zhe shi shi qing bian de geng wei jian dan :
  qing dan 3. zai yu fa zhong zuo wei gui ze de jing guo gai jin de zheng ze biao da shi
  # note this is just a language example, not an accurate name matcher
  grammar Names
  {
  rule name :w { <singlename <singlename };
  rule singlename { <upper<lower+ };
  };
  qiao ! shi yong <upper he <lower zhi hou , wo men jiu fu yong le dai ma 。 ci wai , wo men xian zai huan ke yi chu li Unicode ming cheng , er zhe zhi qian , wo men zhi neng ju xian yu chu li cong A dao Z kai tou de ming cheng 。 dai ma fu yong shi yi xiang chu se de ji shu 。
  zai jin xing geng jin yi bu de wei hu shi , ji hu zong shi xu yao dui ming cheng zhong de po zhe hao huo qi ta ming cheng ( bi ru Don Quixote de la Mancha) jin xing xiu zheng ( ju li lai shuo )。 tong yang , zai jiang dui ge bie gui ze de geng gai ge li chu lai , huo zhe zai xu yao shi chuang jian yi ge xin gui ze de shi hou , nin hui zhu yi dao zhe shi duo me jian dan 。
  yu fa (Grammars) shi xiang dang jian dan de gai nian 。 ta men shi ju you zhuan yong ming cheng kong jian (namespace) he zhuan yong zi li cheng de cheng xu bao ; mei yi ge zi li cheng bei cheng wei yi ge gui ze 。 yu fa ke yi ji cheng qi ta yu fa 。 zhe yang jiu shi de bian cheng ren yuan ji ke yi fu yong qi ta ren de dai ma , ye ke yi bian xie neng gou fu yong de dai ma 。 cong Perl mo kuai de CPAN cun dang wen jian (archive) huo de de cheng gong zhong ke yi ming xian di kan chu zhe zhong fu yong de jia zhi 。Perl 6 yu fa zai gui ze zhong shi yong zheng ze biao da shi , ran hou ke yi jiang zhe xie gui ze yong yu qi ta gui ze zhi zhong 。
  dui bi Parse::RecDescent yu Perl 6 de yu fa
  shu xi Parse::RecDescent de ren dou zhi dao , ta shi yi ge gong neng qiang da de gong ju 。Parse::RecDescent shi yi ge Perl 5 mo kuai , zhi shi yong hen shao dai ma jiu ke yi sheng cheng fei chang qiang da de yu fa 。 zhe xie yu fa yu Perl 6 de yu fa shi fou fei chang xiang si ne ? shi zhe yang de ,Parse::RecDescent de zuo zhe Damian Conway shen ru shen yu le Perl 6 de xu duo gong zuo 。 yin ci , hen duo zai Parse::RecDescent zhong zheng ming hao yong de si xiang dou bei ying yong dao Perl 6 zhong ye jiu bu zu wei qi le 。 ta men de yi xie yu fa you hen duo lei si zhi chu 。
  Parse::RecDescent( ci hou cheng zhi wei P::RD) shi yong new() mo kuai wen fa lai chuang jian xin de yu fa 。 mei ge P::RD yu fa cheng wei P::RD lei zhong de yi ge dui xiang , yu fa zhong de mei yi ge gui ze dou ke yi zuo wei yong lai zhi xing dong zuo de fang fa 。P::RD yu fa ke yi jiang dong zuo (action) yu mei yi ge gui ze guan lian qi lai , jiang qi zuo wei jie xi guo cheng zhong de yi ge wan zheng bu fen 。 zai Perl 5 ben shen zhong , jie xi shi yi ge shi jian , er shi yong le kuo zhan yu fa de dong zuo ze shi da cheng mu biao tu jing zhong de bu xing xi sheng pin (roadkill), na xie kuo zhan de yu fa bei zheng ming shi zao cheng mi huo de zui kui huo shou 。 zhe yi qu bie shi de P::RD bi Perl 5 zheng ze biao da shi geng wei you xiao , yuan yin zai yu dang jian ce dao pi pei dui xiang shi , ta hui shi mou xie shi qing fa sheng 。
  Perl 6 yu fa xi qu le P::RD de jing yan , ta yi shi dao le zhe xie dong zuo de shi yong xing , xian zai , zhe xie dong zuo yi jing cheng wei qi shou yao de zu cheng bu fen 。 mei fa xian yi ge pi pei dui xiang , jiu hui zhi xing yi ge dong zuo ( dai ma kuai )。 ji shi pi pei dui xiang de nei rong ke neng yi jing bei xiu gai ye shi ru ci ! ci wai , zhe xie dong zuo de yu fa yu P::RD zhong de yu fa tong yang jian dan 。
  qing dan 4. bao han dong zuo de Parse::RecDescent yu fa
  # small extract from my cfperl.pl program's global parser
  my $parse_global = new Parse::RecDescent (q{
  input:
  blank | comment | class | section
  comment: /^\s*/ '#' { 1; }
  blank: /^\s*$/ { 1; }
  section: /\w+/ ':'
  { $::current_section = $item[1];
  $::current_classes = 'any'; 1;
  }
  class: compound_class '::'
  { $::current_classes = $item{compound_class}; 1; }
  compound_class: /[-!.|\w]+/
  });
  $parse_global-input("TEXT GOES HERE");
  shang mian de yu fa zhi you yi ge gui ze , ji input, ta jiang pi pei blank、comment、class huo zhe section gui ze 。 zhe xie gui ze zhong de mei yi ge gui ze dou you yi ge ding yi , ta men ke yi shi du li de huo shi ji yu ling yi ge gui ze de , ye ke yi tong shi ju bei zhe liang zhong te xing 。
  zhu yi xiang pu tong de dai ma kuai na yang feng zhuang zai da kuo hao { } nei de dong zuo 。 dui yu yi ge pian duan (section), dong zuo jiang quan ju bian liang $current_section she zhi wei zheng zai jin xing pi pei de pian duan , bing chong xin she zhi $current_classes quan ju bian liang 。 dui yu lei , dong zuo jiang quan ju de $current_classes bian liang she zhi wei pi pei de tiao mu 。
  zhe ge yu fa zai Perl 6 zhong hui shi shen me yang de ne ?
  qing dan 5. qing dan 4 yu fa de Perl 6 yi ben
  # this may be buggy - it's certainly untested
  # every input is known to be one line, without newline characters
  grammar Global
  {
  rule input { <blank | <comment | <class | <section }
  rule blank { ^^ \s* $$ }
  rule comment { ^^ \s* \# }
  rule section
  { (\w+) \s* \:
  {
  $::current_section = $1;
  $::current_classes = 'any';
  }
  }
  rule class { (<compound_class) \s* \:\:
  {
  $::current_classes = $1;
  }
  }
  rule compound_class { <[-!.|\w]+ }
  }
  Perl 5 de zheng ze biao da shi
  ru guo nin dui Perl 5 zheng ze biao da shi fei chang shu xi , na me ke yi tiao guo zhe yi jie 。
  suo you Perl 5 bian cheng ren yuan dou shu xi Perl 5 zheng ze biao da shi 。 zai jin xing pi pei shi , yao yong m// cao zuo fu lai biao shi zhe xie zheng ze biao da shi ( you shi shi ke xuan de ), er dang pi pei bing ti huan shi , ze yao yong s/// cao zuo fu lai biao shi ta men 。 zai te ding de qing kuang xia ,/ zi fu ke yi you qi ta zi fu qu dai , bing qie you yi xie te ding de cao zuo fu , ta men yu zheng ze biao da shi you ji fen lei si , bu guo zhe yang de cao zuo fu bu duo ( li ru tr///)。Perl 5 zheng ze biao da shi yao zhi ming de huo zhe shi “ xun zhao ci nei rong ”, huo zhe shi “ xun zhao ci nei rong , bing
  【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
  Perl 6 zhong yu ji jiang mian shi 。 zai ben wen zhong ,Ted jiang xiang nin jie shao Perl 6 yu yan de yu fa he zheng ze biao da shi , bing jiang ta men yu dang qian ke yong de Perl 5 Parse::RecDescent mo kuai jin xing dui bi 。 ren shi Perl zheng ze biao da shi de xin te xing , bing xue hui ru he ju ti shi yong xin qi er you gong neng qiang da de Perl jiao ben yu yan 。    dui suo you Perl bian cheng ren yuan er yan ,Perl 6 xiang mu shi yi ge re men hua ti 。Perl yi zhi shi yi men bu duan fa zhan de yu yan , ji hu cong ren he ke yi xiang xiang de dao de jiao du dou ke yi que ding ,Perl 6 que shi shi you Perl 5 jin hua er lai ( bu guo , nin ye ke yi shuo ta men de qi yuan xiang tong )。Perl 6 jiang yun xing yu Parrot zhi shang ,Parrot shi yi zhong tong yong xu ni ji , bu dan ke yi jia zai he jie shi Perl 6 zi jie ma , huan ke yi jia zai he jie shi qi ta xu duo yu yan 。    bu yao rang jiang lai de wen ti kun rao zhe nin 。 ru guo nin zeng jing yong le ji ge yue de shi jian lai guan cha mou ge jian zhu wu de jian zhu guo cheng , nin jiu hui zhi dao , xuan hao di ji hou yao jin xing wa jue , jin shu gu jia si hu zong shi chu li zhe 。 gong ren men lai lai wang wang , gong zuo yi zhi zai jin xing , dan shi biao mian kan dao de que zong shi chen jiu de 、 chou lou de 、 sheng xiu de jin shu 。 ran hou , ruo gan tian yi hou , tu ran jian , jian zhu wu jiu wan cheng le 。Perl 6 xiang mu dang qian zheng shi chu yu na ge chang qi de zhong jian jie duan , biao mian kan dao de zhi shi sheng xiu de jin shu , er gong ren men zheng zai shen ru di xia jin xing mu hou gong zuo 。 ru guo nin xiang dong xi xiang mu de jin zhan , na me ke yi qu cha kan zui xin de Parrot fa xing ban ben yi ji Perl 6 mei zhou de geng xin ( qing shen yue shen kao zi liao zhong de lian jie )。    ben wen jiang xiang nin jie shao Perl 6 yu yan de yu fa he zheng ze biao da shi , bing jiang zhe xie yu dang qian ke yong de Perl 5 Parse::RecDescent mo kuai jin xing dui bi 。 ru guo yi qian dui Perl 5 you suo le jie , shu xi Parse::RecDescent, bing qie you ci fa fen xi (lexing) he ju fa fen xi (parsing) fang mian de jing yan , na me zhe xie hui dui nin zhang wo ben wen you hen da bang zhu , ci wai , ben wen shi wei na xie dui Perl 6 yu fa he zheng ze biao da shi gan xing qu de suo you Perl bian cheng ren yuan zhuan xie de 。   Perl 6 zheng ze biao da shi he yu fa gai shu    shou xian xu yao sheng ming yi jian shi :Perl jiang tong guo shi yong :p5 xiu shi fu lai zhi chi Perl 5 zheng ze biao da shi 。 dui yu na xie dui Perl 6 zheng ze biao da shi bu gan xing qu huo zhe bu xiang zhuan dao zhe fang mian lai de ren er yan , zhe shi yi ge fu yin 。 ci wai ,Perl 6 zheng ze biao da shi ke neng ( dan bu shi bi xu ) yu Perl 5 zhong dui ying de zheng ze biao da shi you ben zhi shang de qu bie 。    zai xu yao shi ,Perl 6 zheng ze biao da shi ke yi bei fu yong 。 zai pi pei dan yi de ci shi , fu yong zheng ze biao da shi shi hen huang miu de ; dan zai jie xi pei zhi wen jian shi , ji hu bi xu yao fu yong zheng ze biao da shi ( zhe qu jue yu pei zhi wen fa de fu duo du 、 fa sheng xiu gai de pin lv deng )。    zai Perl 5 zhong ,Regexp::Common mo kuai ( qing shen yue shen kao zi liao ) yi jing zai chang shi fu yong zheng ze biao da shi , dan shi , yin wei Perl 5 bu yuan xu fu yong zheng ze biao da shi , suo yi bu de bu jiang ta men feng zhuang zai yi ge mo kuai jie kou zhong 。 Perl 6 wan quan zhi chi zhe zhong fu yong 。    jin guan nin ke yi bian xie lei si Perl 5 zheng ze biao da shi de mo hu er hui se de Perl 6 zheng ze biao da shi , dan zai mo ren qing kuang xia , yuan xu qi yong kong ge zhu jie ; suo yi , sui ran zai Perl 5 zhong nin ke yi yong “hello there” ben shen lai pi pei “hello there”, dan zai Perl 6 zhong , nin bi xu jiang qi gai wei /hello <sp there/。 zhe yang jiu ke yi zai zheng ze biao da zhong jiang tiao jian qing xi di fen li kai lai 。    geng chong yao de shi , zai yu fa (grammars) nei bu shi yong zheng ze biao da shi shi ,Perl 6 zheng ze biao da shi bi xu bu na me hui se 。 bian cheng ren yuan hui fa xian ( wo xi wang ru ci , Larry Wall ye shi ), dui qing dan 2 de li jie yu wei hu yao bi dui qing dan 1 de rong yi de duo :    qing dan 1. mei you yu fa de zheng ze biao da shi   # note this is just a language example, not an accurate name matcher   # Perl 6 <[A-Z] is equivalent to the Perl 5 [A-Z]   # Perl 6 :w modifier surrounds all tokens with "automagic" whitespace,   # which basically means it will match what most people would call   # "words"   $name = m:w/ <[A-Z]<[a-z]+ <[A-Z]<[a-z]+ /;    qing dan 2. zai yu fa zhong zuo wei gui ze de zheng ze biao da shi   # note this is just a language example, not an accurate name matcher   grammar English   {   rule name :w { <singlename <singlename };   rule singlename { <[A-Z]<[a-z]+ };   };    qing dan 2 bu jin geng rong yi du dong , er qie wei hu qi lai ye geng rong yi 。 li ru ,Perl 6 ben shen yi jing ding yi le <upper he <lower gui ze , zhe shi shi qing bian de geng wei jian dan :    qing dan 3. zai yu fa zhong zuo wei gui ze de jing guo gai jin de zheng ze biao da shi   # note this is just a language example, not an accurate name matcher   grammar Names   {   rule name :w { <singlename <singlename };   rule singlename { <upper<lower+ };   };    qiao ! shi yong <upper he <lower zhi hou , wo men jiu fu yong le dai ma 。 ci wai , wo men xian zai huan ke yi chu li Unicode ming cheng , er zhe zhi qian , wo men zhi neng ju xian yu chu li cong A dao Z kai tou de ming cheng 。 dai ma fu yong shi yi xiang chu se de ji shu 。    zai jin xing geng jin yi bu de wei hu shi , ji hu zong shi xu yao dui ming cheng zhong de po zhe hao huo qi ta ming cheng ( bi ru Don Quixote de la Mancha) jin xing xiu zheng ( ju li lai shuo )。 tong yang , zai jiang dui ge bie gui ze de geng gai ge li chu lai , huo zhe zai xu yao shi chuang jian yi ge xin gui ze de shi hou , nin hui zhu yi dao zhe shi duo me jian dan 。    yu fa (Grammars) shi xiang dang jian dan de gai nian 。 ta men shi ju you zhuan yong ming cheng kong jian (namespace) he zhuan yong zi li cheng de cheng xu bao ; mei yi ge zi li cheng bei cheng wei yi ge gui ze 。 yu fa ke yi ji cheng qi ta yu fa 。 zhe yang jiu shi de bian cheng ren yuan ji ke yi fu yong qi ta ren de dai ma , ye ke yi bian xie neng gou fu yong de dai ma 。 cong Perl mo kuai de CPAN cun dang wen jian (archive) huo de de cheng gong zhong ke yi ming xian di kan chu zhe zhong fu yong de jia zhi 。Perl 6 yu fa zai gui ze zhong shi yong zheng ze biao da shi , ran hou ke yi jiang zhe xie gui ze yong yu qi ta gui ze zhi zhong 。    dui bi Parse::RecDescent yu Perl 6 de yu fa    shu xi Parse::RecDescent de ren dou zhi dao , ta shi yi ge gong neng qiang da de gong ju 。Parse::RecDescent shi yi ge Perl 5 mo kuai , zhi shi yong hen shao dai ma jiu ke yi sheng cheng fei chang qiang da de yu fa 。 zhe xie yu fa yu Perl 6 de yu fa shi fou fei chang xiang si ne ? shi zhe yang de ,Parse::RecDescent de zuo zhe Damian Conway shen ru shen yu le Perl 6 de xu duo gong zuo 。 yin ci , hen duo zai Parse::RecDescent zhong zheng ming hao yong de si xiang dou bei ying yong dao Perl 6 zhong ye jiu bu zu wei qi le 。 ta men de yi xie yu fa you hen duo lei si zhi chu 。   Parse::RecDescent( ci hou cheng zhi wei P::RD) shi yong new() mo kuai wen fa lai chuang jian xin de yu fa 。 mei ge P::RD yu fa cheng wei P::RD lei zhong de yi ge dui xiang , yu fa zhong de mei yi ge gui ze dou ke yi zuo wei yong lai zhi xing dong zuo de fang fa 。P::RD yu fa ke yi jiang dong zuo (action) yu mei yi ge gui ze guan lian qi lai , jiang qi zuo wei jie xi guo cheng zhong de yi ge wan zheng bu fen 。 zai Perl 5 ben shen zhong , jie xi shi yi ge shi jian , er shi yong le kuo zhan yu fa de dong zuo ze shi da cheng mu biao tu jing zhong de bu xing xi sheng pin (roadkill), na xie kuo zhan de yu fa bei zheng ming shi zao cheng mi huo de zui kui huo shou 。 zhe yi qu bie shi de P::RD bi Perl 5 zheng ze biao da shi geng wei you xiao , yuan yin zai yu dang jian ce dao pi pei dui xiang shi , ta hui shi mou xie shi qing fa sheng 。   Perl 6 yu fa xi qu le P::RD de jing yan , ta yi shi dao le zhe xie dong zuo de shi yong xing , xian zai , zhe xie dong zuo yi jing cheng wei qi shou yao de zu cheng bu fen 。 mei fa xian yi ge pi pei dui xiang , jiu hui zhi xing yi ge dong zuo ( dai ma kuai )。 ji shi pi pei dui xiang de nei rong ke neng yi jing bei xiu gai ye shi ru ci ! ci wai , zhe xie dong zuo de yu fa yu P::RD zhong de yu fa tong yang jian dan 。    qing dan 4. bao han dong zuo de Parse::RecDescent yu fa   # small extract from my cfperl.pl program's global parser   my $parse_global = new Parse::RecDescent (q{   input:   blank | comment | class | section   comment: /^\s*/ '#' { 1; }   blank: /^\s*$/ { 1; }   section: /\w+/ ':'   { $::current_section = $item[1];   $::current_classes = 'any'; 1;   }   class: compound_class '::'   { $::current_classes = $item{compound_class}; 1; }   compound_class: /[-!.|\w]+/   });   $parse_global-input("TEXT GOES HERE");    shang mian de yu fa zhi you yi ge gui ze , ji input, ta jiang pi pei blank、comment、class huo zhe section gui ze 。 zhe xie gui ze zhong de mei yi ge gui ze dou you yi ge ding yi , ta men ke yi shi du li de huo shi ji yu ling yi ge gui ze de , ye ke yi tong shi ju bei zhe liang zhong te xing 。    zhu yi xiang pu tong de dai ma kuai na yang feng zhuang zai da kuo hao { } nei de dong zuo 。 dui yu yi ge pian duan (section), dong zuo jiang quan ju bian liang $current_section she zhi wei zheng zai jin xing pi pei de pian duan , bing chong xin she zhi $current_classes quan ju bian liang 。 dui yu lei , dong zuo jiang quan ju de $current_classes bian liang she zhi wei pi pei de tiao mu 。    zhe ge yu fa zai Perl 6 zhong hui shi shen me yang de ne ?    qing dan 5. qing dan 4 yu fa de Perl 6 yi ben   # this may be buggy - it's certainly untested   # every input is known to be one line, without newline characters   grammar Global   {   rule input { <blank | <comment | <class | <section }   rule blank { ^^ \s* $$ }   rule comment { ^^ \s* \# }   rule section   { (\w+) \s* \:   {   $::current_section = $1;   $::current_classes = 'any';   }   }   rule class { (<compound_class) \s* \:\:   {   $::current_classes = $1;   }   }   rule compound_class { <[-!.|\w]+ }   }   Perl 5 de zheng ze biao da shi    ru guo nin dui Perl 5 zheng ze biao da shi fei chang shu xi , na me ke yi tiao guo zhe yi jie 。    suo you Perl 5 bian cheng ren yuan dou shu xi Perl 5 zheng ze biao da shi 。 zai jin xing pi pei shi , yao yong m// cao zuo fu lai biao shi zhe xie zheng ze biao da shi ( you shi shi ke xuan de ), er dang pi pei bing ti huan shi , ze yao yong s/// cao zuo fu lai biao shi ta men 。 zai te ding de qing kuang xia ,/ zi fu ke yi you qi ta zi fu qu dai , bing qie you yi xie te ding de cao zuo fu , ta men yu zheng ze biao da shi you ji fen lei si , bu guo zhe yang de cao zuo fu bu duo ( li ru tr///)。Perl 5 zheng ze biao da shi yao zhi ming de huo zhe shi “ xun zhao ci nei rong ”, huo zhe shi “ xun zhao ci nei rong , bing   
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
时尚秀气模特裴裴(8)
时尚秀气模特裴裴(7)
时尚秀气模特裴裴(6)
时尚秀气模特裴裴(5)
白墙黑瓦
广州东郊[原创]
八美至丹巴的东谷天然盆景
不一样的
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有