Commits

orbitz committed f73f78e

Trying to fix the lexer to support multiple character nonascii keywords

Comments (0)

Files changed (5)

   let code_stream = Stream.of_channel in_chan in
   let code_lexed = list_of_stream (Lexer.lex code_stream) in
   Token.pp_list code_lexed;
-  Formatter.format stdout code_lexed
+  Formatter.format program_options stdout code_lexed
 
 
 let () = main Sys.argv
-let format out_chan code = raise (Failure "uhhh..")
+type parser_state =
+  | Top_level
+  | Function
+
+type options = { program_options : Program_options.t
+	       ; imputed_line_length : int
+	       ; indentation_level : int
+	       ; parser_state : parser_state
+	       }
+
+
+let format program_options out_chan code = raise (Failure "uhhh..")
+
+
+
+let construct_string options 

src/formatter.mli

-val format : out_channel -> Token.t list -> unit
+val format : Program_options.t -> out_channel -> Token.t list -> unit
     let buffer = Buffer.create initial_buffer_size in
     Buffer.add_char buffer first_digit;
     lex_number buffer stream
+  | [< ''='; stream >] ->
+    lex_equal stream
+  | [< ''-'; sream >] ->
+    lex_minus stream
   | [< 'c; stream >] ->
     [< 'Token.Keyword (String.make 1 c); lex stream >]
   | [< >] -> [< >]
     lex_number buffer stream
   | [< stream >] ->
     [< 'Token.Number (Buffer.contents buffer); lex stream >]
+and lex_equal = parser
+  | [< ''/'; stream >] ->
+    lex_not_equal stream
+  | [< '':'; ''='; stream >] ->
+    [< 'Token.Keyword "=:="; lex stream >]
+  | [< ''='; stream >] ->
+    [< 'Token.Keyword "=="; lex stream >]
+  | [< stream >] ->
+    [< 'Token.Keyword "="; lex stream >]
+and lex_not_equal = parser
+  | [< ''='; stream >] ->
+    [< 'Token.Keyword "=/="; lex stream >]
+  | [< stream >] ->
+    [< 'Token.Keyword "=/"; lex stream >]
 and whitespace = parser
   | [< ' (' ' | '\r' | '\t'); stream >] -> whitespace stream
 

src/program_options.ml

-type program_options = { file_path : string option
-		       ; indent_spaces : int
-		       }
+type t = { file_path : string option
+	 ; indent_spaces : int
+	 }