Git Product home page Git Product logo

red's Introduction

# Red
A homemade simple programing language named red
##########################################################################
#                                                                        #
#                   		  This is comments                           #
#                                                                        #
##########################################################################

# The real seperator of every statment is `\n`, but I've found that it easy to make program a mess
# So I add ";"symbol to solve it

# Define a string object whose label is `name`
name = "Justin"; # Define a string object

# Define a int object whose label is `age`
age = 22;

# This echon is a keyword not a builtin function, it means `echo no new line`
# It has the ability to call the description function of the object to print the string message
# The statment after `echon` can be combination of string, int and float objects in this 0.1.1 version
# Recommend: Use<< string object or int object >>this form when you need print  string, int and float object in the sametime,
# This form supported aim to make the echon statment clearer
# NOTE!! there are at least two blank spaces  among `<<`, name and `>>`
# In fact, you can also use blank space or comma to seperate `echon` statment
echon "My name is " << name >> ", I'm " << age >> " years old now!";

# This `echo` keyword has the same function as `echon`, but it will automatically print a new line
echo "";

# Following is the example of if elif and else statment

# A binary operator expression is available, such as a == 8, a != 8, a <= 8 or a >= 8 and so on,
# but unary operator expression is not tested, maybe it doesn't work :(.
# After the expression, a `;` and a '\n' are expected to followed. The `do` keyword should appear
if age == 10;
do;
	echo "Well, age equals 10";
elif age < 10;
do;
	echo "Well, age is less than 10";
elif age > 10;
do;
	echo "Well, age is greater than 10";
else;
do;
	echo "No, age is not a positive number";
# The end symbol of if elif and else statment is `done` keyword
done;

# Example for `+`, `-`
a = 10 + 20;
b = 20 + -10;
echo a;
echo b;
echo a + b;
# echo a - b; has bug


str1 = "Hello, "
str2 = "World!"
str3 = str1 + str2;
echo str3;

echo str1 == str2;
echo str1 == str1;

# Interact with user
echo "Please enter your name:";
name = input;
echon "";
echo "Please enter your age:";
age = input;
echon "";
# Change sstring a to int a
age = toint age;
echon "Your name is " << name >> ", and your age is " << age >>;
echo "";
agee = age + 1;
echon "I will be " << age >> " years old in the next year";

red's People

Contributors

megacjh avatar

Stargazers

 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.