virtualSoC  0.6.2
baskett
vmasm.MainClass Class Reference

Static Public Member Functions

static void Main (string[] args)
 

Detailed Description

Member Function Documentation

◆ Main()

static void vmasm.MainClass.Main ( string []  args)
static
39  {
40  CommandLineArgs cmd = new CommandLineArgs();
41 
42  cmd.RegisterArgument( "i", new OptionArgument( "test.asm", true ) { HelpMessage="inputfile" } );
43  cmd.RegisterArgument( "o", new OptionArgument( "a", false ) { HelpMessage="write output to an outfile" });
44  cmd.RegisterArgument( "t", new OptionArgument( "raw", false) { HelpMessage=" select an output format raw,gz,deflate" } );
45 
46  FlagArgument arg = new FlagArgument();
47  arg.Processor = (v) => PrintAssembler();
48  arg.HelpMessage = "list all mnemonic";
49 
50  cmd.RegisterArgument("lsall", arg);
51 
52  cmd.SetDefaultArgument( "i" );
54 
55  if( !cmd.Validate(args) )
56  {
57  cmd.PrintHelp();
58  return;
59  }
60  else if(cmd.GetValue<bool>("lsall"))
61  {
62  PrintAssembler();
63  return;
64  }
65 
66  string input = cmd.GetValue<string> ("i");
67  string output = cmd.GetValue<string> ("o");
68 
69  Console.WriteLine ("Input File: {0} -> output: {1}", input, output);
70 
71  Assembler asm = new Assembler ();
72  asm.l = PreProcess (input);
73  byte[] data = asm.Comp ();
74 
75  ModuleOutputFactory.WriteToFile (data, output, cmd.GetValue<string> ("t"));
76  }
void RegisterHelpArgument(string name="help")
Registers a help argument that will display the help page for the program if set by the user...
Definition: CommandLineArgs.cs:321
Class for defining, validating and processing command line arguments.
Definition: CommandLineArgs.cs:204
void PrintHelp(string errorMessage=null)
Prints a help message describing the effects of all available options.
Definition: CommandLineArgs.cs:243
An argument that can have any value.
Definition: CommandLineArgs.cs:732
string HelpMessage
The message that will be displayed in the help page for your program.
Definition: CommandLineArgs.cs:137
Action< object > Processor
A method that can be executed when the command line arguments are processed.
Definition: CommandLineArgs.cs:154
bool Validate(string[] args, OptionalOut< string[]> outErrors=null)
Processes a set of command line arguments.
Definition: CommandLineArgs.cs:355
void SetDefaultArgument(string argument)
Sets the default argument that will be filled when no argument name is given.
Definition: CommandLineArgs.cs:334
A simple argument flag.
Definition: CommandLineArgs.cs:683
void RegisterArgument(string name, Argument arg)
Registers a new argument.
Definition: CommandLineArgs.cs:312

The documentation for this class was generated from the following file: