开发者

Can CSP(Communicating sequential processes) parser be generated using ANTLR?

Can I write a parser for Communicating sequential processes(CSP) in ANTLR? I think it uses 开发者_开发问答left recursion like in statement

VMS = (coin → (choc → VMS))

complete language specification can be found at CSPM : A Reference Manua so it is not a LL grammer. Am I right?


In general, even if you have a grammar with left recursion, you can refactor the grammar to remove it. So ANTLR is reasonably likely to be able to process your grammar. There's no a priori reason you can't write a CSP grammar for ANTLR.

Whether the one you have is suitable is another question.

If your quoted phrase is a grammar rule, it doesn't have left recursion. (If it is, I don't understand the syntax of your grammar rules, especially why the parentheses [terminals?] would be unbalanced; that's pretty untradional.) So ANTLR should be able to process it, modulo converting it to ANTRL grammar rule syntax.

You didn't show the rest of the grammar, so one can't have an opinion about the rest of it.


In the case above does not have left recursion. It would looks something like. Note this is a simplified version, CSP is much more complicated. I'm just showing it is possible.

assignment : PROCNAME EQ process
           ;
process : LPAREN EVENT ARROW process RPAREN
        | PROCNAME
        ;

Besides, you can factor out left recursion with ANTLRWorks 'Remove Left Recursion' function.


CSP's are definitely possible in ANTLR, check http://www.carnap.info/ for an example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜