User Tools

Site Tools


xrpl:rpl_language_overview

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
xrpl:rpl_language_overview [2019/05/05 15:05] – Added in-fix nototation via MPLLang translator added stub, changed heading levels Karsten75xrpl:rpl_language_overview [2019/07/26 15:59] – [Symbol Aliasing] fixed table formatting Karsten75
Line 115: Line 115:
 Both the above statements assign 7 to the variable "x". Choose which format you prefer and you think makes your code most readable - then be consistent. :) Both the above statements assign 7 to the variable "x". Choose which format you prefer and you think makes your code most readable - then be consistent. :)
  
 +==== Symbol Aliasing ====
 +
 +Many arithmetic operators  can be substituted with shorthand symbols. 
 +
 +^ Operator ^ Symbol ^
 +| ADD | + | 
 +| SUB | - | 
 +| MUL | * | 
 +| DIV | / | 
 +| MOD | % | 
 +| AND | && | 
 +| OR  | %%||%% | 
 +| NOT | ! | 
 +| POW | %%^%% | 
 +| GT  | > | 
 +| GTE | >=| 
 +| LT  | < | 
 +| LTE | <= |  
 +| EQ  | == | 
 +| NEQ | != | 
 + 
 ==== Code translator ==== ==== Code translator ====
-[[https://github.com/Arin112}Arin112]]+[[https://github.com/Arin112}Arin112]] wrote a code translator that can translate in-fix ((Infix notation is the notation commonly used in arithmetical and logical formulae and statements. It is characterized by the placement of operators between operands—"infixed operators"—such as the plus sign in 2 + 2.)) code to the xRPL post-fix notation.  
 + 
 +For those struggling to master xRPL's post-fix format, this may be a useful tool. It can be obtained from [[https://github.com/Arin112/mplLang|github]] and is accompanied by many samples. Of course, it should be noted that the code and translation will only be up-to-date as long as the repository is maintained.  
 + 
 +Here are some sample translations, taken directly from the GitHub repository: 
 + 
 +<WRAP group> 
 +<WRAP half column> 
 +**mplLang code** 
 +<code c> 
 +x = 2 + 2 * 2; 
 +</code> 
 +</WRAP> 
 +<WRAP half column> 
 +**xRPL translated code** 
 +<code 4rpl> 
 +2 2 2 mul add ->x 
 +</code> 
 +</WRAP> 
 +</WRAP> 
 + 
 +<WRAP group> 
 +<WRAP half column> 
 +<code c> 
 +z = f(x, y); 
 +</code> 
 +</WRAP> 
 +<WRAP half column> 
 +<code 4rpl> 
 +z = f(x, y); 
 +</code> 
 +</WRAP> 
 +</WRAP> 
 + 
 +<WRAP group> 
 +<WRAP half column> 
 +<code c> 
 +[x, y] = CurrentCoords(); 
 +</code> 
 +</WRAP> 
 +<WRAP half column> 
 +<code 4rpl> 
 +CurrentCoords ->y ->x 
 +</code> 
 +</WRAP> 
 +</WRAP> 
 + 
 +<WRAP group> 
 +<WRAP half column> 
 +<code c> 
 +if(a<b && (c+1 == -c)) [a, b, c] = 1, 2.0, 3.14; 
 +</code> 
 +</WRAP> 
 +<WRAP half column> 
 +<code 4rpl> 
 +<-a <-b lt <-c 1 add <-c neg eq and if 
 +1 2 3.140000 ->c ->b ->a 
 +endif 
 +</code> 
 +</WRAP> 
 +</WRAP> 
 + 
 +<WRAP group> 
 +<WRAP half column> 
 +<code c> 
 +do (1 .. 42){ 
 +a = refRead("num"); 
 +refWrite(7*(3.14+i), "num"); 
 +
 +</code> 
 +</WRAP> 
 +<WRAP half column> 
 +<code 4rpl> 
 +42 1 do 
 +"num" <-! ->a 
 +7 3.140000 i add mul "num" ->! 
 +loop 
 +</code> 
 +</WRAP> 
 +</WRAP>