equal
deleted
inserted
replaced
672 \begin{readmore} |
672 \begin{readmore} |
673 The functions related to positions are implemented in the file |
673 The functions related to positions are implemented in the file |
674 @{ML_file "Pure/General/position.ML"}. |
674 @{ML_file "Pure/General/position.ML"}. |
675 \end{readmore} |
675 \end{readmore} |
676 |
676 |
|
677 \begin{exercise}\label{ex:contextfree} |
|
678 Write a parser for the context-free grammar representing arithmetic |
|
679 expressions with addition and multiplication. As usual, multiplication |
|
680 binds stronger than addition, and both of them nest to the right. |
|
681 The context-free grammar is defined as: |
|
682 |
|
683 \begin{center} |
|
684 \begin{tabular}{lcl} |
|
685 @{text "<Basic>"} & @{text "::="} & @{text "<Number> | (<Expr>)"}\\ |
|
686 @{text "<Factor>"} & @{text "::="} & @{text "<Basic> * <Factor> | <Basic>"}\\ |
|
687 @{text "<Expr>"} & @{text "::="} & @{text "<Factor> + <Expr> | <Factor>"}\\ |
|
688 \end{tabular} |
|
689 \end{center} |
|
690 |
|
691 Hint: Be careful with recursive parsers. |
|
692 \end{exercise} |
677 *} |
693 *} |
678 |
694 |
679 section {* Parsers for ML-Code (TBD) *} |
695 section {* Parsers for ML-Code (TBD) *} |
680 |
696 |
681 text {* |
697 text {* |