How to remove space around operators

9 views
Skip to first unread message

Rui Vieira

unread,
Aug 5, 2009, 12:17:06 PM8/5/09
to Booleano
Hi everyone,

I've created a simple grammar, just replacing the equality operator

grammar = Grammar(eq=":")

I wanted to be able to parse a string like 'valuea:"A" valueb:"B"',
however it seems I have to surround the ":" operator with spaces (ie
'valuea : "A"').

How can I parse this without the space(s)?

Thanks!

Gustavo Narea

unread,
Aug 6, 2009, 3:15:36 PM8/6/09
to bool...@googlegroups.com, Rui Vieira
Hello, Rui.

You have to surround it with spaces because the ":" is also used as the
namespace separator in your custom grammar (e.g.,
namespaceA:namespaceB:variable_name). By using spaces you resolve this
ambiguity.

What you can do is use another symbol for the namespace separator, such as a
dot. You can try the following grammar:
grammar = Grammar(eq=":", namespace_separator=".")

This way it won't be ambiguous and thus spaces wouldn't be necessary.

HTH,

- Gustavo.
> --
Gustavo Narea <xri://=Gustavo>.
| Tech blog: =Gustavo/(+blog)/tech ~ About me: =Gustavo/about |

Rui Vieira

unread,
Aug 6, 2009, 6:46:33 PM8/6/09
to Gustavo Narea, bool...@googlegroups.com

Hi Gustavo,

Thanks for the explanation, it makes perfect sense.
Congratulations on booleano, it's very cool.

Rui

On Aug 6, 2009 8:15 PM, "Gustavo Narea" <m...@gustavonarea.net> wrote:

Hello, Rui.

You have to surround it with spaces because the ":" is also used as the
namespace separator in your custom grammar (e.g.,
namespaceA:namespaceB:variable_name). By using spaces you resolve this
ambiguity.

What you can do is use another symbol for the namespace separator, such as a
dot. You can try the following grammar:
   grammar = Grammar(eq=":", namespace_separator=".")

This way it won't be ambiguous and thus spaces wouldn't be necessary.

HTH,

 - Gustavo.

Rui said: > Hi everyone, > > I've created a simple grammar, just replacing the equality operator > ...

Gustavo Narea

unread,
Aug 8, 2009, 2:02:04 PM8/8/09
to Rui Vieira, bool...@googlegroups.com
Hello, Rui.

I'm glad to hear it worked and that you like Booleano!

Please let me know if you have suggestions or something, as it's still taking
shape ;-)

Cheers,
Reply all
Reply to author
Forward
0 new messages