Formalize and test treatment of whitespace
dominicm00 opened this issue · comments
Dominic Martinez commented
Officially, Ham follows Jam's tokenization procedure where everything is separated by whitespace, except variables which are single tokens:
# valid Jam
if ! a && ( b = c ) {
Echo [ on target return $(X:D) ] ;
}
# Removing/adding whitespace between _anything_ here changes the meaning of the program
Unofficially, Ham's parsing mechanism makes most whitespace optional, and can trivially enforce/remove whitespace requirements:
# (possibly) valid Ham
if !a&&(b=c){Echo[on target return $( X : D )];}
# Whitespace can be added/removed between semantic objects (except keywords) without consequence
# if they would not be interpreted as a single leaf
Currently, unit tests only cover the Jam-compatible language definition.
Ham should formalize its treatment of whitespace in the language specification, and then add unit tests to ensure compliance before users rely on this feature.
Dominic Martinez commented
Ham v2 has been moved; closing issues not relevant for v1.