891 - Syntrax

All about problems in Volume 8. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
..
A great helper
Posts: 454
Joined: Thu Oct 18, 2001 2:00 am
Location: Hong Kong

891 - Syntrax

Post by .. »

In this question, we have the rule as shown:

expression :: sequence | alternatives | repetition | terminal
sequence :: ( ws expression expression ) ws
alternatives :: { ws expression expression } ws
repetition :: [ ws expression ] ws
terminal :: " character* " ws
ws :: (<space> | <tab>)*
character :: <any character except " and control-characters (ASCII 0..31)>

Do the '(' and ')' in "ws :: (<space> | <tab>)*" really mean characters?
That is, is this a valid expression?
[() "a"]

Thanks!
My signature:
  • Please make discussion about the algorithm BRFORE posting source code.
    We can learn much more in discussion than reading source code.
  • I HATE testing account.
  • Don't send me source code for debug.

little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey »

The answer to both your questions is no.
I guess the brackets in the definitions of sequence, alternatives and repitition should have been single quoted, like
sequence :: '(' ws expression expression ')'
to indicate that they are literals and not grouping indicators as in the definition of ws.

..
A great helper
Posts: 454
Joined: Thu Oct 18, 2001 2:00 am
Location: Hong Kong

Post by .. »

Thanks, actually I can get the answer by assertion in my program.
Just want to confirm everything as I am getting WA, where I think this is an easy problem.
My signature:
  • Please make discussion about the algorithm BRFORE posting source code.
    We can learn much more in discussion than reading source code.
  • I HATE testing account.
  • Don't send me source code for debug.

baodog
Experienced poster
Posts: 202
Joined: Wed Jul 04, 2007 6:53 am

Datasets Appreciated ...

Post by baodog »

Seems like trivial parsing problem, but getting wa :oops: ...
Datasets are greatly appreciated! Thanks.

For


[code]
4
{("f" "bar") ["c"]}
{{("f" "bar") ["c"]} {("f" "bar") ["c"]}}
{[{("f" "bar" "fdfd" "fd" "dfsf") ["c"]}]}
({[{("f" "bar" "fdfd" "fd" "dfsf") ["c"]}]} {{("f" "bar") ["c"]} {("f" "bar") ["c"]}})
[/code]

I'm getting

[code]
28x8
32x17
36x10
64x17
[/code]

Is this correct? Thanks.

Post Reply

Return to “Volume 8 (800-899)”