properscript
v1.0.5
Published
JavaScript, but proper.
Maintainers
Readme
Installation
Install ProperScript globally via npm:
npm install -g properscriptQuick Start
- Create a file
hello.ps:
changeable message = "Hello, ProperScript!";
announce(message);Visual Studio Code Extension
We have a Visual Studio Code extension to give you ProperScript IntelliSense. Check it out here.
- Compile it:
proper compile hello.ps- Run the compiled JavaScript:
node hello.jsSyntax
Keyword Reference
| ProperScript | JavaScript | Description |
|--------------|------------|-------------|
| changeable | let | Mutable variable |
| persistent | const | Immutable variable |
| announce | console.log | Print to console |
| inform | console.warn | Print warning |
| blunder | error | Print error |
| sorry | error | Error |
| terribly sorry | fatal error | Fatal error message |
| queue | await | Async await |
| please | then | Promise then |
| correct | true | Boolean true |
| mistaken | false | Boolean false |
| acquire | import | Import modules |
| whether | if | Conditional statement |
| period | while | While loop |
| heretofore | while(true) | Infinite loop |
| changeover | switch | Switch statement |
| goback | return | Return statement |
| visit | goto | Goto statement |
For complete documentation, see docs/.
Examples
Hello World
ProperScript (hello.ps):
persistent greeting = "Hello, World!";
announce(greeting);Compiles to (hello.js):
const greeting = "Hello, World!";
console.log(greeting);Counter with Loop
ProperScript (counter.ps):
persistent stopNum = 10;
changeable count = 0;
heretofore {
whether (count === stopNum) {
goback;
}
announce('Current count:', count);
count++;
}Compiles to (counter.js):
const stopNum = 10;
let count = 0;
while(true) {
if (count === stopNum) {
return;
}
console.log('Current count:', count);
count++;
}Async/Await
ProperScript (async.ps):
async function fetchData() {
changeable response = queue fetch('https://api.example.com/data');
changeable data = queue response.json();
goback data;
}
fetchData()
.please(data => announce('Received:', data))
.catch(sorry => announce('terribly sorry:', sorry));Compiles to (async.js):
async function fetchData() {
let response = await fetch('https://api.example.com/data');
let data = await response.json();
return data;
}
fetchData()
.then(data => console.log('Received:', data))
.catch(error => console.log('fatal error:', error));Error Handling
ProperScript (errors.ps):
try {
throw new Error("terribly sorry");
} catch (blunder) {
inform("A blunder occurred:", blunder.message);
}Compiles to (errors.js):
try {
throw new Error("fatal error");
} catch (error) {
console.warn("A error occurred:", error.message);
}More examples in examples/.
CLI Usage
# Compile a single file
proper compile file.ps
# Compile multiple files
proper compile file1.ps file2.ps file3.ps
# Show version
proper --version
# Show help
proper --helpContributing
We welcome contributions! Here's how to get started:
- Fork and clone the repository:
git clone https://github.com/ingStudiosOfficial/properscript.git
cd properscript- Install dependencies:
npm install- Make your changes and test:
node packages/cli/index.cjs compile examples/hello.ps- Submit a pull request
See CONTRIBUTING for more details.
License
Licensed under Apache-2.0. See LICENSE for details.
Credits
Made with 💖 by (ing) Studios and Ethan Lee
Original idea from a r/programmingmemes comment
