fist version of the lexer
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
#### Base syntax
|
||||
|
||||
How to define a new concept
|
||||
|
||||
|
||||
concept newFile:
|
||||
|
||||
props:
|
||||
name
|
||||
|
||||
pre:
|
||||
import os
|
||||
os.path.isfile(name) == False
|
||||
|
||||
|
||||
post:
|
||||
import os
|
||||
os.path.isfile(name) == True
|
||||
|
||||
main:
|
||||
f = open(name)
|
||||
f.close()
|
||||
__context__.add(newFile, name, f)
|
||||
|
||||
example
|
||||
|
||||
create a new file named MyFirstFile.txt => newFile("MyFirstFile.txt")
|
||||
|
||||
|
||||
|
||||
concept newFile:
|
||||
|
||||
props:
|
||||
name
|
||||
path
|
||||
|
||||
pre:
|
||||
import os
|
||||
os.path.isfile(path) == False
|
||||
|
||||
|
||||
post:
|
||||
import os
|
||||
os.path.isfile(path) == True
|
||||
|
||||
main:
|
||||
import os
|
||||
f = open(name)
|
||||
f.close()
|
||||
sheeka.add(File(name, path))
|
||||
|
||||
|
||||
concept open:
|
||||
|
||||
pre:
|
||||
self.is_opened == False
|
||||
|
||||
post:
|
||||
self.is_opened == True
|
||||
|
||||
main:
|
||||
self.open
|
||||
|
||||
|
||||
open the door => d = get_instance(door) && get_concept(open).call(d)
|
||||
|
||||
|
||||
concept File:
|
||||
|
||||
props:
|
||||
name
|
||||
path
|
||||
|
||||
def open():
|
||||
|
||||
|
||||
def close():
|
||||
|
||||
open the file toto.txt => get_concept(open).call(File(path="toto.txt", name="toto.txt))
|
||||
|
||||
concept is_the_opposite:
|
||||
|
||||
props:
|
||||
a, b
|
||||
|
||||
test:
|
||||
a.pre == not b.pre && a.post == b.post
|
||||
|
||||
|
||||
print all concepts
|
||||
|
||||
concepts
|
||||
print all
|
||||
|
||||
concept print:
|
||||
|
||||
main:
|
||||
print(self)
|
||||
|
||||
concept all:
|
||||
|
||||
main:
|
||||
self.find_all()
|
||||
Reference in New Issue
Block a user