Я работаю с Flex/Bison, чтобы создать интерпретатора для класса. Проблема, с которой я сталкиваюсь, по -видимому, связана с использованием/преобразованием динамического вектора. Я пытаюсь создать функцию для оценки сгибающих операций, но я попал в контрольно -пропускной пункт. Тип списка указан как динамический вектор, чтобы разрешить любое количество аргументов, чтобы быть передано ему. < /P>
%union {
CharPtr iden;
Operators oper;
double value;
vector* list;
}
< /code>
%type list expressions list_choice
< /code>
The bison direction is to pass the direction of the fold, the operator for the fold, and the dynamic vector to the function evaulateFold().
FOLD direction operator list_choice ENDFOLD SEMICOLON {$$ = evaluateFold($2, $3, $4);}
< /code>
Once I get it to this point, I cannot do anything with the dynamic array. I tried to copy it to a regular array using for loops but it says that there is no start point reference for the dynamic array this range-based 'for' statement requires a suitable "begin" function and none was foundC/C++(2291). Я попытался перенести массив, чтобы оценить destfold () с помощью,const std::vector& Значения, но затем говорится, что нет способа преобразовать std :: vector * в std :: vector & `` `Не существует подходящего конструктора для преобразования из" std: : Vector *"to" std :: vector & "C/c ++ (415) . Как я должен иметь возможность использовать этот массив для функции? < /P>
double evaluateFold(Operators direction, Operators action, vector* values){
double result = 0;
switch(direction){
case LFOLD:
switch(action){
case SUBTRACT:
subFromLeft(values);
for (auto i : values)
cout
If anybody could help me resolve this, or at least point me in the right direction, that would be awesome. It is more a question of C++ than flex/bison, but maybe there is some trick in flex/bison that I am not aware of that will help me.
Make generates this:
parser.y: In function ‘int yyparse()’: parser.y:127:146: error: invalid initialization of reference of type ‘std::vector&’ from expression of type ‘std::vector*’
< /code>
In file included from parser.y:21: values.h:18:76: note: in passing argument 3 of ‘double evaluateFold(Operators, Operators, std::vector&)’
< /code>
Below is a sample of what the fold function would interpret/evaluate.
// Test Left Fold
function main returns integer;
begin
fold left - (3, 2, 1) endfold;
end;
Подробнее здесь: https://stackoverflow.com/questions/794 ... operations
Как манипулировать этим динамическим вектором для сгиба ⇐ C++
Программы на C++. Форум разработчиков
-
Anonymous
1740069594
Anonymous
Я работаю с Flex/Bison, чтобы создать интерпретатора для класса. Проблема, с которой я сталкиваюсь, по -видимому, связана с использованием/преобразованием динамического вектора. Я пытаюсь создать функцию для оценки сгибающих операций, но я попал в контрольно -пропускной пункт. Тип списка указан как динамический вектор, чтобы разрешить любое количество аргументов, чтобы быть передано ему. < /P>
%union {
CharPtr iden;
Operators oper;
double value;
vector* list;
}
< /code>
%type list expressions list_choice
< /code>
The bison direction is to pass the direction of the fold, the operator for the fold, and the dynamic vector to the function evaulateFold().
FOLD direction operator list_choice ENDFOLD SEMICOLON {$$ = evaluateFold($2, $3, $4);}
< /code>
Once I get it to this point, I cannot do anything with the dynamic array. I tried to copy it to a regular array using for loops but it says that there is no start point reference for the dynamic array this range-based 'for' statement requires a suitable "begin" function and none was foundC/C++(2291). Я попытался перенести массив, чтобы оценить destfold () с помощью,const std::vector& Значения, но затем говорится, что нет способа преобразовать std :: vector * в std :: vector & `` `Не существует подходящего конструктора для преобразования из" std: : Vector *"to" std :: vector & "C/c ++ (415) . Как я должен иметь возможность использовать этот массив для функции? < /P>
double evaluateFold(Operators direction, Operators action, vector* values){
double result = 0;
switch(direction){
case LFOLD:
switch(action){
case SUBTRACT:
subFromLeft(values);
for (auto i : values)
cout
If anybody could help me resolve this, or at least point me in the right direction, that would be awesome. It is more a question of C++ than flex/bison, but maybe there is some trick in flex/bison that I am not aware of that will help me.
Make generates this:
parser.y: In function ‘int yyparse()’: parser.y:127:146: error: invalid initialization of reference of type ‘std::vector&’ from expression of type ‘std::vector*’
< /code>
In file included from parser.y:21: values.h:18:76: note: in passing argument 3 of ‘double evaluateFold(Operators, Operators, std::vector&)’
< /code>
Below is a sample of what the fold function would interpret/evaluate.
// Test Left Fold
function main returns integer;
begin
fold left - (3, 2, 1) endfold;
end;
Подробнее здесь: [url]https://stackoverflow.com/questions/79455122/how-do-i-manipulate-this-dynamic-vector-for-fold-operations[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия