TokenLine flat syntax

  • 1 Replies
  • 123 Views
*

Zero

  • Trusty Member
  • ********
  • Replicant
  • *
  • 648
    • Thinkbots are free
TokenLine flat syntax
« on: July 05, 2018, 10:40:00 am »
Hi,

For authoring chatbots, or anything heavily string-based (like interactive fiction), there's a need for a syntax that would ease as much as possible the writing process of programs that contain a lot of constant strings.

If you break down any syntax to its smallest constituents, you find characters. Every language starts with a flat sequence of characters. The meaning of these characters is then defined to express nesting structures ...etc.

Hence the simplest syntax would be to have one token per line. Indentation doesn't even matter, one token per line is enough (just like a sequence of character is enough) to express structures of any complexity-level.


category
pattern
* told me to say *
template
one of
Why would #1 tell you to say "#2"?
Did you say "#2" after #1 told you to?
end one of


Let's try a good'ol naive fib!


function
fib
arg
number
body
return
if
less than
number
3
then
1
else
sum
fib
substract
number
1
end substract
end fib
fib
substract
number
2
end substract
end fib
end sum
end if
end function


Do you like it korrelan?  ;D


Ed: Of course for real usage, indentation makes it readable, if you don't mind applying trim() everywhere.


function
    fib
    arg
        number
    body
        return
            if
                less than
                    number
                    3
            then
                1
            else
                sum
                    fib
                        substract
                            number
                            1
                        end substract
                    end fib
                    fib
                        substract
                            number
                            2
                        end substract
                    end fib
                end sum
            end if
end function


Applied to consnet:


define
    has car
    parameters
        argument model
        argument owner
    body
        let
            a
            new empty cons cell
        end let
        cons cell
            cons cell
                a
                car
            end cell
            is a
        end cell
        cons cell
            cons cell
                a
                argument model
            end cell
            model of car
        end cell
        cons cell
            cons cell
                a
                argument owner
            end cell
            belongs to
        end cell
end define
« Last Edit: July 05, 2018, 12:10:46 pm by Zero »
Thinkbots are free, as in 'free will'.

*

korrelan

  • Trusty Member
  • **********
  • Millennium Man
  • *
  • 1010
  • Look into my eyes! WOAH!
    • Google +
Re: TokenLine flat syntax
« Reply #1 on: July 05, 2018, 12:58:52 pm »
Why not go the extra step and digress right back to assembly code? Lol. ;D

 :)
It thunk... therefore it is!