• Home
  • Raw
  • Download

Lines Matching +full:turing +full:- +full:complete

20 `Operator-Precedence
21 Parsing <http://en.wikipedia.org/wiki/Operator-precedence_parser>`_ to
36 .. code-block:: c++
38 /// ExprAST - Base class for all expression nodes.
44 /// NumberExprAST - Expression class for numeric literals like "1.0".
64 .. code-block:: c++
66 /// VariableExprAST - Expression class for referencing a variable, like "a".
74 /// BinaryExprAST - Expression class for a binary operator.
85 /// CallExprAST - Expression class for function calls.
96 This is all (intentionally) rather straight-forward: variables capture
106 Turing-complete; we'll fix that in a later installment. The two things
110 .. code-block:: c++
112 /// PrototypeAST - This class represents the "prototype" for a function,
124 /// FunctionAST - This class represents a function definition itself.
152 .. code-block:: c++
161 .. code-block:: c++
163 /// CurTok/getNextToken - Provide a simple token buffer. CurTok is the current
176 .. code-block:: c++
179 /// LogError* - These are little helper functions for error handling.
191 best and is not particular user-friendly, but it will be enough for our
205 .. code-block:: c++
226 .. code-block:: c++
264 .. code-block:: c++
305 that it uses *look-ahead* to determine if the current identifier is a
311 Now that we have all of our simple expression-parsing logic in place, we
315 tutorial <LangImpl6.html#user-defined-unary-operators>`_. In order to parse an arbitrary
318 .. code-block:: c++
339 look-ahead to determine which sort of expression is being inspected, and
355 to use `Operator-Precedence
356 Parsing <http://en.wikipedia.org/wiki/Operator-precedence_parser>`_.
360 .. code-block:: c++
362 /// BinopPrecedence - This holds the precedence for each binary operator that is
366 /// GetTokPrecedence - Get the precedence of the pending binary operator token.
369 return -1;
373 if (TokPrec <= 0) return -1;
382 BinopPrecedence['-'] = 20;
390 the current token, or -1 if the token is not a binary operator. Having a
394 ``GetTokPrecedence`` function. (Or just use a fixed-size array).
410 .. code-block:: c++
438 .. code-block:: c++
455 -1, this check implicitly knows that the pair-stream ends when the token
460 .. code-block:: c++
475 Now that we parsed the left-hand side of an expression and one pair of
482 .. code-block:: c++
496 .. code-block:: c++
521 .. code-block:: c++
549 non-trivial lines), we correctly handle fully general binary expression
565 straight-forward and not very interesting (once you've survived
568 .. code-block:: c++
598 .. code-block:: c++
615 .. code-block:: c++
623 Finally, we'll also let the user type in arbitrary top-level expressions
627 .. code-block:: c++
646 top-level dispatch loop. There isn't much interesting here, so I'll just
647 include the top-level loop. See `below <#full-code-listing>`_ for full code in the
648 "Top-Level Parsing" section.
650 .. code-block:: c++
659 case ';': // ignore top-level semicolons.
675 The most interesting part of this is that we ignore top-level
679 could type "def foo..." in which case 4+5 is the end of a top-level
681 the expression. Having top-level semicolons allows you to type "4+5;",
687 With just under 400 lines of commented code (240 lines of non-comment,
688 non-blank code), we fully defined our minimal language, including a
693 .. code-block:: bash
700 Parsed a top-level expr
717 Here is the complete code listing for this and the previous chapter.
718 Note that it is fully self-contained: you don't need LLVM or any
722 .. code-block:: bash
725 clang++ -g -O3 toy.cpp