@@ -25,6 +25,10 @@ public class EZText
2525 /// </summary>
2626 public int CodeLine { get ; set ; } = 0 ;
2727 /// <summary>
28+ /// Static name for EZText Local Variable, "EZTEXT_GENERATED_VARIABLE_FOR_IF_SYNTAX___123"
29+ /// </summary>
30+ public static readonly string EZTEXT_Local_If_Var = "EZTEXT_GENERATED_VARIABLE_FOR_IF_SYNTAX___123" ;
31+ /// <summary>
2832 /// Errors in EZText
2933 /// </summary>
3034 public string [ ] Errors { get ; set ; } = new string [ 0 ] ;
@@ -56,6 +60,8 @@ public string Translate(string InputCode, int _codeLine)
5660 CodeLine = _codeLine ;
5761 InputCode = InputCode . Replace ( "." , "|" ) ;
5862 string [ ] lines = InputCode . Split ( new [ ] { '\n ' , '|' } ) . Select ( x => x . Trim ( ) ) . Where ( y => ! y . Equals ( "" ) ) . Select ( z=> z
63+ . Replace ( "is not equal to" , "!=" )
64+ . Replace ( "is not" , "!" )
5965 . Replace ( "is equal to" , "equals" )
6066 . Replace ( " equals " , " = " )
6167 . Replace ( "is greater than or equal to" , ">=" )
@@ -64,7 +70,8 @@ public string Translate(string InputCode, int _codeLine)
6470 . Replace ( "is less than" , "<" )
6571 . Replace ( ", then " , " then " )
6672 . Replace ( " then " , " : " )
67- . Replace ( "{p}" , "." )
73+ . Replace ( "[p]" , "." )
74+ . Replace ( "[SPACE]" , " " )
6875 ) . ToArray ( ) ;
6976 for ( int i = 0 ; i < lines . Length ; i ++ )
7077 {
@@ -79,6 +86,7 @@ public string Translate(string InputCode, int _codeLine)
7986 {
8087
8188 }
89+ //MessageBox.Show(Code);
8290 return Code ;
8391 }
8492 static EZText StaticTranslate ( string line )
@@ -146,9 +154,83 @@ static EZText StaticTranslate(string line)
146154 nw . RemoveAt ( 1 ) ;
147155 words = nw . ToArray ( ) ;
148156 }
157+ if ( words [ 1 ] == "the" && words [ 2 ] == "console" && words [ 3 ] == "input" )
158+ {
159+ Code += $ "var { EZTEXT_Local_If_Var } : input console{ Environment . NewLine } ";
160+ List < string > nw = words . ToList ( ) ;
161+ nw [ 1 ] = $ "'{ EZTEXT_Local_If_Var } '";
162+ nw . RemoveAt ( 2 ) ;
163+ nw . RemoveAt ( 2 ) ;
164+ words = nw . ToArray ( ) ;
165+ }
166+ if ( words [ 2 ] == "intersects" && words [ 4 ] == ":" )
167+ {
168+ Code += $ "var { EZTEXT_Local_If_Var } : intersects { words [ 1 ] } { words [ 3 ] } { Environment . NewLine } ";
169+ List < string > nw = words . ToList ( ) ;
170+ nw [ 1 ] = $ "'{ EZTEXT_Local_If_Var } '";
171+ nw . RemoveAt ( 2 ) ;
172+ nw . RemoveAt ( 2 ) ;
173+ words = nw . ToArray ( ) ;
174+ }
175+ if ( words [ 1 ] == "the" && words [ 2 ] == "contents" && words [ 3 ] == "of" && words [ 4 ] == "the" && words [ 5 ] == "file" )
176+ {
177+ Code += $ "var { EZTEXT_Local_If_Var } : file read { words [ 6 ] } { Environment . NewLine } ";
178+ List < string > nw = words . ToList ( ) ;
179+ nw [ 1 ] = $ "'{ EZTEXT_Local_If_Var } '";
180+ nw . RemoveAt ( 2 ) ;
181+ nw . RemoveAt ( 2 ) ;
182+ nw . RemoveAt ( 2 ) ;
183+ nw . RemoveAt ( 2 ) ;
184+ nw . RemoveAt ( 2 ) ;
185+ words = nw . ToArray ( ) ;
186+ }
187+ if ( words [ 2 ] == "is" && words [ 3 ] == "being" && words [ 4 ] == "pressed" )
188+ {
189+ Code += $ "var { EZTEXT_Local_If_Var } : input key { words [ 1 ] } { Environment . NewLine } ";
190+ List < string > nw = words . ToList ( ) ;
191+ nw [ 1 ] = $ "'{ EZTEXT_Local_If_Var } '";
192+ nw . RemoveAt ( 2 ) ;
193+ nw . RemoveAt ( 2 ) ;
194+ nw . RemoveAt ( 2 ) ;
195+ words = nw . ToArray ( ) ;
196+ }
197+ if ( words [ 1 ] == "the" && words [ 3 ] == "mouse" && words [ 4 ] == "button" && words [ 5 ] == "is" && words [ 6 ] == "being" && words [ 7 ] == "pressed" )
198+ {
199+ Code += $ "var { EZTEXT_Local_If_Var } : input mouse button { words [ 2 ] } { Environment . NewLine } ";
200+ List < string > nw = words . ToList ( ) ;
201+ nw [ 1 ] = $ "'{ EZTEXT_Local_If_Var } '";
202+ nw . RemoveAt ( 2 ) ;
203+ nw . RemoveAt ( 2 ) ;
204+ nw . RemoveAt ( 2 ) ;
205+ nw . RemoveAt ( 2 ) ;
206+ nw . RemoveAt ( 2 ) ;
207+ nw . RemoveAt ( 2 ) ;
208+ words = nw . ToArray ( ) ;
209+ }
210+ if ( words [ 1 ] == "the" && ( words [ 2 ] == "mouse" || words [ 3 ] == "mouse" ) && words [ 4 ] == "position" )
211+ {
212+ Code += $ "var { EZTEXT_Local_If_Var } : input mouse position { ( words [ 2 ] == "mouse" ? words [ 3 ] : words [ 2 ] ) } { Environment . NewLine } ";
213+ List < string > nw = words . ToList ( ) ;
214+ nw [ 1 ] = $ "'{ EZTEXT_Local_If_Var } '";
215+ nw . RemoveAt ( 2 ) ;
216+ nw . RemoveAt ( 2 ) ;
217+ nw . RemoveAt ( 2 ) ;
218+ words = nw . ToArray ( ) ;
219+ }
220+ if ( words [ 1 ] == "the" && words [ 2 ] == "mouse" && words [ 3 ] == "wheel" && words [ 4 ] == "state" )
221+ {
222+ Code += $ "var { EZTEXT_Local_If_Var } : input mouse wheel{ Environment . NewLine } ";
223+ List < string > nw = words . ToList ( ) ;
224+ nw [ 1 ] = $ "'{ EZTEXT_Local_If_Var } '";
225+ nw . RemoveAt ( 2 ) ;
226+ nw . RemoveAt ( 2 ) ;
227+ nw . RemoveAt ( 2 ) ;
228+ words = nw . ToArray ( ) ;
229+ }
230+
149231 words [ 0 ] = words [ 0 ] . ToLower ( ) ;
150232 string newline = string . Join ( " " , words ) . Split ( ":" ) [ 0 ] ;
151- string nextcode = StaticTranslate ( string . Join ( " " , words ) . Split ( ":" ) [ 1 ] ) . Code ;
233+ string nextcode = StaticTranslate ( string . Join ( " " , words ) . Split ( ":" , StringSplitOptions . TrimEntries ) [ 1 ] ) . Code ;
152234 Code += newline + ": " + nextcode ;
153235 }
154236 catch
0 commit comments