Skip to content

My own programming language. Completely different from its earlier version pear 1.00. Written using python

Notifications You must be signed in to change notification settings

NaveenDanj/pear-v2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pear Programming Language (v2.0.0)

Introduction

This language is written by me using python. This Language is using intrepreter. All components (Lexer , Parser , Runtime) is written by me. In this language i have tried to reduce the complexity of the code and tried to implement the syntax similar to the psuedo code so its easier to build a code by just looking at the algorithm. Currently supporting String , int , float , boolean data types. Still in the experimental stage.

Installation

Installing Pear to your windows operating system is fairly easy.

  1. First Download the latest version of pear from our official github repository.
  2. Exctract the pear binary to the root of the C drive.
  3. Add Pear binary file path to your environment variable.

Run Pear script

Simply run the command 'pear filename.pr'

Examples

Find maximum number

@start

var float n1 = float( input('Enter number 1 : ') )
var float n2 = float( input('Enter number 2 : ') )
var float n3 = float( input('Enter number 3 : ') )

if var['n1'] > var['n2']

    if var['n1'] > var['n3']
        print 'max number is : ' + str( var['n1'] )
    else
        print 'max number is : ' + str( var['n3'] )
    endif

else

    if var['n2'] > var['n3']

        if var['n2'] > var['n1']
            print 'max number is : ' + str( var['n2'] ) 

        else
            print 'max number is : ' + str( var['n1'] ) 
        endif

    else

        if var['n3'] > var['n1']
            print 'max number is : ' + str( var['n3'] ) 

        else
            print 'max number is : ' + str( var['n1'] ) 
        endif

    endif

endif

@end

Factorial of a given number


@start

var int n = int( input('Enter number 1 : ') )
var int total = 1

while var['n'] > 0
    set var['total'] = var['total'] * var['n']
    set var['n'] = var['n'] - 1
endwhile

print 'Factorial is ' + str(var['total'])

@end

Pear Function Example

@start

    function sum (int param1 , int param2) ->
        print 'total is : ' + str( var('param1') + var('param2')  )
    endfunction

    function InputNumbers () ->
        print 'Sum Of Two Numbers : '
        var int x1 = int( input(' Enter n1 : ') )
        var int x2 = int( input(' Enter n2 : ') )
        call sum ->( var('x1') , var('x2') )
    endfunction
    
    
    call InputNumbers ->()

    print 'Done'

@end

About

My own programming language. Completely different from its earlier version pear 1.00. Written using python

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages