2013-03-20 3 views
2

PetitParser의 규칙이 배포됩니까?PetitParser가 배포되지 않았습니까?

integerLiteral --> (hexIntegerLiteral/octalIntegerLiteral/decimalIntegerLiteral) , (integerTypeSuffix optional) 
    hexIntegerLiteral  --> hexNumeral 
    octalIntegerLiteral --> octalNumeral 
    decimalIntegerLiteral --> decimalNumeral 

다음 0777L 더 이상 분석되지 않은 : 나는 그들을 변경하는 경우

integerLiteral --> hexIntegerLiteral/octalIntegerLiteral/decimalIntegerLiteral 
    hexIntegerLiteral  --> hexNumeral , (integerTypeSuffix optional) 
    octalIntegerLiteral --> octalNumeral , (integerTypeSuffix optional) 
    decimalIntegerLiteral --> decimalNumeral , (integerTypeSuffix optional) 

:

다음 규칙이 있었다. octalNumeral , (integerTypeSuffix optional) 또는 새 버전 octalIntegerLiteral , (integerTypeSuffix optional)과 일치해야하지만 그렇게되지는 않습니다.

답변

3

예, PetitParser의 주문형 제품은 분산 형입니다. 귀하의 예에서 일부 문맥이 누락되어 있으므로 왜 그것이 당신을 위해 작동하지 않습니다 모르겠어요.

PetitParser 최적화 도구가 자동으로 제안한 변경을 수행합니다. 약간 더 일반적인 형식의 다시 쓰기 규칙은 다음과 같이 정의됩니다.

PPOptimizer>>#postfixChoice 
    <optimize> 

    | before prefix body1 body2 postfix after | 
    before := PPListPattern any. 
    prefix := PPPattern any. 
    body1 := PPListPattern any. 
    body2 := PPListPattern any. 
    postfix := PPPattern any. 
    after := PPListPattern any. 
    rewriter 
     replace: before/(prefix , body1)/(prefix , body2)/after 
     with: before/(prefix , (body1/body2))/after. 
    rewriter 
     replace: before/(body1 , postfix)/(body2 , postfix)/after 
     with: before/((body1/body2) , postfix)/after 
관련 문제