make sure scanner and parser both check BOM

pull/3882/head
lydiandy 2020-02-29 22:05:26 +08:00 committed by GitHub
parent 6c85e285e7
commit a485533dc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 6 deletions

View File

@ -65,13 +65,9 @@ pub fn parse_stmt(text string, table &table.Table, scope &ast.Scope) ast.Stmt {
} }
pub fn parse_file(path string, table &table.Table) ast.File { pub fn parse_file(path string, table &table.Table) ast.File {
// println('parse_file("$path")')
text := os.read_file(path) or {
panic(err)
}
mut stmts := []ast.Stmt mut stmts := []ast.Stmt
mut p := Parser{ mut p := Parser{
scanner: scanner.new_scanner(text) scanner: scanner.new_scanner_file(path)
table: table table: table
file_name: path file_name: path
pref: &pref.Preferences{} pref: &pref.Preferences{}

View File

@ -43,7 +43,7 @@ mut:
// string values when generating formatted code. // string values when generating formatted code.
} }
// new scanner from file. // new scanner from file.
fn new_scanner_file(file_path string) &Scanner { pub fn new_scanner_file(file_path string) &Scanner {
if !os.exists(file_path) { if !os.exists(file_path) {
verror("$file_path doesn't exist") verror("$file_path doesn't exist")
} }