Talk:Stack-oriented programming: Difference between revisions

Content deleted Content added
Add section header, move comments to restore chronological order.
Tags: Mobile edit Mobile app edit
Line 8:
 
A very well written article, kudos! <span style="font-size: smaller;" class="autosigned">—Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/86.8.124.145|86.8.124.145]] ([[User talk:86.8.124.145|talk]]) 12:50, 21 June 2009 (UTC)</span><!-- Template:UnsignedIP --> <!--Autosigned by SineBot-->
 
== Wrong Wrong Wrong ==
 
:"A stack-oriented programming language is one that relies on a stack machine model for passing parameters"
 
That implies all nested block structure languages are stack orianted languages and doesn't distinguish the ones that actually have stack operators in the language. Stack orianted languages are a subset of stack based languaged. And passing parameters on the call stack is not required.
 
It also excludes lenguages that do not have parameter. For example a language of functions that operate on a character stream (or string) and manipulates stacks directly.
 
[[TREE-META]] is one example. CWIC another. They are metacompilers. The syntax language is syntax equation, boolean functions. Each euation expresses a goal, recognizing some language structure. They are boolean equations that analyze an input character stream and return success(true) or failure(false). Using operates like ''''':'''<node>'' that creates a node and pushes it onto the node stack and '''''!'''<number>'' that creates a tree, taking the top node stack entry and the top ''<number>'' of parse stack entries putting them to gather to form a tree that is pushed on that parse stack. The +[ ... ]+ make a list of parse stack entries pushed between them.
 
A set of syntax functions that parse an arithmetic expression building a abstract syntax tree on the parse atack:
<pre>
expr = term (('+':ADD|'-':SUB) term!2)*;
term = factor (('*':MPY|'/':DIV) factor)*;
factor = id|num|'('expr')'
id .. let alphanum*;
num .. dgt dgt* MAKENUM();
</pre>
expr is a function who's goal is to first recognize a term. Then some number of term may be added or subtracted from the first expresed by:
(('+':ADD|'-':SUB) term!2)*
The Kleene star is used to express that zero or more ('+' or '-' term) may follow.
If the character '''''+''''' is matched :ADD creates an '''ADD''' node and pushes it on the node stack. Likewise a '''SUB''' node may be created and pushed on the node atack. If nether '+' or '-' is recognized in the input stream the sequence terminates, returning success. On each iteration of the loop, after recognizing a term the !2 pops the top node off the node stack combining it with the top two objects poped off the parse stack making a tree or branch that is pushed on the parse stack. The term equation function parses products transforming them into trees or a single factor. The MPY and DIV nodes are combined with factors in the same manner as terms were in expr. The factor equation defines factor as a number, identifier or a parenthesized expr. Syntax equations consume input character stream characters recognized. Given the expression:
(5*x-3)/(y+1)
The syntax functions would create a tree on the parse stack:
<pre>
DIV
/ \
SUB ADD
/ \ / \
MPY 3 y 1
/ \
5 x
</pre>
The syntax equations described are from the CWIC syntax language only using the Kleenex star '''*''' instead of the CWIC zero or more $ operator. expr using $ operatot:
expr = term $(('+':ADD|'-':SUB) term!2)*
 
The id and num '''..''' equation are token making euations. id catalogs the parsed characters in the dictionary creating a symbol object that is pushed in the parse stack. The num equation recognizes sequence of one or more dgt. MAKENUM() is a function call that intercepts the dictionary processing. It creates a numeric object from the dgt sequence and pushes it or the parse stack.
 
The SYNTAX language is a goal orianted, stack oriented, string processing language. <u>There are no parameters</u> on the call stack or any returned. Success ot failure is commonly a processor status state that can be tested using hardware branch on condition instructions. The parse and node stacks liken to global variables.[[User:Steamerandy|Steamerandy]] ([[User talk:Steamerandy|talk]]) 22:42, 29 January 2016 (UTC)
 
== Program refinement ==