Welcome to the Compiler Project Windows Forms application! This program serves as a simple compiler that scans and processes code based on predefined transition rules.
-
Transition Rules:
- Transition rules for scanning are defined in the
transitionTable.txt
file. - The project includes a
transRule
list and aMapData
method to map keyword, operator, and special character values.
- Transition rules for scanning are defined in the
-
Token Identification:
- The application identifies tokens based on transition rules and a state machine.
- Token categories include keywords, identifiers, operators, literals, and special characters.
-
Token Scanner:
- The
Result
method scans and tokenizes input text based on the defined transition rules. - It categorizes tokens into different types such as Keywords, Identifiers, Operators, Numbers, Strings, and Special Characters.
- The
public string Result(string txt, string src = @"transistionTable.txt")
{
// ... (previous code)
while (txtIndex != txt.Length)
{
// ... (previous code)
iState = nextState(iState, cChar);
switch (iState)
{
// ... (cases for different states)
case 30:
case 33:
iState = 0;
sToken = "";
break;
}
}
return result;
}
- Run the application.
- Enter the code inside the text area or select the "Read from file" button to open a file.
- Press the "Scan" button to initiate the scanning process.
- View the results of the scanning process.
- Exit the application when you are done.
Feel free to explore and utilize this compiler project for scanning and processing code efficiently with this Windows Forms application!