The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
CustomHiddenStreamToken.cs
Go to the documentation of this file.
1 /*
2 [The "BSD licence"]
3 Copyright (c) 2002-2005 Kunle Odutola
4 All rights reserved.
5 
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
9 1. Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11 2. Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in the
13 documentation and/or other materials provided with the distribution.
14 3. The name of the author may not be used to endorse or promote products
15 derived from this software without specific prior written permission.
16 
17 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 
29 
30 namespace Parser
31 {
32  using System;
34  using IToken = antlr.IToken;
37 
47  {
48  private FileInfo fileinfo_;
49 
50  protected CustomHiddenStreamToken() : base()
51  {
52  }
53 
54  public CustomHiddenStreamToken(int t, string txt) : base(t, txt)
55  {
56  }
57 
58  public CustomHiddenStreamToken(int t, string txt, FileInfo fileinfo) : base(t, txt)
59  {
60  fileinfo_ = fileinfo;
61  }
62 
63  public CustomHiddenStreamToken(int t, string txt, FileInfo fileinfo, int line, int col) : base(t, txt)
64  {
65  this.fileinfo_ = fileinfo;
66  this.line = line;
67  this.col = col;
68  }
69 
70  public override string getFilename()
71  {
72  if (fileinfo_ != null)
73  return fileinfo_.FullName;
74  else
75  return null;
76  }
77 
78  override public string ToString()
79  {
80  return "[\"" + getText() + "\",<" + CSharpParser.tokenNames_[type_] + ">,line=" + line + ",col=" + col + "]";
81  }
82 
87  public FileInfo File
88  {
89  [System.Diagnostics.DebuggerStepThrough]
90  get { return fileinfo_; }
91  [System.Diagnostics.DebuggerStepThrough]
92  set { fileinfo_ = value; }
93  }
94 
100  {
101  [System.Diagnostics.DebuggerStepThrough]
102  get { return (CustomHiddenStreamToken) hiddenBefore; }
103  [System.Diagnostics.DebuggerStepThrough]
104  set { hiddenBefore = (CommonHiddenStreamToken) value; }
105  }
106 
112  {
113  [System.Diagnostics.DebuggerStepThrough]
114  get { return (CustomHiddenStreamToken) hiddenAfter; }
115  [System.Diagnostics.DebuggerStepThrough]
116  set { hiddenAfter = (CommonHiddenStreamToken) value; }
117  }
118 
120  {
122 
127  public override string TokenTypeName
128  {
129  [System.Diagnostics.DebuggerStepThrough]
130  get
131  {
132  return typeof(CustomHiddenStreamToken).FullName;;
133  }
134  }
135 
139  public override IToken Create()
140  {
141  return new CustomHiddenStreamToken();
142  }
143  }
144  }
145 }
CustomHiddenStreamToken(int t, string txt, FileInfo fileinfo)
System.IO.FileInfo FileInfo
override string TokenTypeName
Returns the fully qualified name of the Token type that this class creates.
CustomHiddenStreamToken HiddenBefore
Gets or sets the contents of the hidden-before token stream.
CustomHiddenStreamToken HiddenAfter
Gets or sets the contents of the hidden-after token stream.
System.IO.FileInfo FileInfo
Definition: CSharpParser.cs:5
antlr.CommonHiddenStreamToken CommonHiddenStreamToken
antlr.IToken IToken
Definition: CSharpLexer.cs:28
CustomHiddenStreamToken(int t, string txt, FileInfo fileinfo, int line, int col)
A sub-class of antlr.CommonHiddenStreamToken that can be used to track the file from which a token wa...
FileInfo File
Sets the source file of the token
antlr.TokenCreator TokenCreator