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.pull/2159/head
parent
ed3a4961d0
commit
0160c7a89d
|
@ -64,6 +64,7 @@ jobs:
|
||||||
# node-version: 12.x
|
# node-version: 12.x
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
|
gcc --version
|
||||||
git clone --depth=1 https://github.com/ubawurinna/freetype-windows-binaries.git thirdparty/freetype/
|
git clone --depth=1 https://github.com/ubawurinna/freetype-windows-binaries.git thirdparty/freetype/
|
||||||
.\make.bat -gcc
|
.\make.bat -gcc
|
||||||
- name: Test
|
- name: Test
|
||||||
|
|
|
@ -43,6 +43,7 @@ script:
|
||||||
git clone --depth=1 https://github.com/ubawurinna/freetype-windows-binaries thirdparty/freetype/
|
git clone --depth=1 https://github.com/ubawurinna/freetype-windows-binaries thirdparty/freetype/
|
||||||
|
|
||||||
if [[ "${TRAVIS_JOB_NAME}" == "windows_gcc" ]]; then
|
if [[ "${TRAVIS_JOB_NAME}" == "windows_gcc" ]]; then
|
||||||
|
gcc --version
|
||||||
echo "Building V with GCC"
|
echo "Building V with GCC"
|
||||||
export VFLAGS="-os windows"
|
export VFLAGS="-os windows"
|
||||||
./make.bat -gcc
|
./make.bat -gcc
|
||||||
|
|
|
@ -1057,9 +1057,6 @@ fn (v &V) test_v() {
|
||||||
println('Testing...')
|
println('Testing...')
|
||||||
mut tmark := benchmark.new_benchmark()
|
mut tmark := benchmark.new_benchmark()
|
||||||
for dot_relative_file in test_files {
|
for dot_relative_file in test_files {
|
||||||
if dot_relative_file.contains('repl_test.v') {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
relative_file := dot_relative_file.replace('./', '')
|
relative_file := dot_relative_file.replace('./', '')
|
||||||
file := os.realpath( relative_file )
|
file := os.realpath( relative_file )
|
||||||
tmpcfilepath := file.replace('_test.v', '_test.tmp.c')
|
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 {
|
struct ScannerPos {
|
||||||
mut:
|
mut:
|
||||||
pos int
|
pos int
|
||||||
line_nr int
|
line_nr int
|
||||||
|
last_nl_pos int
|
||||||
}
|
}
|
||||||
fn (s ScannerPos) str() string {
|
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 {
|
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) {
|
fn (s mut Scanner) goto_scanner_position(scp ScannerPos) {
|
||||||
s.pos = scp.pos
|
s.pos = scp.pos
|
||||||
s.line_nr = scp.line_nr
|
s.line_nr = scp.line_nr
|
||||||
|
s.last_nl_pos = scp.last_nl_pos
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -232,8 +240,7 @@ fn (s mut Scanner) skip_whitespace() {
|
||||||
for s.pos < s.text.len && s.text[s.pos].is_white() {
|
for s.pos < s.text.len && s.text[s.pos].is_white() {
|
||||||
// Count \r\n as one line
|
// Count \r\n as one line
|
||||||
if is_nl(s.text[s.pos]) && !s.expect('\r\n', s.pos-1) {
|
if is_nl(s.text[s.pos]) && !s.expect('\r\n', s.pos-1) {
|
||||||
s.last_nl_pos = s.pos
|
s.inc_line_number()
|
||||||
s.line_nr++
|
|
||||||
}
|
}
|
||||||
s.pos++
|
s.pos++
|
||||||
}
|
}
|
||||||
|
@ -431,6 +438,7 @@ fn (s mut Scanner) scan() ScanRes {
|
||||||
case `\r`:
|
case `\r`:
|
||||||
if nextc == `\n` {
|
if nextc == `\n` {
|
||||||
s.pos++
|
s.pos++
|
||||||
|
s.last_nl_pos = s.pos
|
||||||
return scan_res(.nl, '')
|
return scan_res(.nl, '')
|
||||||
}
|
}
|
||||||
case `\n`:
|
case `\n`:
|
||||||
|
@ -444,10 +452,7 @@ fn (s mut Scanner) scan() ScanRes {
|
||||||
return scan_res(.dot, '')
|
return scan_res(.dot, '')
|
||||||
case `#`:
|
case `#`:
|
||||||
start := s.pos + 1
|
start := s.pos + 1
|
||||||
for s.pos < s.text.len && s.text[s.pos] != `\n` {
|
s.ignore_line()
|
||||||
s.pos++
|
|
||||||
}
|
|
||||||
s.line_nr++
|
|
||||||
if nextc == `!` {
|
if nextc == `!` {
|
||||||
// treat shebang line (#!) as a comment
|
// treat shebang line (#!) as a comment
|
||||||
s.line_comment = s.text.substr(start + 1, s.pos).trim_space()
|
s.line_comment = s.text.substr(start + 1, s.pos).trim_space()
|
||||||
|
@ -543,10 +548,7 @@ fn (s mut Scanner) scan() ScanRes {
|
||||||
}
|
}
|
||||||
if nextc == `/` {
|
if nextc == `/` {
|
||||||
start := s.pos + 1
|
start := s.pos + 1
|
||||||
for s.pos < s.text.len && s.text[s.pos] != `\n`{
|
s.ignore_line()
|
||||||
s.pos++
|
|
||||||
}
|
|
||||||
s.line_nr++
|
|
||||||
s.line_comment = s.text.substr(start + 1, s.pos)
|
s.line_comment = s.text.substr(start + 1, s.pos)
|
||||||
s.line_comment = s.line_comment.trim_space()
|
s.line_comment = s.line_comment.trim_space()
|
||||||
s.fgenln('// ${s.prev_tok.str()} "$s.line_comment"')
|
s.fgenln('// ${s.prev_tok.str()} "$s.line_comment"')
|
||||||
|
@ -565,7 +567,7 @@ fn (s mut Scanner) scan() ScanRes {
|
||||||
s.error('comment not terminated')
|
s.error('comment not terminated')
|
||||||
}
|
}
|
||||||
if s.text[s.pos] == `\n` {
|
if s.text[s.pos] == `\n` {
|
||||||
s.line_nr++
|
s.inc_line_number()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if s.expect('/*', s.pos) {
|
if s.expect('/*', s.pos) {
|
||||||
|
@ -711,7 +713,7 @@ fn (s mut Scanner) ident_string() string {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if c == `\n` {
|
if c == `\n` {
|
||||||
s.line_nr++
|
s.inc_line_number()
|
||||||
}
|
}
|
||||||
// Don't allow \0
|
// Don't allow \0
|
||||||
if c == `0` && s.pos > 2 && s.text[s.pos - 1] == `\\` {
|
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 {
|
fn is_name_char(c byte) bool {
|
||||||
return c.is_letter() || c == `_`
|
return c.is_letter() || c == `_`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue