Skip to content
FISH Programming Language has been developed using Antlr4 and Java that includes intermediate code generation and runtime.
Java Shell ANTLR
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
data updated repo Apr 29, 2018


SER 502 - TEAM 16

Naga Ravi Teja Thoram -
Tarun Kolla -
Koushik Kotamraju -
Siva Pranav Mandadi -

System Execution environment: Windows.
Tools Used: Java SDK 1.8, Eclipse, ANTLR4.

Instructions to install Fish Programming Language:

-Download the install folder present in the repository
-The folder consists of .jar file for compiler and runtime.
-The 2 .bat files are used to execute the compiler and runtime

Instructions to build and execute the program:

-Write the Input program snippet with the file name <FileName>.fish within the same folder of the .jar files
if not give the absolute path to the program file.

Command to Execute the compiler and the runtime:

For Windows:

 -Execute using the given .bat commands to run the .fish file. 

To Compile:

 fishCompile <FileName>.fish if in same folder 
 fishCompile "absolute path" \<FileName>.fish for different folder
 Output: <FileName>.fish.ic

To generate output:

 fish <FileName>.fish.ic if in same folder
 fish "absolute path" \<FileName>.fish.ic for different folder
 output: Generates the program output on to the command prompt

For OSX:

Navigate to the install folder or use absolute path and then

To Compile:

 java -jar compile.jar <FileName>.fish
 Output: <FileName>.fish.ic

To generate output:

  java -jar runtime.jar <FileName>.fish.ic
  Output: Generates the program output on to the command prompt

FISH language programming guidelines:

FISH is a simple programming language that starts and ends with a statement as:
    write "Hello FISH"

It consists of the following: (Click to expand)

  1. Statements
  2. Assignment

    Fish language supports assignment statements and can be written as:

    f = 1


    Data types should be declared with a $ sign as:

    $a $b


    Write is used to display a prompt such as:

     write f

    Write can also be used to display portion of a line:

    write "Keep fishing"


    Read is used for obtaining input of the primitive types such as Int and can be writen as:

    write "give the value of f:"
    read f

  3. Data Types
  4. Int

    It is recommended that Integer values are to be declared at the start of the program and can be initialized as follows:

    f = 0

    We can also have multiple initializations on the same line

    $f $i
    f = 0 i = -1


    Real numbers such as 1.0, 2.2, 3.67 etc., can be initialized as follows:

    f = 2.7

    As Fish language supports dynamic typing we do not have to specify the type.


    Fish supports boolean types and can be initialized as:

    f = true
    i = false

  5. Operation
  6. Arithmetic

    Fish programming language supports arithmetic operations such as addition '+', subtraction '-', multiplication '*', division '/', modulus '%'.

    i = 2
    read f
    operate = (f % 3) - i
    write operate


    Fish supports relational operators such as equalto '==', notequalto '!=', lessthan '<', graterthan '>', lessthaorequalto '<=', greaterthanorequlato'>='.

    $f $i
    f = 2
    read i
    if(i >= 2):
        write "i is greater than or equal to 2"


    Logical operators AND '&&' , OR '||' are supported by fish and their syntax is as follows:

        write "It works"

  7. Constructs
  8. Conditional

    If is a control flow statement that starts as if(): and ends with endif as:

     read f
     if(f == 0):
         write "f is zero"

    If can also be followed with an else statement:

    $f $i $s $h
    f=0 i=1
    read h
    if( h == 0):
        s = f + i
        write s
        s = f * i
        write s


    The loop statement continually executes a block while a particular condition is true. Its syntax can be expressed as:

     loop(f > 1):
         write f
     f = f - 1

  9. Functions
  10. Function Block

    Fish language supports functions that start with fun(), ends with endfun and should have a return as:

    fun NAME($f):
        <return Statement> 

    Function call

    Functions in Fish supports function calls as that also writes return values:

    $f $i
    f = NAME(<argument>)
    f = i + NAME(<argument>)
    write NAME(<argument>)

Scope & Restrictions

This sections talks about what FISH programming language can do. The list below has a detailed explanation of the same.

1. Dynamic Typing

  • Our programming language dynamically decides the data types of variables just like Java Script/Python.
  • We support three data types and user only need to declare variable, need not bother about type of variable.
  • Whenever a variable is declared we are giving default value as "0" and setting default type as "NONE".
  • Based on the context, we typecast data or shows error message to perform operations among data types.
  • Consider the example program
  • o/p of that program is :
    1 type:NUMBER
    3.0 type:REAL

      The output illustrates the dynamic typing in our language because based on context the type of variable "a" is changing.

  • The simple principle we followed in order to achieve dynamic typing is taking care of context/types whenever assignment statement triggers.
  • The priority FISH follows to choose type based on context whenever heterogeneous types occurs is
    Scenario 1 (in case of Arithmetic and Relational Operations):
      REAL > NUMBER > NONE (example "" also illustrates this concept at the statement a = a + b
      where b = 2.0 after executing this statement a becomes REAL prior to that it is NUMBER)
    Scenario 2 (in case of Logical operations) :
      BOOLEAN (logical operations such as AND/OR works only if operands are BOOLEAN)

2. Strong Typing

  • Identifier and assignment statement are places where we can loose our control over program. Whenever we are assigning a identifier to another identifier i.e a=b (b must hold a value prior to this assignment statement). Since Fish is a Strongly typed language it

  •   checks scope of 'b' in the environment before assignment.
      Consider the program
    o/p of that program is :
    variable not declared : d
    variable not declared : b


  • This program proves that FISH dont allow assignment of undeclared variable to another variable or use of undeclared variable any where in the program thereby proving the quality of STRONG TYPING.
  • The restriction in this strong typing occurs only at "checking no.of arguments at functioncall == no.of parameters at function definition". We have not checked this during runtime.

3. Meta Language Inspiration

  • Inspired from ML, Fish also prints type of "variable" on console when used along with write "statement" (i.e write a => display value and type of 'a' on console).
    Printing type of variable will also exhibits our "DYNAMIC TYPING".

4. Wonders of FISH write Statement

  • write can hold a function call (prints return value)
  • write can evaluate expressions (arithmetic operations,logical and relational operations)
  • (illustrated in program and )

5. Arguments

  • FISH Functions can take expressions as "arguments" and Fish Functions can be part of expressions. This scenario is illustrated in the program.

6. Variable Declaration

  • Fish allows to declare variable at any part of program and from that point of declaration that variable holds "Global Scope". This is good thing but this led to some restriction for us i.e. Use of Same variables in the Function Block and Main Block can corrupt the program. This problem is due to use of global environment hash table instead we have to create environment states block specifically to restrict scope.

7. Restriction

  • FISH functions demand at least one argument. Our grammar and runtime is in accordance with this feature.
  • FISH functions do not support "Recursion".
    The reason for this is because we havent created Dynamic Stack Frame to handle environment and runtime stack of each function. We handled everything in global stack.
  • FISH functions expects definition of recent function call first.
    Consider the example "" in this as "SUB" is latest function call the definition of the SUB must be found prior to "ADD"
    The reason for this restriction is due to usage of stack during compile time while forming intermediate code to store the point of function call.
  • Functions can take given expressions as arguments bu it is recommend to leave a space between the operand and operators. Consider the example of f+1, this recommended to be written as f + 1.

Other Resources

You can’t perform that action at this time.