There is a parser generator capable of generating a parser that can parse this: S → 'x' S 'x' | 'X'

For a while, I have been intrigued by the fact that ANTLR is not able to parse the following free context grammar rule: S → 'x' S 'x' | 'X'.

It did not seem difficult to me.

As far as I know, ANTLR is the most powerful LL parser. Are there other parser generators (LR or others) that can generate a parser for this?

g

Cohen

+3
source share
2 answers

, LL (n) LALR (n) LR (n) n. . n. n x, . , - , ?

( n), , , . , , , ; , , S → 'x' 'x' S | 'x', .

+5

Antlr , :

grammar fred;

sentence : ( 'x' 'x' 'x' ) => 'x' sentence 'x'
         |                    'x'
         ;

, , 1 . : " " x ", " x ", .

Antlr 3.3/Antlrworks 1.4.2 : enter image description here

- , , :

grammar fred;

start    : sentence
         ;

sentence : 'x'  'x'('x' 'x')*  'x'
         |      'x'
         ;

enter image description here

, , ( ) .

+2

Source: https://habr.com/ru/post/1792547/


All Articles