Exemplo n.º 1
0
        public AstFile Build(FileContext fileCtx, string moduleName)
        {
            // look ahead
            var modCtx = ToStatementModule(fileCtx);

            if (modCtx is not null)
            {
                moduleName = AstSymbolName.ToCanonical(modCtx.module_name().identifier_module().GetText());
            }
            else
            {
                moduleName = AstSymbolName.ToCanonical(moduleName);
                var mod = _context.CompilerContext.Modules.GetOrAddModule(moduleName);
                _context.SetCurrent(mod);
            }

            var file = BuildFile(fileCtx, moduleName);

            if (modCtx is null)
            {
                // remove the AstModule we added.
                _context.RevertCurrent();
            }

            var module = _context.CompilerContext.Modules.FindModule <AstModuleImpl>(file.SymbolTable.Name);

            module !.AddFile(file !);
            return(file);
        }
Exemplo n.º 2
0
 public AstSymbolName(AstSymbolName nameToCopy)
 {
     _native    = new AstName(nameToCopy.NativeName);
     _canonical = new AstName(nameToCopy.CanonicalName);
 }
Exemplo n.º 3
0
 internal AstIdentifier(ParserRuleContext context, AstIdentifierKind identifierKind)
 {
     Context        = context ?? throw new ArgumentNullException(nameof(context));
     SymbolName     = AstSymbolName.Parse(context.GetText());
     IdentifierKind = identifierKind;
 }
Exemplo n.º 4
0
 protected AstIdentifier(AstIdentifier identifierToCopy)
 {
     Context        = identifierToCopy.Context;
     IdentifierKind = identifierToCopy.IdentifierKind;
     SymbolName     = new AstSymbolName(identifierToCopy.SymbolName);
 }
Exemplo n.º 5
0
 public AstIdentifier(AstSymbolName symbolName, AstIdentifierKind identifierKind)
 {
     SymbolName     = symbolName;
     IdentifierKind = identifierKind;
 }