seek.qbk 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. [/==============================================================================
  2. Copyright (C) 2001-2011 Joel de Guzman
  3. Copyright (C) 2001-2011 Hartmut Kaiser
  4. Copyright (C) 2011 Jamboree
  5. Distributed under the Boost Software License, Version 1.0. (See accompanying
  6. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. ===============================================================================/]
  8. [section:seek Qi Seek Parser Directive ]
  9. [heading Description]
  10. The `seek[]` parser-directive skips all input until the subject parser matches.
  11. [heading Header]
  12. // forwards to <boost/spirit/repository/home/qi/directive/seek.hpp>
  13. #include <boost/spirit/repository/include/qi_seek.hpp>
  14. Also, see __include_structure__.
  15. [heading Namespace]
  16. [table
  17. [[Name]]
  18. [[`boost::spirit::repository::qi::seek`]]
  19. ]
  20. [heading Model of]
  21. [:__unary_parser_concept__]
  22. [variablelist Notation
  23. [[`a`] [A __parser_concept__.]]
  24. ]
  25. [heading Expression Semantics]
  26. Semantics of an expression is defined only where it differs from, or is
  27. not defined in __unary_parser_concept__.
  28. [table
  29. [[Expression] [Semantics]]
  30. [[`seek[a]`] [Advances until the parser `a` matches.]]
  31. ]
  32. [heading Attributes]
  33. See __qi_comp_attr_notation__.
  34. [table
  35. [[Expression] [Attribute]]
  36. [[`seek[a]`]
  37. [``a: A --> seek[a]: A
  38. a: Unused --> seek[a]: Unused``]]
  39. ]
  40. [heading Complexity]
  41. [:The overall complexity is defined by the complexity of its subject
  42. parser. The complexity of `seek` itself is O(N), where N is the number
  43. of unsuccessful matches.]
  44. [note *seeking sequence with skipping*
  45. Using `seek[a >> b]` with skipping is inefficient, because when sequence fails, the backtracked position is non-skipped.
  46. The solution is to ensure the input will always be pre-skipped, for example:
  47. ``
  48. seek[lexeme[skip[a >> b]]]
  49. ``
  50. does the trick.]
  51. [heading Example]
  52. [import ../../example/qi/seek.cpp]
  53. The following example shows a simple use case of the `seek[]` directive, parsing C-style comment.
  54. (For the full source of the example, see [@../../example/qi/seek.cpp seek.cpp])
  55. Some namespace aliases:
  56. [reference_qi_seek_namespace]
  57. The input string and its iterators:
  58. [reference_qi_seek_vars]
  59. Parsing and showing the result:
  60. [reference_qi_seek_parse]
  61. [endsect]