0% found this document useful (0 votes)
6 views1 page

A Language Design

@ uses only symbols and not English keywords such as "while" or "for" Features It does not have to define types for any variables as it dose find a suitable type Array in this language is expandable No pointer as it automatically reference and deterrence it all values are passed by value Some features like main() function, block, and basic operations are copied from Java and C++.

Uploaded by

Naoya Makino
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

A Language Design

@ uses only symbols and not English keywords such as "while" or "for" Features It does not have to define types for any variables as it dose find a suitable type Array in this language is expandable No pointer as it automatically reference and deterrence it all values are passed by value Some features like main() function, block, and basic operations are copied from Java and C++.

Uploaded by

Naoya Makino
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

CPSC2150:Instructor Nalin Wijesinghe Examples

Assignment 3: design Due October 06, 08 main()


Naoya Makino: 100106040 {
Purpose: design a programming language named @ that uses X:=”Hello world”
only symbols and not English keywords. <<x // putut “Hello World”
Assumptions y := 1
• No English key words such as “while” or “for” ∀(y <= 10)// for every y less than or equal to 10
Features {
• It does not have to define types for any variables as <<y // output the value of the y
it dose find a suitable type y++ //increment by one and ‘;’ indicates the
• Array in this language is expandable property of ‘∀’ is until here
}
• No pointer as it automatically reference and
write(x)//call a function called “write”
deterrence it }
• All values are passed by value write(x)
• Some features like main() function, {} block, and {
basic operations are copied from Java and C++ <<x
The table of Major Symbols }
Symbols Explanations Examples Another example
:= Assigns X := 10 main(){
== Equal to (X == 10) → y x :=[]//create an empty erray. By the way,
:=5 i := 0
→ Implies; if…, then… (X == 10) → j := 0
y:=5 minimum := 0
! Negation (x != 10) → y ∀(i <= 10)// for every x <= 10
:=5 {
< x < y means x is less than y. 3 < 4 x[i] >> //input x[i]
> x > y means x is greater than 4 > 3 ∀(j <= 10) // nested for loop
y. {
+ 4 + 6 means the sum of 4 X := 4 + 6 (x[i] < x[j]) → minimum := x[i] //
and 6. if x[i] is smaller than previous entries, then minimum = x[i]
- 9 − 4 means the subtraction X:= 9-4 J++
of 4 from 9. }
* 3 * 4 means the X := 3*4 i++
multiplication of 3 by 4. }
/ 6 ⁄ 3 means the division of 6 X:= 2/1 <<”minimum value out of the ten entry is ” <<
by 3. minimum
&& Conjunction (x == 10) && (y }
==5)
Ex: Example binary search
|| Disjunction (x == 10) || (y
binarySearch(sortedArray[], first, last, key)
==5)
{
>> Input steam x >>
∀(first <= last) { //while first <= last
>> return function >> x // return x
mid := (first + last) / 2// compute mid point.
<< Output steam <<x (key > sortedArray[mid]) → first = mid + 1; //
∀x ∀ x: P(x) means P(x) is ∀ xF(x <=10) repeat search in top half.
true for all x. it loops until y++ (key < sortedArray[mid]) →last = mid - 1; //
F(x) is false repeat search in bottom half.
[,] [a,b,c] means the set ℕ = [ 1, 2, 3] >> ↓ mid; // found it. return position
consisting of a, b, and c. }
// // indicates a comment line X := 10// x is >> -(first + 1); // failed to find key
assigned 10 }
↓ Else (X < 10 ) → x++
↓ x--
++ Increment by one X++
-- Decrement by one x--

You might also like