-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
8 changed files
with
146 additions
and
124 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
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
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
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 |
---|---|---|
@@ -1,8 +1,17 @@ | ||
export default ` | ||
export default { | ||
label: 'Greeting', | ||
modules: [ | ||
{ | ||
name: '.greeting', | ||
label: 'greeting.abra', | ||
code: ` | ||
val greeting = "Hello" | ||
func greet(recipient: String) = greeting + ", " + recipient | ||
func greet(recipient: String): String = greeting + ", " + recipient | ||
val languageName = "Abra" | ||
greet(languageName) | ||
`.trimStart() | ||
`.trimStart() | ||
} | ||
] | ||
} |
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,82 @@ | ||
export default { | ||
label: 'Imports/Exports', | ||
modules: [ | ||
{ | ||
name: '.main', | ||
label: 'main.abra', | ||
code: ` | ||
import Ship from .ship | ||
import Person from .person | ||
import prettyPrint from .util | ||
val ship = Ship( | ||
name: "Planet Express Ship", | ||
crew: [ | ||
Person(firstName: "Turanga", lastName: "Leela"), | ||
Person(firstName: "Phillip", middleInitial: "J", lastName: "Fry"), | ||
Person(firstName: "Bender", middleInitial: "B", lastName: "Rodriguez"), | ||
] | ||
) | ||
println(prettyPrint(ship)) | ||
`.trimStart() | ||
}, | ||
{ | ||
name: '.person', | ||
label: 'person.abra', | ||
code: ` | ||
export type Person { | ||
firstName: String | ||
middleInitial: String? = None | ||
lastName: String | ||
} | ||
`.trimStart() | ||
}, | ||
{ | ||
name: '.ship', | ||
label: 'ship.abra', | ||
code: ` | ||
import Person from .person | ||
export type Ship { | ||
name: String | ||
crew: Person[] | ||
} | ||
`.trimStart() | ||
}, | ||
{ | ||
name: '.util', | ||
label: 'util.abra', | ||
code: ` | ||
import Ship from .ship | ||
import Person from .person | ||
// Ugly prettyPrint function, nothing to see here 🙈 | ||
export func prettyPrint(ship: Ship): String { | ||
var str = "Ship(\\n" | ||
str += " name: \\"\${ship.name}\\",\\n" | ||
str += " crew: [\\n" | ||
for person, idx in ship.crew { | ||
str += prettyPrintPerson(person, " ") | ||
if idx != ship.crew.length - 1 { | ||
str += "," | ||
} | ||
str += "\\n" | ||
} | ||
str += " ]\\n" | ||
str += ")" | ||
} | ||
func prettyPrintPerson(person: Person, indent = ""): String { | ||
var str = "\${indent}Person(\\n" | ||
str += "$indent firstName: \\"\${person.firstName}\\",\\n" | ||
if person.middleInitial |i| { | ||
str += "$indent middleInitial: \\"$i\\",\\n" | ||
} | ||
str += "$indent lastName: \\"\${person.lastName}\\",\\n" | ||
str += "$indent)" | ||
} | ||
`.trimStart() | ||
} | ||
] | ||
} |
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
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
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