修改bnf
This commit is contained in:
@@ -151,6 +151,7 @@ InheritDeclaration ::= InheritsKeyword ReferenceIdentifier {
|
||||
}
|
||||
ComponentBody ::= '{' ComponentElement* '}'{
|
||||
pin=1
|
||||
recoverWhile=recoverWhileForComponentBody
|
||||
}
|
||||
//组件元素定义
|
||||
private ComponentElement ::=ChildrenPlaceholder| Property | Callback
|
||||
@@ -160,11 +161,7 @@ private ComponentElement ::=ChildrenPlaceholder| Property | Callback
|
||||
| RepetitionElement | SubComponent {
|
||||
recoverWhile(".*")=recoverWhileForComponentBody
|
||||
}
|
||||
private recoverWhileForComponentBody::= !(
|
||||
'property'|'callback'|'changed'
|
||||
|'states'|'transitions'|'pure'
|
||||
|'function'|'public'|'protected'|'for'|'if'|'}'|';'|'@'
|
||||
|GenericIdentifier|PropertyModifier)
|
||||
private recoverWhileForComponentBody::= !('{'|';'|'}'|'@'|GenericIdentifier)
|
||||
|
||||
ChildrenPlaceholder ::= '@' 'children'{
|
||||
pin=1
|
||||
@@ -249,7 +246,8 @@ RepetitionIndex ::= '[' LocalVariable ']'{
|
||||
//--------------------------------SubElementDeclaration Start---------------------------------------------------
|
||||
//子组件结构元素定义
|
||||
SubComponent ::= (PropertyName ':=')? ReferenceIdentifier ComponentBody{
|
||||
pin=2
|
||||
pin=3
|
||||
recoverWhile=recoverWhileForComponentBody
|
||||
}
|
||||
|
||||
//--------------------------------TransitionsDeclaration Start---------------------------------------------------
|
||||
@@ -298,11 +296,11 @@ CodeBlock ::= '{' Statement* '}'{
|
||||
pin=1
|
||||
}
|
||||
private Statement ::= (ReturnStatement|IfElseStatement|ExpressionStatement) ';'?{
|
||||
recoverWhile=recoverWhileStatement
|
||||
recoverWhile=recoverWhileForComponentBody
|
||||
}
|
||||
ExpressionStatement ::= Expression (';' &Statement)?
|
||||
|
||||
private recoverWhileStatement::=!(GenericIdentifier|';'|'}')
|
||||
//private recoverWhileStatement::=!(GenericIdentifier|';'|'}')
|
||||
|
||||
ReturnStatement ::= 'return' (Expression)?{
|
||||
pin=1
|
||||
@@ -331,11 +329,14 @@ private QualifiedNamePropertyBinding::= QualifiedPropertyNameReference ':' Bindi
|
||||
PropertyBinding ::= ReferenceIdentifier ':' BindingStatement{
|
||||
pin=2
|
||||
}
|
||||
private WhileIdentifier::=!('}'|GenericIdentifier)
|
||||
//优先尝试表达式解析 {}属于代码块 {name:xx}属于表达式,那么需要预测后面两个token,第二个token不是':'的情况下才是代码块
|
||||
//所以优先判断对象创建判断,然后进行代码块判断,最后进行表达式
|
||||
//代码块分号可选
|
||||
//表达式需要分号结尾
|
||||
BindingStatement ::=ObjectCreationExpressionWithSem|(CodeBlock ';'?)| ExpressionWithSem
|
||||
BindingStatement ::=ObjectCreationExpressionWithSem|(CodeBlock ';'?)| ExpressionWithSem{
|
||||
recoverWhile=WhileIdentifier
|
||||
}
|
||||
//用于错误的直观化
|
||||
private ObjectCreationExpressionWithSem::=ObjectCreationExpression';'{
|
||||
pin=1
|
||||
|
||||
Reference in New Issue
Block a user