XML Dump
Borsch supports development dumps of the lexical elements and the interpreter internal form. Both are to the simple XML format.
[woq@plecka ~/borsch]$ cat scripts/factorial_inc.txt function factorial($number) { if($number < 2) return 1; else return $number * factorial($number - 1); } [woq@plecka ~/borsch]$ cat scripts/factorial.txt include("scripts/factorial_inc.txt"); echo("Factorial of numbers from 0 to 9:\n"); echo("==================================\n"); for($i = 0; $i <= 9; $i++) echo("Factorial of " + $i + " is " + factorial($i) + "\n"); [woq@plecka ~/borsch]$ ./borsch --lex-dump scripts/factorial.txt <?xml version='1.0' encoding='utf-8' standalone='yes'?> <tokens> <LEX_FUNC_NAME string="factorial"/> <LEX_LPA/> <LEX_VARIABLE string="number"/> <LEX_RPA/> <LEX_LVA/> <LEX_IF/> <LEX_LPA/> <LEX_VARIABLE string="number"/> <LEX_OP_LESS/> <LEX_INT int="2"/> <LEX_RPA/> <LEX_RETURN/> <LEX_INT int="1"/> <LEX_SEMICOLON/> <LEX_ELSE/> <LEX_RETURN/> <LEX_VARIABLE string="number"/> <LEX_OP_MULT/> <LEX_FUNC_NAME string="factorial"/> <LEX_LPA/> <LEX_VARIABLE string="number"/> <LEX_OP_MINUS/> <LEX_INT int="1"/> <LEX_RPA/> <LEX_SEMICOLON/> <LEX_RVA/> <LEX_FUNC_NAME string="echo"/> <LEX_LPA/> <LEX_STRING string="Factorial of numbers from 0 to 9:"/> <LEX_RPA/> <LEX_SEMICOLON/> <LEX_FUNC_NAME string="echo"/> <LEX_LPA/> <LEX_STRING string="=================================="/> <LEX_RPA/> <LEX_SEMICOLON/> <LEX_FOR/> <LEX_LPA/> <LEX_VARIABLE string="i"/> <LEX_OP_ASSIGN/> <LEX_INT int="0"/> <LEX_SEMICOLON/> <LEX_VARIABLE string="i"/> <LEX_OP_LESS_EQ/> <LEX_INT int="9"/> <LEX_SEMICOLON/> <LEX_VARIABLE string="i"/> <LEX_OP_PLUS_PLUS/> <LEX_RPA/> <LEX_FUNC_NAME string="echo"/> <LEX_LPA/> <LEX_STRING string="Factorial of "/> <LEX_OP_PLUS/> <LEX_VARIABLE string="i"/> <LEX_OP_PLUS/> <LEX_STRING string=" is "/> <LEX_OP_PLUS/> <LEX_FUNC_NAME string="factorial"/> <LEX_LPA/> <LEX_VARIABLE string="i"/> <LEX_RPA/> <LEX_OP_PLUS/> <LEX_STRING string=" "/> <LEX_RPA/> <LEX_SEMICOLON/> <LEX_NULL/> </tokens> [woq@plecka ~/borsch]$ ./borsch --call-tree-dump scripts/factorial.txt <?xml version='1.0' encoding='utf-8' standalone='yes'?> <Script> <GlobalCommands> <FunctionCall name="echo"> <Parameters> <Value type="string">Factorial of numbers from 0 to 9:</Value> <Parameters> </FunctionCall> <FunctionCall name="echo"> <Parameters> <Value type="string">==================================</Value> <Parameters> </FunctionCall> <Loop> <Init> <BinaryOperator type="LEX_OP_ASSIGN"> <LeftTree> <Variable name="i"/> </LeftTree> <RightTree> <Value type="int">0</Value> </RightTree> </BinaryOperator> </Init> <Condition> <BinaryOperator type="LEX_OP_LESS_EQ"> <LeftTree> <Variable name="i"/> </LeftTree> <RightTree> <Value type="int">9</Value> </RightTree> </BinaryOperator> </Condition> <Inc> <UnaryOperator type="LEX_OP_PLUS_PLUS_POST"> <Variable name="i"/> </UnaryOperator> </Inc> <Body> <FunctionCall name="echo"> <Parameters> <BinaryOperator type="LEX_OP_PLUS"> <LeftTree> <BinaryOperator type="LEX_OP_PLUS"> <LeftTree> <BinaryOperator type="LEX_OP_PLUS"> <LeftTree> <BinaryOperator type="LEX_OP_PLUS"> <LeftTree> <Value type="string">Factorial of </Value> </LeftTree> <RightTree> <Variable name="i"/> </RightTree> </BinaryOperator> </LeftTree> <RightTree> <Value type="string"> is </Value> </RightTree> </BinaryOperator> </LeftTree> <RightTree> <FunctionCall name="factorial"> <Parameters> <Variable name="i"/> <Parameters> </FunctionCall> </RightTree> </BinaryOperator> </LeftTree> <RightTree> <Value type="string"></Value> </RightTree> </BinaryOperator> <Parameters> </FunctionCall> </Body> </Loop> </GlobalCommands> <GlobalFunctions> <Function name="factorial"> <Parameter>number</Parameter> <If> <Condition> <BinaryOperator type="LEX_OP_LESS"> <LeftTree> <Variable name="number"/> </LeftTree> <RightTree> <Value type="int">2</Value> </RightTree> </BinaryOperator> </Condition> <UnaryOperator type="LEX_RETURN"> <Value type="int">1</Value> </UnaryOperator> </If> <Else> <UnaryOperator type="LEX_RETURN"> <BinaryOperator type="LEX_OP_MULT"> <LeftTree> <Variable name="number"/> </LeftTree> <RightTree> <FunctionCall name="factorial"> <Parameters> <BinaryOperator type="LEX_OP_MINUS"> <LeftTree> <Variable name="number"/> </LeftTree> <RightTree> <Value type="int">1</Value> </RightTree> </BinaryOperator> <Parameters> </FunctionCall> </RightTree> </BinaryOperator> </UnaryOperator> </Else> </Function> <Function name="echo"> <Parameter>param</Parameter> </Function> <Function name="exit"> <Parameter>param</Parameter> </Function> <Function name="get_global"> <Parameter>name</Parameter> </Function> <Function name="set_global"> <Parameter>name</Parameter> <Parameter>value</Parameter> </Function> </GlobalFunctions> </Script> [woq@plecka ~/borsch]$ ./borsch scripts/factorial.txt Factorial of numbers from 0 to 9: ================================== Factorial of 0 is 1 Factorial of 1 is 1 Factorial of 2 is 2 Factorial of 3 is 6 Factorial of 4 is 24 Factorial of 5 is 120 Factorial of 6 is 720 Factorial of 7 is 5040 Factorial of 8 is 40320 Factorial of 9 is 362880 [woq@plecka ~/borsch]$