how to get PLY to ignore text exists in between the open and close tags?

13 Views Asked by At

In the case of php only code enclosed get parsed, ignore other characters before or after it.

Assume we have the following:

LEX
t_OPEN= r'\<\?php'
t_CLOSE = r'\?\>'


YACC
'''program : OPEN statements CLOSE'''

if the input looks like below, it will generate an error

randomstring <?php echo 1 ?>

I tried tokens use regex to capture not enclosed text, did not work. is there any way to do this?

def t_RANDOM(t) :
    r'(.*)\<\?'
    pass
0

There are 0 best solutions below