osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

I'd like to use "semantic indentation"


On Sun, Oct 1, 2017 at 5:12 AM, Stefan Ram <ram at zedat.fu-berlin.de> wrote:
>   I would like to write source code similar to:
>
> country( 'USA' )
>   state( 'Alabama' )
>     town( 'Abbeville' )
>     town( 'Addison' )
>   state( 'Arizona' )
>     town( 'Apache Junction' )
>     town( 'Avondale )
>     town( 'Benson' )
>
>   using "semantic indentation".
>
>   It seems I can't do this with Python.
>
>   Is there any workaround?

If the indentation has semantic significance, you shouldn't need to
say "country" or "state" or "town". I suggest this format:

USA:
    Alabama:
        Abbeville
        Addison
    Arizona:
        Apache Junction
        Avondale
        Benson

and then, as Paul suggested, write a simple parser to read it.

ChrisA