plcopen 0.22.0
载入中...
搜索中...
未找到
token.h
浏览该文件的文档.
1#pragma once
2
3#include <cstdint>
4#include <string_view>
5
6#include "st/types.h"
7
8namespace plcopen::core::st
9{
10
11enum class TokenKind : std::uint8_t
12{
15
17 int_literal, // decimal or based; value in Token::unsigned_value
18 real_literal, // value in Token::real_value
19 time_literal, // nanoseconds in Token::signed_value
20 bool_literal, // TRUE/FALSE; value in Token::unsigned_value (0/1)
21 typed_literal, // TYPE#... ; type in Token::literal_type (L1a 3.4)
27 located_address, // %I/%Q/%M followed by X/B/W/D/L address
28
29 // punctuation
30 assign, // :=
35 dotdot, // ..
36 hash, // user type qualifier: Type#Member
44 star_star, // ** power operator (L1a 5.2)
46 ampersand, // & (alias of AND)
47 equal, // =
48 not_equal, // <>
53
54 // keywords (subset; unsupported IEC keywords are classified separately)
85
86 // textual SFC (L6)
99
100 // declaration qualifiers
110
111 // type keywords
135
136 // recognized-but-unsupported IEC keyword; payload in Token::diag_code
138};
139
140struct Token
141{
143 std::int32_t line = 1;
144 std::int32_t column = 1;
145 std::string_view text; // slice of the source buffer
146 std::uint64_t unsigned_value = 0; // int/bool literals (magnitude / 0-1)
147 std::int64_t signed_value = 0; // time ns / typed-literal sign marker
148 double real_value = 0.0; // real literals
149 bool based = false; // int literal written in 2#/8#/16#
150 bool real_form = false; // typed literal carries a real payload
151 Type literal_type = Type::bool_; // typed_literal target type
152 std::uint16_t diag_payload = 0; // DiagCode value for error/unsupported
153 bool debug_provenance = false;
154 std::string_view debug_pou;
155 std::string_view debug_call_path;
156 std::int32_t debug_line = 0;
157 std::int32_t debug_column = 0;
158 std::uint16_t debug_call_depth = 0;
159};
160
161} // namespace plcopen::core::st
std::string_view text
std::string_view debug_call_path
std::uint16_t diag_payload
std::uint64_t unsigned_value
std::string_view debug_pou
std::uint16_t debug_call_depth