v and v2: support @VEXE

pull/4148/head
Delyan Angelov 2020-03-28 22:51:45 +02:00 committed by GitHub
parent 715d4f6601
commit e09447d011
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -4,6 +4,7 @@
module compiler
import os
import v.pref
const (
single_quote = `\'`
@ -550,6 +551,7 @@ fn (s mut Scanner) scan() ScanRes {
s.pos++
name := s.ident_name()
// @FN => will be substituted with the name of the current V function
// @VEXE => will be substituted with the path to the V compiler
// @FILE => will be substituted with the path of the V source file
// @LINE => will be substituted with the V line number where it appears (as a string).
// @COLUMN => will be substituted with the column where it appears (as a string).
@ -560,6 +562,10 @@ fn (s mut Scanner) scan() ScanRes {
if name == 'FN' {
return scan_res(.string, s.fn_name)
}
if name == 'VEXE' {
vexe := pref.vexe_path()
return scan_res(.string, cescaped_path( vexe ) )
}
if name == 'FILE' {
return scan_res(.string, cescaped_path(os.real_path(s.file_path)))
}

View File

@ -6,6 +6,7 @@ module scanner
import (
os
v.token
v.pref
)
const (
@ -560,6 +561,7 @@ pub fn (s mut Scanner) scan() token.Token {
s.pos++
name := s.ident_name()
// @FN => will be substituted with the name of the current V function
// @VEXE => will be substituted with the path to the V compiler
// @FILE => will be substituted with the path of the V source file
// @LINE => will be substituted with the V line number where it appears (as a string).
// @COLUMN => will be substituted with the column where it appears (as a string).
@ -570,6 +572,10 @@ pub fn (s mut Scanner) scan() token.Token {
if name == 'FN' {
return s.scan_res(.string, s.fn_name)
}
if name == 'VEXE' {
vexe := pref.vexe_path()
return s.scan_res(.string, cescaped_path( vexe ) )
}
if name == 'FILE' {
return s.scan_res(.string, cescaped_path(os.real_path(s.file_path)))
}