Exemplo n.º 1
0
 public CParser(ParserState parserState, CLexer lexer)
 {
     this.ParserState = parserState;
     this.lexer = new LookAheadLexer(
         new CDirectiveLexer(parserState, lexer));
     this.grammar = new CGrammar();
 }
Exemplo n.º 2
0
        public void Convert()
        {
            var lexer        = new CLexer(rdr);
            var parser       = new CParser(parserState, lexer);
            var declarations = parser.Parse();
            var symbolTable  = new SymbolTable(platform)
            {
                NamedTypes =
                {
                    { "size_t",  new PrimitiveType_v1 {
                          Domain = Domain.UnsignedInt, ByteSize = 4
                      } },                                                                               //$BUGBUG: arch-dependent!
                    { "va_list", new PrimitiveType_v1 {
                          Domain = Domain.Pointer, ByteSize = platform.PointerType.Size
                      } }
                }
            };

            foreach (var decl in declarations)
            {
                symbolTable.AddDeclaration(decl);
            }

            var lib = new SerializedLibrary
            {
                Types      = symbolTable.Types.ToArray(),
                Procedures = symbolTable.Procedures.ToList(),
            };
            var ser = SerializedLibrary.CreateSerializer();

            ser.Serialize(writer, lib);
        }
Exemplo n.º 3
0
        public void Convert()
        {
            var lexer        = new CLexer(rdr);
            var parser       = new CParser(parserState, lexer);
            var declarations = parser.Parse();

            foreach (var decl in declarations)
            {
                decl.Accept(this);
            }

            var lib = new SerializedLibrary
            {
                Types      = Types.ToArray(),
                Procedures = procs.ToList(),
            };
            var ser = SerializedLibrary.CreateSerializer();

            ser.Serialize(writer, lib);
        }
Exemplo n.º 4
0
 public CDirectiveLexer(ParserState state, CLexer lexer)
 {
     this.state     = state;
     this.lexer     = lexer;
     this.tokenPrev = new CToken(CTokenType.EOF);
 }
Exemplo n.º 5
0
 public CDirectiveLexer(ParserState state, CLexer lexer)
 {
     this.state = state;
     this.lexer = lexer;
     this.tokenPrev = new CToken(    CTokenType.EOF);
 }