Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd11d863

Browse files
committed
Fix
1 parent361d261 commitd11d863

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

‎pyformlang/cfg/cfg.py‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,16 +1081,19 @@ def _read_line(cls, line, productions, terminals, variables):
10811081
body_component=body_component[5:-1]
10821082
else:
10831083
type_component=""
1084-
ifbody_componentnotinEPSILON_SYMBOLSortype_component \
1085-
=="TER":
1086-
body_ter=Terminal(body_component)
1084+
ifnotbody_component[0].isupper()ortype_component=="TER":
1085+
ifbody_componentinEPSILON_SYMBOLS:
1086+
body_ter=Epsilon()
1087+
else:
1088+
body_ter=Terminal(body_component)
10871089
terminals.add(body_ter)
10881090
body.append(body_ter)
1089-
elifbody_component[0]instring.ascii_uppercaseor \
1090-
type_component=="VAR":
1091+
elifbody_component[0].isupper()ortype_component=="VAR":
10911092
body_var=Variable(body_component)
10921093
variables.add(body_var)
10931094
body.append(body_var)
1095+
else:
1096+
raiseValueError(f"Invalid rule definition:{body_component}")
10941097
productions.add(Production(head,body))
10951098

10961099
defis_normal_form(self):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp