lang: more anticipating io_forget_history

This commit is contained in:
Nigel Tao committed 2024-02-09 15:03:44 +11:00
1 parent 6482ba3923
commit 9fb3859488
5 files changed
+63 -55

No files matched your search

+1
View File
@@ -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). code (instead of writing C/C++ code that _uses_ Wuffs' standard library).
- Added `if.likely` and `if.unlikely`. - Added `if.likely` and `if.unlikely`.
- Added `io_forget_history`.
- Added `slice_var as nptr array[etc] etc` conversion. - Added `slice_var as nptr array[etc] etc` conversion.
- Added read-only type decorators: `roarray`, `roslice` and `rotable`. - Added read-only type decorators: `roarray`, `roslice` and `rotable`.
- Ban recursive function calls. - Ban recursive function calls.
+3 -2
View File
@@ -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 // IOManip is "io_bind (io:LHS, data:MHS, history_position:RHS) { List2 }" or
// "io_limit (io:LHS, limit:MHS) { List2 }": // "io_forget_history (io:LHS) { List2 }" or "io_limit (io:LHS, limit:MHS) {
// - ID0: <IDIOBind|IDIOLimit> // List2 }":
// - ID0: <IDIOBind|IDIOForgetHistory|IDIOLimit>
// - LHS: <Expr> // - LHS: <Expr>
// - MHS: <Expr> // - MHS: <Expr>
// - RHS: <Expr> // - RHS: <Expr>
+2
View File
@@ -164,6 +164,8 @@ func (q *checker) tcheckStatement(n *a.Node) error {
switch n.Keyword() { switch n.Keyword() {
case t.IDIOBind: case t.IDIOBind:
arg1Typ = typeExprSliceU8 arg1Typ = typeExprSliceU8
case t.IDIOForgetHistory:
// No-op.
case t.IDIOLimit: case t.IDIOLimit:
arg1Typ = typeExprU64 arg1Typ = typeExprU64
} }
+3 -1
View File
@@ -858,7 +858,7 @@ func (p *parser) parseStatement1() (*a.Node, error) {
} }
return a.NewChoose(name, args).AsNode(), nil return a.NewChoose(name, args).AsNode(), nil
case t.IDIOBind, t.IDIOLimit: case t.IDIOBind, t.IDIOForgetHistory, t.IDIOLimit:
return p.parseIOManipNode() return p.parseIOManipNode()
case t.IDIf: 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`, return nil, fmt.Errorf(`parse: invalid %s argument %q at %s:%d`,
keyword.Str(p.tm), io.Str(p.tm), p.filename, p.line()) keyword.Str(p.tm), io.Str(p.tm), p.filename, p.line())
} }
case t.IDIOForgetHistory:
// No-op.
case t.IDIOLimit: case t.IDIOLimit:
arg1Name = t.IDLimit arg1Name = t.IDLimit
if (io.Operator() != 0) && (io.IsArgsDotFoo() == 0) { if (io.Operator() != 0) && (io.IsArgsDotFoo() == 0) {
+54 -52
View File
@@ -368,32 +368,33 @@ const (
minKeyword = 0xB0 minKeyword = 0xB0
maxKeyword = 0xCF maxKeyword = 0xCF
IDAssert = ID(0xB0) IDAssert = ID(0xB0)
IDBreak = ID(0xB1) IDBreak = ID(0xB1)
IDChoose = ID(0xB2) IDChoose = ID(0xB2)
IDChoosy = ID(0xB3) IDChoosy = ID(0xB3)
IDConst = ID(0xB4) IDConst = ID(0xB4)
IDContinue = ID(0xB5) IDContinue = ID(0xB5)
IDElse = ID(0xB6) IDElse = ID(0xB6)
IDEndwhile = ID(0xB7) IDEndwhile = ID(0xB7)
IDFunc = ID(0xB8) IDFunc = ID(0xB8)
IDIOBind = ID(0xB9) IDIOBind = ID(0xB9)
IDIOLimit = ID(0xBA) IDIOForgetHistory = ID(0xBA)
IDIf = ID(0xBB) IDIOLimit = ID(0xBB)
IDImplements = ID(0xBC) IDIf = ID(0xBC)
IDInv = ID(0xBD) IDImplements = ID(0xBD)
IDIterate = ID(0xBE) IDInv = ID(0xBE)
IDPost = ID(0xBF) IDIterate = ID(0xBF)
IDPre = ID(0xC0) IDPost = ID(0xC0)
IDPri = ID(0xC1) IDPre = ID(0xC1)
IDPub = ID(0xC2) IDPri = ID(0xC2)
IDReturn = ID(0xC3) IDPub = ID(0xC3)
IDStruct = ID(0xC4) IDReturn = ID(0xC4)
IDUse = ID(0xC5) IDStruct = ID(0xC5)
IDVar = ID(0xC6) IDUse = ID(0xC6)
IDVia = ID(0xC7) IDVar = ID(0xC7)
IDWhile = ID(0xC8) IDVia = ID(0xC8)
IDYield = ID(0xC9) IDWhile = ID(0xC9)
IDYield = ID(0xCA)
) )
const ( const (
@@ -816,32 +817,33 @@ var builtInsByID = [nBuiltInIDs]string{
IDNot: "not", IDNot: "not",
IDAssert: "assert", IDAssert: "assert",
IDBreak: "break", IDBreak: "break",
IDChoose: "choose", IDChoose: "choose",
IDChoosy: "choosy", IDChoosy: "choosy",
IDConst: "const", IDConst: "const",
IDContinue: "continue", IDContinue: "continue",
IDElse: "else", IDElse: "else",
IDEndwhile: "endwhile", IDEndwhile: "endwhile",
IDFunc: "func", IDFunc: "func",
IDIOBind: "io_bind", IDIOBind: "io_bind",
IDIOLimit: "io_limit", IDIOForgetHistory: "io_forget_history",
IDIf: "if", IDIOLimit: "io_limit",
IDImplements: "implements", IDIf: "if",
IDInv: "inv", IDImplements: "implements",
IDIterate: "iterate", IDInv: "inv",
IDPost: "post", IDIterate: "iterate",
IDPre: "pre", IDPost: "post",
IDPri: "pri", IDPre: "pre",
IDPub: "pub", IDPri: "pri",
IDReturn: "return", IDPub: "pub",
IDStruct: "struct", IDReturn: "return",
IDUse: "use", IDStruct: "struct",
IDVar: "var", IDUse: "use",
IDVia: "via", IDVar: "var",
IDWhile: "while", IDVia: "via",
IDYield: "yield", IDWhile: "while",
IDYield: "yield",
IDArray: "array", IDArray: "array",
IDNptr: "nptr", IDNptr: "nptr",