我正在尝试解析一个包含一些特殊单词和整数的字符串。 让特殊词成为“HHH”。需要在它之前跳过数据并在之后解析数据。这是我的尝试:
#include <iostream>
#include <boost/spirit/include/qi.hpp>
namespace qi = boost::spirit::qi;
int main ()
{
std::string input = "asd eee rrr HHH 456";
std::string::iterator strbegin = input.begin();
int result;
bool ok = qi::phrase_parse(
strbegin, input.end(),
(*(qi::char_ - qi::lit("HHH")) >> qi::lit("HHH") >> qi::int_),
qi::space,
result);
std::cout << ok << std::endl;
std::cout << result << std::endl;
}
我收到此错误消息:
main.cpp:14: instantiated from here
/usr/include/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp:454: error: no matching function for call to mpl_::void_::void_(int)
/usr/include/boost/mpl/void.hpp:29: note: candidates are: mpl_::void_::void_()
/usr/include/boost/mpl/void.hpp:29: note: mpl_::void_::void_(const mpl_::void_&)
/usr/include/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp: In static member function static bool boost::spirit::qi::detail::extract_int<T, Radix, 1u, -0x00000000000000001, Accumulator, Accumulate>::parse_main(Iterator&, const Iterator&, Attribute&) [with Iterator = __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Attribute = mpl_::void_, T = int, unsigned int Radix = 10u, Accumulator = boost::spirit::qi::detail::positive_accumulator<10u>, bool Accumulate = false]:
/usr/include/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp:501: instantiated from static bool boost::spirit::qi::detail::extract_int<T, Radix, 1u, -0x00000000000000001, Accumulator, Accumulate>::parse(Iterator&, const Iterator&, Attribute&) [with Iterator = __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Attribute = mpl_::void_, T = int, unsigned int Radix = 10u, Accumulator = boost::spirit::qi::detail::positive_accumulator<10u>, bool Accumulate = false]
/usr/include/boost/spirit/home/qi/numeric/numeric_utils.hpp:108: instantiated from static bool boost::spirit::qi::extract_int<T, Radix, MinDigits, MaxDigits>::call(Iterator&, const Iterator&, Attribute&) [with Iterator = __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Attribute = mpl_::void_, T = int, unsigned int Radix = 10u, unsigned int MinDigits = 1u, int MaxDigits = -0x00000000000000001]
/usr/include/boost/spirit/home/qi/numeric/int.hpp:98: instantiated from bool boost::spirit::qi::int_parser_impl<T, Radix, MinDigits, MaxDigits>::parse(Iterator&, const Iterator&, Context&, const Skipper&, Attribute&) const [with Iterator = __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Context = const boost::fusion::unused_type, Skipper = boost::spirit::qi::char_class<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::standard> >, Attribute = mpl_::void_, T = int, unsigned int Radix = 10u, unsigned int MinDigits = 1u, int MaxDigits = -0x00000000000000001]
/usr/include/boost/spirit/home/qi/detail/fail_function.hpp:38: instantiated from bool boost::spirit::qi::detail::fail_function<Iterator, Context, Skipper>::operator()(const Component&, Attribute&) const [with Component = boost::spirit::qi::int_parser_impl<int, 10u, 1u, -0x00000000000000001>, Attribute = mpl_::void_, Iterator = __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Context = const boost::fusion::unused_type, Skipper = boost::spirit::qi::char_class<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::standard> >]
/usr/include/boost/spirit/home/support/algorithm/any_if.hpp:171: instantiated from bool boost::spirit::detail::any_if(const First1&, const First2&, const Last&, F&, mpl_::false_) [with Pred = boost::spirit::traits::attribute_not_unused<const boost::fusion::unused_type, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, First1 = boost::fusion::cons_iterator<const boost::fusion::cons<boost::spirit::qi::int_parser_impl<int, 10u, 1u, -0x00000000000000001>, boost::fusion::nil> >, Last = boost::fusion::cons_iterator<const boost::fusion::nil>, First2 = boost::fusion::vector_iterator<boost::fusion::vector1<int&>, 1>, F = boost::spirit::qi::detail::fail_function<__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, const boost::fusion::unused_type, boost::spirit::qi::char_class<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::standard> > >]
/usr/include/boost/spirit/home/support/algorithm/any_if.hpp:171: instantiated from bool boost::spirit::detail::any_if(const First1&, const First2&, const Last&, F&, mpl_::false_) [with Pred = boost::spirit::traits::attribute_not_unused<const boost::fusion::unused_type, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, First1 = boost::fusion::cons_iterator<const boost::fusion::cons<boost::spirit::qi::literal_string<const char (&)[4], true>, boost::fusion::cons<boost::spirit::qi::int_parser_impl<int, 10u, 1u, -0x00000000000000001>, boost::fusion::nil> > >, Last = boost::fusion::cons_iterator<const boost::fusion::nil>, First2 = boost::fusion::vector_iterator<boost::fusion::vector1<int&>, 1>, F = boost::spirit::qi::detail::fail_function<__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, const boost::fusion::unused_type, boost::spirit::qi::char_class<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::standard> > >]
/usr/include/boost/spirit/home/support/algorithm/any_if.hpp:171: instantiated from bool boost::spirit::detail::any_if(const First1&, const First2&, const Last&, F&, mpl_::false_) [with Pred = boost::spirit::traits::attribute_not_unused<const boost::fusion::unused_type, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, First1 = boost::fusion::cons_iterator<const boost::fusion::cons<boost::spirit::qi::kleene<boost::spirit::qi::difference<boost::spirit::qi::char_class<boost::spirit::tag::char_code<boost::spirit::tag::char_, boost::spirit::char_encoding::standard> >, boost::spirit::qi::literal_string<const char (&)[4], true> > >, boost::fusion::cons<boost::spirit::qi::literal_string<const char (&)[4], true>, boost::fusion::cons<boost::spirit::qi::int_parser_impl<int, 10u, 1u, -0x00000000000000001>, boost::fusion::nil> > > >, Last = boost::fusion::cons_iterator<const boost::fusion::nil>, First2 = boost::fusion::vector_iterator<boost::fusion::vector1<int&>, 0>, F = boost::spirit::qi::detail::fail_function<__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, const boost::fusion::unused_type, boost::spirit::qi::char_class<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::standard> > >]
/usr/include/boost/spirit/home/support/algorithm/any_if.hpp:186: instantiated from bool boost::spirit::any_if(const Sequence1&, Sequence2&, F, Pred) [with Pred = boost::spirit::traits::attribute_not_unused<const boost::fusion::unused_type, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, Sequence1 = boost::fusion::cons<boost::spirit::qi::kleene<boost::spirit::qi::difference<boost::spirit::qi::char_class<boost::spirit::tag::char_code<boost::spirit::tag::char_, boost::spirit::char_encoding::standard> >, boost::spirit::qi::literal_string<const char (&)[4], true> > >, boost::fusion::cons<boost::spirit::qi::literal_string<const char (&)[4], true>, boost::fusion::cons<boost::spirit::qi::int_parser_impl<int, 10u, 1u, -0x00000000000000001>, boost::fusion::nil> > >, Sequence2 = boost::fusion::vector1<int&>, F = boost::spirit::qi::detail::fail_function<__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, const boost::fusion::unused_type, boost::spirit::qi::char_class<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::standard> > >]
/usr/include/boost/spirit/home/qi/operator/sequence_base.hpp:81: instantiated from bool boost::spirit::qi::sequence_base<Derived, Elements>::parse_impl(Iterator&, const Iterator&, Context&, const Skipper&, Attribute&, mpl_::false_) const [with Iterator = __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Context = const boost::fusion::unused_type, Skipper = boost::spirit::qi::char_class<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::standard> >, Attribute = int, Derived = boost::spirit::qi::sequence<boost::fusion::cons<boost::spirit::qi::kleene<boost::spirit::qi::difference<boost::spirit::qi::char_class<boost::spirit::tag::char_code<boost::spirit::tag::char_, boost::spirit::char_encoding::standard> >, boost::spirit::qi::literal_string<const char (&)[4], true> > >, boost::fusion::cons<boost::spirit::qi::literal_string<const char (&)[4], true>, boost::fusion::cons<boost::spirit::qi::int_parser_impl<int, 10u, 1u, -0x00000000000000001>, boost::fusion::nil> > > >, Elements = boost::fusion::cons<boost::spirit::qi::kleene<boost::spirit::qi::difference<boost::spirit::qi::char_class<boost::spirit::tag::char_code<boost::spirit::tag::char_, boost::spirit::char_encoding::standard> >, boost::spirit::qi::literal_string<const char (&)[4], true> > >, boost::fusion::cons<boost::spirit::qi::literal_string<const char (&)[4], true>, boost::fusion::cons<boost::spirit::qi::int_parser_impl<int, 10u, 1u, -0x00000000000000001>, boost::fusion::nil> > >]
/usr/include/boost/spirit/home/qi/operator/sequence_base.hpp:115: instantiated from bool boost::spirit::qi::sequence_base<Derived, Elements>::parse(Iterator&, const Iterator&, Context&, const Skipper&, Attribute&) const [with Iterator = __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Context = const boost::fusion::unused_type, Skipper = boost::spirit::qi::phrase_parse(Iterator&, Iterator, const Expr&, const Skipper&, boost::spirit::qi::skip_flag::enum_t, Attr&) [with Iterator = __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Expr = boost::proto::exprns_::expr<boost::proto::tag::shift_right, boost::proto::argsns_::list2<const boost::proto::exprns_::expr<boost::proto::tag::shift_right, boost::proto::argsns_::list2<const boost::proto::exprns_::expr<boost::proto::tag::dereference, boost::proto::argsns_::list1<const boost::proto::exprns_::expr<boost::proto::tag::minus, boost::proto::argsns_::list2<const boost::spirit::terminal<boost::spirit::tag::char_code<boost::spirit::tag::char_, boost::spirit::char_encoding::standard> >&, const boost::proto::utility::literal<const char (&)[4], boost::proto::domainns_::default_domain>&>, 2l>&>, 1l>&, const boost::proto::utility::literal<const char (&)[4], boost::proto::domainns_::default_domain>&>, 2l>&, const boost::spirit::terminal<boost::spirit::tag::int_>&>, 2l>, Skipper = boost::proto::exprns_::expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::standard> >, 0l>, Attr = int]::skipper_type, Attribute = int, Derived = boost::spirit::qi::sequence<boost::fusion::cons<boost::spirit::qi::kleene<boost::spirit::qi::difference<boost::spirit::qi::char_class<boost::spirit::tag::char_code<boost::spirit::tag::char_, boost::spirit::char_encoding::standard> >, boost::spirit::qi::literal_string<const char (&)[4], true> > >, boost::fusion::cons<boost::spirit::qi::literal_string<const char (&)[4], true>, boost::fusion::cons<boost::spirit::qi::int_parser_impl<int, 10u, 1u, -0x00000000000000001>, boost::fusion::nil> > > >, Elements = boost::fusion::cons<boost::spirit::qi::kleene<boost::spirit::qi::difference<boost::spirit::qi::char_class<boost::spirit::tag::char_code<boost::spirit::tag::char_, boost::spirit::char_encoding::standard> >, boost::spirit::qi::literal_string<const char (&)[4], true> > >, boost::fusion::cons<boost::spirit::qi::literal_string<const char (&)[4], true>, boost::fusion::cons<boost::spirit::qi::int_parser_impl<int, 10u, 1u, -0x00000000000000001>, boost::fusion::nil> > >]
/usr/include/boost/spirit/home/qi/parse.hpp:114: instantiated from bool boost::spirit::qi::phrase_parse(Iterator&, Iterator, const Expr&, const Skipper&, boost::spirit::qi::skip_flag::enum_t, Attr&) [with Iterator = __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Expr = boost::proto::exprns_::expr<boost::proto::tag::shift_right, boost::proto::argsns_::list2<const boost::proto::exprns_::expr<boost::proto::tag::shift_right, boost::proto::argsns_::list2<const boost::proto::exprns_::expr<boost::proto::tag::dereference, boost::proto::argsns_::list1<const boost::proto::exprns_::expr<boost::proto::tag::minus, boost::proto::argsns_::list2<const boost::spirit::terminal<boost::spirit::tag::char_code<boost::spirit::tag::char_, boost::spirit::char_encoding::standard> >&, const boost::proto::utility::literal<const char (&)[4], boost::proto::domainns_::default_domain>&>, 2l>&>, 1l>&, const boost::proto::utility::literal<const char (&)[4], boost::proto::domainns_::default_domain>&>, 2l>&, const boost::spirit::terminal<boost::spirit::tag::int_>&>, 2l>, Skipper = boost::proto::exprns_::expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::standard> >, 0l>, Attr = int]
/usr/include/boost/spirit/home/qi/parse.hpp:132: instantiated from bool boost::spirit::qi::phrase_parse(Iterator&, Iterator, const Expr&, const Skipper&, Attr&) [with Iterator = __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Expr = boost::proto::exprns_::expr<boost::proto::tag::shift_right, boost::proto::argsns_::list2<const boost::proto::exprns_::expr<boost::proto::tag::shift_right, boost::proto::argsns_::list2<const boost::proto::exprns_::expr<boost::proto::tag::dereference, boost::proto::argsns_::list1<const boost::proto::exprns_::expr<boost::proto::tag::minus, boost::proto::argsns_::list2<const boost::spirit::terminal<boost::spirit::tag::char_code<boost::spirit::tag::char_, boost::spirit::char_encoding::standard> >&, const boost::proto::utility::literal<const char (&)[4], boost::proto::domainns_::default_domain>&>, 2l>&>, 1l>&, const boost::proto::utility::literal<const char (&)[4], boost::proto::domainns_::default_domain>&>, 2l>&, const boost::spirit::terminal<boost::spirit::tag::int_>&>, 2l>, Skipper = boost::spirit::standard::space_type, Attr = int]
main.cpp:14: instantiated from here
/usr/include/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp:454: error: no matching function for call to mpl_::void_::void_(int)
/usr/include/boost/mpl/void.hpp:29: note: candidates are: mpl_::void_::void_()
/usr/include/boost/mpl/void.hpp:29: note: mpl_::void_::void_(const mpl_::void_&)
In file included from /usr/include/boost/spirit/home/qi/auxiliary/attr.hpp:18,
from /usr/include/boost/spirit/home/qi/auxiliary.hpp:19,
from /usr/include/boost/spirit/home/qi.hpp:15,
from /usr/include/boost/spirit/include/qi.hpp:16,
from main.cpp:2:
/usr/include/boost/spirit/home/qi/detail/assign_to.hpp: In static member function static void boost::spirit::traits::assign_to_attribute_from_value<Attribute, T, Enable>::call(const T&, Attribute&) [with Attribute = mpl_::void_, T = int, Enable = void]:
/usr/include/boost/spirit/home/qi/detail/assign_to.hpp:99: instantiated from void boost::spirit::traits::assign_to(const T&, Attribute&) [with T = int, Attribute = mpl_::void_]
/usr/include/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp:448: instantiated from static bool boost::spirit::qi::detail::extract_int<T, Radix, 1u, -0x00000000000000001, Accumulator, Accumulate>::parse_main(Iterator&, const Iterator&, Attribute&) [with Iterator = __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Attribute = mpl_::void_, T = int, unsigned int Radix = 10u, Accumulator = boost::spirit::qi::detail::negative_accumulator<10u>, bool Accumulate = false]
/usr/include/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp:501: instantiated from static bool boost::spirit::qi::detail::extract_int<T, Radix, 1u, -0x00000000000000001, Accumulator, Accumulate>::parse(Iterator&, const Iterator&, Attribute&) [with Iterator = __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Attribute = mpl_::void_, T = int, unsigned int Radix = 10u, Accumulator = boost::spirit::qi::detail::negative_accumulator<10u>, bool Accumulate = false]
/usr/include/boost/spirit/home/qi/numeric/numeric_utils.hpp:106: instantiated from static bool boost::spirit::qi::extract_int<T, Radix, MinDigits, MaxDigits>::call(Iterator&, const Iterator&, Attribute&) [with Iterator = __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Attribute = mpl_::void_, T = int, unsigned int Radix = 10u, unsigned int MinDigits = 1u, int MaxDigits = -0x00000000000000001]
/usr/include/boost/spirit/home/qi/numeric/int.hpp:98: instantiated from bool boost::spirit::qi::int_parser_impl<T, Radix, MinDigits, MaxDigits>::parse(Iterator&, const Iterator&, Context&, const Skipper&, Attribute&) const [with Iterator = __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Context = const boost::fusion::unused_type, Skipper = boost::spirit::qi::char_class<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::standard> >, Attribute = mpl_::void_, T = int, unsigned int Radix = 10u, unsigned int MinDigits = 1u, int MaxDigits = -0x00000000000000001]
/usr/include/boost/spirit/home/qi/detail/fail_function.hpp:38: instantiated from bool boost::spirit::qi::detail::fail_function<Iterator, Context, Skipper>::operator()(const Component&, Attribute&) const [with Component = boost::spirit::qi::int_parser_impl<int, 10u, 1u, -0x00000000000000001>, Attribute = mpl_::void_, Iterator = __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Context = const boost::fusion::unused_type, Skipper = boost::spirit::qi::char_class<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::standard> >]
/usr/include/boost/spirit/home/support/algorithm/any_if.hpp:171: instantiated from bool boost::spirit::detail::any_if(const First1&, const First2&, const Last&, F&, mpl_::false_) [with Pred = boost::spirit::traits::attribute_not_unused<const boost::fusion::unused_type, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, First1 = boost::fusion::cons_iterator<const boost::fusion::cons<boost::spirit::qi::int_parser_impl<int, 10u, 1u, -0x00000000000000001>, boost::fusion::nil> >, Last = boost::fusion::cons_iterator<const boost::fusion::nil>, First2 = boost::fusion::vector_iterator<boost::fusion::vector1<int&>, 1>, F = boost::spirit::qi::detail::fail_function<__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, const boost::fusion::unused_type, boost::spirit::qi::char_class<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::standard> > >]
/usr/include/boost/spirit/home/support/algorithm/any_if.hpp:171: instantiated from bool boost::spirit::detail::any_if(const First1&, const First2&, const Last&, F&, mpl_::false_) [with Pred = boost::spirit::traits::attribute_not_unused<const boost::fusion::unused_type, __gnu_cxx::__normal_iterator<
答案 0 :(得分:5)
初始问题中的语法可以分解为具有以下属性:
(*(qi::char_ - qi::lit("HHH")) >> qi::lit("HHH") >> qi::int_)
~~~~~~~~~~ string ~~~~~~~~~~~~ ~~~ unused ~~~ ~~ int ~~
如果您不需要string
属性的结果,则omit[]
解析指令可用于忽略解析器的属性。例如,以下使用omit[]
忽略上面的string
属性,从而生成仅提供int
属性的解析器。
(qi::omit[*(qi::char_ - qi::lit("HHH"))] >> qi::lit("HHH") >> qi::int_)
~~~~~~~~~~~~~~~~ unused ~~~~~~~~~~~~~~~~ ~~~ unused ~~~ ~~ int ~~
以下是基于原始代码的完整example:
#include <iostream>
#include <boost/spirit/include/qi.hpp>
namespace qi = boost::spirit::qi;
int main ()
{
std::string input = "asd eee rrr HHH 456";
std::string::iterator strbegin = input.begin();
int result;
bool ok = qi::phrase_parse(
strbegin, input.end(),
(qi::omit[*(qi::char_ - qi::lit("HHH"))] >> qi::lit("HHH")
>> qi::int_),
qi::space,
result);
std::cout << ok << std::endl;
std::cout << result << std::endl;
}
产生以下输出:
1
456
答案 1 :(得分:1)
此处的错误是您提供的规则会解析为string
和int
。我为实现这一目标所做的最小改变是:
#include <iostream>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix.hpp>
using namespace boost::spirit;
int main ()
{
std::string input = "asd eee rrr HHH 456";
std::string::iterator strbegin = input.begin();
int result;
qi::rule<std::string::iterator,int(),qi::space_type> rule =
(*(qi::char_ - qi::lit("HHH")) >> qi::lit("HHH") >> qi::int_[_val = _1]);
bool ok =
qi::phrase_parse(strbegin, input.end(),
rule,
qi::space,
result);
std::cout << ok << std::endl;
std::cout << result << std::endl;
}
在这里,构建一个规则对象,我指定我想从中输出int
,并告诉它通过语义动作分配这个值的位置。