-
Notifications
You must be signed in to change notification settings - Fork 225
Description
I noticed a issue in the Souffle parser when handling ".include" within identifiers. Here is an example illustrating the problem:
.decl test(b: symbol)
test(b) :- A.includeB(b).
.output test(IO=stdout)
.comp A_comp {
.decl includeB(b: symbol)
includeB("B").
}
.init A = A_comp
Compiling this Datalog program with Souffle results in the following errors:
Error: syntax error, unexpected invalid token in file test.dl at line 2
test(b) :- A.includeB(b).
--------------------^-----
Error: unexpected B in file test.dl at line 2
test(b) :- A.includeB(b).
--------------------^-----
2 errors generated, evaluation aborted
I suspect the issue lies within Souffle's lexer, which incorrectly recognizes ".include" as a keyword or directive, rather than part of an identifier. Relevant code can be found in src/parser/scanner.ll on lines 156-159:
".include" {
yyinfo.LastIncludeDirectiveLoc = yylloc;
BEGIN(INCLUDE);
}I think the correct handling of ".include" should be similar to other directives like ".decl" or ".functor," where it should only be treated as a directive declaration when followed by one or more spaces.
To test my hypothesis, I modified line 156 in scanner.ll to:
".include"/{WS} {Compiling the above Datalog program with modified Souffle produces the following output:
---------------
test
===============
B
===============
If this issue is really a bug, I am happy to submit a pull request to fix it.