P4C
The P4 Compiler
Loading...
Searching...
No Matches
constantParsing.h
1/*
2Copyright 2013-present Barefoot Networks, Inc.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17#ifndef FRONTENDS_COMMON_CONSTANTPARSING_H_
18#define FRONTENDS_COMMON_CONSTANTPARSING_H_
19
20#include "lib/cstring.h"
21
22namespace P4::IR {
23class Constant;
24} // namespace P4::IR
25
26namespace P4::Util {
27class SourceInfo;
28} // namespace P4::Util
29
30namespace P4 {
31
66 cstring text;
67 unsigned skip;
68 unsigned base;
69 bool hasWidth;
70};
71
72std::ostream &operator<<(std::ostream &out, const UnparsedConstant &constant);
73
74bool operator<(const UnparsedConstant &a, const UnparsedConstant &b);
75
84IR::Constant *parseConstant(const Util::SourceInfo &srcInfo, const UnparsedConstant &constant,
85 long defaultValue);
86
91int parseConstantChecked(const Util::SourceInfo &srcInfo, const UnparsedConstant &constant);
92
93} // namespace P4
94
95#endif /* FRONTENDS_COMMON_CONSTANTPARSING_H_ */
Definition source_file.h:131
Definition cstring.h:85
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
unsigned base
An ignored prefix of the numeric constant (e.g. '0x').
Definition constantParsing.h:68
IR::Constant * parseConstant(const Util::SourceInfo &srcInfo, const UnparsedConstant &constant, long defaultValue)
Definition constantParsing.cpp:63
unsigned skip
Raw P4 text which was recognized as a numeric constant.
Definition constantParsing.h:67
bool hasWidth
The base in which the constant is expressed.
Definition constantParsing.h:69
int parseConstantChecked(const Util::SourceInfo &srcInfo, const UnparsedConstant &constant)
Definition constantParsing.cpp:76
Definition constantParsing.h:65