小编Lea*_*ner的帖子

在 python PLY(lex/yacc) 中使用空生产规则的语法错误

这里给出了完整的例子:

import ply.lex as lex
import Property
# List of token names.   This is always required
tokens = [
    'CheckupInformation',
    'Introduction',
    'Information',
    'perfect',
    'sick',
    'LPAREN',
    'RPAREN',
    'CHAR',
    'NUMBER'
    ] 
def t_CheckupInformation(t)     : 'CheckupInformation'     ; return t
def t_Introduction(t)  : 'Introduction'  ; return t
def t_Information(t) : 'Information' ; return t
def t_perfect(t): 'perfect'; return t
def t_sick(t) : 'sick'; return t



t_LPAREN  = r'\('
t_RPAREN  = r'\)'
t_CHAR = r'[a-zA-Z_][a-zA-Z0-9_\-]*'
t_ignore = " \t"
# Define a rule so we …
Run Code Online (Sandbox Code Playgroud)

python yacc lex ply bnf

0
推荐指数
1
解决办法
602
查看次数

标签 统计

bnf ×1

lex ×1

ply ×1

python ×1

yacc ×1