⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bootstrap.t.svn-base

📁 这是一个DFA简化和生成LL(1)分析表的程序,自动生成表格及图形
💻 SVN-BASE
字号:
# bootstrap.t# Test the bootstrap capability of spike.pluse strict;use warnings;use test_spike;{    package Parser1;    use Text::Balanced qw/ extract_delimited extract_codeblock /;}plan tests => 1 * blocks() + 3 * 1;run_tests;__DATA__=== TEST 1: regex terminal--- grammargrammar: rule(s) eofile                  {                      my @rules = @{ $item[1] };                     {                         startrule => $rules[0]->[0],                         rules => { map {@$_} @rules },                     };                  }       | <error>eofile: /^\Z/rule: rulename ':' <commit> production(s /\|/)                   {                      [ $item[1], $item[4] ];                   }    | <error?> <reject>rulename: /[A-Za-z]\w*/production: item(s)          | nilitem: repetition    | subrule    | terminal    | action    | directivesubrule: /[A-Za-z]\w*\b(?!\s*:)/terminal: string        | regexstring: /"(\\.|[^"])*"/      | /'(\\.|[^'])*'/regex: {extract_delimited($text,'/')}    { $item[1] || undef }action: {extract_codeblock($text)}       { $item[1] || undef }directive: '<error?>'         | '<error>'         | '<reject>'         | '<commit>'         | '<uncommit>'         | '<leftop:' subrule regex subrule '>'                                { [ @item[2..4] ] }repetition: subrule howoften    { [ $item[1], @{$item[2]} ]; }howoften: '(?)'                         { [ '?' ]; }        | '(s?' <commit> regex(?) ')'   { [ 's?', @{$item[3]} ]; }        | '(s'  <commit> regex(?) ')'   { [ 's', @{$item[3]} ]; }nil: ''  { ["''"] }--- inputidentifier: /[A-Za-z]\w*/--- ast{  'rules' => {    'identifier' => [      [        '/[A-Za-z]\\w*/',      ]    ]  },  'startrule' => 'identifier'};=== TEST 2: string terminal--- inputkeyword: 'if'       | 'else'--- ast{  'rules' => {    'keyword' => [      [        '\'if\''      ],      [        '\'else\''      ]    ]  },  'startrule' => 'keyword'};=== TEST 3: concat rule--- inputif_stmt: 'if' '(' cond ')' blockcond: /\d+/block: '{' /[^}]*/ "}"--- ast{  'rules' => {    'cond' => [      [        '/\\d+/'      ]    ],    'if_stmt' => [      [        '\'if\'',        '\'(\'',        'cond',        '\')\'',        'block'      ]    ],    'block' => [      [        '\'{\'',        '/[^}]*/',        '"}"'      ]    ]  },  'startrule' => 'if_stmt'};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -