You can make the Parva compiler with the usual command - from your work directory:

CMAKE Parva

You can compile one of these programs and look at the generated code with a batch command like the following (without running the program):

COMPILE examples\egxx (for example COMPILE examples\eg02)

You can compile and then immediately execute a program with a batch command like

RUN examples\egxx (for example RUN examples\eg05)

Or you can run the Parva compiler in the usual sort of way:

Parva eg05.pav Parva eg05.pav -l (to merge the error messages)

____________________________________________________________________________________

void main () { $C+  // eg00.pav
// We must be able to use strings in read and write statements as before
  int i;
  read("Supply a value for i " , i);
  write("The value you supplied was ", i);
}

____________________________________________________________________________________

void main () { $C+  // eg01.pav
// We must be able to use strings and general expressions in write statements
  int age;
  read("Hello - how old are you? ", age);
  writeLine("You must have been born in about", 2017 - age);
  writeLine("Any claim that you are older than I am is clearly", age > 72);
}

____________________________________________________________________________________

void main () { $C+  // eg02.pav
// We must be able to read and write strings
  string name;
  read("Hello - what is your name? ", name);
  write("It's nice to meet you, ", name);
}

____________________________________________________________________________________

void main () { $C+  // eg03.pav
// We must be able to assign strings to variables
  string formerHero, despot;
  formerHero = "Uncle Bob";
  writeLine(formerHero, " is old, and almost senile");
  despot = formerHero;
  writeLine("Even a tyrant like ", despot, " will die eventually");
}

____________________________________________________________________________________

void main () { $C+  // eg04.pav
// We must be able to declare string variables in nested blocks
  string formerHero;
  formerHero = "Uncle Bob";
  writeLine(formerHero, " is old, and almost senile");
  if (true) {
    string despot = formerHero;
    writeLine("Even a tyrant like ", despot, " will die eventually");
  }
}

____________________________________________________________________________________

void main () { $C+  // eg05.pav
// We must be able to assign strings to variables
  string yourName, myName;
  myName = "Pat";
  read("What is your name? ", yourName);
  write(myName, " is pleased to meet ", yourName);
}

____________________________________________________________________________________

void main () { $C+  // eg06.pav
// We must be able to compare strings for equality and convert them to upper case
  string yourName, myName, theBoff;
  myName = "Pat";
  theBoff = myName;
  read("What is your name? ", yourName);
  writeLine(myName, " is pleased to meet ", yourName);
  if (myName == yourName)
    writeLine("(Our names are the same)");
  if (upper(theBoff) == upper(yourName))
    writeLine("(Our uppercased names are the same)");
}

____________________________________________________________________________________

void main () { $C+  // eg07.pav
// We must be able to read and store a list of brilliant students in an array of strings

// You will find them all in the file CS301 in the kit

  const size = 38; // an obvious "magic number"

  string[] cs301 = new string[size];
  int i = 0;
  while (i < size) {
    read(cs301[i]);
    i++;
  }
  i = 0;
  while (i < size) {
    writeLine(i, "\t", cs301[i]);
    i++;
  }
}

____________________________________________________________________________________

void main () { $C+  // eg08.pav
// Some silly assignments
  string greeting = "hello", world = "world";
  greeting = world;
  read("Supply planet ", world);
  writeLine(greeting);
  writeLine(world);
  world = greeting;
  writeLine(greeting);
  writeLine(world);
}

____________________________________________________________________________________

void main () { $C+  // eg09.pav
// Some arb code with some arb strings!
  string g = "gee", h = "aitch";
  writeLine("g= ", g, " h= ", h);
  g = h;
  h = g;
  writeLine("g= ", g, " h= ", h);
  h = upper(g);
  writeLine("g= ", g, " h= ", h);
  writeLine("g= ", upper(g), " h= ", upper(h));
}

____________________________________________________________________________________

void main () { $C+ $D+  // eg10.pav
// A bit of debugging help, perhaps.  Don't forget the stackdump facility.
  string s, t;
  read(s);
  writeLine(upper(s));
  writeLine(s);
  t = s;
  read(s);
  writeLine(t);
  $SD
}

____________________________________________________________________________________

void main () { $C+  // eg11.pav
// We must be able to catch some silly misteaks
  string s = "Pat Terry";
  s++;  // Promotion at last?
  int i;
  read(s);
  writeLine(Upper(s));
  s = 3 * s;
  s = - s;
  s = s + 2;
  i = s;
  writeLine(s, "s");
}

____________________________________________________________________________________

void main () { $C+  // eg12.pav
// Short circuit Boolean operations
  string i, j, k;
  while (true) {
    read(i, j, k);
    write(i == j || k != i && i == upper(k));
    if (i == "stop" || i == upper("STOP")) break;
  }
}

____________________________________________________________________________________

void main () { $C+  // eg13.pav
// Undeclared variables
  list[i] = k + 5 + list[k + true] + list;
  s = "string";
  char s = upper("string");
  char s = s;
}

____________________________________________________________________________________

void main () { $C+  // eg14.pav
// Somewhat anxious to write the message many times
 write("hello ");
 write("hello ");
 write("there ");
 write("hello ");
 writeLine("there world ");
 write("there ");
 write("I have said it at last ");
}

____________________________________________________________________________________


Home  © P.D. Terry