Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,9 @@
[submodule "vendor/grammars/vscode-slice"]
path = vendor/grammars/vscode-slice
url = https://github.com/zeroc-ice/vscode-slice
[submodule "vendor/grammars/vscode-sophia"]
path = vendor/grammars/vscode-sophia
url = https://github.com/mradkov/vscode-sophia.git
[submodule "vendor/grammars/vscode-teal"]
path = vendor/grammars/vscode-teal
url = https://github.com/teal-language/vscode-teal.git
Expand Down
2 changes: 2 additions & 0 deletions grammars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1366,6 +1366,8 @@ vendor/grammars/vscode-singularity:
vendor/grammars/vscode-slice:
- source.ice
- source.slice
vendor/grammars/vscode-sophia:
- source.sophia
vendor/grammars/vscode-teal:
- source.teal
vendor/grammars/vscode-tmdl:
Expand Down
8 changes: 8 additions & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7439,6 +7439,14 @@ Soong:
filenames:
- Android.bp
language_id: 222900098
Sophia:
type: programming
color: "#5319E7"
ace_mode: text
tm_scope: source.sophia
extensions:
- ".aes"
language_id: 751572298
SourcePawn:
type: programming
color: "#f69e1d"
Expand Down
65 changes: 65 additions & 0 deletions samples/Sophia/FundMe.aes
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* A simple crowd-funding example
* License: MIT — source: https://github.com/mradkov/vscode-sophia (examples/FundMe.aes)
*/
@compiler >= 4

payable contract FundMe =

record spend_args = { recipient : address
, amount : int }

record state = { contributions : map(address, int)
, total : int
, beneficiary : address
, deadline : int
, goal : int }

stateful function spend(args : spend_args) =
Chain.spend(args.recipient, args.amount)

entrypoint init(beneficiary, deadline, goal) : state =
{ contributions = {},
beneficiary = beneficiary,
deadline = deadline,
total = 0,
goal = goal }

function is_contributor(addr) =
Map.member(addr, state.contributions)

stateful entrypoint contribute() : bool =
if(Chain.block_height >= state.deadline)
spend({ recipient = Call.caller, amount = Call.value }) // Refund money
false
else
let amount =
switch(Map.lookup(Call.caller, state.contributions))
None => Call.value
Some(n) => n + Call.value
put(state{ contributions[Call.caller] = amount,
total @ tot = tot + Call.value })
true

stateful entrypoint withdraw() : unit =
if(Chain.block_height < state.deadline)
abort("Cannot withdraw before deadline")
if(Call.caller == state.beneficiary)
withdraw_beneficiary()
elif(is_contributor(Call.caller))
withdraw_contributor()
else
abort("Not a contributor or beneficiary")

stateful function withdraw_beneficiary() : unit =
require(state.total >= state.goal, "Project was not funded")
spend({recipient = state.beneficiary,
amount = Contract.balance })

stateful function withdraw_contributor() : unit =
if(state.total >= state.goal)
abort("Project was funded")
let to = Call.caller
spend({recipient = to,
amount = state.contributions[to]})
put(state{ contributions @ c = Map.delete(to, c) })
20 changes: 20 additions & 0 deletions samples/Sophia/NamespaceExample.aes
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// License: MIT — source: https://github.com/mradkov/vscode-sophia (examples/Example.aes)

namespace Nsp =
function f() = ()

contract interface I =
entrypoint f : () => int

contract C =
using Nsp
using Nsp as N
using Nsp for [f]
using Nsp hiding [f]
using Nsp as N for [f]
using Nsp as N hiding [f]

entrypoint init() = ()

main contract Main =
entrypoint init() = ()
1 change: 1 addition & 0 deletions vendor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
- **Snakemake:** [MagicStack/MagicPython](https://github.com/MagicStack/MagicPython)
- **Solidity:** [davidhq/SublimeEthereum](https://github.com/davidhq/SublimeEthereum)
- **Soong:** [flimberger/android-system-tools](https://github.com/flimberger/android-system-tools)
- **Sophia:** [mradkov/vscode-sophia](https://github.com/mradkov/vscode-sophia)
- **SourcePawn:** [Sarrus1/sourcepawn-vscode](https://github.com/Sarrus1/sourcepawn-vscode)
- **Spline Font Database:** [Alhadis/language-fontforge](https://github.com/Alhadis/language-fontforge)
- **Squirrel:** [mathewmariani/squirrel-language](https://github.com/mathewmariani/squirrel-language)
Expand Down
1 change: 1 addition & 0 deletions vendor/grammars/vscode-sophia
Submodule vscode-sophia added at bf21a6
31 changes: 31 additions & 0 deletions vendor/licenses/git_submodule/vscode-sophia.dep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: vscode-sophia
version: bf21a6360dee8b3a39856fb04270cb9590e33862
type: git_submodule
homepage: https://github.com/mradkov/vscode-sophia.git
license: mit
licenses:
- sources: LICENSE
text: |
MIT License

Copyright (c) 2019 Milen Radkov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
notices: []
Loading