2020-02-25 23:11:52 +08:00
|
|
|
//===-- lib/Parser/debug-parser.h -------------------------------*- C++ -*-===//
|
2018-05-02 03:50:34 +08:00
|
|
|
//
|
2019-12-21 04:52:07 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2018-05-02 03:50:34 +08:00
|
|
|
//
|
2020-01-11 04:12:03 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2018-05-02 03:50:34 +08:00
|
|
|
|
2018-02-17 03:42:17 +08:00
|
|
|
#ifndef FORTRAN_PARSER_DEBUG_PARSER_H_
|
|
|
|
#define FORTRAN_PARSER_DEBUG_PARSER_H_
|
2018-01-31 03:50:59 +08:00
|
|
|
|
|
|
|
// Implements the parser with syntax "(YOUR MESSAGE HERE)"_debug for use
|
|
|
|
// in temporary modifications to the grammar intended for tracing the
|
|
|
|
// flow of the parsers. Not to be used in production.
|
|
|
|
|
|
|
|
#include "basic-parsers.h"
|
2020-02-25 23:11:52 +08:00
|
|
|
#include "flang/Parser/parse-state.h"
|
2018-03-21 01:59:07 +08:00
|
|
|
#include <cstddef>
|
2018-01-31 03:50:59 +08:00
|
|
|
#include <optional>
|
|
|
|
|
2018-05-03 04:48:12 +08:00
|
|
|
namespace Fortran::parser {
|
2018-01-31 03:50:59 +08:00
|
|
|
|
|
|
|
class DebugParser {
|
2018-02-06 04:54:36 +08:00
|
|
|
public:
|
2018-01-31 03:50:59 +08:00
|
|
|
using resultType = Success;
|
|
|
|
constexpr DebugParser(const DebugParser &) = default;
|
2018-03-21 01:59:07 +08:00
|
|
|
constexpr DebugParser(const char *str, std::size_t n)
|
2020-03-29 12:00:16 +08:00
|
|
|
: str_{str}, length_{n} {}
|
2018-04-21 06:56:19 +08:00
|
|
|
std::optional<Success> Parse(ParseState &) const;
|
2018-02-06 06:29:26 +08:00
|
|
|
|
2018-02-06 04:54:36 +08:00
|
|
|
private:
|
2018-01-31 03:50:59 +08:00
|
|
|
const char *const str_;
|
2018-04-20 04:03:23 +08:00
|
|
|
const std::size_t length_;
|
2018-01-31 03:50:59 +08:00
|
|
|
};
|
|
|
|
|
2018-03-21 01:59:07 +08:00
|
|
|
constexpr DebugParser operator""_debug(const char str[], std::size_t n) {
|
2018-01-31 03:50:59 +08:00
|
|
|
return DebugParser{str, n};
|
|
|
|
}
|
2020-03-29 12:00:16 +08:00
|
|
|
} // namespace Fortran::parser
|
|
|
|
#endif // FORTRAN_PARSER_DEBUG_PARSER_H_
|