mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 11:42:49 -06:00
Create copies when tagging
Not sure if this behaviour is identical to previous version, or in truth how important it really is anyway
This commit is contained in:
@@ -662,8 +662,10 @@ interface String {
|
|||||||
tagWith: (tag: string) => string;
|
tagWith: (tag: string) => string;
|
||||||
}
|
}
|
||||||
String.prototype.tagWith = function (tag: string): string {
|
String.prototype.tagWith = function (tag: string): string {
|
||||||
this.tag = tag
|
// returns a copy
|
||||||
return this
|
let s2 = this
|
||||||
|
s2.tag = tag
|
||||||
|
return s2
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -833,10 +835,11 @@ class SymKS implements Taggable {
|
|||||||
return terminalStr.join('')
|
return terminalStr.join('')
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO magic numbering fails here
|
|
||||||
public tagWith(tag: string): SymKS {
|
public tagWith(tag: string): SymKS {
|
||||||
this.tag = tag
|
let s = new SymKS()
|
||||||
return this
|
s.tokens = [...this.tokens] // copy array
|
||||||
|
s.tag = tag
|
||||||
|
return s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -861,10 +864,10 @@ class SymKP implements Taggable {
|
|||||||
return terminalStr.join('')
|
return terminalStr.join('')
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO magic numbering fails here
|
|
||||||
public tagWith(tag: string): SymKP {
|
public tagWith(tag: string): SymKP {
|
||||||
this.tag = tag
|
let s = new SymKP([...this.tokens], [...this.alts]) // copy arguments
|
||||||
return this
|
s.tag = tag
|
||||||
|
return s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user