mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
compiler: change s.line_nr in just one place in tandem with s.last_nl_pos
* compiler: change s.line_nr in just one place, so that s.last_nl_pos will be updated in tandem too. * v test v: run repl tests again * Show gcc version in both windows gcc cases in a) github actions, and b) travis . * adding inline to is_name_char is_nl and contains_capital does not help actually, just increases slightly binary size. * Cleanup spurious spaces.
This commit is contained in:
parent
ed3a4961d0
commit
0160c7a89d
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
@ -64,6 +64,7 @@ jobs:
|
||||
# node-version: 12.x
|
||||
- name: Build
|
||||
run: |
|
||||
gcc --version
|
||||
git clone --depth=1 https://github.com/ubawurinna/freetype-windows-binaries.git thirdparty/freetype/
|
||||
.\make.bat -gcc
|
||||
- name: Test
|
||||
|
@ -43,6 +43,7 @@ script:
|
||||
git clone --depth=1 https://github.com/ubawurinna/freetype-windows-binaries thirdparty/freetype/
|
||||
|
||||
if [[ "${TRAVIS_JOB_NAME}" == "windows_gcc" ]]; then
|
||||
gcc --version
|
||||
echo "Building V with GCC"
|
||||
export VFLAGS="-os windows"
|
||||
./make.bat -gcc
|
||||
|
@ -1057,9 +1057,6 @@ fn (v &V) test_v() {
|
||||
println('Testing...')
|
||||
mut tmark := benchmark.new_benchmark()
|
||||
for dot_relative_file in test_files {
|
||||
if dot_relative_file.contains('repl_test.v') {
|
||||
continue
|
||||
}
|
||||
relative_file := dot_relative_file.replace('./', '')
|
||||
file := os.realpath( relative_file )
|
||||
tmpcfilepath := file.replace('_test.v', '_test.tmp.c')
|
||||
|
@ -74,20 +74,28 @@ fn new_scanner(text string) &Scanner {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// The goal of ScannerPos is to track the current scanning position,
|
||||
// so that if there is an error found later, v could show a more accurate
|
||||
// position about where the error initially was.
|
||||
// NB: The fields of ScannerPos *should be kept synchronized* with the
|
||||
// corresponding fields in Scanner.
|
||||
struct ScannerPos {
|
||||
mut:
|
||||
pos int
|
||||
line_nr int
|
||||
last_nl_pos int
|
||||
}
|
||||
fn (s ScannerPos) str() string {
|
||||
return 'ScannerPos{ ${s.pos:5d} , ${s.line_nr:5d} }'
|
||||
return 'ScannerPos{ ${s.pos:5d} , ${s.line_nr:5d} , ${s.last_nl_pos:5d} }'
|
||||
}
|
||||
fn (s &Scanner) get_scanner_pos() ScannerPos {
|
||||
return ScannerPos{ pos: s.pos line_nr: s.line_nr }
|
||||
return ScannerPos{ pos: s.pos line_nr: s.line_nr last_nl_pos: s.last_nl_pos }
|
||||
}
|
||||
fn (s mut Scanner) goto_scanner_position(scp ScannerPos) {
|
||||
s.pos = scp.pos
|
||||
s.line_nr = scp.line_nr
|
||||
s.last_nl_pos = scp.last_nl_pos
|
||||
}
|
||||
|
||||
|
||||
@ -231,9 +239,8 @@ fn (s mut Scanner) ident_number() string {
|
||||
fn (s mut Scanner) skip_whitespace() {
|
||||
for s.pos < s.text.len && s.text[s.pos].is_white() {
|
||||
// Count \r\n as one line
|
||||
if is_nl(s.text[s.pos]) && !s.expect('\r\n', s.pos-1) {
|
||||
s.last_nl_pos = s.pos
|
||||
s.line_nr++
|
||||
if is_nl(s.text[s.pos]) && !s.expect('\r\n', s.pos-1) {
|
||||
s.inc_line_number()
|
||||
}
|
||||
s.pos++
|
||||
}
|
||||
@ -431,6 +438,7 @@ fn (s mut Scanner) scan() ScanRes {
|
||||
case `\r`:
|
||||
if nextc == `\n` {
|
||||
s.pos++
|
||||
s.last_nl_pos = s.pos
|
||||
return scan_res(.nl, '')
|
||||
}
|
||||
case `\n`:
|
||||
@ -444,10 +452,7 @@ fn (s mut Scanner) scan() ScanRes {
|
||||
return scan_res(.dot, '')
|
||||
case `#`:
|
||||
start := s.pos + 1
|
||||
for s.pos < s.text.len && s.text[s.pos] != `\n` {
|
||||
s.pos++
|
||||
}
|
||||
s.line_nr++
|
||||
s.ignore_line()
|
||||
if nextc == `!` {
|
||||
// treat shebang line (#!) as a comment
|
||||
s.line_comment = s.text.substr(start + 1, s.pos).trim_space()
|
||||
@ -543,10 +548,7 @@ fn (s mut Scanner) scan() ScanRes {
|
||||
}
|
||||
if nextc == `/` {
|
||||
start := s.pos + 1
|
||||
for s.pos < s.text.len && s.text[s.pos] != `\n`{
|
||||
s.pos++
|
||||
}
|
||||
s.line_nr++
|
||||
s.ignore_line()
|
||||
s.line_comment = s.text.substr(start + 1, s.pos)
|
||||
s.line_comment = s.line_comment.trim_space()
|
||||
s.fgenln('// ${s.prev_tok.str()} "$s.line_comment"')
|
||||
@ -565,7 +567,7 @@ fn (s mut Scanner) scan() ScanRes {
|
||||
s.error('comment not terminated')
|
||||
}
|
||||
if s.text[s.pos] == `\n` {
|
||||
s.line_nr++
|
||||
s.inc_line_number()
|
||||
continue
|
||||
}
|
||||
if s.expect('/*', s.pos) {
|
||||
@ -711,7 +713,7 @@ fn (s mut Scanner) ident_string() string {
|
||||
break
|
||||
}
|
||||
if c == `\n` {
|
||||
s.line_nr++
|
||||
s.inc_line_number()
|
||||
}
|
||||
// Don't allow \0
|
||||
if c == `0` && s.pos > 2 && s.text[s.pos - 1] == `\\` {
|
||||
@ -827,6 +829,23 @@ fn (s mut Scanner) debug_tokens() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn (s mut Scanner) ignore_line() {
|
||||
s.eat_to_end_of_line()
|
||||
s.inc_line_number()
|
||||
}
|
||||
|
||||
fn (s mut Scanner) eat_to_end_of_line(){
|
||||
for s.pos < s.text.len && s.text[s.pos] != `\n` {
|
||||
s.pos++
|
||||
}
|
||||
}
|
||||
|
||||
fn (s mut Scanner) inc_line_number() {
|
||||
s.last_nl_pos = s.pos
|
||||
s.line_nr++
|
||||
}
|
||||
|
||||
fn is_name_char(c byte) bool {
|
||||
return c.is_letter() || c == `_`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user