summaryrefslogtreecommitdiffstats
blob: 9deaa4848c5a3569b354795fda6226818e4e8d08 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
lexer grammar Mwe2Lexer;

options {
	tokenVocab=InternalMwe2Lexer;
}

@header {
package org.eclipse.emf.mwe2.language.lexer;

// Use our own Lexer superclass by means of import. 
import org.eclipse.xtext.parser.antlr.Lexer;
}

@members{
  private boolean singleQuotedString = false;
  private boolean doubleQuotedString = false;
  private boolean stringVariable = false;
}

AutoInject : {!singleQuotedString && !doubleQuotedString || stringVariable}?=>'auto-inject';

Import : {!singleQuotedString && !doubleQuotedString || stringVariable}?=>'import';

Module : {!singleQuotedString && !doubleQuotedString || stringVariable}?=>'module';

False : {!singleQuotedString && !doubleQuotedString || stringVariable}?=>'false';

True : {!singleQuotedString && !doubleQuotedString || stringVariable}?=>'true';

ReverseSolidusDollarSignLeftCurlyBracket : '\\${';

Var : {!singleQuotedString && !doubleQuotedString || stringVariable}?=>'var';

DollarSignLeftCurlyBracket : '${' {stringVariable = true;};

FullStopAsterisk : {!singleQuotedString && !doubleQuotedString || stringVariable}?=>'.*';

ReverseSolidusQuotationMark : '\\"';

ReverseSolidusApostrophe : '\\\'';

ReverseSolidusReverseSolidus : '\\\\';

QuotationMark : {!singleQuotedString || stringVariable}?=>'"' { if (!singleQuotedString) { doubleQuotedString = !doubleQuotedString; } } ;

Apostrophe :{!doubleQuotedString || stringVariable}?=> '\'' { if (!doubleQuotedString) { singleQuotedString = !singleQuotedString; } };

FullStop : {!singleQuotedString && !doubleQuotedString || stringVariable}?=>'.';

Colon : {!singleQuotedString && !doubleQuotedString || stringVariable}?=>':';

EqualsSign : {!singleQuotedString && !doubleQuotedString || stringVariable}?=>'=';

CommercialAt : {!singleQuotedString && !doubleQuotedString || stringVariable}?=>'@';

LeftCurlyBracket : {!singleQuotedString && !doubleQuotedString || stringVariable}?=>'{';

RightCurlyBracket : {!singleQuotedString && !doubleQuotedString || stringVariable}?=>'}' { stringVariable = false; };



RULE_ID : '^'? ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*;

RULE_ML_COMMENT : {!singleQuotedString && !doubleQuotedString || stringVariable}?=> ('/*' ( options {greedy=false;} : . )*'*/');

RULE_SL_COMMENT : {!singleQuotedString && !doubleQuotedString || stringVariable}?=> ('//' ~(('\n'|'\r'))* ('\r'? '\n')?);

RULE_WS : (' '|'\t'|'\r'|'\n')+;

RULE_ANY_OTHER : .;