aboutsummaryrefslogtreecommitdiff
path: root/src/Markdown/_MarkdownLexer.flex
blob: 0a15e41a4faeb74a830c9b5fe08f8a4029361282 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package org.jetbrains.markdown.lexer;

import com.intellij.lexer.*;
import com.intellij.psi.tree.IElementType;
import static org.jetbrains.markdown.MarkdownElementTypes.*;

%%

%{
  public _MarkdownLexer() {
    this((java.io.Reader)null);
  }
%}

%public
%class _MarkdownLexer
%implements FlexLexer
%function advance
%type IElementType
%unicode

Newline="\r"|"\n"|"\r\n"
Spacechar=[\ \t\f]
Number=[0-9]+(\.[0-9]*)?
String=[^~\*_`&\[\]()<!#\\ \t\n\r]+
AnyChar=.
Line=!'\r' !'\n' .* {Newline}

%%
<YYINITIAL> {
  {Spacechar}                         { return SPACECHAR; }
  {Newline}                             { return NEWLINE; }
  "\\357\\273\\277"                 { return BOM; }

  {Number}                          { return NUMBER; }
  {String}                          { return STRING; }
  {AnyChar}                         { return ANYCHAR; }

  [^] { return com.intellij.psi.TokenType.BAD_CHARACTER; }
}