1.0.0 • Published 5 years ago

@popscript/core v1.0.0

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

🍿 Popscript programming language

Popscript is a programming language focused on simplicity, productivity and speed.

📦 Install it

You'll need:

  • Node.js > 13
  • NPM > 6
   # Open terminal and type:

   ~ npm i

   # Once package are installed, type:

   ~ npm run dev

   # It will execute simple example code.

💬 Simple hello world script

   print "Hello world!"

🔨 How it works

Popscript is a tab-based language. Its particularity is that it does not require a keyboard combo like CTRL + ALT.

• Variables

      • Strings
   username = "Ness"
   print "Welcome" username + "!"
      • Numbers
   number = 10
   print "Number is" number
      • Arrays
   array = ( "item" "item" "item" )
   print "Array is" array
      • Booleans
   boolean = true
   print "Switched:" boolean
   

• Remove values

      • Strings
   text = "My name is Ness"
   print text - "Ness" ; Output : "My name is "
      • Numbers
   number = 5
   print number - 2 ; Output : 3
      • Arrays
   array = ( "item" "item2" "item3" )
   print array - "item" ; Output : ["item2", "item3"]

• Add values

      • Strings
   text = "My name is Ness"
   text += "."
   print text ; Output : "My name is Ness."
      • Numbers
   number = 5
   number += 5
   print number ; Output : 10
      • Arrays
   array = ( "item" "item2" "item3" )
   array += "item4"
   print array ; Output : ["item", "item1", "item2", "item3"]

• Indexes

   array = ( "item" "item2" "item3" )
   print array:0 ; Output : "item"

• Properties

   array = ( "item" "item2" "item3" )
   print array:length ; Output : 2

• Type conversion

   number = 5
   print str : number
   
   number = "10"
   print int : number
   

• Comments

   ; This is a comment
   comment = "coucou" ; Comments can follow any declaration.

• Conditions

   number = 5
   if number > 5
	   print "Number higher than 5"
   elif number = 5
       print "Number equal to 5"
   else
	   print "Number lower than 5"
	

• Loops

      • For loops
   array = ( "item1" "item2" "item3" )
   for item in array
	   print "Item is" item
      • While loops
   number = 0
   while number < 10
	   number += 1
	   print "Number value is" number

• Functions

      • Define functions
    fn welcome => user
	    print "Welcome" user + "!"
      • Call functions
    welcome => "Ness"

• And / Then

   username = "Ness" and print username
   number   = 5 and number += 5 then print number
   

• Modules

      • Export
   ; File is module.ps
   export fn welcome => user
	   print "Welcome" user + "!"
	
      • Import
   
   import module from "module"
   module -> welcome => "Ness" ; Output: "Welcome Ness!"