-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f533e7c
Showing
36 changed files
with
3,609 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
; http://editorconfig.org/ | ||
|
||
root = true | ||
|
||
[*] | ||
insert_final_newline = true | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[{Makefile,go.mod,go.sum,*.go}] | ||
indent_style = tab | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
# Created by https://www.gitignore.io/api/go,git,svn,jetbrains | ||
# Edit at https://www.gitignore.io/?templates=go,git,svn,jetbrains | ||
|
||
### Git ### | ||
# Created by git for backups. To disable backups in Git: | ||
# $ git config --global mergetool.keepBackup false | ||
*.orig | ||
|
||
# Created by git when using merge tools for conflicts | ||
*.BACKUP.* | ||
*.BASE.* | ||
*.LOCAL.* | ||
*.REMOTE.* | ||
*_BACKUP_*.txt | ||
*_BASE_*.txt | ||
*_LOCAL_*.txt | ||
*_REMOTE_*.txt | ||
|
||
### Go ### | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
### Go Patch ### | ||
/vendor/ | ||
/Godeps/ | ||
|
||
### JetBrains ### | ||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm | ||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 | ||
|
||
.idea | ||
|
||
# User-specific stuff | ||
.idea/**/workspace.xml | ||
.idea/**/tasks.xml | ||
.idea/**/usage.statistics.xml | ||
.idea/**/dictionaries | ||
.idea/**/shelf | ||
|
||
# Generated files | ||
.idea/**/contentModel.xml | ||
|
||
# Sensitive or high-churn files | ||
.idea/**/dataSources/ | ||
.idea/**/dataSources.ids | ||
.idea/**/dataSources.local.xml | ||
.idea/**/sqlDataSources.xml | ||
.idea/**/dynamic.xml | ||
.idea/**/uiDesigner.xml | ||
.idea/**/dbnavigator.xml | ||
|
||
# Gradle | ||
.idea/**/gradle.xml | ||
.idea/**/libraries | ||
|
||
# Gradle and Maven with auto-import | ||
# When using Gradle or Maven with auto-import, you should exclude module files, | ||
# since they will be recreated, and may cause churn. Uncomment if using | ||
# auto-import. | ||
# .idea/modules.xml | ||
# .idea/*.iml | ||
# .idea/modules | ||
# *.iml | ||
# *.ipr | ||
|
||
# CMake | ||
cmake-build-*/ | ||
|
||
# Mongo Explorer plugin | ||
.idea/**/mongoSettings.xml | ||
|
||
# File-based project format | ||
*.iws | ||
|
||
# IntelliJ | ||
out/ | ||
|
||
# mpeltonen/sbt-idea plugin | ||
.idea_modules/ | ||
|
||
# JIRA plugin | ||
atlassian-ide-plugin.xml | ||
|
||
# Cursive Clojure plugin | ||
.idea/replstate.xml | ||
|
||
# Crashlytics plugin (for Android Studio and IntelliJ) | ||
com_crashlytics_export_strings.xml | ||
crashlytics.properties | ||
crashlytics-build.properties | ||
fabric.properties | ||
|
||
# Editor-based Rest Client | ||
.idea/httpRequests | ||
|
||
# Android studio 3.1+ serialized cache file | ||
.idea/caches/build_file_checksums.ser | ||
|
||
### JetBrains Patch ### | ||
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 | ||
|
||
# *.iml | ||
# modules.xml | ||
# .idea/misc.xml | ||
# *.ipr | ||
|
||
# Sonarlint plugin | ||
.idea/sonarlint | ||
|
||
### SVN ### | ||
.svn/ | ||
|
||
# End of https://www.gitignore.io/api/go,git,svn,jetbrains |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
ignoreGeneratedHeader = false | ||
severity = "warning" | ||
confidence = 0.8 | ||
errorCode = 1 | ||
warningCode = 1 | ||
|
||
[rule.blank-imports] | ||
[rule.context-as-argument] | ||
[rule.context-keys-type] | ||
[rule.dot-imports] | ||
[rule.error-return] | ||
[rule.error-strings] | ||
[rule.error-naming] | ||
[rule.exported] | ||
[rule.if-return] | ||
[rule.increment-decrement] | ||
[rule.var-naming] | ||
[rule.var-declaration] | ||
[rule.package-comments] | ||
[rule.range] | ||
[rule.receiver-naming] | ||
[rule.time-naming] | ||
[rule.unexported-return] | ||
[rule.indent-error-flow] | ||
[rule.errorf] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
# Spiker | ||
> A Golang package implementation of real-time computing | ||
> | ||
> Inspired by [cristiandima/tdop](https://github.com/cristiandima/tdop) | ||
|
||
## Install | ||
```sh | ||
go get -u github.com/shockerli/spiker | ||
``` | ||
|
||
## Examples | ||
|
||
### Keywords | ||
```js | ||
true/false/if/else/in/... | ||
``` | ||
|
||
### Instruction separation | ||
Spiker requires instructions to be terminated with a semicolon at the end of each statement | ||
|
||
### Data type | ||
- Number | ||
> Integer, Float | ||
```js | ||
123; | ||
-123; | ||
12.34; | ||
-12.34; | ||
``` | ||
|
||
- String | ||
```js | ||
"abc" | ||
``` | ||
|
||
- Boolean | ||
```js | ||
true; | ||
false; | ||
``` | ||
|
||
- Array | ||
```js | ||
[]; | ||
[1, 2, "a"]; | ||
[1, [], [2,], [3, 4,], 5]; | ||
``` | ||
|
||
- Dict | ||
```js | ||
v = [9:99, 8:8.8, "hello":12.02]; | ||
v = ["name":"jioby", "age":18, "log":[1:2, 3:4]]; | ||
v = [1, 9:9.9, 3]; | ||
``` | ||
|
||
### Arithmetic Operators | ||
```js | ||
1 + 2 - 3 * 4 / 5 % 6; | ||
-0.19 + 3.2983; | ||
3 ** 2; | ||
``` | ||
|
||
### Bitwise Operators | ||
```js | ||
1 & 2; | ||
1 | 2; | ||
1 ^ 2; | ||
1 >> 2; | ||
1 << 2; | ||
``` | ||
|
||
### Comparison Operators | ||
```js | ||
3 == 2; | ||
3 != 2; | ||
3 > 2; | ||
3 >= 2; | ||
3 < 2; | ||
3 <= 2; | ||
``` | ||
|
||
### Logical Operators | ||
```js | ||
!2; | ||
1 && 2; | ||
1 || 2; | ||
``` | ||
|
||
### Assignment Operators | ||
```js | ||
v = 2; | ||
v += 2; | ||
v -= 2; | ||
v *= 2; | ||
v /= 2; | ||
v %= 2; | ||
|
||
a = b = c = 100; | ||
``` | ||
|
||
### Build-in functions | ||
- export | ||
> return the expression value and interrupt script | ||
```js | ||
export(v); | ||
export(v[i]); | ||
``` | ||
|
||
- exist | ||
> determines whether a variable or index exists | ||
```js | ||
exist(v); | ||
exist(v[i]); | ||
``` | ||
|
||
- len | ||
> return the length of a value | ||
```js | ||
len("123"); | ||
len(v); | ||
len(v[i]); | ||
``` | ||
|
||
- del | ||
> delete one or more variable or index | ||
```js | ||
del(a) | ||
del(a, b) | ||
del(a, b[1]) | ||
del(a[i], b[i]) | ||
``` | ||
|
||
### Control structures | ||
```js | ||
if (a > b && c != d) { | ||
a = b; | ||
} else if (c > b) { | ||
a = c; | ||
} else { | ||
export(c + d); | ||
} | ||
``` | ||
|
||
### More | ||
```js | ||
a = 101; | ||
b = 102; | ||
c = "103"; | ||
d = [1, 2, a, b, c+b, "abc"]; | ||
|
||
if (a > b) { | ||
export(len(d)); | ||
} else if (a < b) { | ||
if (c) { | ||
d = -1000; | ||
} else { | ||
d = 0; | ||
} | ||
|
||
d += len(c); | ||
export(d); | ||
} | ||
|
||
export(d[2]); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package spiker | ||
|
||
// AstNode AST node interface | ||
type AstNode interface { | ||
String() string | ||
Raw() *Token | ||
} | ||
|
||
// Ast syntax parsing infrastructure | ||
type Ast struct { | ||
raw *Token | ||
} | ||
|
||
// Raw return the token | ||
func (ast Ast) Raw() *Token { | ||
return ast.raw | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package spiker | ||
|
||
// NodeFuncDef function define | ||
type NodeFuncDef struct { | ||
Ast | ||
Name NodeVariable | ||
Param []NodeParam | ||
Body []AstNode | ||
} | ||
|
||
// TODO | ||
func (fn NodeFuncDef) String() string { | ||
return "" | ||
} | ||
|
||
// NodeParam function param | ||
type NodeParam struct { | ||
Ast | ||
DefaultValue interface{} | ||
Name NodeVariable | ||
Value interface{} | ||
} | ||
|
||
func (p NodeParam) String() string { | ||
f := p.Name.String() | ||
|
||
if p.Value != nil { | ||
f += Interface2String(p.Value) | ||
} else if p.DefaultValue != nil { | ||
f += Interface2String(p.DefaultValue) | ||
} | ||
|
||
return f | ||
} |
Oops, something went wrong.