GithubHelp home page GithubHelp logo

sitanhuang / rjc Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 7.08 MB

RJC programming language

Home Page: https://github.com/SitanHuang/RJC

CMake 2.69% C++ 87.24% Objective-J 0.20% C 7.19% Makefile 2.68%

rjc's Introduction

RJC Programming language

written in c++, by the java programmer

kdevelop 4 project (cmake)

c++14

LICENSE:

Garbage Collector is WIP

Example 1

load "std/std.j"

:int test 5
if test bg 4
	puts 'test bg 4'
end
if test sm 5
	puts 'test sm 5'
elif test sm 6
	puts 'test sm 6'
end
if (test sm 5) or (test bg 4)
	puts 'hahaha'
end

puts "
--------------\n
"

:class a array
puts a
a.set 0,'1'
a.set 1,'2'
a.set 2,'['jfffdsjfdsjflkdsflkds',1,5]'
a.setString 3,'hahahaha'
puts a
puts a.size;
puts a.at 2;

output:

test bg 4
test sm 6
hahaha

--------------


[]
[1,2,[" jfffdsjfdsjflkdsflkds",1,5],"hahahaha"]
4
[" jfffdsjfdsjflkdsflkds",1,5]

Adding a method

load 'std/' + "std.j"
class p
        fcn init string s
                @string s s
        end
end

fcn p$toString
        return string s
end

:class p p 'hahaha'
puts p

output:

hahaha

Operator overloading

load 'std/std.j'

class num
	fcn init int i
		@int v i
	end

	fcn '+' int i
		v v - i
	end

	fcn toString
		return string v
	end

end

:class n num 5
n."+" 4
puts n

output:

1

Modules

modules are special classes with an instance

load "std/std.j"
module print
	fcn puts string s
		puts s
		puts
		puts s
	end
end

print.puts 'Hello world!'

output:

Hello world!

Hello world!

Example 2

load "std/std.j"

class printer

	puts '-----'

	fcn init string s
		@string value s
	end

	fcn init
		printer$init nil
	end

	fcn print int times
		:int temp 0
		loop temp neq times
			puts value
			temp temp + 1
		end
	end

	fcn toString
		return string value
	end

	fcn setValue string s
		value s
	end
	
end

:class p printer
puts p
p.setValue "Hello world!"
puts p
p.print 5

output:

-----
$nil$
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!

rjc's People

Contributors

sitanhuang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.