Răsfoiți Sursa

ignore #! line at beginning of the hx file

Nicolas Cannasse 16 ani în urmă
părinte
comite
81cecfc1d4
3 a modificat fișierele cu 8 adăugiri și 2 ștergeri
  1. 1 0
      doc/CHANGES.txt
  2. 6 2
      lexer.mll
  3. 1 0
      parser.ml

+ 1 - 0
doc/CHANGES.txt

@@ -9,6 +9,7 @@
 	flash9 : fixed verify error with inline + null type
 	flash9 : bugfix when overriding/implementing an method with an applied type parameter
 	php: fixed issues with classes that implement Dynamic
+	all : ignore #! line at beginning of the hx file
 
 2009-07-26: 2.04
 	flash9 : fixed get_full_path error with -D fdb

+ 6 - 2
lexer.mll

@@ -159,9 +159,13 @@ let find_line_index idx p =
 let ident = ('_'* ['a'-'z'] ['_' 'a'-'z' 'A'-'Z' '0'-'9']* | '_'+ | '_'+ ['0'-'9'] ['_' 'a'-'z' 'A'-'Z' '0'-'9']* )
 let idtype = '_'* ['A'-'Z'] ['_' 'a'-'z' 'A'-'Z' '0'-'9']*
 
-rule token = parse
+rule skip_header = parse
+	| "\239\187\191" { skip_header lexbuf }
+	| "#!" [^'\n' '\r']* { skip_header lexbuf }
+	| "" | eof { }
+
+and token = parse
 	| eof { mk lexbuf Eof }
-	| "\239\187\191" { token lexbuf }
 	| [' ' '\t']+ { token lexbuf }
 	| "\r\n" { newline lexbuf; token lexbuf }
 	| '\n' | '\r' { newline lexbuf; token lexbuf }

+ 1 - 0
parser.ml

@@ -657,6 +657,7 @@ let parse ctx code file =
 	cache := DynArray.create();
 	doc := None;
 	Lexer.init file;
+	Lexer.skip_header code;
 	let rec next_token() = process_token (Lexer.token code)
 
 	and process_token tk =