Procházet zdrojové kódy

check if anything breaks if we lex this

Simon Krajewski před 3 roky
rodič
revize
69e408b4d7
3 změnil soubory, kde provedl 4 přidání a 0 odebrání
  1. 2 0
      src/core/ast.ml
  2. 1 0
      src/syntax/grammar.mly
  3. 1 0
      src/syntax/lexer.ml

+ 2 - 0
src/core/ast.ml

@@ -131,6 +131,7 @@ type token =
 	| PClose
 	| Dot
 	| DblDot
+	| QuestionDot
 	| Arrow
 	| IntInterval of string
 	| Sharp of string
@@ -589,6 +590,7 @@ let s_token = function
 	| PClose -> ")"
 	| Dot -> "."
 	| DblDot -> ":"
+	| QuestionDot -> "?."
 	| Arrow -> "->"
 	| IntInterval s -> s ^ "..."
 	| Sharp s -> "#" ^ s

+ 1 - 0
src/syntax/grammar.mly

@@ -1494,6 +1494,7 @@ and expr_next' e1 = parser
 		| EConst(Ident n) -> expr_next (EMeta((Meta.from_string n,[],snd e1),eparam), punion p1 p2) s
 		| _ -> die "" __LOC__)
 	| [< '(Dot,p); e = parse_field e1 p >] -> e
+	| [< '(QuestionDot,p); e = parse_field e1 p >] -> e
 	| [< '(POpen,p1); e = parse_call_params (fun el p2 -> (ECall(e1,el)),punion (pos e1) p2) p1; s >] -> expr_next e s
 	| [< '(BkOpen,p1); e2 = secure_expr; s >] ->
 		let p2 = expect_unless_resume_p BkClose s in

+ 1 - 0
src/syntax/lexer.ml

@@ -413,6 +413,7 @@ let rec token lexbuf =
 	| ":" -> mk lexbuf DblDot
 	| "," -> mk lexbuf Comma
 	| "." -> mk lexbuf Dot
+	| "?." -> mk lexbuf QuestionDot
 	| "%" -> mk lexbuf (Binop OpMod)
 	| "&" -> mk lexbuf (Binop OpAnd)
 	| "|" -> mk lexbuf (Binop OpOr)