//----< attempt to open source of tokens >----------------------- /* * If src is successfully opened, it uses TokenState.nextState(context_) * to set the initial state, based on the source content. */ public bool open(string path) { TokenSourceFile src = new TokenSourceFile(context_); context_.src = src; this.path = path; return src.open(path); // if true, src has set initial state }
//----< attempt to open string source >-------------------------- public bool openString(string str) { TokenSourceFile src = new TokenSourceFile(context_); context_.src = src; return(src.openString(str)); }
//----< attempt to open source of tokens >----------------------- /* * If src is successfully opened, it uses TokenState.nextState(context_) * to set the initial state, based on the source content. */ public bool open(string path) { TokenSourceFile src = new TokenSourceFile(context_); context_.src = src; this.path = path; return(src.open(path)); }
static void Main(string[] args) { TokenContext context_ = new TokenContext(); TokenSourceFile src = new TokenSourceFile(context_); context_.src = src; string refFilePath = "../../Test2.txt"; string testFilePath = System.IO.Path.GetFullPath(refFilePath); Console.WriteLine("\nProcessing " + testFilePath); src.open(refFilePath); for (int i = 0; i < 5; i++) { Console.WriteLine("peek({0}): {1}", i, (char)src.peek(i)); } for (int i = 0; i < 5; i++) { Console.WriteLine("next(): {0}", (char)src.next()); } src.close(); // test openString() string str = "1234567890"; Console.WriteLine("\nLoad String: " + str); src.openString(str); for (int i = 0; i < 5; i++) { Console.WriteLine("peek({0}): {1}", i, (char)src.peek(i)); } for (int i = 0; i < 5; i++) { Console.WriteLine("next(): {0}", (char)src.next()); } src.close(); }
//----< attempt to open source of tokens >----------------------- public bool open(string path) { TokenSourceFile src = new TokenSourceFile(context_); context_.src = src; return src.open(path); }