vfmt: minor fixes
parent
aa0ad9d922
commit
519f2990f2
|
@ -199,8 +199,8 @@ fn (p mut Parser) comp_time() {
|
||||||
fn (p mut Parser) chash() {
|
fn (p mut Parser) chash() {
|
||||||
hash := p.lit.trim_space()
|
hash := p.lit.trim_space()
|
||||||
// println('chsh() file=$p.file hash="$hash"')
|
// println('chsh() file=$p.file hash="$hash"')
|
||||||
p.fgen_nl()
|
|
||||||
p.next()
|
p.next()
|
||||||
|
p.fgen_nl()
|
||||||
if hash.starts_with('flag ') {
|
if hash.starts_with('flag ') {
|
||||||
if p.first_pass() {
|
if p.first_pass() {
|
||||||
mut flag := hash[5..]
|
mut flag := hash[5..]
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
module compiler
|
module compiler
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
strings
|
strings
|
||||||
)
|
)
|
||||||
|
@ -1655,3 +1657,4 @@ pub fn (f &Fn) str_for_error() string {
|
||||||
}
|
}
|
||||||
return s + ')'
|
return s + ')'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
module compiler
|
module compiler
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
os
|
os
|
||||||
strings
|
strings
|
||||||
|
@ -464,6 +466,7 @@ fn (p mut Parser) parse(pass Pass) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.key_pub {
|
.key_pub {
|
||||||
|
p.fspace()
|
||||||
next := p.peek()
|
next := p.peek()
|
||||||
match next {
|
match next {
|
||||||
.key_fn {
|
.key_fn {
|
||||||
|
|
|
@ -24,11 +24,12 @@ fn (scanner mut Scanner) fgen(s_ string) {
|
||||||
|
|
||||||
[if vfmt]
|
[if vfmt]
|
||||||
fn (scanner mut Scanner) fgenln(s_ string) {
|
fn (scanner mut Scanner) fgenln(s_ string) {
|
||||||
mut s := s_//.trim_space()
|
mut s := s_.trim_right(' ')
|
||||||
if scanner.fmt_line_empty && scanner.fmt_indent > 0 {
|
if scanner.fmt_line_empty && scanner.fmt_indent > 0 {
|
||||||
s = strings.repeat(`\t`, scanner.fmt_indent) + s
|
s = strings.repeat(`\t`, scanner.fmt_indent) + s
|
||||||
}
|
}
|
||||||
scanner.fmt_lines << s
|
scanner.fmt_lines << s
|
||||||
|
//println('s="$s"')
|
||||||
//scanner.fmt_lines << '//!'
|
//scanner.fmt_lines << '//!'
|
||||||
scanner.fmt_lines << '\n'
|
scanner.fmt_lines << '\n'
|
||||||
//scanner.fmt_out.writeln(s)
|
//scanner.fmt_out.writeln(s)
|
||||||
|
@ -235,15 +236,21 @@ fn (p &Parser) gen_fmt() {
|
||||||
}
|
}
|
||||||
//s := p.scanner.fmt_out.str().replace('\n\n\n', '\n').trim_space()
|
//s := p.scanner.fmt_out.str().replace('\n\n\n', '\n').trim_space()
|
||||||
//s := p.scanner.fmt_out.str().trim_space()
|
//s := p.scanner.fmt_out.str().trim_space()
|
||||||
s := p.scanner.fmt_lines.join('').trim_space().replace_each([
|
//p.scanner.fgenln('// nice')
|
||||||
|
s := p.scanner.fmt_lines.join('')/*.replace_each([
|
||||||
'\n\n\n\n', '\n\n',
|
'\n\n\n\n', '\n\n',
|
||||||
' \n', '\n',
|
' \n', '\n',
|
||||||
') or{', ') or {',
|
') or{', ') or {',
|
||||||
])
|
])
|
||||||
|
*/
|
||||||
|
//.replace('\n\n\n\n', '\n\n')
|
||||||
|
.replace(' \n', '\n')
|
||||||
|
.replace(') or{', ') or {')
|
||||||
|
|
||||||
if s == '' {
|
if s == '' {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//if !p.file_name.contains('float.v') {return}
|
if !p.file_path.contains('fn.v') {return}
|
||||||
path := os.tmpdir() + '/' + p.file_name
|
path := os.tmpdir() + '/' + p.file_name
|
||||||
println('generating ${path}')
|
println('generating ${path}')
|
||||||
mut out := os.create(path) or {
|
mut out := os.create(path) or {
|
||||||
|
@ -251,7 +258,8 @@ fn (p &Parser) gen_fmt() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
println('replacing ${p.file_path}...\n')
|
println('replacing ${p.file_path}...\n')
|
||||||
out.writeln(s)//p.scanner.fmt_out.str().trim_space())
|
out.writeln(s.trim_space())//p.scanner.fmt_out.str().trim_space())
|
||||||
|
out.writeln('')
|
||||||
out.close()
|
out.close()
|
||||||
os.mv(path, p.file_path)
|
os.mv(path, p.file_path)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
module os
|
module os
|
||||||
|
|
||||||
// (Must be realized in Syscall) (Must be specified)
|
// (Must be realized in Syscall) (Must be specified)
|
||||||
// File modes.
|
// File modes.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
O_RDONLY = 1 // open the file read-only.
|
O_RDONLY = 1 // open the file read-only.
|
||||||
O_WRONLY = 2 // open the file write-only.
|
O_WRONLY = 2 // open the file write-only.
|
||||||
O_RDWR = 3 // open the file read-write.
|
O_RDWR = 3 // open the file read-write.
|
||||||
|
|
||||||
O_APPEND = 8 // append data to the file when writing.
|
O_APPEND = 8 // append data to the file when writing.
|
||||||
O_CREATE = 16 // create a new file if none exists.
|
O_CREATE = 16 // create a new file if none exists.
|
||||||
O_EXCL = 32 // used with O_CREATE, file must not exist.
|
O_EXCL = 32 // used with O_CREATE, file must not exist.
|
||||||
O_SYNC = 64 // open for synchronous I/O.
|
O_SYNC = 64 // open for synchronous I/O.
|
||||||
O_TRUNC = 128 // truncate regular writable file when opened.
|
O_TRUNC = 128 // truncate regular writable file when opened.
|
||||||
)
|
)
|
||||||
|
|
||||||
// ref: http://www.ccfit.nsu.ru/~deviv/courses/unix/unix/ng7c229.html
|
// ref: http://www.ccfit.nsu.ru/~deviv/courses/unix/unix/ng7c229.html
|
||||||
const (
|
const (
|
||||||
S_IFMT = 0xF000 // type of file
|
S_IFMT = 0xF000 // type of file
|
||||||
|
@ -28,5 +28,3 @@ const(
|
||||||
STD_ERROR_HANDLE = -12
|
STD_ERROR_HANDLE = -12
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue