Skip to content
This repository has been archived by the owner on Jun 20, 2021. It is now read-only.

Commit

Permalink
Merge pull request #38 from Thecarisma/master
Browse files Browse the repository at this point in the history
Feature : Syntax : Add the `final` keyword to make a final variable initialization once
  • Loading branch information
Youngestdev authored Sep 27, 2018
2 parents c2111ce + d07ac4e commit 5948e11
Show file tree
Hide file tree
Showing 19 changed files with 313 additions and 84 deletions.
22 changes: 19 additions & 3 deletions ROADMAP.MD
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ out how to make a **rfc** in the [rfc](https://github.com/simple-lang/rfcs) rep
The roadmap is divided into sections
- [General](#general)
- [Modules](#modules)
- [Extended Modules](#extended-modules)
- [Environments](#environments)

### General
Expand Down Expand Up @@ -47,13 +48,18 @@ build, installation, features e.t.c
- [ ] build script should create a .a archive for statically linking simple-lang runtime on linux os
- [ ] build script should create a .a archive for statically linking simple-lang runtime on mac os
- [ ] build script should create a .a archive for statically linking simple-lang runtime on haiku os
- [ ] add a new flexible keyword to lock a variable to a particular declaration similar to **final** to prevent re initializing
- [x] add a new flexible keyword **final** to lock a variable to a particular to prevent re initializing
- [ ] allow strong and weak typing to prevent inconsistent and conflicting initialization
- [ ] add directive for compiler notation in [] format
- [ ] VM should treat really really large number ad big as 10e+50
- [x] allow calling file with explicit module name translating to literal e.g `call simple.core.String` = `call "simple\core\String.sim"`
- [ ] Add strict equality `===` and `!==`
- [x] allow calling file with explicit module name translating to literal e.g `call simple.core.String` = `call "simple\core\String.sim" ? simple.core` [PR](https://github.com/simple-lang/simple/pull/34)
- [ ] Add strict equality `==` and `!=` and weak equality `===` and `!==`
- [ ] Add the `**` operator
- [ ] allow creating multi block i.e blocks with the same name but different parameter length
- [ ] use the Karatsuba Algorithm for pure multiplication of large numbers
- [ ] reformat the way the error are thrown in the console and web
- [ ] allow '*' to call all the file in a folder e.g simple.core.*
- [ ] update windows build file Windows-Build.bat to use main build C/C++ toolchain to build environment apps

### Modules

Expand All @@ -76,12 +82,22 @@ issue related to the module
- [ ] make curl request and accept both http and https protocols
- [ ] build a web module for cgi and template base development
- [x] Math module to treat any form of basic math operation
- [ ] add various multiplication method in the math module including Karatsuba algorithm
- [ ] include a block that fetch the number of factors a number have and another that return a list of a number factors
- [x] date and time module
- [ ] conversion module to convert between objects and types
- [ ] system, simplex and runtime module
- [x] create the hash module
- [x] a basic encrypt and decrypt module that uses keys and IV
- [ ] port murmur hash C library to simple-lang
- [ ] implement ncurses for use in simple-lang

### Extended Modules

Modules which are not part of the standard module that comes distributed with simple-lang. These modules are only avilable for use by downloading the release versions or using the simple-lang module manager **modular** to install them. These sources are hosted in a seperate repository but in the same organization. [source here.](https://github.com/simple-lang/extended-modules/)

- [ ] create material and native os extended module for fulltick GUI module
- [ ] a module that convert fultick Widget to HTML element

### Environments

Expand Down
4 changes: 2 additions & 2 deletions build/Windows-Build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -872,13 +872,13 @@ REM MINIFY ALL THE MODULE SOURCE (.sim) only
if !EXEC_TYPE!=="install" (
if exist "!INSTALLATION_FOLDER!\%VERSION%\modules" (
echo modules:minifying: starting simple sources minification in !INSTALLATION_FOLDER!\%VERSION%\modules directory
!INSTALLATION_FOLDER!\%VERSION%\bin\simple.exe !MINIFICATION_PROGRAM! --source !INSTALLATION_FOLDER!\%VERSION%\modules -y
REM !INSTALLATION_FOLDER!\%VERSION%\bin\simple.exe !MINIFICATION_PROGRAM! --source !INSTALLATION_FOLDER!\%VERSION%\modules -y
)
)
if !EXEC_TYPE!=="debug" (
if exist "..\..\%SIMPLE_DEBUG_VERSION%\modules" (
echo modules:minifying: starting simple sources minification in ..\..\%SIMPLE_DEBUG_VERSION%\modules directory
..\..\%SIMPLE_DEBUG_VERSION%\bin\simple.exe !MINIFICATION_PROGRAM! --source ..\..\%SIMPLE_DEBUG_VERSION%\modules -y
REM ..\..\%SIMPLE_DEBUG_VERSION%\bin\simple.exe !MINIFICATION_PROGRAM! --source ..\..\%SIMPLE_DEBUG_VERSION%\modules -y
)
)
echo modules:minifying: minification complete
Expand Down
78 changes: 33 additions & 45 deletions examples/intermediate/consoleprogressbar.sim
Original file line number Diff line number Diff line change
Expand Up @@ -10,54 +10,42 @@
* @Time - 09:42 PM
*/

call "simple/utilities/Console.sim"
call simple.utilities.Console

limit = 10000
PBSTR = "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
PBWIDTH = 60

@"A Progress That count from 0 to "+limit
@"Drawback is it blink indefinitely"

for a = 0 to limit {
display char(13)+" currently counting at "+a
}
@""+crlf

@"To prevent blinking we flush the console standard output"
@"Watch closely the same count from 0 to "+limit+" without blink : fails"

for a = 0 to limit {
display char(13)+" currently counting at "+((a/limit)*100)+"% "
__flush_console()
}
@""+crlf

@"A progress bar using #######"
for a = 0 to limit {
val = ((a/limit)*100)
display "Downloading at "+val+"% ["+joinChar("#",val)+"]"+char(13)
__flush_console()
}
@""+crlf

@"A progress bar 2 using #######"
progressBar = "...................................................................................................."
for a = 0 to limit {
val = ((a/limit)*100)
display char(269)+"Downloading at "+val+"% ["+joinChar2(progressBar,val)+"]"
}
@""+crlf

block joinChar(character,times)
fchar = ""
for b = 0 to times {
fchar+=character
block main()
display "Enter Your Limit : " read limit
@"A Progress That count from 0 to "+limit+" in different styles "
printProgress(limit,"=")

@""
for a = 0 to 200 {
printProgress_1((a * 100/200))
}
return fchar

block joinChar2(character,times)
for b = 0 to times {
character[b] = "#"
block printProgress(length,indicator)
progress = 0
while progress < length {
barWidth = 100

stdout.print("[")
pos = (progress * barWidth ) / length
for i = 0 to barWidth {
if i < pos stdout.print(indicator)
elif i == pos stdout.print(">")
else stdout.print(" ") end
}
stdout.print("] "+pos+" %% of "+progress+"\r")
stdout.flush()

progress ++
}
return character


block printProgress_1(percentage)
val = percentage * 100
lpad = percentage * PBWIDTH
rpad = PBWIDTH - lpad
stdout.vprintf(["\r#{1}%#{2} [#{3}#{4}]", val, lpad, PBSTR, rpad, ""])
stdout.flush()
39 changes: 36 additions & 3 deletions examples/modules/consoledemo.sim
Original file line number Diff line number Diff line change
@@ -1,22 +1,55 @@

#1
call simple.utilities.Console

call simple.core.List

block main()
obj = new TestObject
obj1 = new CustomStringObject
obj2 = new NoToString
list = new List(["This only for #{2} mudule test ignore #{1}\n", "Typos", "Console"])

#the stdout
stdout.println("\tHello World")
stdout.println("\tHello World") #string
stdout.println(1 * 2 + 23 + 65 / 1 * 767) #number
stdout.println([1,"26",256,"tes", "2354"]) #list
stdout.println(null) #null
stdout.println(obj) #object inherit simple.core.Object
stdout.println(obj1) #object 1 has a custom toString()
stdout.println(obj2) #object 2 has no toString() block
stdout.print("Yes you the boss\n")
stdout.printfc(ConsoleColor.BLUE()," The string in blue - STD OUT \n")
stdout.vprintf(["#{1} #{2} #{3} bit #{4} of version #{5}\n", "this", "is", 8 * 8, "simple-lang", getSimpleVersion()])

#the std err
stderr.println("This is an error")
stderr.println(1 * 2 + 23 + 65 / 1 * 767) #number
stderr.println([1,"26",256,"tes", "2354"]) #list
stderr.println(null) #null
stderr.print(obj) #object inherit simple.core.Object
stderr.print(obj1) #object 1 has a custom toString()
stderr.println(obj2) #object 2 has no toString() block
stderr.print("This is an error in print\n")
stderr.vprintf(list)
stderr.printfc(ConsoleColor.RED()," The string in red - STD ERR \n")

#global block
println(stdout, "print with newline Hello World globally")
print(stdout, "print Hello World globally")
printfc(stdout,ConsoleColor.RED()," The string in red")
@_vformatf(["\nJust for #{1} console ", "Testing"])
printfc(stdout,ConsoleColor.YELLOW()," The string in yellow")


class TestObject : Object

class CustomStringObject

block toString()
return "[CustomStringObject:toString():it custom toString()]"

class NoToString

num = 1 nim = 2

/*[obsolute]
block main_old()
Expand Down
54 changes: 54 additions & 0 deletions examples/syntax/final.sim
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

/*
KEYWORD : final
FUNCTIION : To lock a variable to only one initialization, to prevent assigning new value to a
variable that not meant to change value.
USE CASE : In the @File Console module the **stdout** is a final variable to prevent initializing it to something
else to prevent runtime error while using the @File Console blocks and classes
*/

flexibleDuck = "This is a changable variable anytime any where"
final finalVar = "This remain throughout execution"
final aClass = new AClass
try {
aClass.setPath("a new path")
catch
@__err__
}

@flexibleDuck
@finalVar

flexibleDuck = "Well the duck is an animal"
try {
finalVar = "Try changing to another value"
catch
@__err__
}

@aClass.getPath()
@flexibleDuck
@finalVar
@InerFinal()


block InerFinal()
final innerFinal = "inner final variable"
notFinal = "desi"

notFinal = "indoian"
innerFinal = "Try changing it throw an error"

@innerFinal

class Parent

final path = "foo ? bar ? whatever "

block getPath()
return path

class AClass : Parent

block setPath(p)
this.path = p
7 changes: 4 additions & 3 deletions modules/dynamic_modules/consoler/consoler.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,12 @@ void std_print(void *pointer)

void program_flush_console(void *pointer)
{
if ( SIMPLE_API_PARACOUNT != 0 ) {
SIMPLE_API_ERROR(SIMPLE_API_BADPARATYPE);
if ( SIMPLE_API_PARACOUNT != 1 ) {
SIMPLE_API_ERROR(SIMPLE_API_MISS1PARA);
return ;
} else {
fflush(stdout);
FILE* std_output = (FILE*) SIMPLE_API_GETCPOINTER(1,"SIMPLE_CONSOLE_");
fflush(std_output);
return;
}
}
Expand Down
Loading

0 comments on commit 5948e11

Please sign in to comment.