2013-09-30 22 views
0

我有以下的(很简单)Ragel文件scanner.rl:使用ragel -D scanner.rl为什么这个Ragel文件会产生隐式转换错误? (Ragel与d)

void lex(string data) { 
    int cs, act, top; 
    auto p = data.ptr; 
    typeof(p) 
     pe = &data[$ -1], 
     eof = pe, 
     ts, 
     te; 

    %%{ 
     machine scanner; 

     identifier = alpha . alnum**; 

     main := |* 
      identifier => { ("Identifier: " + data[ts..te]).writeln; }; 
      space; 
     *|; 

     write data; 
     write init; 
     write exec; 
    }%% 
} 

void main() { 
    "this is a test".lex; 
} 

我转换scanner.rlscanner.d。当我尝试编译生成的文件Ddmd scanner.d,我收到以下错误信息:

scanner.d(97): Error: cannot implicitly convert expression (&_scanner_actions[cast(ulong)_scanner_from_state_actions[cast(ulong)cs]]) of type const(byte)* to byte* scanner.d(110): Error: cannot implicitly convert expression (&_scanner_trans_keys[cast(ulong)_scanner_key_offsets[cast(ulong)cs]]) of type const(char)* to char* scanner.d(166): Error: cannot implicitly convert expression (&_scanner_actions[cast(ulong)_scanner_trans_actions[cast(ulong)_trans]]) of type const(byte)* to byte* scanner.rl(22): Error: cannot implicitly convert expression (ts) of type immutable(char)* to ulong scanner.d(186): Error: cannot implicitly convert expression (&_scanner_actions[cast(ulong)_scanner_to_state_actions[cast(ulong)cs]]) of type const(byte)* to byte*

也许我失去了一些重要的东西?

+1

你确定ragel正在生成D2代码吗?看起来它缺少const ....看着ragel的源代码,看起来像ragel -D生成D1和ragel -E生成D2,虽然这在--help中没有记录!我试过了,得到了另一个错误,但现在得走了,所以再也看不到了...... –

+1

感谢ton @ AdamD.Ruppe!这是问题。我将向上游提交关于'-E'的错误报告。如果您将重新发布您的评论作为答案,我会接受它。 – Jordan

回答

2

你确定ragel正在生成D2代码吗?看起来它缺少const ....看着ragel的源代码,看起来像ragel -D生成D1和ragel -E生成D2,虽然这在--help中没有记录!