Giter VIP home page Giter VIP logo

syntax's Introduction

Raj Lang Syntax

Syntax of raj programming language

๐Ÿค Contributing

Please Vote for proposals or propose new at Dicussions

Syntax

// Single line comment
# This is also single line comment

/*
* Multi
* line
* comment
*/

// Defining a function

fn main() {
  print("Hello World"); // Without new line
  println("Hello World"); // With new line
  
  // Prints "Hello, World! - Hello, World! - ... 8 times"
  for(i = 0; i < 10; i++) {
    print("Hello, World!", end=" - ");  // custom end character
  }
}

// Defining variables

let myVar1 = 1; // mutable variable with local scope
// or
myVar2 = 10 // doesn't need keyword to declare. if already declared then changes it
const PI = 3.1415; // im-mutable constant with global scope

// Loops

// for
for ( i = 0; i < 10; i++ ) {
  println(i);
}

// while (not infinite loop)
while (sayHello) {
  print("Hello World");
  break;
}

// loops infinitely with optimizations
loop {
  println("I love Programming");
}

// do-while
do {
  println("Do");
}
while (true) {
  println("while");
  break;
}

// arrays

myArr = [ 1, 2, 3, 4, 5 ];

myNestedArr = [ 1, [ 2, 20, 200, 2000 ], 3, 4, [ 5, 4, 3, 2, 1 ] ]; // arrays within array


// Object

myObj = {
  name: "Rajaniraiyn",
  age: 17,
  nationality: "Indian"
  location: {
    village: "Okkur",
    district: "Sivagangai",
    state: "Tamilnadu",
    country: "India",
  },
}

// Conditionals

if ( a == b) {
  println("Hello World");
} else {
  println("Hello Everyone");
}

// template literals

`
this is the 
m
u
l
t
i
line
template-literal
`
"""
this is also a 
m
u
l
t
i
line
template-literal
"""

// switch statements


switch(a) {
  1 || 3 :
    println("a is one");
    break;
    
  2 || 4:
    println("a is two");
    break;
    
  default:
    println("a is not one or two");
    break;
}

syntax's People

Contributors

rajaniraiyn avatar

Stargazers

 avatar

Watchers

 avatar

syntax's Issues

Suggest for syntax docs

I think we should maintain a documentation on the site rather than a code block ๐Ÿ˜„

Import statement

Is your feature request related to a problem? Please describe.
Many languages like Python, Java and JavaScript have different ways to import other files or functions.

Describe the solution you'd like
A syntax to import functions or other files.

Describe alternatives you've considered
Probably we could mimic the Python import syntax and parse it to the syntax of the other languages.

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.