mirror of
https://github.com/ValKmjolnir/Nasal-Interpreter.git
synced 2026-07-26 21:08:45 +08:00
📝 update scripts
This commit is contained in:
+17
-17
@@ -1,12 +1,12 @@
|
||||
use std.runtime;
|
||||
|
||||
var to_lower=func(s){
|
||||
var to_lower = func(s) {
|
||||
var tmp="";
|
||||
for(var i=0;i<size(s);i+=1){
|
||||
for(var i=0;i<size(s);i+=1) {
|
||||
var c=s[i];
|
||||
if('a'[0]<=c and c<='z'[0])
|
||||
if ('a'[0]<=c and c<='z'[0])
|
||||
tmp~=chr(c);
|
||||
elsif('A'[0]<=c and c<='Z'[0])
|
||||
elsif ('A'[0]<=c and c<='Z'[0])
|
||||
tmp~=chr(c-'A'[0]+'a'[0]);
|
||||
else
|
||||
tmp~=chr(c);
|
||||
@@ -14,23 +14,23 @@ var to_lower=func(s){
|
||||
return tmp;
|
||||
}
|
||||
|
||||
var spliter=func(content){
|
||||
var spliter = func(content) {
|
||||
var token={};
|
||||
var len=size(content);
|
||||
var s="";
|
||||
for(var i=0;i<len;i+=1){
|
||||
for(var i=0;i<len;i+=1) {
|
||||
var n=content[i];
|
||||
var c=chr(n);
|
||||
if(('a'[0]<=n and n<='z'[0]) or ('A'[0]<=n and n<='Z'[0])){
|
||||
if (('a'[0]<=n and n<='z'[0]) or ('A'[0]<=n and n<='Z'[0])) {
|
||||
s~=c;
|
||||
}elsif(c=='.' or c==',' or c=='-' or c=='\'' or c=='\"' or c=='!' or c=='?'){
|
||||
if(size(s)) {
|
||||
} elsif (c=='.' or c==',' or c=='-' or c=='\'' or c=='\"' or c=='!' or c=='?') {
|
||||
if (size(s)) {
|
||||
token[to_lower(s)]+=1;
|
||||
}
|
||||
token[c]+=1;
|
||||
s="";
|
||||
}elsif(size(s)){
|
||||
if(s[0]!="-"[0] and s[0]!="'"[0] and s[-1]!="-"[0] and s[-1]!="'"[0])
|
||||
} elsif (size(s)) {
|
||||
if (s[0]!="-"[0] and s[0]!="'"[0] and s[-1]!="-"[0] and s[-1]!="'"[0])
|
||||
token[to_lower(s)]+=1;
|
||||
s="";
|
||||
}
|
||||
@@ -38,25 +38,25 @@ var spliter=func(content){
|
||||
return token;
|
||||
}
|
||||
|
||||
func(argv){
|
||||
if(size(argv)<1){
|
||||
func(argv) {
|
||||
if (size(argv)<1) {
|
||||
println("no input files.");
|
||||
exit(-1);
|
||||
}
|
||||
var all_exists=1;
|
||||
foreach(var f;argv){
|
||||
if(!io.exists(f)){
|
||||
foreach(var f;argv) {
|
||||
if (!io.exists(f)) {
|
||||
println("cannot open file <",f,">");
|
||||
all_exists=0;
|
||||
}
|
||||
}
|
||||
if(!all_exists){
|
||||
if (!all_exists) {
|
||||
exit(-1);
|
||||
}
|
||||
var file_content="";
|
||||
foreach(var f;argv)
|
||||
file_content~=io.readfile(f)~" ";
|
||||
var vec=keys(spliter(file_content));
|
||||
sort(vec,func(a,b){return cmp(a,b)<=0;});
|
||||
sort(vec,func(a,b) {return cmp(a,b)<=0;});
|
||||
println(vec);
|
||||
}(runtime.argv());
|
||||
Reference in New Issue
Block a user