mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-21 08:47:28 +01:00
Change "$foo" to base."$foo"
This commit is contained in:
1 parent
875362ea07
commit
9e5aec5d25
11 files changed
+71
-59
No files matched your search
@@ -19,7 +19,7 @@ import (
|
||||
t "github.com/google/wuffs/lang/token"
|
||||
)
|
||||
|
||||
var StatusList = [...]string{
|
||||
var Statuses = [...]string{
|
||||
// Warnings.
|
||||
"~end of data",
|
||||
|
||||
@@ -42,14 +42,6 @@ var StatusList = [...]string{
|
||||
"?disabled by previous error",
|
||||
}
|
||||
|
||||
var StatusMap = map[string]bool{}
|
||||
|
||||
func init() {
|
||||
for _, s := range StatusList {
|
||||
StatusMap[s] = true
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: a collection of forbidden variable names like and, or, not, as, ref,
|
||||
// deref, false, true, in, out, this, u8, u16, etc?
|
||||
|
||||
|
||||
@@ -107,6 +107,14 @@ func Check(tm *t.Map, files []*a.File, resolveUse func(usePath string) ([]byte,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, z := range builtin.Statuses {
|
||||
id, err := tm.Insert(`"` + z + `"`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c.statuses[t.QID{t.IDBase, id}] = nil
|
||||
}
|
||||
|
||||
for _, phase := range phases {
|
||||
for _, f := range files {
|
||||
if phase.kind == a.KInvalid {
|
||||
@@ -586,6 +594,10 @@ func (c *Checker) checkAllTypeChecked(node *a.Node) error {
|
||||
}
|
||||
}
|
||||
for _, v := range c.statuses {
|
||||
if v == nil {
|
||||
// Built-in statuses have a nil v node.
|
||||
continue
|
||||
}
|
||||
if err := allTypeChecked(c.tm, v.AsNode()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
+1
-6
@@ -18,8 +18,6 @@ import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"github.com/google/wuffs/lang/builtin"
|
||||
|
||||
a "github.com/google/wuffs/lang/ast"
|
||||
t "github.com/google/wuffs/lang/token"
|
||||
)
|
||||
@@ -385,10 +383,7 @@ func (q *checker) tcheckExprOther(n *a.Expr, depth uint32) error {
|
||||
|
||||
} else if id1.IsStrLiteral(q.tm) {
|
||||
if _, ok := q.c.statuses[n.StatusQID()]; !ok {
|
||||
msg, _ := t.Unescape(n.Ident().Str(q.tm))
|
||||
if _, ok := builtin.StatusMap[msg]; !ok {
|
||||
return fmt.Errorf("check: no error or status with message %q", msg)
|
||||
}
|
||||
return fmt.Errorf("check: unrecognized status %s", n.StatusQID().Str(q.tm))
|
||||
}
|
||||
n.SetMType(typeExprStatus)
|
||||
return nil
|
||||
|
||||
+11
-1
@@ -1017,7 +1017,7 @@ func (p *parser) parseOperand() (*a.Expr, error) {
|
||||
}
|
||||
lhs := a.NewExpr(0, 0, 0, id, nil, nil, nil, nil)
|
||||
|
||||
for {
|
||||
for first := true; ; first = false {
|
||||
flags := a.Flags(0)
|
||||
switch p.peek1() {
|
||||
default:
|
||||
@@ -1056,6 +1056,16 @@ func (p *parser) parseOperand() (*a.Expr, error) {
|
||||
|
||||
case t.IDDot:
|
||||
p.src = p.src[1:]
|
||||
|
||||
if x := p.peek1(); x.IsStrLiteral(p.tm) {
|
||||
if !first {
|
||||
return nil, fmt.Errorf(`parse: string literal %s has too many package qualifiers at %s:%d`,
|
||||
x.Str(p.tm), p.filename, p.line())
|
||||
}
|
||||
p.src = p.src[1:]
|
||||
return a.NewExpr(0, 0, id, x, nil, nil, nil, nil), nil
|
||||
}
|
||||
|
||||
selector, err := p.parseIdent()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in new issue
Block a user