1 | namespace antlr.debug |
---|
2 | { |
---|
3 | using System; |
---|
4 | |
---|
5 | public class MatchEventArgs : GuessingEventArgs |
---|
6 | { |
---|
7 | public MatchEventArgs() |
---|
8 | { |
---|
9 | } |
---|
10 | public MatchEventArgs(int type, int val, object target, string text, int guessing, bool inverse, bool matched) |
---|
11 | { |
---|
12 | setValues(type, val, target, text, guessing, inverse, matched); |
---|
13 | } |
---|
14 | |
---|
15 | public virtual object Target |
---|
16 | { |
---|
17 | get { return this.target_; } |
---|
18 | set { this.target_ = value; } |
---|
19 | } |
---|
20 | |
---|
21 | public virtual string Text |
---|
22 | { |
---|
23 | get { return this.text_; } |
---|
24 | set { this.text_ = value; } |
---|
25 | } |
---|
26 | |
---|
27 | public virtual int Value |
---|
28 | { |
---|
29 | get { return this.val_; } |
---|
30 | set { this.val_ = value; } |
---|
31 | } |
---|
32 | |
---|
33 | internal bool Inverse |
---|
34 | { |
---|
35 | set { this.inverse_ = value; } |
---|
36 | } |
---|
37 | |
---|
38 | internal bool Matched |
---|
39 | { |
---|
40 | set { this.matched_ = value; } |
---|
41 | } |
---|
42 | |
---|
43 | // NOTE: for a mismatch on type STRING, the "text" is used as the lookahead |
---|
44 | // value. Normally "value" is this |
---|
45 | public enum ParserMatchEnums |
---|
46 | { |
---|
47 | TOKEN = 0, |
---|
48 | BITSET = 1, |
---|
49 | CHAR = 2, |
---|
50 | CHAR_BITSET = 3, |
---|
51 | STRING = 4, |
---|
52 | CHAR_RANGE = 5, |
---|
53 | } |
---|
54 | public static int TOKEN = 0; |
---|
55 | public static int BITSET = 1; |
---|
56 | public static int CHAR = 2; |
---|
57 | public static int CHAR_BITSET = 3; |
---|
58 | public static int STRING = 4; |
---|
59 | public static int CHAR_RANGE = 5; |
---|
60 | |
---|
61 | private bool inverse_; |
---|
62 | private bool matched_; |
---|
63 | private object target_; |
---|
64 | private int val_; |
---|
65 | private string text_; |
---|
66 | |
---|
67 | |
---|
68 | public virtual bool isInverse() |
---|
69 | { |
---|
70 | return inverse_; |
---|
71 | } |
---|
72 | public virtual bool isMatched() |
---|
73 | { |
---|
74 | return matched_; |
---|
75 | } |
---|
76 | /// <summary>This should NOT be called from anyone other than ParserEventSupport! |
---|
77 | /// </summary> |
---|
78 | internal void setValues(int type, int val, object target, string text, int guessing, bool inverse, bool matched) |
---|
79 | { |
---|
80 | base.setValues(type, guessing); |
---|
81 | this.Value = val; |
---|
82 | this.Target = target; |
---|
83 | this.Inverse = inverse; |
---|
84 | this.Matched = matched; |
---|
85 | this.Text = text; |
---|
86 | } |
---|
87 | |
---|
88 | public override string ToString() |
---|
89 | { |
---|
90 | return "ParserMatchEvent [" + (isMatched()?"ok,":"bad,") + (isInverse()?"NOT ":"") + (Type == TOKEN?"token,":"bitset,") + Value + "," + Target + "," + Guessing + "]"; |
---|
91 | } |
---|
92 | } |
---|
93 | } |
---|