Replies: 1 comment
-
This might be the cause of langston-barrett/tree-sitter-souffle#8 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
Have you noticed the ambiguities in Souffle grammar between to the dot-keywords (
.type
,.decl
, ...) and qualified names?Examples
For instance the type declaration is parsed as
T
being an alias for typefoo.type.t
:But this is parsed as
T
being an alias for typefoo
followed by another type definition.type .t
where.
is unexpected beforet
:The issue is not limited to
.type
, similar ambiguities can be built for other dot-keywords in competition with clause terminal-dot.This is correctly parsed as fact
init(1)
:Whereas this is parsed as unexpected initialization
.init
before the missing terminal-dot of theq(v)
clause:Analysis
The grammar is ambiguous because there is no way to distinguish
.keyword
from.
immediately followed bykeyword
.For instance these rules requires to distinguish
.type
from.
immediately followed bytype
:The ambuiguity is fixed arbitrarily by the lexer rules that match dot-keywords by looking-ahead for a whitespace after the keyword:
Hence the actual grammar is whitespace sensitive:
Where
/(?! ".type ")
is the negative look-ahead of".type "
.Discussion
How to solve this issue ?
x
if.x
is a dot-keyword of the language: no more.type input
,.decl type
,comp: number
.r#x
:.type r#input
,.decl r#type
,r#comp: number
.type r#input
,decl r#type
.Beta Was this translation helpful? Give feedback.
All reactions