U E D R , A S I H C RSS

NewCompileError/2014_05_24 (rev. 1.10)

New Compile Error/2014_05_24

LL(1) parser

  • 처음 한 글자를 보고 구분할 수 있어야 함.
  • LL(1) parser에서 불가능한 경우
    • A ::= AB (left recursive가 발생하기 때문에 처리 불가.) elimination 필요.
    • A ::= BC | BD (left common prefix로 첫 글자인 B하나만으로 두 경우의 구분이 불가.) factorization 필요.

Chomsky Hierarchy 참고

< EBNF >
 Expr ::= Term([+|-] Expr)?
 Term ::= Factor ([*|/] Term)?
 Factor :: = (Expr)
           | Value
 Value ::= Integer | Double
s : synthesis
i : inherit
< Synthesis, Inherit >
 Expr  ::= Term
  (s) expr.isDouble = term.isDouble
  (i) term.type = if expr.isDouble then double else int

 Expr1 ::= Term [+-] Expr2
  (s) expr1.isDouble = term.isDouble or expr2.isDouble
  (i) term.type = expr1.isDouble then double else int
  (i) expr2.type = expr1.isDouble then double else int

 Factor ::= (Expr)
  (s) factor.isDouble = expr.isDouble
  (i) expr.type = factor.isDouble then double else int

 Factor ::= Value
  (s) factor.isDouble = value.isDouble
  (i) value.type = factor.isDouble then double else int

 Value :: Decimal Integer
  (s) value.isDouble = false
  (i) value.type = value.type == double then double else int

 Value :: Double
  (s) value.isDouble = true
  (i) value.type = value.type == double then double else int
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:51
Processing time 0.0166 sec