Skip to content

createLiteral parenthesis check #124

@driacats

Description

@driacats

While working with JaCaMo, I found this bug: there is no validation in createLiteral to check whether the given string is actually acceptable. If you try the following code:

Literal a = createLiteral("a(b)");

The code creates a literal with the functor a(b). I know that parseLiteral also exists, and given the same string, it correctly creates the literal, but I find it strange that createLiteral does not throw an exception in such cases.

Additionally, from the Mind Inspector's graphical interface, there is (obviously) no visual difference between a(b) (where the entire string is the functor) and a(b) (where a is the functor and b is the argument). This leads to an unpleasant debugging situation where the beliefs contain a(b) (or multiple instances of it, since for some reason also equal functors are not viewed as equals from the point of view of the agent BeliefBase), and a plan like the one below does not get executed:

+!hello
     : a(b)
    <- .print( "Hello!" ).

Perhaps parentheses are not the only characters that should be checked, but I consider them the most important because, theoretically, the functor should not be able to create functors with parentheses at all.

In case you find this issue interesting but don't have time to address it, I am available to try to implement this validation.

Thank you for your work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions