tôi biên soạn file bò rừng tạo của tôi trong Visual Studio và có các lỗi này:Vấn đề gọi std :: max
... \ position.hh (83): lỗi C2589: '(': dấu hiệu bất hợp pháp ở bên phải của '::'
... \ position.hh (83): lỗi C2059: lỗi cú pháp: '::'
... \ position.hh (83): lỗi C2589: '(' : dấu hiệu bất hợp pháp trên bên phải của '::'
... \ position.hh (83): lỗi C2059: lỗi cú pháp: '::'
các đồng mã rresponding là:
inline void columns (int count = 1)
{
column = std::max (1u, column + count);
}
Tôi nghĩ rằng vấn đề là với std :: max; nếu tôi thay đổi std :: max thành mã tương đương thì không còn vấn đề gì nữa, nhưng có giải pháp nào tốt hơn thay vì thay đổi mã được tạo không?
Dưới đây là file bò rừng bizon tôi đã viết:
//
// bison.yy
//
%skeleton "lalr1.cc"
%require "2.4.2"
%defines
%define parser_class_name "cmd_parser"
%locations
%debug
%error-verbose
%code requires {
class ParserDriver;
}
%parse-param { ParserDriver& driver }
%lex-param { ParserDriver& driver }
%union {
struct ast *a;
double d;
struct symbol *s;
struct symlist *sl;
int fn;
}
%code {
#include "helper_func.h"
#include "ParserDriver.h"
std::string error_msg = "";
}
%token <d> NUMBER
%token <s> NAME
%token <fn> FUNC
%token EOL
%token IF THEN ELSE WHILE DO LET
%token SYM_TABLE_OVERFLOW
%token UNKNOWN_CHARACTER
%nonassoc <fn> CMP
%right '='
%left '+' '-'
%left '*' '/'
%nonassoc '|' UMINUS
%type <a> exp stmt list explist
%type <sl> symlist
%{
extern int yylex(yy::cmd_parser::semantic_type *yylval,
yy::cmd_parser::location_type* yylloc);
%}
%start calclist
%%
... grammar rules ...