Skip to content
This repository has been archived by the owner on Dec 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #78 from SK1Y101/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
mergify[bot] authored Mar 26, 2021
2 parents 72d5a75 + dbf33b3 commit 204f43e
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 35 deletions.
3 changes: 1 addition & 2 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"files": [
"README.md",
"ExampleCode/README.md"
"README.md"
],
"imageSize": 100,
"commit": false,
Expand Down
56 changes: 39 additions & 17 deletions ExampleCode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Dynamically typed Object Oriented Program Language.
![Snyk Vulnerabilities for GitHub Repo](https://img.shields.io/snyk/vulnerabilities/github/SK1Y101/PySkiylia)
[![codecov](https://codecov.io/gh/SK1Y101/PySkiylia/branch/main/graph/badge.svg?token=DRJ67ZQA7M)](https://codecov.io/gh/SK1Y101/PySkiylia)
[![time tracker](https://wakatime.com/badge/github/SK1Y101/PySkiylia.svg?style=flat-square)](https://wakatime.com/badge/github/SK1Y101/PySkiylia)

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat)](#contributors)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
Expand All @@ -20,26 +19,49 @@ This repository folder contains examples of Skiylia-specific code, and (possibly

Support here: [issues]

## Contributors
## Sample Function code

///This section contains a small snippet of Skiylia
code that calculates the factorial of a number///

def factorial(n):
if int(n) != n:
return null //can't compute factorial of a float this way
if n < 2:
return 1
return n * factorial(n - 1) //recursion that makes this work

var num = 6
print("The factorial of", num, "is", factorial(num))

//output: The factorial of 6 is 720

## Sample Class structure

///This section contains a small snippet of Skiylia
code that demonstrates class methods and properties///

class Person:
init(name, age): //executed on initialisation
self.name = name
self.age = age

hello():
print("Hi there, I'm", self.name, ", and I'm", self.age)

birthday():
self.age = self.age + 1

All the people who have contributed ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="https://github.com/SK1Y101"><img src="https://avatars.githubusercontent.com/u/8695579?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jack Lloyd-Walters</b></sub></a><br /><a href="https://github.com/SK1Y101/PySkiylia/commits?author=SK1Y101" title="Code">💻</a> <a href="https://github.com/SK1Y101/PySkiylia/pulls?q=is%3Apr+reviewed-by%3ASK1Y101" title="Reviewed Pull Requests">👀</a></td>
<td align="center"><a href="https://github.com/SK2Y202"><img src="https://avatars.githubusercontent.com/u/81203841?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jack Lloyd-Walters</b></sub></a><br /><a href="https://github.com/SK1Y101/PySkiylia/pulls?q=is%3Apr+reviewed-by%3ASK2Y202" title="Reviewed Pull Requests">👀</a></td>
</tr>
</table>
var John = Person("John", 24)
John.hello()

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
John.birthday()
John.name = "Johnathon"
John.hello()

<!-- ALL-CONTRIBUTORS-LIST:END -->
///Hi there, I'm John, and I'm 24
Hi there, I'm Johnathon, and I'm 25///

This project follows the [all-contributors](https://allcontributors.org) specification.
Contributions of any kind are welcome!

[Latest release]: https://github.com/SK1Y101/PySkiylia/releases
[issues]: https://github.com/SK1Y101/PySkiylia/issues
Expand Down
23 changes: 23 additions & 0 deletions ExampleCode/classExample.skiy
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
///This section contains a small snippet of Skiylia
code that demonstrates class methods and properties///

class Person:
init(name, age): //executed on initialisation
self.name = name
self.age = age

hello():
print("Hi there, I'm", self.name, ", and I'm", self.age)

birthday():
self.age = self.age + 1

var John = Person("John", 24)
John.hello()

John.birthday()
John.name = "Johnathon"
John.hello()

///Hi there, I'm John, and I'm 24
Hi there, I'm Johnathon, and I'm 25///
13 changes: 13 additions & 0 deletions ExampleCode/factorial.skiy
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
///This section contains a small snippet of Skiylia
code that calculates the factorial of a number///
def factorial(n):
if int(n) != n:
return null //can't compute factorial of a float this way
if n < 2:
return 1
return n * factorial(n - 1) //recursion that makes this work

var num = 6
print("The factorial of", num, "is", factorial(num))

//output: The factorial of 6 is 720
13 changes: 13 additions & 0 deletions PySkiylia/Lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ def tokenFromChar(self):
elif c == "/":
#as division and comments use the same character, check if the next is a comment
if self.match("/"):
#as comments can mess with indentation, remove any leading up to it
self.removewhitespace()
#as multi-line comments are ///, whereas a single line is //, we need to check for that too!
if self.match("/"):
#keep advancing until we find the tripple comment escape
Expand Down Expand Up @@ -302,3 +304,14 @@ def advance(self, chars=1):
def atEnd(self):
#return if the current position s greater than the source length
return self.current >= len(self.source)

#match the indentation to any actual surrounding code
def removewhitespace(self):
#if we have a previous token
if self.tokens:
#then set our indent to that
lt = self.previousToken()
self.indent = lt.indent
#unless it was a colon, then we have to indent further
if lt.type == "Colon":
self.indent += 1
27 changes: 17 additions & 10 deletions PySkiylia/PySkiylia.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,28 @@
class Skiylia:
#set the default values here
haderror = False
version = "v0.6.1"
debug = True
version = "v0.6.3"
debug = False
#run this at initialisation
def __init__(self, args=""):
#check if the user has asked for help
if args and args[-1] in ["--help", "-h", "-?", "/?"]:
#show them the default usage
print("Usage:\tPySkiylia [scriptname]")
sys.exit(0)
#or if they want to enable debug mode
elif args and args[-1] in ["-debug", "-d"]:
#enable debugging
self.debug = True
#ad remove the flag from the arguments list
args = args[:-1]
#we won't support more than one argument
if len(args) > 1:
#tell the user and exit
print("PySkiylia does not accept more than one argument")
sys.exit(1)
#if we have been given a single argument
elif len(args) == 1:
#check if te user has asked for help
if args[0] in ["--help", "-h", "-?", "/?"]:
#show them the default usage
print("Usage:\tPySkiylia [scriptname]")
sys.exit(0)
#save the argument if it is valid
self.args = self.checkValidFile(args[0])
else:
Expand Down Expand Up @@ -61,7 +67,7 @@ def checkValidFile(self, path):
#startup the prompt if no arguments have been given
def runPrompt(self):
#print some base information
print("PySkiylia "+self.version)
print("PySkiylia",self.version,"- debugging mode"*self.debug)
#keep looping the code
while True:
#fetch the user input
Expand Down Expand Up @@ -105,8 +111,8 @@ def run(self, source):
tokens = lexer.scanTokens()
#Lexer output for debugging
if self.debug:
print("Tokenised source code:")
print([(token.type, token.indent) for token in tokens])
print("\nTokenised source code:")
print(*["{} {},".format(token.type, token.indent) for token in tokens])

#fetch the Parser class
parser = Parser(self, tokens, lexer.primitives)
Expand All @@ -120,6 +126,7 @@ def run(self, source):
print("\nAbstracted source code:")
astprinter = ASTPrinter()
astprinter.display(statements)
print()

#initialise the interpreter
interpreter = Interpreter(self, parser.arglimit)
Expand Down
63 changes: 57 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# PySkiylia
Dynamically typed Object Oriented Program Language.
Dynamically typed Object Oriented Programming Language.

[![forthebadge](https://forthebadge.com/images/badges/made-with-python.svg)](https://forthebadge.com)

Expand All @@ -11,7 +11,6 @@ Dynamically typed Object Oriented Program Language.
![GitHub top language](https://img.shields.io/github/languages/top/SK1Y101/PySkiylia)
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/SK1Y101/PySkiylia)
![Lines of code](https://img.shields.io/tokei/lines/github.com/SK1Y101/PySkiylia)

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat)](#contributors)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
Expand All @@ -20,19 +19,68 @@ Dynamically typed Object Oriented Program Language.

![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/SK1Y101/PySkiylia?include_prereleases)
![GitHub commits since latest release (by date including pre-releases)](https://img.shields.io/github/commits-since/SK1Y101/PySkiylia/latest/develop?include_prereleases)
![GitHub commit activity](https://img.shields.io/github/commit-activity/w/SK1Y101/PySkiylia)
![GitHub milestone](https://img.shields.io/github/milestones/progress/SK1Y101/PySkiylia/1)
![GitHub milestones](https://img.shields.io/github/milestones/open/SK1Y101/PySkiylia)
[![Percentage of issues still open](http://isitmaintained.com/badge/open/SK1Y101/PySkiylia.svg)](http://isitmaintained.com/project/SK1Y101/PySkiylia "Percentage of issues still open")
![GitHub issues](https://img.shields.io/github/issues-raw/SK1Y101/PySkiylia)
![GitHub pull requests](https://img.shields.io/github/issues-pr-raw/SK1Y101/PySkiylia)
![GitHub last commit](https://img.shields.io/github/last-commit/SK1Y101/PySkiylia)

**PySkiylia: [Latest release]**

Support here: [issues]
Open issues can be found here: [issues]

To create an issue, be it a bug, question, feature request, or other, use this link here: [Open an issue]

# Skiylia

Skiylia is dynamically typed, object oriented, and most importantly *interpreted*. While it may share many similarities with C derivatives, its heritage is definitely Pythonic.

## Sample code

Within this [folder] is all the code examples that have been used to test the project. Feel free to play around and get a feel for the language!
///This section contains a small snippet of Skiylia
code that calculates the factorial of a number///

def factorial(n):
if int(n) != n:
return null //can't compute factorial of a float this way
if n < 2:
return 1
return n * factorial(n - 1) //recursion that makes this work

var num = 6
print("The factorial of", num, "is", factorial(num))

//output: The factorial of 6 is 720

Within this [folder] is a collection of code examples that have been used to test the project. While not exhaustive by any means, they should cover the basics. Feel free to play around and get a feel for the language!

Who knows, at some point in the future there may even be a link to a Skiylia tutorial. It's certainly an idea in the works.

## Running Skiylia

Under the [Latest release] you'll find the most up to date version of PySkiylia, containing all the python sub-modules. Running PySkiylia.py from the command line will open the interpreter in REPL mode, while passing a .skiy file as a second argument will allow execution of said script.

## Contributing

Any contributions made are absolutely welcome. Checkout the issues area for any outstanding problems, or to file your own!

Forking this repository is an excellent way to contribute to the code that makes this interpreter tick. Open a pull request (preferably to the develop branch) if you have anything to add, and it'll be looked over.

# Acknowledgements

I, [Jack](https://github.com/SK1Y101), definitely couldn't have created PySkiylia without any outside sources.

I owe a huge debt to Bob Nystrom and his excellent book, [Crafting Interpreters]. Not only did he give me true inspiration to develop Skiylia, but also provided cleanly documented concepts and a delightful read. If there is *anyone* that hasn't yet read his implementation of Lox from cover to cover, I would thoroughly recommend doing so.

## Tools

- The interpreter was written in [Python](https://www.python.org/) 3.8, and can be ran on any machine with it installed.
- [Mergify](https://mergify.io/) has been automatically managing all of the repository branches.
- [All-contributors](https://allcontributors.org/) has been managing the contributors section.
- [Snyk](https://snyk.io/) has been monitoring for security concerns.
- [Release-drafter](https://github.com/release-drafter/release-drafter) has been compiling all pull requests into changelogs on each draft release, massively expediating the process.
- And while we don't have an dependencies (yet?) [Dependabot](https://dependabot.com/) has been keeping in the shadows.

## Contributors

Expand All @@ -53,8 +101,11 @@ All the people who have contributed ([emoji key](https://allcontributors.org/doc
<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://allcontributors.org) specification.
Contributions of any kind are welcome!



[Latest release]: https://github.com/SK1Y101/PySkiylia/releases
[issues]: https://github.com/SK1Y101/PySkiylia/issues
[folder]: https://github.com/SK1Y101/PySkiylia/tree/main/ExampleCode
[Crafting Interpreters]: https://craftinginterpreters.com/
[Open an issue]: https://github.com/SK1Y101/PySkiylia/issues/new/choose

0 comments on commit 204f43e

Please sign in to comment.