r/Compilers • • 23d ago

Can a programming language dispense with parentheses and conventional syntactic delimiters?

/r/u_Pi-Plushie/comments/1xqfqb0/can_a_programming_language_dispense_with/
0 Upvotes

8 comments sorted by

3

u/pauseless 23d ago

Yes? Tcl works here - don’t be confused by `{}` in the language, as it is simply conceptually the syntax for making strings. I assume you’re not throwing out `""` or similar for strings? I assume you’d allow new lines to separate expressions?

Forth is probably the best, as mentioned by others.

You can get really far with APL before needing any kind of control structure. If you just want no parens, `(+⌿÷≢)1 56 23 4` can be written as:

mean←+⌿÷≢
mean 1 56 23 4

Not using parens and not using control structures such as for loops.

1

u/Pi-Plushie 23d ago

indeed, for now, PLUSHIE is only handling strings and is in the process of understanding numbers. For it numbers are still only integers that are represented by lenght of character chains ! So there is no need for "". The number 22 is represented as Twenty-two pointing to Twenty-one etc and then can also be represented as 22 but needing something to prevent the parsing system to parse 222 into 22 and 2 which is a undesired feature !

New lines are only needed for human reader convenience.

Thank you for your useful contribution to my adventure with PLUSHIE !

5

u/asperta 23d ago

Take COBOL as an example of a verbose language:

MOVE 1 TO ITERATION-COUNTER.
    PERFORM UNTIL ITERATION-COUNTER GREATER THAN 5
        DISPLAY "Mainframe"
        ADD 1 TO ITERATION-COUNTER
    END-PERFORM.

Just don't end up making kilometric source files!

-3

u/Pi-Plushie 23d ago

Thank you for your quick answer ! You are totally right, that's part of the risk. The point is that PLUSHIE language learns new expressions and function that can be use later on to reduce the length of the code.

4

u/bod_owens 23d ago

This sounds like Forth: a dictionary of words, extended at runtime, with the interpreter itself modifiable. Hard to say more because the terms are undefined: what is a 'chained memory structure', 'word-based parsing model's and are words whitespace-separated or matched as substrings? All of these are obviously made to sound like terms of art, but they're not. A five-line example would help more than the questions.

1

u/Pi-Plushie 21d ago edited 21d ago

Hi again.

I see that my preceding response was judged negatively. I tried to explain PLUSHIE's concept to my best in PLUSHIE's web site : https://pi-plushie.github.io/PLUSHIE-Site/index-en.html

Do not hesitate to hit hard on me if necessary as I need help to improve my communication.

The memory structure necessary for PLUSHIE is the same as LISP: Memory blocks of 2 pointers to memory.

PLUSHIE does not have a true compiler. It "compiles" its code at the reading time:

PLUSHIE does not tokenize source code using predefined separators. It reads the character stream one character at a time and continuously compares its current ending against its list of known expressions.

Whenever a known expression is detected, the stream is split at that point. The previously unrecognized character sequence becomes a new known expression, and the instruction formed by the first two expressions is immediately executed.

Parsing, vocabulary extension and execution therefore happen incrementally, within the same process. The vocabulary may change while the source stream is still being read.

Thus it is unusual and the result of a given sequence of characters depend on the history of the code.

The purpose of it is not to replace existing languages but rather exploring the evolution of the complexity of the self-learning language.

The instruction that is executed between known expression is a double indirection copy:

Mem ( Mem( Destination )) = Mem (Mem (Source ))

At start, the boostrap file contains one already known expression (Lien or Link) that points to the underlying function enabling to access the second pointer of a given memory block.

From that first expression, the initializing text file is progressively parsed using immediately the newly learned expression .

Thus if Print has already been defined as well as its variable To be printed the sequence:

To be printed Hello world Run Print

would be processed this way:

To be printed is recognized as a known expression. It is stored in the execution list. As there is only one expression in it, reading goes on.

Hello world is not recognized so the reading goes up to Run which is recognized as a known word.

The sentence is parsed in "Hello world " and "Run "

Hello world is included into the dictionary of known expression as an atom pointing to itself

The two expressions are stored in the execution list. As there is more than one expression in the execution list, the first two expressions become an instruction and "Hello world " is copied on "To be printed ".

When the last expression "Print " is recognized, Run Print is executed:

Print is copied (via double indirection) to the execution pointer Run and the value of To be printed is displayed.

Hope this example clarifies the process.

-1

u/Pi-Plushie 23d ago

Thank you for your comment. In PLUSHIE there is no predefined separator as the keywords can be defined / modified by the user. So the words are matched as substrings. Of course for the ease of human reading usign spaces between words is recommanded An example of loop is:

While chainofcharacters repeat procédure returnprocedure Loop Run Loop.

Hello world could be expressed as : Using Hello world Run Display.

If anyone is interested and if this accepted by the forum rules I can give the link to the web site that present the langage. Any feedback (even negatives one) are welcome !

1

u/chibuku_chauya 22d ago

For parens, the various shells and Tcl do this by having it such that the first thing appearing syntactically is a command and anything that follows is an argument.