Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using System;
- namespace Elog {
- public class Elog {
- public static void Main(string[] args) {
- if(args.Length == 1) run(System.IO.File.ReadAllText(args[0]), "");
- else if(args.Length > 1) {
- string f = System.IO.File.ReadAllText(args[0]);
- for(int i = 1; i < args.Length; run(f, args[i++])) ;
- }
- }
- public static void run(string s, string inr) {
- int cur = 0, sts = 0;
- Stack<bool> st = new Stack<bool>();
- bool[] ins = new bool[inr.Length];
- int[] vars = new int[256];
- for(int i=0;i<256;vars[i++] = -1);
- for(int i=0;i<inr.Length;ins[i] = (inr[i++]-'0'==0?false:true));
- foreach(char c in s) {
- if(sts == 0) {
- if(c == ';') sts = 2;
- else if(c == ':') sts = 1;
- else if(c == '.') st.Push(st.Peek());
- else if(c == '\'') st.Push(st.Pop()?false:true);
- else if(c == '&') st.Push(st.Pop() && st.Pop());
- else if(c == '|') st.Push(st.Pop() || st.Pop());
- else if(c == '^') st.Push(st.Pop() ^ st.Pop());
- else if(c == '0') st.Push(false);
- else if(c == '1') st.Push(true);
- else if(c > 20) {
- if(vars[c] == -1) vars[c] = (ins[cur++]?1:0);
- if(vars[c] > -1) st.Push(vars[c]==1);
- }
- } else if(sts == 1 && c > 20) {
- vars[c] = (st.Pop()?1:0);
- sts = 0;
- } else if(c > 20) if(c == '0' || c == '1') Console.Write(c); else Console.Write(vars[c]);
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement