Rather than asking if something is legal, asking if an action is listed as illegal or punishable by law in a given code should be simpler.
Law will focus on mentioning illegal actions punishable, rather than list legal actions.
The list for legal actions would be much longer than the one for illegal actions, and in case it isn't then we're in deep trouble.
Is it legal to take a stroll in the park? Very generic, ambigous...I doubt that any code would list such action.
Is it illegal to take a stroll in the park while wearing no clothes at all? Simpler question and specific, I wouldn't be surprised if listed in codes and regulations.
Yes and No for first and second makes sense, if No for first question, then it's not a good place to be living in, and one should "move" to another place... hopefully ....legally.