feat:修改文法制导定义为S属性定义,以避免左递归 (#55)

Co-authored-by: jackfiled <xcrenchangjun@outlook.com>
Reviewed-on: PostGuard/Canon#55
Co-authored-by: ichirinko <1621543655@qq.com>
Co-committed-by: ichirinko <1621543655@qq.com>
This commit is contained in:
ichirinko
2024-04-25 11:42:36 +08:00
committed by jackfiled
parent b4a6632018
commit b20c3234c5
6 changed files with 725 additions and 695 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -54,15 +54,19 @@ public static class PascalGrammar
]
},
{
// IdList -> id | IdList , id
// (deprecated)IdList -> id | IdList , id
// 更改语法制导定义为S属性定义
// IdList -> , id IdList | : Type
new NonTerminator(NonTerminatorType.IdentifierList), [
[
new Terminator(DelimiterType.Comma),
Terminator.IdentifierTerminator,
new NonTerminator(NonTerminatorType.IdentifierList),
],
[
new NonTerminator(NonTerminatorType.IdentifierList),
new Terminator(DelimiterType.Comma),
Terminator.IdentifierTerminator
new Terminator(DelimiterType.Colon),
new NonTerminator(NonTerminatorType.Type)
]
]
},
@@ -127,19 +131,20 @@ public static class PascalGrammar
]
},
{
// VarDeclaration -> IdList : Type | VarDeclaration ; IdList : Type
// (deprecated) VarDeclaration -> IdList : Type | VarDeclaration ; IdList : Type
// VarDeclaration -> id IdList | VarDeclaration ; id IdList
// 更改语法制导定义为S属性定义
new NonTerminator(NonTerminatorType.VarDeclaration), [
[
new NonTerminator(NonTerminatorType.IdentifierList),
new Terminator(DelimiterType.Colon),
new NonTerminator(NonTerminatorType.Type)
Terminator.IdentifierTerminator,
new NonTerminator(NonTerminatorType.IdentifierList)
],
[
new NonTerminator(NonTerminatorType.VarDeclaration),
new Terminator(DelimiterType.Semicolon),
Terminator.IdentifierTerminator,
new NonTerminator(NonTerminatorType.IdentifierList),
new Terminator(DelimiterType.Colon),
new NonTerminator(NonTerminatorType.Type)
]
]
},
@@ -281,12 +286,13 @@ public static class PascalGrammar
]
},
{
// ValueParameter -> IdList : BasicType
// (deprecated)ValueParameter -> IdList : BasicType
// 更改语法制导定义为S属性定义
// ValueParameter -> id IdList
new NonTerminator(NonTerminatorType.ValueParameter), [
[
new NonTerminator(NonTerminatorType.IdentifierList),
new Terminator(DelimiterType.Colon),
new NonTerminator(NonTerminatorType.BasicType)
Terminator.IdentifierTerminator,
new NonTerminator(NonTerminatorType.IdentifierList)
]
]
},