LangProc / langproc-2017-lab

4 stars 8 forks source link

Brackets #57

Open gioannides opened 6 years ago

gioannides commented 6 years ago

Is [] considered a valid word? Meaning for example the input is [] , should this be interpreted as a word which is an empty string? Or do the enclosing brackets have to have at least 1 character inside them in order to be considered a word? For instance is also [ ] a valid word?

m8pple commented 6 years ago

I think you asked in the lecture, but just to answer here too:

The spec says that:

Any sequence of characters beginning with [ starts a word, and the word ends at the next ].

When thinking about grammars, a general-purpose sequence will include the empty sequence, unless otherwise disallowed. So yes, [] is a legal word, and the value of the word will be the empty string.

This is a bit like having "" in C, which is a string literal containing an empty sequence of characters.

Requiring that there be at least 1 character inside the brackets is more restrictive (equivalent to + rather than *), so it would need to be explicitly specified.

I think another question that came up was with things like [[[[[]. Again, you would need to follow the spec, so if it starts at the first [ and finishes at the next ], it would be a word with the value [[[.

wmvndrscht commented 6 years ago

*Correction (approved by DT in labs) I think another question that came up was with things like [[[[[]. Again, you would need to follow the spec, so if it starts at the first [ and finishes at the next ], it would be a word with the value [[[[.

gioannides commented 6 years ago

Thank you

m8pple commented 6 years ago

Thanks to @wmvndrscht - yes, I mis-counted the number of brackets when typing in.