Skip to content

Commit 7e2dfa4

Browse files
committed
增加了一部分的关键字中文化
1 parent 33bc781 commit 7e2dfa4

File tree

2 files changed

+59
-37
lines changed

2 files changed

+59
-37
lines changed

src/language/provider.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ class TasmHoverProvider implements vscode.HoverProvider {
1717
if(tasmsymbol){
1818
output=tasmsymbol.markdown()
1919
}
20-
else if(keyword !== undefined){
21-
let md=info.getType(keyword.type)+" **"+keyword.name+"**\n\n"+keyword.def
22-
output.appendMarkdown(md)
23-
output.appendCodeblock("Syntax: " + keyword.data)
24-
}
20+
else if(keyword !== undefined) output=keyword.markdown()
2521
//else if(label !== undefined){
2622
// output.appendCodeblock('assembly','(Label) ' + label.name + " => " + label.value)
2723
// }

src/language/wordinfo.ts

Lines changed: 58 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -331,17 +331,19 @@ class KeywordDef {
331331
data: string;
332332
type : KeywordType;
333333
allowType : AllowKinds;
334+
alias:string[]|undefined
334335
/**
335336
* 注册关键字相关的信息
336337
* @param name string关键字名称
337338
* @param def string定义 描述
338339
* @param type keywordType类型
339340
* @param data syntax等提示信息
340341
* @param count 操作数个数
341-
* @param allow 是否允许使用
342+
* @param allow 允许接的操作数类型
342343
*/
343-
constructor(name : string, def : string,type: KeywordType = KeywordType.Instruction,data? : string,count : number = 2,allow? : AllowKinds){
344-
this.name=name;
344+
constructor(name : string, def : string,type: KeywordType = KeywordType.Instruction,data? : string,count : number = 2,allow? : AllowKinds,alias?:string[]){
345+
this.name=name
346+
this.alias=alias
345347
if(data !== undefined){
346348
this.data = data;
347349
}else{
@@ -353,11 +355,25 @@ class KeywordDef {
353355
}else{
354356
this.allowType = allow;
355357
}
356-
console.log('"keyword.'+name+'":"'+def+'",')
357-
this.opCount = count;
358-
this.type = type;
359-
this.def = def;//localize("\"keyword."+name,def);
360-
}
358+
this.opCount = count
359+
this.type = type
360+
this.def = def
361+
}
362+
public markdown():vscode.MarkdownString{
363+
let md=new vscode.MarkdownString(getType(this.type)+" **"+this.name+"**\n\n")
364+
md.appendMarkdown(this.def+"\n\n")
365+
if(this.alias) {
366+
let msg=localize("keyword.alias","alias: ")
367+
let i:number
368+
for(i=0;i<this.alias.length-1;i++){
369+
msg+="`"+this.alias[i]+"`,"
370+
}
371+
msg+="`"+this.alias[i]+"`"
372+
md.appendMarkdown(msg)
373+
}
374+
md.appendCodeblock("Syntax: " + this.data)
375+
return md
376+
}
361377
}
362378

363379
const KEYWORD_DICONTARY : Array<KeywordDef>= [
@@ -539,22 +555,30 @@ const KEYWORD_DICONTARY : Array<KeywordDef>= [
539555
new KeywordDef("pusha", localize("keyword.pusha","pushes all register to the stack"),KeywordType.Instruction,"pusha",0),
540556
new KeywordDef("popa", localize("keyword.popa","pops all register to from the stack stack"),KeywordType.Instruction,"popa",0),
541557
//Code Navigation
542-
new KeywordDef("jmp", localize("keyword.jmp","jump to a part in the code"),KeywordType.Instruction,"jmp [label]",1,AllowKinds.Label),
543-
new KeywordDef("jcxz", localize("keyword.jcxz","jump if cx is 0"),KeywordType.Instruction,"jcxz [label]",1,AllowKinds.Label),
544-
new KeywordDef("je", localize("keyword.je","jump if the numbers are equals"),KeywordType.Instruction,"je [label]",1,AllowKinds.Label),
545-
new KeywordDef("jne", localize("keyword.jne","jump if the operands are not equals"),KeywordType.Instruction,"jne [label]",1,AllowKinds.Label),
546-
new KeywordDef("jc", localize("keyword.jc","jump if carry flag on"),KeywordType.Instruction,"jc [label]",1,AllowKinds.Label),
547-
new KeywordDef("jnc", localize("keyword.jnc","jump if carry flag off"),KeywordType.Instruction,"jnc [label]",1,AllowKinds.Label),
548-
new KeywordDef("jz", localize("keyword.jz","jump if zero flag on"),KeywordType.Instruction,"jz [label]",1,AllowKinds.Label),
549-
new KeywordDef("jnz", localize("keyword.jnz","jump if zero flag off"),KeywordType.Instruction,"jnz [label]",1,AllowKinds.Label),
550-
new KeywordDef("ja", localize("keyword.ja","jump if greater (Unsinged)"),KeywordType.Instruction,"ja [label]",1,AllowKinds.Label),
551-
new KeywordDef("jae", localize("keyword.jae","jump if greater or equals (Unsigned)"),KeywordType.Instruction,"jae [label]",1,AllowKinds.Label),
552-
new KeywordDef("jb", localize("keyword.jb","jump if less (Unsinged)"),KeywordType.Instruction,"jb [label]",1,AllowKinds.Label),
553-
new KeywordDef("jbe", localize("keyword.jbe","jump if less or equals (Unsigned)"),KeywordType.Instruction,"jbe [label]",1,AllowKinds.Label),
554-
new KeywordDef("jb", localize("keyword.jb","jump if greater (Singed)"),KeywordType.Instruction,"jg [label]",1,AllowKinds.Label),
555-
new KeywordDef("jbe", localize("keyword.jbe","jump if greater or equals (Signed)"),KeywordType.Instruction,"jge [label]",1,AllowKinds.Label),
556-
new KeywordDef("jl", localize("keyword.jl","jump if less (Singed)"),KeywordType.Instruction,"jl [label]",1,AllowKinds.Label),
557-
new KeywordDef("jle", localize("keyword.jle","jump if less or equals (Signed)"),KeywordType.Instruction,"jle [label]",1,AllowKinds.Label),
558+
new KeywordDef("jmp" , localize("keyword.jmp" ,"jump to a part in the code") ,KeywordType.Instruction,"jmp [label]" ,1,AllowKinds.Label),
559+
560+
new KeywordDef("jz" , localize("keyword.jz" ,"jump if zero flag on\n\njump if equal") ,KeywordType.Instruction,"jz [label]" ,1,AllowKinds.Label ,["je"]) ,
561+
new KeywordDef("jnz" , localize("keyword.jnz" ,"jump if zero flag off\n\njump if not equal") ,KeywordType.Instruction,"jnz [label]" ,1,AllowKinds.Label ,['jne']),
562+
new KeywordDef("js" , localize("keyword.js" ,"jump if sign flag on") ,KeywordType.Instruction,"js [label]" ,1,AllowKinds.Label),
563+
new KeywordDef("jns" , localize("keyword.jns" ,"jump if sign flag off") ,KeywordType.Instruction,"jns [label]" ,1,AllowKinds.Label),
564+
new KeywordDef("jp" , localize("keyword.jp" ,"jump if parity flag on") ,KeywordType.Instruction,"jp [label]" ,1,AllowKinds.Label,['jpe']),
565+
new KeywordDef("jnp" , localize("keyword.jnp" ,"jump if parity flag off") ,KeywordType.Instruction,"jnp [label]" ,1,AllowKinds.Label,['jpo']),
566+
new KeywordDef("jo" , localize("keyword.jo" ,"jump if Overflow flag on") ,KeywordType.Instruction,"jo [label]" ,1,AllowKinds.Label),
567+
new KeywordDef("jno" , localize("keyword.jno" ,"jump if Overflow flag off") ,KeywordType.Instruction,"jno [label]" ,1,AllowKinds.Label),
568+
569+
new KeywordDef("ja" , localize("keyword.ja" ,"jump if greater (Unsinged)") ,KeywordType.Instruction,"ja [label]" ,1,AllowKinds.Label,['jnbe']),
570+
new KeywordDef("jna" , localize("keyword.jna","jump if less or equal(Unsinged)") ,KeywordType.Instruction,"ja [label]" ,1,AllowKinds.Label,['jbe']),
571+
new KeywordDef("jc" , localize("keyword.jc" ,"jump if less (Unsinged)\n\njump if carry flag on") ,KeywordType.Instruction,"jc [label]" ,1,AllowKinds.Label ,['jb' ,'jnae']),
572+
new KeywordDef("jnc" , localize("keyword.jnc" ,"jump if greater or equals(Unsigned)\n\njump if carry flag off") ,KeywordType.Instruction,"jnc [label]" ,1,AllowKinds.Label ,['jnb' ,'jae']) ,
573+
574+
new KeywordDef("jg" , localize("keyword.jg" ,"jump if greater (Singed)") ,KeywordType.Instruction,"jg [label]" ,1,AllowKinds.Label),
575+
new KeywordDef("jge" , localize("keyword.jge" ,"jump if greater or equals (Signed)") ,KeywordType.Instruction,"jge [label]" ,1,AllowKinds.Label),
576+
new KeywordDef("jl" , localize("keyword.jl" ,"jump if less (Singed)") ,KeywordType.Instruction,"jl [label]" ,1,AllowKinds.Label),
577+
new KeywordDef("jle" , localize("keyword.jle" ,"jump if less or equals (Signed)") ,KeywordType.Instruction,"jle [label]" ,1,AllowKinds.Label),
578+
579+
new KeywordDef("jcxz", localize("keyword.jcxz","jump if cx is 0") ,KeywordType.Instruction,"jcxz [label]",1,AllowKinds.Label),
580+
new KeywordDef("jecxz", localize("keyword.jecxz","jump if ecx is 0") ,KeywordType.Instruction,"jcxz [label]",1,AllowKinds.Label),
581+
558582
//Procs
559583
new KeywordDef("call", localize("keyword.call","Calls a procedure"),KeywordType.Instruction,"call [procName]",1),
560584
new KeywordDef("far", localize("keyword.far","Turns the procedure into a far procedure"),KeywordType.SavedWord,"[procName] far",0),
@@ -627,20 +651,22 @@ const KEYWORD_DICONTARY : Array<KeywordDef>= [
627651
new KeywordDef("c", localize("keyword.c","(Not supported)"),KeywordType.Instruction,"c",0),
628652
new KeywordDef("wrt", localize("keyword.wrt","(Not supported)"),KeywordType.Instruction,"wrt",0),
629653
//Repeating
630-
new KeywordDef("loop", localize("keyword.loop","Jumps to a label if cx is not 0 and deceases it as well"),KeywordType.Instruction,"loop [label]",1,AllowKinds.Label),
631-
new KeywordDef("loope", localize("keyword.loope"," "),KeywordType.Instruction,"loope [label]",1,AllowKinds.Label),
632-
new KeywordDef("loopz", localize("keyword.loopz"," "),KeywordType.Instruction,"loopz [label]",1,AllowKinds.Label),
633-
new KeywordDef("loopne", localize("keyword.loopne"," "),KeywordType.Instruction,"loopne [label]",1,AllowKinds.Label),
634-
new KeywordDef("loopnz", localize("keyword.loopnz"," "),KeywordType.Instruction,"loopnz [label]",1,AllowKinds.Label)
654+
new KeywordDef("loop", localize("keyword.loop","- decrease `CX`\n\n- Jumps to a label if cx is not 0"),KeywordType.Instruction,"loop [label]",1,AllowKinds.Label),
655+
new KeywordDef("loopz", localize("keyword.loope","- decrease `CX`\n\n- Jumps to a label if cx is not 0 **and** Zero flag is 1"),KeywordType.Instruction,"loope [label]",1,AllowKinds.Label,['loope']),
656+
new KeywordDef("loopnz", localize("keyword.loopz","- decrease `CX`\n\n- Jumps to a label if cx is not 0 **and** zero flag is not 1"),KeywordType.Instruction,"loopz [label]",1,AllowKinds.Label,['loopne']),
635657
];
636658
export function GetKeyword(word : string) : KeywordDef | undefined{
637659
for (let i = 0; i < KEYWORD_DICONTARY.length; i++) {
638660
const keyword = KEYWORD_DICONTARY[i];
639661
if(keyword.name === word){
640662
return keyword;
641-
}
642-
}
643-
return;
663+
}
664+
if(keyword.alias){
665+
for (let i = 0; i < keyword.alias.length; i++) {
666+
const alia = keyword.alias[i];
667+
if(alia === word) return keyword
668+
}}
669+
} return;
644670
}
645671

646672
export function getType(type : KeywordType) : string {

0 commit comments

Comments
 (0)