mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
token: rename Position to Pos, rename position() to pos() (#13279)
This commit is contained in:
@@ -70,7 +70,7 @@ pub fn (dtt DateTimeType) str() string {
|
||||
pub struct Comment {
|
||||
pub:
|
||||
text string
|
||||
pos token.Position
|
||||
pos token.Pos
|
||||
}
|
||||
|
||||
// str returns the `string` representation of the `Comment` type.
|
||||
@@ -86,7 +86,7 @@ pub fn (c Comment) str() string {
|
||||
pub struct Null {
|
||||
pub:
|
||||
text string
|
||||
pos token.Position
|
||||
pos token.Pos
|
||||
}
|
||||
|
||||
// str returns the `string` representation of the `Null` type
|
||||
@@ -100,7 +100,7 @@ pub struct Quoted {
|
||||
pub mut:
|
||||
text string
|
||||
pub:
|
||||
pos token.Position
|
||||
pos token.Pos
|
||||
is_multiline bool
|
||||
quote byte
|
||||
}
|
||||
@@ -122,7 +122,7 @@ pub fn (q Quoted) str() string {
|
||||
pub struct Bare {
|
||||
pub:
|
||||
text string
|
||||
pos token.Position
|
||||
pos token.Pos
|
||||
}
|
||||
|
||||
// str returns the `string` representation of the `Bare` type.
|
||||
@@ -140,7 +140,7 @@ pub fn (b Bare) str() string {
|
||||
pub struct Bool {
|
||||
pub:
|
||||
text string
|
||||
pos token.Position
|
||||
pos token.Pos
|
||||
}
|
||||
|
||||
// str returns the `string` representation of the `Bool` type.
|
||||
@@ -157,7 +157,7 @@ pub fn (b Bool) str() string {
|
||||
// Number can be integers, floats, infinite, NaN - they can have exponents (`5e2`) and be sign prefixed (`+2`).
|
||||
pub struct Number {
|
||||
pub:
|
||||
pos token.Position
|
||||
pos token.Pos
|
||||
pub mut:
|
||||
text string
|
||||
}
|
||||
@@ -197,7 +197,7 @@ pub fn (n Number) f64() f64 {
|
||||
pub struct Date {
|
||||
pub:
|
||||
text string
|
||||
pos token.Position
|
||||
pos token.Pos
|
||||
}
|
||||
|
||||
// str returns the `string` representation of the `Date` type.
|
||||
@@ -215,7 +215,7 @@ pub struct Time {
|
||||
pub:
|
||||
text string
|
||||
offset int
|
||||
pos token.Position
|
||||
pos token.Pos
|
||||
}
|
||||
|
||||
// str returns the `string` representation of the `Time` type.
|
||||
@@ -234,7 +234,7 @@ pub struct DateTime {
|
||||
pub mut:
|
||||
text string
|
||||
pub:
|
||||
pos token.Position
|
||||
pos token.Pos
|
||||
date Date
|
||||
time Time
|
||||
}
|
||||
@@ -253,7 +253,7 @@ pub fn (dt DateTime) str() string {
|
||||
// EOF is the data representation of the end of the TOML document.
|
||||
pub struct EOF {
|
||||
pub:
|
||||
pos token.Position
|
||||
pos token.Pos
|
||||
}
|
||||
|
||||
// str returns the `string` representation of the `EOF` type.
|
||||
|
||||
@@ -53,7 +53,7 @@ fn (c Checker) visit(value &ast.Value) ? {
|
||||
}
|
||||
|
||||
// excerpt returns a string of the token's surroundings
|
||||
fn (c Checker) excerpt(tp token.Position) string {
|
||||
fn (c Checker) excerpt(tp token.Pos) string {
|
||||
return c.scanner.excerpt(tp.pos, 10)
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@ fn (c Checker) check_date_time(dt ast.DateTime) ? {
|
||||
// Re-use date and time validation code for detailed testing of each part
|
||||
c.check_date(ast.Date{
|
||||
text: split[0]
|
||||
pos: token.Position{
|
||||
pos: token.Pos{
|
||||
len: split[0].len
|
||||
line_nr: dt.pos.line_nr
|
||||
pos: dt.pos.pos
|
||||
@@ -310,7 +310,7 @@ fn (c Checker) check_date_time(dt ast.DateTime) ? {
|
||||
}) ?
|
||||
c.check_time(ast.Time{
|
||||
text: split[1]
|
||||
pos: token.Position{
|
||||
pos: token.Pos{
|
||||
len: split[1].len
|
||||
line_nr: dt.pos.line_nr
|
||||
pos: dt.pos.pos + split[0].len
|
||||
|
||||
@@ -43,7 +43,7 @@ fn (d Decoder) modify(mut value ast.Value) ? {
|
||||
}
|
||||
|
||||
// excerpt returns a string of the token's surroundings
|
||||
fn (d Decoder) excerpt(tp token.Position) string {
|
||||
fn (d Decoder) excerpt(tp token.Pos) string {
|
||||
return d.scanner.excerpt(tp.pos, 10)
|
||||
}
|
||||
|
||||
|
||||
@@ -1160,7 +1160,7 @@ pub fn (mut p Parser) comment() ast.Comment {
|
||||
util.printdbg(@MOD + '.' + @STRUCT + '.' + @FN, 'parsed hash comment "#$p.tok.lit"')
|
||||
return ast.Comment{
|
||||
text: p.tok.lit
|
||||
pos: p.tok.position()
|
||||
pos: p.tok.pos()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1173,7 +1173,7 @@ pub fn (mut p Parser) key() ?ast.Key {
|
||||
if p.tok.kind == .number {
|
||||
if p.peek_tok.kind == .minus {
|
||||
mut lits := p.tok.lit
|
||||
pos := p.tok.position()
|
||||
pos := p.tok.pos()
|
||||
for p.peek_tok.kind != .assign && p.peek_tok.kind != .period && p.peek_tok.kind != .rsbr {
|
||||
p.next() ?
|
||||
if p.tok.kind !in parser.space_formatting {
|
||||
@@ -1337,7 +1337,7 @@ pub fn (mut p Parser) number_or_date() ?ast.Value {
|
||||
// bare parse and returns an `ast.Bare` type.
|
||||
pub fn (mut p Parser) bare() ?ast.Bare {
|
||||
mut lits := p.tok.lit
|
||||
pos := p.tok.position()
|
||||
pos := p.tok.pos()
|
||||
for p.peek_tok.kind != .assign && p.peek_tok.kind != .period && p.peek_tok.kind != .rsbr
|
||||
&& p.peek_tok.kind !in parser.space_formatting {
|
||||
p.next() ?
|
||||
@@ -1373,7 +1373,7 @@ pub fn (mut p Parser) quoted() ast.Quoted {
|
||||
}
|
||||
return ast.Quoted{
|
||||
text: lit
|
||||
pos: p.tok.position()
|
||||
pos: p.tok.pos()
|
||||
quote: quote
|
||||
is_multiline: is_multiline
|
||||
}
|
||||
@@ -1387,7 +1387,7 @@ pub fn (mut p Parser) boolean() ?ast.Bool {
|
||||
}
|
||||
return ast.Bool{
|
||||
text: p.tok.lit
|
||||
pos: p.tok.position()
|
||||
pos: p.tok.pos()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1395,7 +1395,7 @@ pub fn (mut p Parser) boolean() ?ast.Bool {
|
||||
pub fn (mut p Parser) number() ast.Number {
|
||||
return ast.Number{
|
||||
text: p.tok.lit
|
||||
pos: p.tok.position()
|
||||
pos: p.tok.pos()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1404,7 +1404,7 @@ pub fn (mut p Parser) number() ast.Number {
|
||||
pub fn (mut p Parser) date_time() ?ast.DateTimeType {
|
||||
// Date and/or Time
|
||||
mut lit := ''
|
||||
pos := p.tok.position()
|
||||
pos := p.tok.pos()
|
||||
mut date := ast.Date{}
|
||||
mut time := ast.Time{}
|
||||
|
||||
@@ -1447,7 +1447,7 @@ pub fn (mut p Parser) date_time() ?ast.DateTimeType {
|
||||
pub fn (mut p Parser) date() ?ast.Date {
|
||||
// Date
|
||||
mut lit := p.tok.lit
|
||||
pos := p.tok.position()
|
||||
pos := p.tok.pos()
|
||||
|
||||
p.check(.number) ?
|
||||
lit += p.tok.lit
|
||||
@@ -1470,7 +1470,7 @@ pub fn (mut p Parser) date() ?ast.Date {
|
||||
pub fn (mut p Parser) time() ?ast.Time {
|
||||
// Time
|
||||
mut lit := p.tok.lit
|
||||
pos := p.tok.position()
|
||||
pos := p.tok.pos()
|
||||
|
||||
if p.is_at(.bare) && (lit.starts_with('T') || lit.starts_with('t')) {
|
||||
if p.tok.lit.starts_with('T') {
|
||||
@@ -1530,6 +1530,6 @@ pub fn (mut p Parser) time() ?ast.Time {
|
||||
// eof returns an `ast.EOF` type.
|
||||
pub fn (mut p Parser) eof() ast.EOF {
|
||||
return ast.EOF{
|
||||
pos: p.tok.position()
|
||||
pos: p.tok.pos()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
module token
|
||||
|
||||
// Position represents a position in a TOML document.
|
||||
pub struct Position {
|
||||
pub struct Pos {
|
||||
pub:
|
||||
len int // length of the literal in the source
|
||||
line_nr int // the line number in the source where the token occured
|
||||
@@ -42,8 +42,8 @@ pub enum Kind {
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn (tok &Token) position() Position {
|
||||
return Position{
|
||||
pub fn (tok &Token) pos() Pos {
|
||||
return Pos{
|
||||
len: tok.len
|
||||
line_nr: tok.line_nr - 1
|
||||
pos: tok.pos
|
||||
|
||||
Reference in New Issue
Block a user