llvm.org GIT mirror llvm / 99aada9
Remove redundant code block and update comment. By patch zoren here: https://github.com/llvm-mirror/llvm/pull/20 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296968 91177308-0d34-0410-b5e6-96231b3b80d8 Sylvestre Ledru 2 years ago
1 changed file(s) with 1 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
102102
103103 Now that we have the relevant tokens coming from the lexer and we have
104104 the AST node to build, our parsing logic is relatively straightforward.
105 First we define a new parsing function:
106
107 .. code-block:: ocaml
108
109 let rec parse_primary = parser
110 ...
111 (* ifexpr ::= 'if' expr 'then' expr 'else' expr *)
112 | [< 'Token.If; c=parse_expr;
113 'Token.Then ?? "expected 'then'"; t=parse_expr;
114 'Token.Else ?? "expected 'else'"; e=parse_expr >] ->
115 Ast.If (c, t, e)
116
117 Next we hook it up as a primary expression:
105 Next we add a new case for parsing a if-expression as a primary expression:
118106
119107 .. code-block:: ocaml
120108