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 @@ -974,6 +974,9 @@
[submodule "vendor/grammars/metta-textmate-linguist"]
path = vendor/grammars/metta-textmate-linguist
url = https://github.com/Abigiya-M/metta-textmate-linguist.git
[submodule "vendor/grammars/miniscript-textmate-linguist"]
path = vendor/grammars/miniscript-textmate-linguist
url = https://github.com/ayecue/miniscript-textmate-linguist.git
[submodule "vendor/grammars/mint-vscode"]
path = vendor/grammars/mint-vscode
url = https://github.com/mint-lang/mint-vscode
Expand Down
2 changes: 2 additions & 0 deletions grammars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,8 @@ vendor/grammars/mercury-tmlanguage:
- source.mercury
vendor/grammars/metta-textmate-linguist:
- source.metta
vendor/grammars/miniscript-textmate-linguist:
- source.ms
vendor/grammars/mint-vscode:
- source.mint
vendor/grammars/mlir-grammar:
Expand Down
2 changes: 2 additions & 0 deletions lib/linguist/heuristics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,8 @@ disambiguations:
and:
- negative_pattern: '/\*'
- pattern: '^\s*\.(?:include\s|globa?l\s|[A-Za-z][_A-Za-z0-9]*:)'
- language: MiniScript
pattern: '^\s*\bend (?:function|while|if|for)\b|\s\b(?:isa)\b\s'
- language: MAXScript
- extensions: ['.msg']
rules:
Expand Down
8 changes: 8 additions & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4787,6 +4787,14 @@ MiniD:
tm_scope: none
ace_mode: text
language_id: 231
MiniScript:
type: programming
color: "#4B4A56"
extensions:
- ".ms"
tm_scope: source.ms
ace_mode: text
language_id: 704299647
MiniYAML:
type: data
color: "#ff1111"
Expand Down
135 changes: 135 additions & 0 deletions samples/MiniScript/acey-deucey.ms
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
// Source: https://github.com/JoeStrout/miniscript/blob/master/MiniScript-cpp/demo/acey-deucey.ms
// Acey Deucey card game
// (Text-based version)

// Define some common stuff that makes this code work both
// in Mini Micro, and in command-line MiniScript.
if version.hostName == "Mini Micro" then
clear
chaChing = file.loadSound("/sys/sounds/cha-ching.wav")
hit = file.loadSound("/sys/sounds/hit.wav")
else
// For command-line MiniScript, make dummy mock-ups
// for the Sound class and our two sounds.
Sound = {}
Sound.play = null
chaChing = new Sound
hit = new Sound
end if

// Print the welcome message.
print "Welcome to Acey Deucey!"
print "On each round, you ante $2."
print "You are then dealt two cards."
print "Choose how much to bet, then one more card is dealt:"
print " If the new card falls between the first two, you win 2X your bet!"
print " If the new card falls outside the first two, you lose your bet."
print " If the new card matches either of the first two cards exactly, you lose 2X!"
print

// Initialize our money and card values.
// (We use the Unicode code points for the suit characters.)
money = 100
cardValues = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "J", "Q", "K"]
suits = [char(9827), char(9830), char(9829), char(9824)]

// Initialize the deck with all combinations of value and suit.
deck = []
for cv in cardValues
for suit in suits
deck.push cv + suit
end for
end for
deck.shuffle
discard = []

// Function to deal a card from our deck,
// leaving it on the discard pile.
deal = function
if deck.len == 0 then
globals.deck = discard
globals.discard = []
deck.shuffle
end if
discard.push deck.pop
return discard[-1]
end function

// Calculate the "rank" of a card.
cardRank = function(card, aceHigh=false)
card = card[0]
if card == "A" then return 1 + 12*aceHigh
return cardValues.indexOf(card) + 1
end function

// Get the user's bet. Make sure it's valid.
getBet = function
while true
betStr = input("Enter bet (0 to skip, Q to quit): ").upper
if betStr == "Q" then return betStr
if val(betStr) < 0 then
print "A negative bet? Nice try!"
else if val(betStr) > money then
print "You only have $" + money + "."
else
return betStr
end if
end while
end function

// Main loop.
while money > 2
globals.money = money - 2
print
print "You have $" + money + "."
wait
card1 = deal
rank1 = cardRank(card1, false)
card2 = deal
rank2 = cardRank(card2, true)
print " Card 1: " + card1 + " (Rank: " + rank1 + ")"
wait 0.5
print " Card 2: " + card2 + " (Rank: " + rank2 + ")"
wait 0.5
if rank1 == rank2 then
print "Matched pair: ante lost."
wait
continue
end if

betStr = getBet
if betStr == "Q" then break
bet = val(betStr)
if bet <= 0 then
print "Chicken!"
continue
end if
card3 = deal
rank3 = cardRank(card3)
print " Card 3: " + card3 + " (Rank: " + rank3 + ")"
wait
if rank3 == rank1 or rank3 == rank2 then
print "Ohhh! Double loss!"
hit.play
globals.money = money - bet * 2
else if rank3 < rank1 and rank3 < rank2 then
print "Too low!"
globals.money = money - bet
else if rank3 > rank1 and rank3 > rank2 then
print "Too high!"
globals.money = money - bet
else
print "You win!"
chaChing.play
globals.money = money + bet
end if
wait
end while

// Print the result.
if money == 0 then print "You are totally broke."
if money > 0 then print "You end the day with $" + money + "."
if money < 0 then print "You owe the bank $" + (-money) + "!"
print "Thanks for playing!"


10 changes: 10 additions & 0 deletions samples/MiniScript/countdown.ms
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Source: https://github.com/JoeStrout/miniscript/blob/master/MiniScript-cpp/demo/countdown.ms
// Countdown
// This is the tiniest Mini Micro demo.
// It shows basic looping, plus use of range, print, and wait.

for i in range(10,1)
print i + "..."
wait
end for
print "BLASTOFF!"
19 changes: 19 additions & 0 deletions samples/MiniScript/dogYears.ms
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Source: https://github.com/JoeStrout/miniscript/blob/master/MiniScript-cpp/demo/dogYears.ms
// Dog Years
//
// Simple demo of input, print, while, if/else, and break.
//

while true
ageStr = input("Enter your age: ")
age = val(ageStr)
if age == 0 then
print "C'mon, don't be shy..."
else if age < 3 then
print "So young! Really? I don't think so..."
else
print "That's " + age*7 + " in dog years."
if age > 30 then print "Wow, you're old!"
break // (exits the "while" loop)
end if
end while
Loading