Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Issue with whitespaces #547

Unanswered
ls-cnr asked this question in Q&A
Discussion options

I am writing the parser for first-order conditions. I am using Scala and the scala-parser-combinators library. It works well, but I discovered this issue.

Here, I report the clause for negation (example: not predicate(p1)). It uses recursion, calling fol_condition, i.e. the root level rule for fol conditions:

 def fol_condition: Parser[FOLNature] = fol_negation | fol_predicate | ...
 def fol_negation : Parser[Negation] = "not"~fol_condition ^^ {case _~sub => Negation(sub)}
 def fol_predicate : Parser[Predicate] = ident~"("~repsep(logic_term,",")~")"^^ {case id~_~args~_ => Predicate(id,args)}
....

So, a string like "not predicate(p1)" produces the correct result Negation(Predicate("predicate",...)) However, when I parse a string like "note(p2)", it should produce a Predicate("note",...); instead, it returns Negation(Predicate(a,...)). In other words, the parser ignores whether there is a space between "not" and the following fol_condition.

This is not the desired behaviour. I would inform the parser that "not a" is different from "nota" because there is a space in between.

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant
Converted from issue

This discussion was converted from issue #540 on March 28, 2024 16:43.

AltStyle によって変換されたページ (->オリジナル) /