小编mor*_*itz的帖子

原始令牌候选者排序

perl6如何确定proto token首先匹配哪个?

下面的代码按预期方式工作,它与string匹配1234,并Grammar::Tracer显示与之匹配的第一个标记是s:sym<d>,这是有意义的,因为它是最长的标记。

但是,如果我将文字更改为令牌,例如,将token threeform 更改'3'<digit>,它将无法匹配,并Grammar::Tracer显示s:sym<b>与first匹配。

移动s:sym<d>到顶部,在两种情况下都匹配字符串,但是对该行为的解释是什么?

#!/usr/bin/env perl6
no precompilation;
use Grammar::Tracer;

grammar G {

  token TOP { <s> }

  proto token s { * }

  token s:sym<a> { <one> }
  token s:sym<b> { <one> <two> }
  token s:sym<c> { <one> <two> <three> }
  token s:sym<d> { <one> <two> <three> <four> }

  token one   { '1' }
  token two …
Run Code Online (Sandbox Code Playgroud)

regex grammar perl6 raku

13
推荐指数
1
解决办法
99
查看次数

如何监控python的concurrent.futures.ProcessPoolExecutor?

我们使用ProcessPoolExecutorconcurrent.futures在流程中的池异步接收请求,并进行实际的同步处理的服务.

一旦我们遇到流程池耗尽的情况,那么新请求必须等到其他一些流程完成.

有没有办法询问进程池的当前用法?这将使我们能够监控其状态并进行适当的容量规划.

如果没有,是否有任何良好的替代流程池实现与支持此类监控/容量规划的异步接口?

python monitoring process capacity concurrent.futures

12
推荐指数
1
解决办法
1159
查看次数

自定义解析返回值,保留未命名的终端

考虑语法:

TOP ? 'x' Y 'z'
Y ? 'y'
Run Code Online (Sandbox Code Playgroud)

以下是如何["TOP","x",["Y","y"],"z"]使用各种解析器获取精确值(不是手动编写,而是从语法生成):

xyz__Parse-Eyapp.eyp

%strict
%tree

%%
start:
    TOP { shift; use JSON::MaybeXS qw(encode_json); print encode_json $_[0] };
TOP:
    'x' Y 'z'   { shift; ['TOP', (scalar @_) ? @_ : undef] };
Y:
    'y' { shift; ['Y', (scalar @_) ? @_ : undef] };

%%
Run Code Online (Sandbox Code Playgroud)

xyz__Regexp-Grammars.pl

use 5.028;
use strictures;
use Regexp::Grammars;
use JSON::MaybeXS qw(encode_json);
print encode_json $/{TOP} if (do { local $/; readline; }) =~ qr{
<nocontext:>
<TOP>
<rule: TOP> …
Run Code Online (Sandbox Code Playgroud)

grammar parsing perl6

10
推荐指数
1
解决办法
92
查看次数