2018-05-01 21:50:34 +02:00
|
|
|
// Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2018-02-16 20:42:17 +01:00
|
|
|
#ifndef FORTRAN_PARSER_DEBUG_PARSER_H_
|
|
|
|
#define FORTRAN_PARSER_DEBUG_PARSER_H_
|
2018-01-30 20:50:59 +01: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"
|
|
|
|
#include "parse-state.h"
|
2018-03-20 18:59:07 +01:00
|
|
|
#include <cstddef>
|
2018-01-30 20:50:59 +01:00
|
|
|
#include <optional>
|
|
|
|
|
2018-05-02 22:48:12 +02:00
|
|
|
namespace Fortran::parser {
|
2018-01-30 20:50:59 +01:00
|
|
|
|
|
|
|
class DebugParser {
|
2018-02-05 21:54:36 +01:00
|
|
|
public:
|
2018-01-30 20:50:59 +01:00
|
|
|
using resultType = Success;
|
|
|
|
constexpr DebugParser(const DebugParser &) = default;
|
2018-03-20 18:59:07 +01:00
|
|
|
constexpr DebugParser(const char *str, std::size_t n)
|
|
|
|
: str_{str}, length_{n} {}
|
2018-04-21 00:56:19 +02:00
|
|
|
std::optional<Success> Parse(ParseState &) const;
|
2018-02-05 23:29:26 +01:00
|
|
|
|
2018-02-05 21:54:36 +01:00
|
|
|
private:
|
2018-01-30 20:50:59 +01:00
|
|
|
const char *const str_;
|
2018-04-19 22:03:23 +02:00
|
|
|
const std::size_t length_;
|
2018-01-30 20:50:59 +01:00
|
|
|
};
|
|
|
|
|
2018-03-20 18:59:07 +01:00
|
|
|
constexpr DebugParser operator""_debug(const char str[], std::size_t n) {
|
2018-01-30 20:50:59 +01:00
|
|
|
return DebugParser{str, n};
|
|
|
|
}
|
2018-10-25 14:55:23 +02:00
|
|
|
}
|
2018-02-16 20:42:17 +01:00
|
|
|
#endif // FORTRAN_PARSER_DEBUG_PARSER_H_
|