mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
Rename $(etc) to [etc]
This commit is contained in:
1 parent
4e7ef5fb88
commit
c1af1e2c82
14 files changed
+44
-42
No files matched your search
+1
-1
@@ -328,7 +328,7 @@ const MaxExprDepth = 255
|
||||
//
|
||||
// For selectors, like "LHS.ID2", ID0 is IDDot.
|
||||
//
|
||||
// For lists, like "$(0, 1, 2)", ID0 is IDDollar.
|
||||
// For lists, like "[0, 1, 2]", ID0 is IDComma.
|
||||
//
|
||||
// For statuses like "?foo" and bar."$baz", ID0 is IDStatus, ID1 is the package
|
||||
// and ID2 is the message.
|
||||
|
||||
+3
-3
@@ -126,15 +126,15 @@ func (n *Expr) appendStr(buf []byte, tm *t.Map, parenthesize bool, depth uint32)
|
||||
buf = append(buf, '.')
|
||||
buf = append(buf, tm.ByID(n.id2)...)
|
||||
|
||||
case t.IDDollar:
|
||||
buf = append(buf, "$("...)
|
||||
case t.IDComma:
|
||||
buf = append(buf, '[')
|
||||
for i, o := range n.list0 {
|
||||
if i != 0 {
|
||||
buf = append(buf, ", "...)
|
||||
}
|
||||
buf = o.AsExpr().appendStr(buf, tm, false, depth)
|
||||
}
|
||||
buf = append(buf, ')')
|
||||
buf = append(buf, ']')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -869,7 +869,7 @@ func (q *checker) bcheckExprOther(n *a.Expr, depth uint32) (a.Bounds, error) {
|
||||
case t.IDStatus:
|
||||
// No-op.
|
||||
|
||||
case t.IDDollar:
|
||||
case t.IDComma:
|
||||
for _, o := range n.Args() {
|
||||
if _, err := q.bcheckExpr(o.AsExpr(), depth); err != nil {
|
||||
return a.Bounds{}, err
|
||||
|
||||
+1
-1
@@ -306,7 +306,7 @@ func (c *Checker) checkConst(node *a.Node) error {
|
||||
func (c *Checker) checkConstElement(n *a.Expr, nb a.Bounds, nLists int) error {
|
||||
if nLists > 0 {
|
||||
nLists--
|
||||
if n.Operator() != t.IDDollar {
|
||||
if n.Operator() != t.IDComma {
|
||||
return fmt.Errorf("invalid const value %q", n.Str(c.tm))
|
||||
}
|
||||
for _, o := range n.Args() {
|
||||
|
||||
@@ -36,7 +36,7 @@ var (
|
||||
typeExprGeneric1 = a.NewTypeExpr(0, t.IDBase, t.IDDagger1, nil, nil, nil)
|
||||
typeExprGeneric2 = a.NewTypeExpr(0, t.IDBase, t.IDDagger2, nil, nil, nil)
|
||||
typeExprIdeal = a.NewTypeExpr(0, t.IDBase, t.IDQIdeal, nil, nil, nil)
|
||||
typeExprList = a.NewTypeExpr(0, t.IDBase, t.IDDollar, nil, nil, nil)
|
||||
typeExprList = a.NewTypeExpr(0, t.IDBase, t.IDComma, nil, nil, nil)
|
||||
typeExprNullptr = a.NewTypeExpr(0, t.IDBase, t.IDQNullptr, nil, nil, nil)
|
||||
typeExprPlaceholder = a.NewTypeExpr(0, t.IDBase, t.IDQPlaceholder, nil, nil, nil)
|
||||
typeExprTypeExpr = a.NewTypeExpr(0, t.IDBase, t.IDQTypeExpr, nil, nil, nil)
|
||||
|
||||
+1
-1
@@ -499,7 +499,7 @@ func (q *checker) tcheckExprOther(n *a.Expr, depth uint32) error {
|
||||
n.SetMType(typeExprStatus)
|
||||
return nil
|
||||
|
||||
case t.IDDollar:
|
||||
case t.IDComma:
|
||||
for _, o := range n.Args() {
|
||||
o := o.AsExpr()
|
||||
if err := q.tcheckExpr(o, depth); err != nil {
|
||||
|
||||
+10
-9
@@ -138,7 +138,7 @@ func (p *parser) parseTopLevelDecl() (*a.Node, error) {
|
||||
p.tm.ByID(id), p.filename, p.line())
|
||||
}
|
||||
p.src = p.src[1:]
|
||||
value, err := p.parsePossibleDollarExpr()
|
||||
value, err := p.parsePossibleListExpr()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -301,7 +301,7 @@ func (p *parser) parseList(stop t.ID, parseElem func(*parser) (*a.Node, error))
|
||||
ret := []*a.Node(nil)
|
||||
for len(p.src) > 0 {
|
||||
if p.src[0].ID == stop {
|
||||
if stop == t.IDCloseParen {
|
||||
if stop == t.IDCloseParen || stop == t.IDCloseBracket {
|
||||
p.src = p.src[1:]
|
||||
}
|
||||
return ret, nil
|
||||
@@ -315,7 +315,7 @@ func (p *parser) parseList(stop t.ID, parseElem func(*parser) (*a.Node, error))
|
||||
|
||||
switch x := p.peek1(); x {
|
||||
case stop:
|
||||
if stop == t.IDCloseParen {
|
||||
if stop == t.IDCloseParen || stop == t.IDCloseBracket {
|
||||
p.src = p.src[1:]
|
||||
}
|
||||
return ret, nil
|
||||
@@ -885,24 +885,25 @@ func (p *parser) parseVarNode(inIterate bool) (*a.Node, error) {
|
||||
return a.NewVar(op, id, typ, value).AsNode(), nil
|
||||
}
|
||||
|
||||
func (p *parser) parsePossibleDollarExprNode() (*a.Node, error) {
|
||||
n, err := p.parsePossibleDollarExpr()
|
||||
func (p *parser) parsePossibleListExprNode() (*a.Node, error) {
|
||||
n, err := p.parsePossibleListExpr()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return n.AsNode(), err
|
||||
}
|
||||
|
||||
func (p *parser) parsePossibleDollarExpr() (*a.Expr, error) {
|
||||
if x := p.peek1(); x != t.IDDollar {
|
||||
func (p *parser) parsePossibleListExpr() (*a.Expr, error) {
|
||||
// TODO: put the [ and ] parsing into parseExpr.
|
||||
if x := p.peek1(); x != t.IDOpenBracket {
|
||||
return p.parseExpr()
|
||||
}
|
||||
p.src = p.src[1:]
|
||||
args, err := p.parseList(t.IDCloseParen, (*parser).parsePossibleDollarExprNode)
|
||||
args, err := p.parseList(t.IDCloseBracket, (*parser).parsePossibleListExprNode)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return a.NewExpr(0, t.IDDollar, 0, 0, nil, nil, nil, args), nil
|
||||
return a.NewExpr(0, t.IDComma, 0, 0, nil, nil, nil, args), nil
|
||||
}
|
||||
|
||||
func (p *parser) parseExprNode() (*a.Node, error) {
|
||||
|
||||
@@ -107,7 +107,7 @@ func Render(w io.Writer, tm *t.Map, src []t.Token, comments []string) (err error
|
||||
// Render the lineTokens.
|
||||
prevID, prevIsTightRight := t.ID(0), false
|
||||
for _, tok := range lineTokens {
|
||||
if prevID != 0 && !prevIsTightRight && !tok.ID.IsTightLeft() {
|
||||
if prevID == t.IDEq || (prevID != 0 && !prevIsTightRight && !tok.ID.IsTightLeft()) {
|
||||
// The "(" token's tight-left-ness is context dependent. For
|
||||
// "f(x)", the "(" is tight-left. For "a * (b + c)", it is not.
|
||||
if tok.ID != t.IDOpenParen || !isCloseIdentStrLiteral(tm, prevID) {
|
||||
|
||||
Reference in new issue
Block a user