Giter Club home page Giter Club logo

cxx2flow's Issues

不支持函数递归调用

目前不支持函数递归调用,希望能够完善增强一下,谢谢!

#include <bits/stdc++.h>
using namespace std;

int f(int n) {
if (n <= 2) return n;
return f(n - 1) + f(n - 2);
}

int main() {
int n, ans = 0;
cin >> n;
ans = f(n);
cout << ans << endl;
return 0;
}

命令行模式处理 if-else语句报错

您好,
命令行处理下面的代码报错“unexpected dumy ast node”,但是用图形界面gui软件就可以识别if-else语句,麻烦大神修复一下命令行的问题,谢谢!

`#include
using namespace std;

int main(){
int a = 10, b = 5;
if(a > b) {
cout << "ok";
} else {
cout << "bad";
}
return 0;
}`

1699423362166

333

dummy ast node error

The following code,

#include <stdio.h>

static void a(void)
{
	printf("a\n");
}

static void b(void)
{
	printf("b\n");
}

static void x(int y)
{
	if (y > 0) {
		return a();
	} else {
		return b();
	}
}

int main(void)
{
	int y;
	scanf("%d", &y);

	x(y);
}

With the following parameters,

cxx2flow test.c x | dot -Tpng -o test.png

Results in this output,

Error: cxx2flow::unexpected_dummy_ast

  × unexpected dummy ast node
    ╭─[test.c:15:1]
 15 │             return a();
 16 │ ╭─▶     } else {
 17 │ │           return b();
 18 │ ├─▶     }
    · ╰──── dummy ast node here
 19 │     }
    ╰────
  help: dummy node found in the ast
        this might be a bug, please report it to the author

解析cpp文件 执行报错 target_function_not_found

          你好,我遇到一个问题

执行
cxx2flow --cpp -c src/auto.cpp autonomous_driving_decision
报错:
20 errors generated.
Error: cxx2flow::target_function_not_found

× target function not found
╭────
1 │ autonomous_driving_decision
· ─────────────┬─────────────
· ╰── this is the name of your target function
╰────
help: maybe you have a typo, or source code is incomplete,
please check your input

源文件:
#include <stdbool.h>
#include <stdio.h>

// 定义车辆状态枚举类型
typedef enum
{
NORMAL,
EMERGENCY_BRAKE,
MAINTAIN_SPEED,
SLOW_DOWN,
STOP
} VehicleState;

// 定义传感器输入结构体
typedef struct
{
int obstacle_distance; // 障碍物距离(单位:米)
int speed; // 车速(单位:千米/小时)
bool is_traffic_light_green; // 交通灯状态(true表示绿灯,false表示红灯)
bool is_pedestrian_nearby; // 附近是否有行人
} SensorInput;

// 自动驾驶行为决策函数
VehicleState autonomous_driving_decision(SensorInput sensor_data)
{
if (sensor_data.obstacle_distance < 0 || sensor_data.speed < 0)
{
printf("Error: Invalid sensor data.\n");
return STOP;
}

if (sensor_data.is_traffic_light_green)
{
    if (sensor_data.obstacle_distance > 50 && sensor_data.speed > 60)
    {
        return MAINTAIN_SPEED;
    }
    else if (sensor_data.obstacle_distance <= 50 && sensor_data.speed > 40)
    {
        return SLOW_DOWN;
    }
    else
    {
        if (sensor_data.is_pedestrian_nearby &&
            sensor_data.obstacle_distance > 10)
        {
            return SLOW_DOWN;
        }
        else
        {
            return NORMAL;
        }
    }
}
else
{
    if (sensor_data.obstacle_distance > 30 && sensor_data.speed > 30)
    {
        return MAINTAIN_SPEED;
    }
    else if (sensor_data.obstacle_distance <= 10)
    {
        return EMERGENCY_BRAKE;
    }
    else
    {
        if (sensor_data.is_pedestrian_nearby &&
            sensor_data.obstacle_distance > 20)
        {
            return EMERGENCY_BRAKE;
        }
        else
        {
            return NORMAL;
        }
    }
}

}

Originally posted by @homui in #47 (comment)

switch出现的一点问题

代码

int main(void)
{
	struct grades_list list = {NULL, NULL, 0};
	struct grades *g;
	int is_exit = 0;
	while (is_exit == 0) {
		int choice, num, i, sub_choice;
		char ID[16];
		scanf("%d", &choice);
		switch (choice) {
		case 0:
			clean_info(&list);
			is_exit = 1;
			break;
		case 1: /* 输入 */
			scanf("%d", &num);
			for (i = 0; i < num; ++i) {
				get_grades(&list);
			}
			sort_grades(&list);
			break;
		case 2: /* 输出 */
			for_each(&list, print_basic_info);
			break;
		case 3: /* 修改 */
			scanf("%s%d", ID, &sub_choice);
			g = find_grades(&list, ID);
			if (g == NULL)
				break;
			switch (sub_choice) {
			case 1:
				scanf("%d", &(g->english));
				break;
			case 2:
				scanf("%d", &(g->math));
				break;
			case 3:
				scanf("%d", &(g->physics));
				break;
			case 4:
				scanf("%d", &(g->c_lang));
				break;
			default:
				break;
			}
			count_grades(g);
			break;
		case 4: /* 统计平均 */
			for_each(&list, print_average);
			break;
		case 5: /* 输出总成绩及平均成绩 */
			for_each(&list, print_sum_and_average);
			break;
		default:
			break;
		}
	}
	return 0;
}

报错信息

% ./cxx2flow b.c -c | dot -Tpng -o a.png
Error: UnexpectedOutgoingNodes { node_index: NodeIndex(22), neighbors: [] }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.