mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
E language with samples
This commit is contained in:
@@ -476,6 +476,11 @@ Dylan:
|
|||||||
color: "#3ebc27"
|
color: "#3ebc27"
|
||||||
primary_extension: .dylan
|
primary_extension: .dylan
|
||||||
|
|
||||||
|
E:
|
||||||
|
type: programming
|
||||||
|
color: "#ccce35"
|
||||||
|
primary_extension: .E
|
||||||
|
|
||||||
Ecere Projects:
|
Ecere Projects:
|
||||||
type: data
|
type: data
|
||||||
group: JavaScript
|
group: JavaScript
|
||||||
|
|||||||
@@ -52,6 +52,9 @@
|
|||||||
"Ceylon": [
|
"Ceylon": [
|
||||||
".ceylon"
|
".ceylon"
|
||||||
],
|
],
|
||||||
|
"Cirru": [
|
||||||
|
".cirru"
|
||||||
|
],
|
||||||
"Clojure": [
|
"Clojure": [
|
||||||
".cl2",
|
".cl2",
|
||||||
".clj",
|
".clj",
|
||||||
@@ -95,6 +98,9 @@
|
|||||||
"DM": [
|
"DM": [
|
||||||
".dm"
|
".dm"
|
||||||
],
|
],
|
||||||
|
"E": [
|
||||||
|
".E"
|
||||||
|
],
|
||||||
"ECL": [
|
"ECL": [
|
||||||
".ecl"
|
".ecl"
|
||||||
],
|
],
|
||||||
@@ -535,8 +541,8 @@
|
|||||||
".gemrc"
|
".gemrc"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"tokens_total": 445429,
|
"tokens_total": 446274,
|
||||||
"languages_total": 523,
|
"languages_total": 538,
|
||||||
"tokens": {
|
"tokens": {
|
||||||
"ABAP": {
|
"ABAP": {
|
||||||
"*/**": 1,
|
"*/**": 1,
|
||||||
@@ -12715,6 +12721,43 @@
|
|||||||
"<=>": 1,
|
"<=>": 1,
|
||||||
"other.name": 1
|
"other.name": 1
|
||||||
},
|
},
|
||||||
|
"Cirru": {
|
||||||
|
"print": 38,
|
||||||
|
"array": 14,
|
||||||
|
"int": 36,
|
||||||
|
"string": 7,
|
||||||
|
"set": 12,
|
||||||
|
"f": 3,
|
||||||
|
"block": 1,
|
||||||
|
"(": 20,
|
||||||
|
"a": 22,
|
||||||
|
"b": 7,
|
||||||
|
"c": 9,
|
||||||
|
")": 20,
|
||||||
|
"call": 1,
|
||||||
|
"bool": 6,
|
||||||
|
"true": 1,
|
||||||
|
"false": 1,
|
||||||
|
"yes": 1,
|
||||||
|
"no": 1,
|
||||||
|
"map": 8,
|
||||||
|
"m": 3,
|
||||||
|
"float": 1,
|
||||||
|
"require": 1,
|
||||||
|
"./stdio.cr": 1,
|
||||||
|
"self": 2,
|
||||||
|
"child": 1,
|
||||||
|
"under": 2,
|
||||||
|
"parent": 1,
|
||||||
|
"get": 4,
|
||||||
|
"x": 2,
|
||||||
|
"just": 4,
|
||||||
|
"-": 4,
|
||||||
|
"code": 4,
|
||||||
|
"eval": 2,
|
||||||
|
"nothing": 1,
|
||||||
|
"container": 3
|
||||||
|
},
|
||||||
"Clojure": {
|
"Clojure": {
|
||||||
"(": 83,
|
"(": 83,
|
||||||
"defn": 4,
|
"defn": 4,
|
||||||
@@ -16024,6 +16067,160 @@
|
|||||||
"#undef": 1,
|
"#undef": 1,
|
||||||
"Undefine": 1
|
"Undefine": 1
|
||||||
},
|
},
|
||||||
|
"E": {
|
||||||
|
"def": 24,
|
||||||
|
"makeVehicle": 3,
|
||||||
|
"(": 65,
|
||||||
|
"self": 1,
|
||||||
|
")": 64,
|
||||||
|
"{": 57,
|
||||||
|
"vehicle": 2,
|
||||||
|
"to": 27,
|
||||||
|
"milesTillEmpty": 1,
|
||||||
|
"return": 19,
|
||||||
|
"self.milesPerGallon": 1,
|
||||||
|
"*": 1,
|
||||||
|
"self.getFuelRemaining": 1,
|
||||||
|
"}": 57,
|
||||||
|
"makeCar": 4,
|
||||||
|
"var": 6,
|
||||||
|
"fuelRemaining": 4,
|
||||||
|
"car": 8,
|
||||||
|
"extends": 2,
|
||||||
|
"milesPerGallon": 2,
|
||||||
|
"getFuelRemaining": 2,
|
||||||
|
"makeJet": 1,
|
||||||
|
"jet": 3,
|
||||||
|
"println": 2,
|
||||||
|
"The": 2,
|
||||||
|
"can": 1,
|
||||||
|
"go": 1,
|
||||||
|
"car.milesTillEmpty": 1,
|
||||||
|
"miles.": 1,
|
||||||
|
"name": 4,
|
||||||
|
"x": 3,
|
||||||
|
"y": 3,
|
||||||
|
"moveTo": 1,
|
||||||
|
"newX": 2,
|
||||||
|
"newY": 2,
|
||||||
|
"getX": 1,
|
||||||
|
"getY": 1,
|
||||||
|
"setName": 1,
|
||||||
|
"newName": 2,
|
||||||
|
"getName": 1,
|
||||||
|
"sportsCar": 1,
|
||||||
|
"sportsCar.moveTo": 1,
|
||||||
|
"sportsCar.getName": 1,
|
||||||
|
"is": 1,
|
||||||
|
"at": 1,
|
||||||
|
"X": 1,
|
||||||
|
"location": 1,
|
||||||
|
"sportsCar.getX": 1,
|
||||||
|
"makeVOCPair": 1,
|
||||||
|
"brandName": 3,
|
||||||
|
"String": 1,
|
||||||
|
"near": 6,
|
||||||
|
"myTempContents": 6,
|
||||||
|
"none": 2,
|
||||||
|
"brand": 5,
|
||||||
|
"__printOn": 4,
|
||||||
|
"out": 4,
|
||||||
|
"TextWriter": 4,
|
||||||
|
"void": 5,
|
||||||
|
"out.print": 4,
|
||||||
|
"ProveAuth": 2,
|
||||||
|
"<$brandName>": 3,
|
||||||
|
"prover": 1,
|
||||||
|
"getBrand": 4,
|
||||||
|
"coerce": 2,
|
||||||
|
"specimen": 2,
|
||||||
|
"optEjector": 3,
|
||||||
|
"sealedBox": 2,
|
||||||
|
"offerContent": 1,
|
||||||
|
"CheckAuth": 2,
|
||||||
|
"checker": 3,
|
||||||
|
"template": 1,
|
||||||
|
"match": 4,
|
||||||
|
"[": 10,
|
||||||
|
"get": 2,
|
||||||
|
"authList": 2,
|
||||||
|
"any": 2,
|
||||||
|
"]": 10,
|
||||||
|
"specimenBox": 2,
|
||||||
|
"null": 1,
|
||||||
|
"if": 2,
|
||||||
|
"specimenBox.__respondsTo": 1,
|
||||||
|
"specimenBox.offerContent": 1,
|
||||||
|
"else": 1,
|
||||||
|
"for": 3,
|
||||||
|
"auth": 3,
|
||||||
|
"in": 1,
|
||||||
|
"throw.eject": 1,
|
||||||
|
"Unmatched": 1,
|
||||||
|
"authorization": 1,
|
||||||
|
"__respondsTo": 2,
|
||||||
|
"_": 3,
|
||||||
|
"true": 1,
|
||||||
|
"false": 1,
|
||||||
|
"__getAllegedType": 1,
|
||||||
|
"null.__getAllegedType": 1,
|
||||||
|
"#File": 1,
|
||||||
|
"objects": 1,
|
||||||
|
"hardwired": 1,
|
||||||
|
"files": 1,
|
||||||
|
"file1": 1,
|
||||||
|
"<file:myFile.txt>": 1,
|
||||||
|
"file2": 1,
|
||||||
|
"<file:/home/marcs/myFile.txt>": 1,
|
||||||
|
"#Using": 2,
|
||||||
|
"a": 4,
|
||||||
|
"variable": 1,
|
||||||
|
"file": 3,
|
||||||
|
"filePath": 2,
|
||||||
|
"file3": 1,
|
||||||
|
"<file>": 1,
|
||||||
|
"single": 1,
|
||||||
|
"character": 1,
|
||||||
|
"specify": 1,
|
||||||
|
"Windows": 1,
|
||||||
|
"drive": 1,
|
||||||
|
"file4": 1,
|
||||||
|
"<file:c:/docs/myFile.txt>": 1,
|
||||||
|
"file5": 1,
|
||||||
|
"<c:/docs/myFile.txt>": 1,
|
||||||
|
"file6": 1,
|
||||||
|
"<c:\\docs\\myFile.txt>": 1,
|
||||||
|
"pragma.syntax": 1,
|
||||||
|
"send": 1,
|
||||||
|
"message": 4,
|
||||||
|
"when": 2,
|
||||||
|
"friend": 4,
|
||||||
|
"<-receive(message))>": 1,
|
||||||
|
"chatUI.showMessage": 4,
|
||||||
|
"catch": 2,
|
||||||
|
"prob": 2,
|
||||||
|
"receive": 1,
|
||||||
|
"receiveFriend": 2,
|
||||||
|
"friendRcvr": 2,
|
||||||
|
"bind": 2,
|
||||||
|
"save": 1,
|
||||||
|
"file.setText": 1,
|
||||||
|
"makeURIFromObject": 1,
|
||||||
|
"chatController": 2,
|
||||||
|
"load": 1,
|
||||||
|
"getObjectFromURI": 1,
|
||||||
|
"file.getText": 1,
|
||||||
|
"<": 1,
|
||||||
|
"-": 2,
|
||||||
|
"tempVow": 2,
|
||||||
|
"#...use": 1,
|
||||||
|
"#....": 1,
|
||||||
|
"report": 1,
|
||||||
|
"problem": 1,
|
||||||
|
"finally": 1,
|
||||||
|
"#....log": 1,
|
||||||
|
"event": 1
|
||||||
|
},
|
||||||
"ECL": {
|
"ECL": {
|
||||||
"#option": 1,
|
"#option": 1,
|
||||||
"(": 32,
|
"(": 32,
|
||||||
@@ -47799,6 +47996,7 @@
|
|||||||
"C#": 278,
|
"C#": 278,
|
||||||
"C++": 31181,
|
"C++": 31181,
|
||||||
"Ceylon": 50,
|
"Ceylon": 50,
|
||||||
|
"Cirru": 244,
|
||||||
"Clojure": 510,
|
"Clojure": 510,
|
||||||
"COBOL": 90,
|
"COBOL": 90,
|
||||||
"CoffeeScript": 2951,
|
"CoffeeScript": 2951,
|
||||||
@@ -47810,6 +48008,7 @@
|
|||||||
"Dart": 74,
|
"Dart": 74,
|
||||||
"Diff": 16,
|
"Diff": 16,
|
||||||
"DM": 169,
|
"DM": 169,
|
||||||
|
"E": 601,
|
||||||
"ECL": 281,
|
"ECL": 281,
|
||||||
"edn": 227,
|
"edn": 227,
|
||||||
"Elm": 628,
|
"Elm": 628,
|
||||||
@@ -47941,6 +48140,7 @@
|
|||||||
"C#": 2,
|
"C#": 2,
|
||||||
"C++": 27,
|
"C++": 27,
|
||||||
"Ceylon": 1,
|
"Ceylon": 1,
|
||||||
|
"Cirru": 9,
|
||||||
"Clojure": 7,
|
"Clojure": 7,
|
||||||
"COBOL": 4,
|
"COBOL": 4,
|
||||||
"CoffeeScript": 9,
|
"CoffeeScript": 9,
|
||||||
@@ -47952,6 +48152,7 @@
|
|||||||
"Dart": 1,
|
"Dart": 1,
|
||||||
"Diff": 1,
|
"Diff": 1,
|
||||||
"DM": 1,
|
"DM": 1,
|
||||||
|
"E": 6,
|
||||||
"ECL": 1,
|
"ECL": 1,
|
||||||
"edn": 1,
|
"edn": 1,
|
||||||
"Elm": 3,
|
"Elm": 3,
|
||||||
@@ -48066,5 +48267,5 @@
|
|||||||
"Xtend": 2,
|
"Xtend": 2,
|
||||||
"YAML": 1
|
"YAML": 1
|
||||||
},
|
},
|
||||||
"md5": "a46f14929a6e9e4356fda95beb035439"
|
"md5": "09d83474428d52300e1b368b738c226c"
|
||||||
}
|
}
|
||||||
31
samples/E/Extends.E
Normal file
31
samples/E/Extends.E
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
# from
|
||||||
|
# http://wiki.erights.org/wiki/Walnut/Ordinary_Programming/Objects_and_Functions
|
||||||
|
def makeVehicle(self) {
|
||||||
|
def vehicle {
|
||||||
|
to milesTillEmpty() {
|
||||||
|
return self.milesPerGallon() * self.getFuelRemaining()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return vehicle
|
||||||
|
}
|
||||||
|
|
||||||
|
def makeCar() {
|
||||||
|
var fuelRemaining := 20
|
||||||
|
def car extends makeVehicle(car) {
|
||||||
|
to milesPerGallon() {return 19}
|
||||||
|
to getFuelRemaining() {return fuelRemaining}
|
||||||
|
}
|
||||||
|
return car
|
||||||
|
}
|
||||||
|
|
||||||
|
def makeJet() {
|
||||||
|
var fuelRemaining := 2000
|
||||||
|
def jet extends makeVehicle(jet) {
|
||||||
|
to milesPerGallon() {return 2}
|
||||||
|
to getFuelRemaining() {return fuelRemaining}
|
||||||
|
}
|
||||||
|
return jet
|
||||||
|
}
|
||||||
|
|
||||||
|
def car := makeCar()
|
||||||
|
println(`The car can go ${car.milesTillEmpty()} miles.`)
|
||||||
21
samples/E/Functions.E
Normal file
21
samples/E/Functions.E
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# from
|
||||||
|
# http://wiki.erights.org/wiki/Walnut/Ordinary_Programming/Objects_and_Functions
|
||||||
|
def makeCar(var name) {
|
||||||
|
var x := 0
|
||||||
|
var y := 0
|
||||||
|
def car {
|
||||||
|
to moveTo(newX,newY) {
|
||||||
|
x := newX
|
||||||
|
y := newY
|
||||||
|
}
|
||||||
|
to getX() {return x}
|
||||||
|
to getY() {return y}
|
||||||
|
to setName(newName) {name := newName}
|
||||||
|
to getName() {return name}
|
||||||
|
}
|
||||||
|
return car
|
||||||
|
}
|
||||||
|
# Now use the makeCar function to make a car, which we will move and print
|
||||||
|
def sportsCar := makeCar("Ferrari")
|
||||||
|
sportsCar.moveTo(10,20)
|
||||||
|
println(`The car ${sportsCar.getName()} is at X location ${sportsCar.getX()}`)
|
||||||
69
samples/E/Guards.E
Normal file
69
samples/E/Guards.E
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
# from
|
||||||
|
# http://wiki.erights.org/wiki/Walnut/Advanced_Topics/Build_your_Own_Guards
|
||||||
|
def makeVOCPair(brandName :String) :near {
|
||||||
|
|
||||||
|
var myTempContents := def none {}
|
||||||
|
|
||||||
|
def brand {
|
||||||
|
to __printOn(out :TextWriter) :void {
|
||||||
|
out.print(brandName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def ProveAuth {
|
||||||
|
to __printOn(out :TextWriter) :void {
|
||||||
|
out.print(`<$brandName prover>`)
|
||||||
|
}
|
||||||
|
to getBrand() :near { return brand }
|
||||||
|
to coerce(specimen, optEjector) :near {
|
||||||
|
def sealedBox {
|
||||||
|
to getBrand() :near { return brand }
|
||||||
|
to offerContent() :void {
|
||||||
|
myTempContents := specimen
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sealedBox
|
||||||
|
}
|
||||||
|
}
|
||||||
|
def CheckAuth {
|
||||||
|
to __printOn(out :TextWriter) :void {
|
||||||
|
out.print(`<$brandName checker template>`)
|
||||||
|
}
|
||||||
|
to getBrand() :near { return brand }
|
||||||
|
match [`get`, authList :any[]] {
|
||||||
|
def checker {
|
||||||
|
to __printOn(out :TextWriter) :void {
|
||||||
|
out.print(`<$brandName checker>`)
|
||||||
|
}
|
||||||
|
to getBrand() :near { return brand }
|
||||||
|
to coerce(specimenBox, optEjector) :any {
|
||||||
|
myTempContents := null
|
||||||
|
if (specimenBox.__respondsTo("offerContent", 0)) {
|
||||||
|
# XXX Using __respondsTo/2 here is a kludge
|
||||||
|
specimenBox.offerContent()
|
||||||
|
} else {
|
||||||
|
myTempContents := specimenBox
|
||||||
|
}
|
||||||
|
for auth in authList {
|
||||||
|
if (auth == myTempContents) {
|
||||||
|
return auth
|
||||||
|
}
|
||||||
|
}
|
||||||
|
myTempContents := none
|
||||||
|
throw.eject(optEjector,
|
||||||
|
`Unmatched $brandName authorization`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
match [`__respondsTo`, [`get`, _]] {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
match [`__respondsTo`, [_, _]] {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
match [`__getAllegedType`, []] {
|
||||||
|
null.__getAllegedType()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [ProveAuth, CheckAuth]
|
||||||
|
}
|
||||||
14
samples/E/IO.E
Normal file
14
samples/E/IO.E
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# E sample from
|
||||||
|
# http://wiki.erights.org/wiki/Walnut/Ordinary_Programming/InputOutput
|
||||||
|
#File objects for hardwired files:
|
||||||
|
def file1 := <file:myFile.txt>
|
||||||
|
def file2 := <file:/home/marcs/myFile.txt>
|
||||||
|
|
||||||
|
#Using a variable for a file name:
|
||||||
|
def filePath := "c:\\docs\\myFile.txt"
|
||||||
|
def file3 := <file>[filePath]
|
||||||
|
|
||||||
|
#Using a single character to specify a Windows drive
|
||||||
|
def file4 := <file:c:/docs/myFile.txt>
|
||||||
|
def file5 := <c:/docs/myFile.txt>
|
||||||
|
def file6 := <c:\docs\myFile.txt>
|
||||||
9
samples/E/Promises.E
Normal file
9
samples/E/Promises.E
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# E snippet from
|
||||||
|
# http://wiki.erights.org/wiki/Walnut/Distributed_Computing/Promises
|
||||||
|
when (tempVow) -> {
|
||||||
|
#...use tempVow
|
||||||
|
} catch prob {
|
||||||
|
#.... report problem
|
||||||
|
} finally {
|
||||||
|
#....log event
|
||||||
|
}
|
||||||
18
samples/E/minChat.E
Normal file
18
samples/E/minChat.E
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# from
|
||||||
|
# http://wiki.erights.org/wiki/Walnut/Secure_Distributed_Computing/Auditing_minChat
|
||||||
|
pragma.syntax("0.9")
|
||||||
|
to send(message) {
|
||||||
|
when (friend<-receive(message)) -> {
|
||||||
|
chatUI.showMessage("self", message)
|
||||||
|
} catch prob {chatUI.showMessage("system", "connection lost")}
|
||||||
|
}
|
||||||
|
to receive(message) {chatUI.showMessage("friend", message)}
|
||||||
|
to receiveFriend(friendRcvr) {
|
||||||
|
bind friend := friendRcvr
|
||||||
|
chatUI.showMessage("system", "friend has arrived")
|
||||||
|
}
|
||||||
|
to save(file) {file.setText(makeURIFromObject(chatController))}
|
||||||
|
to load(file) {
|
||||||
|
bind friend := getObjectFromURI(file.getText())
|
||||||
|
friend <- receiveFriend(chatController)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user