Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brackets #57

Open
gioannides opened this issue Jan 20, 2018 · 4 comments
Open

Brackets #57

gioannides opened this issue Jan 20, 2018 · 4 comments

Comments

@gioannides
Copy link

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
Copy link
Contributor

m8pple commented Jan 24, 2018

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
Copy link

wmvndrscht commented Jan 24, 2018

*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
Copy link
Author

Thank you

@m8pple
Copy link
Contributor

m8pple commented Jan 24, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants