Skip to content

Commit 4afe170

Browse files
authored
Merge pull request #153 from Tarmil/patch-1
Add access control keywords to declaration regexes
2 parents 3d27a6e + aa07d27 commit 4afe170

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

fsharp-mode-font.el

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,42 +93,50 @@ with initial value INITVALUE and optional DOCSTRING."
9393
(def-fsharp-compiled-var fsharp-function-def-regexp
9494
(concat "\\<\\(?:let\\|and\\|with\\)\\s-+"
9595
fsharp-inline-rec-regexp-noncapturing "?"
96+
fsharp-access-control-regexp-noncapturing "*"
9697
(format "\\(%s\\)" fsharp-valid-identifier-regexp)
9798
"\\(?:\\s-+[A-Za-z_]\\|\\s-*(\\)" ;; matches function arguments or open-paren; unclear why 0-9 not in class
9899
))
99100

100101
(def-fsharp-compiled-var fsharp-pattern-function-regexp
101102
(concat "\\<\\(?:let\\|and\\)\\s-+"
102103
fsharp-inline-rec-regexp-noncapturing "?"
104+
fsharp-access-control-regexp-noncapturing "*"
103105
(format "\\(%s\\)" fsharp-valid-identifier-regexp)
104106
"\\s-*=\\s-*function")
105107
"Matches an implicit matcher, eg let foo m = function | \"cat\" -> etc.")
106108

107109
;; Note that this regexp is used for iMenu. To font-lock active patterns, we
108110
;; need to use an anchored match in fsharp-font-lock-keywords.
109111
(def-fsharp-compiled-var fsharp-active-pattern-regexp
110-
"\\<\\(?:let\\|and\\)\\s-+\\(?:\\(?:inline\\|rec\\)\\s-+\\)?(\\(|[A-Za-z0-9_'|]+|\\))\\(?:\\s-+[A-Za-z_]\\|\\s-*(\\)")
112+
(concat "\\<\\(?:let\\|and\\)\\s-+"
113+
fsharp-inline-rec-regexp-noncapturing "?"
114+
fsharp-access-control-regexp-noncapturing "*"
115+
"(\\(|[A-Za-z0-9_'|]+|\\))\\(?:\\s-+[A-Za-z_]\\|\\s-*(\\)"))
111116

112117
(def-fsharp-compiled-var fsharp-member-access-regexp
113118
"\\<\\(?:override\\|member\\|abstract\\)\\s-+"
114119
"Matches members declarations and modifiers on classes.")
115120

116121
(def-fsharp-compiled-var fsharp-member-function-regexp
117122
(concat fsharp-member-access-regexp
118-
"\\(?:\\(?:inline\\|rec\\)\\s-+\\)?\\(?:"
119-
fsharp-valid-identifier-regexp
120-
"\\.\\)?\\("
121-
fsharp-valid-identifier-regexp
122-
"\\)")
123+
fsharp-inline-rec-regexp-noncapturing "?"
124+
fsharp-access-control-regexp-noncapturing "*"
125+
"\\(?:" fsharp-valid-identifier-regexp "\\.\\)?"
126+
"\\(" fsharp-valid-identifier-regexp "\\)")
123127
"Captures the final identifier in a member function declaration.")
124128

125129
(def-fsharp-compiled-var fsharp-overload-operator-regexp
126130
(concat fsharp-member-access-regexp
127-
"\\(?:\\(?:inline\\|rec\\)\\s-+\\)?\\(([!%&*+-./<=>?@^|~]+)\\)")
131+
fsharp-inline-rec-regexp-noncapturing "?"
132+
fsharp-access-control-regexp-noncapturing "*"
133+
"\\(([!%&*+-./<=>?@^|~]+)\\)")
128134
"Match operators when overloaded by a type/class.")
129135

130136
(def-fsharp-compiled-var fsharp-constructor-regexp
131-
"^\\s-*\\<\\(new\\) *(.*)[^=]*="
137+
(concat "^\\s-*"
138+
fsharp-access-control-regexp-noncapturing "*"
139+
"\\<\\(new\\) *(.*)[^=]*=")
132140
"Matches the `new' keyword in a constructor")
133141

134142
(def-fsharp-compiled-var fsharp-type-def-regexp

test/apps/FSharp.Compatibility/Format.fs.faceup

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@
849849

850850
«m:/// »«x:Re-implementation of OCaml's Pervasives.output, since the one in the
851851
»«m:/// »«x:F# compatibility library doesn't have the right type signature.
852-
»«k:let» «k:private» «v:output» «v:oc» («v:buf» : «t:string») («v:pos» : «t:int») («v:len» : «t:int») =
852+
»«k:let» «k:private» «f:output» «v:oc» («v:buf» : «t:string») («v:pos» : «t:int») («v:len» : «t:int») =
853853
output_string oc (buf.Substring (pos, len))
854854

855855
«k:let» «f:pp_set_formatter_out_channel» «v:state» «v:os» =

0 commit comments

Comments
 (0)