vipsi - the friendly vip script interpreter

Appendix

Syntax Cave-ats

Function call without parenthesis

With all Vipsi command syntax: Functions
Functions
Glossary: Function
functions
which take exactly one Vipsi command syntax: Arguments
Glossary: Arguments
argument
, Flow control: if … then
Flow control: try … then
the
Separators: Round brackets "( … )"parenthesis may be omitted, Flow control: if … then
Flow control: if … then
if the
Vipsi command syntax: Arguments
Glossary: Arguments
argument
is a simple Glossary: Valuevalue Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
no Vipsi command syntax: Expressions
Glossary: Expression
expression
with Vipsi command syntax: Operators
Operators
Glossary: Operator
operators
. Flow control: if … then
Flow control: if … then
If the
Vipsi command syntax: Arguments
Glossary: Arguments
argument
is a Vipsi command syntax: Expressions
Glossary: Expression
expression
, Flow control: if … then
Flow control: try … then
then
you must use Separators: Round brackets "( … )"parenthesis.

Numeric functions: sinsin 2*Constants: pipi   ==   Numeric functions: sinsin(2) * Constants: pipi   !=   Numeric functions: sinsin(2*Constants: pipi)
Instruction starting with a list literal

Flow control: if … thenIf a Vipsi command syntax: Statements
Glossary: Statement
statement
starts with '{' List functions: thisthis is Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
not
recognized as a Data Types: Lists and arrays
Glossary: list, list_val
list
, but as start of a List functions: localslocal context instead. It is very unlikely for a normal program that a Vipsi command syntax: Statements
Glossary: Statement
statement
starts with a Literals: List literals
Lists and arrays: List literals
list literal
. Maybe it happens to you sometime on Flow control: if … then
Flow control: try … then
the
vipsi shell command line:

vipsi> { 1, 2, 3 }
*****  numeric Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
Glossary: text, text_valtext value expected
vipsi> { 1, 2, 3 }

Flow control: if … thenIf you want to print it from Flow control: if … then
Flow control: try … then
the
command line, use Instructions: putput, Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
encloce it in Separators: Round brackets "( … )"parenthesis:

vipsi> Instructions: putput {1,2,3}  = { 1, 2, 3 }
vipsi> ({1,2,3})  = { 1, 2, 3 }
vipsi>  

Flow control: if … thenIf you want to print Flow control: if … then
Flow control: try … then
the
Data Types: Lists and arrays
Glossary: list, list_val
list
from a Example Scripts: CGI Scripts
Example Scripts: Scripts
script
, you must use Instructions: putput anyway Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
Flow control: if … then
Flow control: try … then
the
problem Flow control: do … loopdoes Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
not
occur:

Instructions: putput { 1,2,3 }
Statements starting with '%', '-' or '+'

Flow control: if … thenIf a Vipsi command syntax: Statements
Glossary: Statement
statement
after a Vipsi command syntax: Statements
Glossary: Statement
statement
with Vipsi command syntax: Arguments
Glossary: Arguments
arguments
starts with '-', '+' Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
'%' Flow control: if … then
Flow control: try … then
then
List functions: thisthis character is Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
not
recognized as a Glossary: number, num_valnumber Numeric functions: signsign start of a Integer numbers: Binary
Floating point: Binary
Text functions: binstr
binary
Literals: Number literals
Numbers: Number literals
number literal
but interpreted as Vipsi command syntax: Operators
Operators
Glossary: Operator
operator
Operators: Subtract "-"minus, Operators: Add "+"plus Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
Operators: Remainder with Variable "%="
Operators: Remainder "%"
remainder
linking it to Flow control: if … then
Flow control: try … then
the
last Vipsi command syntax: Arguments
Glossary: Arguments
argument
of Flow control: if … then
Flow control: try … then
the
previous Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
instruction
.

List functions: thisThis will almost certainly happen only in broken code.

In a sane program, each statement starts with an Vipsi command syntax: Identifiers (names)
Data Types: Identifiers, names
Operators: Make Identifier "@"
Glossary: Name, Identifier
identifier
Vipsi command syntax: Identifiers (names)
Data Types: Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
name
:

Flow control: if … thenIf a Vipsi command syntax: Statements
Glossary: Statement
statement
starts with '%', '+' Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
'-', Flow control: if … then
Flow control: try … then
then
List functions: thisthis Vipsi command syntax: Expressions
Glossary: Expression
expression
will Flow control: returnreturn a result Glossary: Valuevalue. In a Example Scripts: CGI Scripts
Example Scripts: Scripts
script
List functions: thisthis result Glossary: Valuevalue will be discarded. I can hardly think of any useful code, with a Vipsi command syntax: Statements
Glossary: Statement
statement
beginning with a numeric Glossary: Valuevalue. Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
And
all examples i can imagine are lunatic Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
malicious.

#!/usr/bin/vipsi
// very broken:
    +123 Instructions: var
How does VScript::Value() work?: Var*&
var
a=0 -123 Instructions: var
How does VScript::Value() work?: Var*&
var
b=0 +123 Instructions: var
How does VScript::Value() work?: Var*&
var
c=0 %011 Instructions: putput Constants: nlnl, "-> ", a, Constants: tabtab, b, Constants: tabtab, c, Constants: nlnl // very insane: Instructions: procproc mySideEffect(a){ Instructions: putput a; Flow control: returnreturn a } Instructions: putput 222 +mySideEffect(77)

Even in Flow control: if … then
Flow control: try … then
the
shell Flow control: if … thenif you want to print Flow control: if … then
Flow control: try … then
the
result of an Vipsi command syntax: Expressions
Glossary: Expression
expression
, Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
Flow control: if … then
Flow control: try … then
the
Vipsi command syntax: Expressions
Glossary: Expression
expression
starts with a Literals: Number literals
Numbers: Number literals
number literal
which starts with '%', '+' Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
'-', List functions: thisthis is no problem, because you'll rarely append such a calculation after another Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
instruction
with Vipsi command syntax: Arguments
Glossary: Arguments
arguments
. List functions: thisThis would look pretty insane:

vipsi> Instructions: putput 100  -123  -23
vipsi> Instructions: putput 100  +123  223
vipsi> Instructions: putput 100  %011  1
vipsi>  

Flow control: if … thenIf you successfully construct a case where it matters, use Instructions: putput Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
enclose it in Separators: Round brackets "( … )"parenthesis:

vipsi> Flow control: if … then
Flow control: if … then
if 1 -123 then
/* prints nothing */
vipsi> Flow control: if … thenif 1 Instructions: putput -123 Flow control: if … then
Flow control: try … then
then
-123 vipsi> Flow control: if … then
Flow control: if … then
if 1 (-123) then
-123 vipsi> Flow control: if … then
Flow control: if … then
if 1; -123 then
-123 vipsi>
return and end with no return value

These two Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
instructions
are special in Flow control: if … then
Flow control: try … then
the
way, that they are Flow control: if … then
Flow control: try … then
the
only Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
instructions
which can optionally take no Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
one Vipsi command syntax: Arguments
Glossary: Arguments
argument
. All other Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
instructions
can take either no Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
Operators: Make Identifier "@"at least one Vipsi command syntax: Arguments
Glossary: Arguments
argument
. List functions: thisThis is important for Flow control: if … then
Flow control: try … then
the
parser, because it must know whether Flow control: if … then
Flow control: try … then
the
Vipsi command syntax: Expressions
Glossary: Expression
expression
after an Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
instruction
must be interpretet as an Vipsi command syntax: Arguments
Glossary: Arguments
argument
to that Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
instruction
Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
as a Instructions: newnew Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
instruction
, even Flow control: if … thenif it yields a result. Flow control: if … then
Flow control: try … then
The
latter case is very common, because Flow control: if … then
Flow control: try … then
the
Operators: Assignment "="
Built-in operators: Assignments:
assignment
Vipsi command syntax: Operators
Operators
Glossary: Operator
operators
all Flow control: returnreturn Flow control: if … then
Flow control: try … then
the
assigned Glossary: Valuevalue (acually a reference to Flow control: if … then
Flow control: try … then
the
Glossary: Variable, var_refvariable) as result! Therefore:

Instructions: putput a=22

will Operators: Assignment "="assign 22 to a Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
print Flow control: if … then
Flow control: try … then
the
result, which is 22. Flow control: whileWhile

Instructions: putput "x" a=22

will print "x" but Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
not
Flow control: if … then
Flow control: try … then
the
result of Flow control: if … then
Flow control: try … then
the
Operators: Assignment "="
Built-in operators: Assignments:
assignment
a=22, because that is a Instructions: newnew Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
instruction
. Flow control: if … thenIf you wanted to print both, "x" Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
"22", Flow control: if … then
Flow control: try … then
then
you needed to append a=22 with a Separators: Comma ","comma "," to Flow control: if … then
Flow control: try … then
the
Vipsi command syntax: Arguments
Glossary: Arguments
argument
Data Types: Lists and arrays
Glossary: list, list_val
list
of Instructions: putput.

Additionally, Flow control: if … then
Flow control: if … then
if the
Flow control: nextnext Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
instruction
is self-defined Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
, Flow control: if … then
Flow control: try … then
the
parser Flow control: do … loopdoes Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
not
know
whether it will Flow control: returnreturn a result Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
assume that it will. List functions: thisThis makes no difference for a Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
written Operators: Make Identifier "@"at Flow control: if … then
Flow control: try … then
the
place of an Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
instruction
, because either it Flow control: do … loopdoes Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
not
Flow control: returnreturn a result Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
Flow control: if … then
Flow control: try … then
the
returned result will be discarded. (Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
note
: on Flow control: if … then
Flow control: try … then
the
vipsi shell printed for your convenience.)

Therefore Flow control: if … then
Flow control: try … then
the
parser has a little problem with Flow control: returnreturn Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
Flow control: end
Shell Immediate Commands: exit, quit, end
end
, which may Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
may Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
not
be followed by an Vipsi command syntax: Arguments
Glossary: Arguments
argument
. How to decide? Flow control: if … then
Flow control: try … then
The
stunning fact is, it's Shell Immediate Commands: exit, quit, endquite easy: Because both Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
instructions
break from Flow control: if … then
Flow control: try … then
the
program flow, Flow control: if … then
Flow control: try … then
the
Flow control: nextnext Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
instruction
won't be executed. Therefore in a proper program Flow control: if … then
Flow control: try … then
the
Flow control: nextnext Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
instruction
can only be a switching Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
terminating Vipsi command syntax: Flow control
Flow control
flow control
List functions: words
Shell Immediate Commands: words
word
: Flow control: if … then
Flow control: try … then
else
, Flow control: if … thenelif, Flow control: if … then
Flow control: try … then
then
Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
Flow control: do … looploop. Every other List functions: words
Shell Immediate Commands: words
word
makes no sense. So Flow control: if … then
Flow control: try … then
the
Flow control: returnreturn Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
Flow control: end
Shell Immediate Commands: exit, quit, end
end
handler just test, whether Flow control: if … then
Flow control: try … then
the
Flow control: nextnext List functions: words
Shell Immediate Commands: words
word
is one of those List functions: words
Shell Immediate Commands: words
words
(actually they test for 'Invariants: Built-in instructionsbuilt-in instruction returning no Glossary: Valuevalue') Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
Flow control: returnreturns with no result Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
evaluates Flow control: if … then
Flow control: try … then
the
following Vipsi command syntax: Expressions
Glossary: Expression
expression
.

There is no problem. Except in one situation, which stunningly often happens to me:

When a program fails somehow Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
i debug it, i often Instructions: putput in a Flow control: returnreturn somewhere. Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
And
that position, self-evidently is Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
not
before one of Flow control: if … then
Flow control: try … then
the
terminating Vipsi command syntax: Flow control
Flow control
flow control
List functions: words
Shell Immediate Commands: words
word
. Frequently enough before a Functions with varying return types: call
Instructions: call
call
to a self-defined Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
Flow control: if … then
Flow control: try … then
then
Flow control: if … then
Flow control: try … then
the
Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
Functions with varying return types: call
Instructions: call
call
after Flow control: if … then
Flow control: try … then
the
Flow control: returnreturn unexpectedly Instructions: getgets called before Flow control: returnreturn Flow control: returnreturns, just because Flow control: if … then
Flow control: try … then
the
parser assumes that it delivers an Vipsi command syntax: Arguments
Glossary: Arguments
argument
. Puzzled me sometimes.

From a real-world case:

Instructions: procproc Doit()
{
    QuelltextEinlesen()
    TagsAbtrennen()
    Flow control: returnreturn                  // <-- inserted for testing
    TagsBehandeln()
    AnkerErzeugen()
    QuerverweiseEinfügen()
    BuchNachHtmlKonvertieren()
    BuchdateienSchreiben()
}

In Flow control: if … then
Flow control: try … then
the
case above Flow control: if … then
Flow control: try … then
the
Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
TagsBehandeln() was called despite Flow control: if … then
Flow control: try … then
the
Flow control: returnreturn in front of it. List functions: thisThis is, as you can see, because i never terminate my Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
instructions
with Separators: Semicolon ";"semicolons ";" as i should Flow control: do … loopdo. Just adding a Separators: Semicolon ";"semicolon ";" after Flow control: if … then
Flow control: try … then
the
Flow control: returnreturn did remedy Flow control: if … then
Flow control: try … then
the
problem.

var argc = count globals - 1

Ever wondered why there is 1 subtracted when storing Flow control: if … then
Flow control: try … then
the
Numeric functions: countcount of List functions: globals
Shell Immediate Commands: globals
global
Glossary: Variable, var_refvariables into a Glossary: Variable, var_refvariable, which frequently happens to be named argc?

It's no bug, work-around Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
even an ambiguity, it's just that Numeric functions: countcount List functions: globals
Shell Immediate Commands: globals
globals
is executed after Instructions: var
How does VScript::Value() work?: Var*&
var
argc
, Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
therefore Flow control: if … then
Flow control: try … then
the
Glossary: Variable, var_refvariable argc already Numeric functions: existsexists when Numeric functions: countcount Numeric functions: countcounts Flow control: if … then
Flow control: try … then
the
Glossary: number, num_valnumber of List functions: globals
Shell Immediate Commands: globals
global
Glossary: Variable, var_refvariables. So Flow control: if … then
Flow control: try … then
the
Numeric functions: countcount will Functions with varying return types: include
Instructions: include
include
Glossary: Variable, var_refvariable argc Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
we Operators: Subtract from Variable "-="
Operators: Subtract "-"
subtract
1 for that fact.

Just to Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
note
it somewhere.

Valid HTML   Valid CSS