Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic: could not match regexp with string #826

Open
s4kibs4mi opened this issue Sep 11, 2019 · 4 comments
Open

panic: could not match regexp with string #826

s4kibs4mi opened this issue Sep 11, 2019 · 4 comments
Labels

Comments

@s4kibs4mi
Copy link

Error :

panic: could not match regexp with string
^(?P<address>[0-9a-fx]+) <(?P<position>.*)> '(?P<type>.*?)'(:'(?P<type2>.*?)')? <(?P<kind>.*)>[\s]*$
0x7fe6fc85a348 <col:56> 'int' <LValueToRValue> part_of_explicit_cast


goroutine 12 [running]:
github.com/elliotchance/c2go/ast.groupsFromRegex(0xc000210af0, 0x64, 0xc0002b3409, 0x44, 0xc00037bde0)
	/Users/sakib/go/src/github.com/elliotchance/c2go/ast/ast.go:286 +0x360
github.com/elliotchance/c2go/ast.parseImplicitCastExpr(0xc0002b3409, 0x44, 0x12c0246)
	/Users/sakib/go/src/github.com/elliotchance/c2go/ast/implicit_cast_expr.go:17 +0x62
github.com/elliotchance/c2go/ast.Parse(0xc0002b33f8, 0x55, 0x12baa29, 0x5)
	/Users/sakib/go/src/github.com/elliotchance/c2go/ast/ast.go:154 +0x306a
main.convertLinesToNodes(0xc0002bbae0, 0xd7, 0x1af, 0x0, 0x0, 0x0)
	/Users/sakib/go/src/github.com/elliotchance/c2go/main.go:89 +0x1a6
main.convertLinesToNodesParallel.func1.1(0xc000228540, 0xc00000e088, 0xc0002bbae0, 0xd7, 0x1af, 0x0)
	/Users/sakib/go/src/github.com/elliotchance/c2go/main.go:113 +0x53
created by main.convertLinesToNodesParallel.func1
	/Users/sakib/go/src/github.com/elliotchance/c2go/main.go:111 +0x124

Source :

#include <stdio.h>

void genFib(int x, int y, int n) {
	if (n == 0){
		return;
	}

	printf("%d\n", x);
	return genFib(y, x + y, --n);
}

int main() {
	genFib(1, 1, 10);
	return 0;
}
@elliotchance
Copy link
Owner

This is becuase c2go doesn't recognise one of the AST lines generated from clang. The regexp will need to be updated so it can be understood.

If you want to have a go at fixing this, you can find an example here: #760

@AvinashRamashray
Copy link

@s4kibs4mi :Did you find solution for your problem?

I am also getting similar error.
Please suggest how to proceed for this.

@jtarchie
Copy link

jtarchie commented May 1, 2020

@elliotchance, I too have just experienced this issue.

Maybe the regex is too strict and needs to more forgiving for other formats.
Perhaps the idea, if the information I need is there, use it, and if there is more, ignore it.

Instead of updating the regex for my specific line:

panic: could not match regexp with string
^(?P<address>[0-9a-fx]+) <(?P<position>.*)>(?P<inherited> Inherited)? (?P<os>\w+) (?P<version>[\d.]+) (?P<unknown1>[\d.]+) (?P<unknown2>[\d.]+)(?P<unavalable> Unavailable)? "(?P<message1>.*?)"(?P<message2> ".*?")?[\s]*$
0x7fddc201bf28 <col:99, col:134> macos 10.13 0 0 "" "" 0

Maybe we can clean this up.

The issue #760 seems to build a regex from another regex. Can you point me in the direction where the tests for these are?

@elliotchance
Copy link
Owner

@jtarchie because c2go parses the string rendered AST tree produced from clang there's a lot of edge cases, especially as clang gains more features, as the AWS output is just for debugging, it's not intended to be a porcelain format.

I originally wanted to keep the regex as tight as possible to make sure the structs that represent the data don't become dirty over or out of sync over time, because it's such an easy to update a case when it's found. You can find all the test cases and node types in the ast package: https://github.com/elliotchance/c2go/tree/master/ast

If it's an existing node type you can add a new test case for it, here is an example of adding a fix: #853

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants