-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser.cs
58 lines (57 loc) · 1.78 KB
/
parser.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace langg
{
public class Parser
{
public static int NumericExpression(int st1,String el,int st2)
{
switch (el)
{
case "+":
return st1 + st2;
case "-":
return st1 - st2;
case "*":
return st1 * st2;
case "/":
return st1 / st2;
case "%":
return st1 % st2;
case "**":
return (int) Math.Pow(st1,st2);
}
return 0;
}
public static Boolean EQExpression(int st1,String el,int st2)
{
switch (el)
{
case ">":
return st1 > st2;
case "<":
return st1 < st2;
case "!=":
return st1 != st2;
case "==":
return st1 == st2;
case ">=":
return st1 >= st2;
case "<=":
return st1 == st2;
}
return false;
}
}
public class Exceptions
{
public static void OperathorNotFound() { Console.WriteLine("Operathor not found!"); Console.ReadKey(); Environment.Exit(-111); }
public static void NonVarException() { Console.WriteLine("Variable not found!");Console.ReadKey();Environment.Exit(-112); }
public static void WritelnException() { Console.WriteLine("Variable or String not found!");Console.ReadKey();Environment.Exit(-113); }
}
}