小编Ami*_*irh的帖子

在ANTLR BNF语法符号中,epsilon的等价物是什么?

在利用ANTLR 3.3时,我正在改变当前语法以支持没有括号的输入.这是我的语法的第一个版本:

grammar PropLogic;

        NOT : '!' ;
        OR  : '+' ;
        AND : '.' ;
        IMPLIES : '->' ;
        SYMBOLS : ('a'..'z') | '~' ;
        OP : '(' ;
        CP : ')' ;

    prog    : formula EOF ;


    formula : NOT formula
        | OP formula( AND formula CP | OR formula CP | IMPLIES formula CP)
        | SYMBOLS ;


    WHITESPACE : ( '\t' | ' ' | '\r' | '\n'| '\u000C' )+    { $channel = HIDDEN; } ;
Run Code Online (Sandbox Code Playgroud)

然后我改变它以支持适当的功能: …

java validation antlr antlr3

6
推荐指数
1
解决办法
8275
查看次数

灵活的引号是否为字符串添加了额外的字符?

当我遇到这两个函数时,我正在通过ruby koans学习红宝石:

def test_flexible_quotes_can_handle_multiple_lines
   *long_string = %{
   It was the best of times,
   It was the worst of times.
   }*
   assert_equal *54*, long_string.size
end

def test_here_documents_can_also_handle_multiple_lines
   *long_string = <<EOS
   It was the best of times,
   It was the worst of times.
   EOS*
   assert_equal *53*, long_string.size
end
Run Code Online (Sandbox Code Playgroud)

问题是,当使用灵活的引号时,我无法理解这个额外字符的来源.Ruby koans说两个答案都是正确的.

ruby string quotes

2
推荐指数
1
解决办法
1056
查看次数

标签 统计

antlr ×1

antlr3 ×1

java ×1

quotes ×1

ruby ×1

string ×1

validation ×1