pulumi/pkg/diag/pos.go
joeduffy 2dd8665c46 Prepare for semantic analysis
This change begins to lay the groundwork for doing semantic analysis and
lowering to the cloud target's representation.  In particular:

* Split the mu/schema package.  There is now mu/ast which contains the
  core types and mu/encoding which concerns itself with JSON and YAML
  serialization.

* Notably I am *not* yet introducing a second AST form.  Instead, we will
  keep the parse tree and AST unified for the time being.  I envision very
  little difference between them -- at least for now -- and so this keeps
  things simpler, at the expense of two downsides: 1) the trees will be
  mutable (which turns out to be a good thing for performance), and 2) some
  fields will need to be ignored during de/serialization.  We can always
  revisit this later when and if the need to split them arises.

* Add a binder phase.  It is currently a no-op.
2016-11-16 09:29:44 -08:00

32 lines
741 B
Go

// Copyright 2016 Marapongo, Inc. All rights reserved.
package diag
// Pos represents a position in a file.
type Pos struct {
Ln int
Col int
}
// EmptyPos may be used when no position is needed.
var EmptyPos = Pos{0, 0}
// IsEmpty returns true if the Pos information is missing.
func (pos Pos) IsEmpty() bool {
return pos.Ln == 0 && pos.Col == 0
}
// Location represents a region spanning two positions in a file.
type Location struct {
From Pos
To Pos
}
// EmptyLocation may be used when no position information is available.
var EmptyLocation = Location{EmptyPos, EmptyPos}
// IsEmpty returns true if the Location information is missing.
func (loc Location) IsEmpty() bool {
return loc.From.IsEmpty() && loc.To.IsEmpty()
}