diff --git a/doc/changelog.md b/doc/changelog.md index dd54aa1f..529122ea 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -40,6 +40,7 @@ The dot points below probably aren't of interest unless you're _writing_ Wuffs code (instead of writing C/C++ code that _uses_ Wuffs' standard library). - Added `if.likely` and `if.unlikely`. +- Added `io_forget_history`. - Added `slice_var as nptr array[etc] etc` conversion. - Added read-only type decorators: `roarray`, `roslice` and `rotable`. - Ban recursive function calls. diff --git a/lang/ast/ast.go b/lang/ast/ast.go index 9aae698b..99c7469f 100644 --- a/lang/ast/ast.go +++ b/lang/ast/ast.go @@ -607,8 +607,9 @@ func NewField(flags Flags, name t.ID, xType *TypeExpr) *Field { } // IOManip is "io_bind (io:LHS, data:MHS, history_position:RHS) { List2 }" or -// "io_limit (io:LHS, limit:MHS) { List2 }": -// - ID0: +// "io_forget_history (io:LHS) { List2 }" or "io_limit (io:LHS, limit:MHS) { +// List2 }": +// - ID0: // - LHS: // - MHS: // - RHS: diff --git a/lang/check/type.go b/lang/check/type.go index 4b09311c..2a2feee6 100644 --- a/lang/check/type.go +++ b/lang/check/type.go @@ -164,6 +164,8 @@ func (q *checker) tcheckStatement(n *a.Node) error { switch n.Keyword() { case t.IDIOBind: arg1Typ = typeExprSliceU8 + case t.IDIOForgetHistory: + // No-op. case t.IDIOLimit: arg1Typ = typeExprU64 } diff --git a/lang/parse/parse.go b/lang/parse/parse.go index bbc98ca8..718d8ec0 100644 --- a/lang/parse/parse.go +++ b/lang/parse/parse.go @@ -858,7 +858,7 @@ func (p *parser) parseStatement1() (*a.Node, error) { } return a.NewChoose(name, args).AsNode(), nil - case t.IDIOBind, t.IDIOLimit: + case t.IDIOBind, t.IDIOForgetHistory, t.IDIOLimit: return p.parseIOManipNode() case t.IDIf: @@ -1087,6 +1087,8 @@ func (p *parser) parseIOManipNode() (*a.Node, error) { return nil, fmt.Errorf(`parse: invalid %s argument %q at %s:%d`, keyword.Str(p.tm), io.Str(p.tm), p.filename, p.line()) } + case t.IDIOForgetHistory: + // No-op. case t.IDIOLimit: arg1Name = t.IDLimit if (io.Operator() != 0) && (io.IsArgsDotFoo() == 0) { diff --git a/lang/token/list.go b/lang/token/list.go index 90486cc9..4c071ad5 100644 --- a/lang/token/list.go +++ b/lang/token/list.go @@ -368,32 +368,33 @@ const ( minKeyword = 0xB0 maxKeyword = 0xCF - IDAssert = ID(0xB0) - IDBreak = ID(0xB1) - IDChoose = ID(0xB2) - IDChoosy = ID(0xB3) - IDConst = ID(0xB4) - IDContinue = ID(0xB5) - IDElse = ID(0xB6) - IDEndwhile = ID(0xB7) - IDFunc = ID(0xB8) - IDIOBind = ID(0xB9) - IDIOLimit = ID(0xBA) - IDIf = ID(0xBB) - IDImplements = ID(0xBC) - IDInv = ID(0xBD) - IDIterate = ID(0xBE) - IDPost = ID(0xBF) - IDPre = ID(0xC0) - IDPri = ID(0xC1) - IDPub = ID(0xC2) - IDReturn = ID(0xC3) - IDStruct = ID(0xC4) - IDUse = ID(0xC5) - IDVar = ID(0xC6) - IDVia = ID(0xC7) - IDWhile = ID(0xC8) - IDYield = ID(0xC9) + IDAssert = ID(0xB0) + IDBreak = ID(0xB1) + IDChoose = ID(0xB2) + IDChoosy = ID(0xB3) + IDConst = ID(0xB4) + IDContinue = ID(0xB5) + IDElse = ID(0xB6) + IDEndwhile = ID(0xB7) + IDFunc = ID(0xB8) + IDIOBind = ID(0xB9) + IDIOForgetHistory = ID(0xBA) + IDIOLimit = ID(0xBB) + IDIf = ID(0xBC) + IDImplements = ID(0xBD) + IDInv = ID(0xBE) + IDIterate = ID(0xBF) + IDPost = ID(0xC0) + IDPre = ID(0xC1) + IDPri = ID(0xC2) + IDPub = ID(0xC3) + IDReturn = ID(0xC4) + IDStruct = ID(0xC5) + IDUse = ID(0xC6) + IDVar = ID(0xC7) + IDVia = ID(0xC8) + IDWhile = ID(0xC9) + IDYield = ID(0xCA) ) const ( @@ -816,32 +817,33 @@ var builtInsByID = [nBuiltInIDs]string{ IDNot: "not", - IDAssert: "assert", - IDBreak: "break", - IDChoose: "choose", - IDChoosy: "choosy", - IDConst: "const", - IDContinue: "continue", - IDElse: "else", - IDEndwhile: "endwhile", - IDFunc: "func", - IDIOBind: "io_bind", - IDIOLimit: "io_limit", - IDIf: "if", - IDImplements: "implements", - IDInv: "inv", - IDIterate: "iterate", - IDPost: "post", - IDPre: "pre", - IDPri: "pri", - IDPub: "pub", - IDReturn: "return", - IDStruct: "struct", - IDUse: "use", - IDVar: "var", - IDVia: "via", - IDWhile: "while", - IDYield: "yield", + IDAssert: "assert", + IDBreak: "break", + IDChoose: "choose", + IDChoosy: "choosy", + IDConst: "const", + IDContinue: "continue", + IDElse: "else", + IDEndwhile: "endwhile", + IDFunc: "func", + IDIOBind: "io_bind", + IDIOForgetHistory: "io_forget_history", + IDIOLimit: "io_limit", + IDIf: "if", + IDImplements: "implements", + IDInv: "inv", + IDIterate: "iterate", + IDPost: "post", + IDPre: "pre", + IDPri: "pri", + IDPub: "pub", + IDReturn: "return", + IDStruct: "struct", + IDUse: "use", + IDVar: "var", + IDVia: "via", + IDWhile: "while", + IDYield: "yield", IDArray: "array", IDNptr: "nptr",