public void visit(compiler_directive_list _compiler_directive_list) { bw.Write((Int16)171); write_compiler_directive_list(_compiler_directive_list); }
public void write_compiler_directive_list(compiler_directive_list _compiler_directive_list) { write_compiler_directive(_compiler_directive_list); if (_compiler_directive_list.directives == null) { bw.Write((byte)0); } else { bw.Write((byte)1); bw.Write(_compiler_directive_list.directives.Count); for(Int32 ssyy_i = 0; ssyy_i < _compiler_directive_list.directives.Count; ssyy_i++) { if (_compiler_directive_list.directives[ssyy_i] == null) { bw.Write((byte)0); } else { bw.Write((byte)1); _compiler_directive_list.directives[ssyy_i].visit(this); } } } }
public override void visit(compiler_directive_list _compiler_directive_list) { }
/////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// //CreateNonTerminalObject /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// public Object CreateNonTerminalObject() { switch ((RuleConstants)LRParser.ReductionRule.Index) { case RuleConstants.RULE_PREPROCESSOR_PROGRAM : //<preprocessor_program> ::= <preprocessor_lexems> <empty> { compilation_unit _compilation_unit = new compilation_unit(); _compilation_unit.Language = LanguageId.PascalABCNET; if (LRParser.GetReductionSyntaxNode(0) != null) { parsertools.create_source_context(_compilation_unit, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0)); CompilerDirectives.AddRange(((compiler_directive_list)LRParser.GetReductionSyntaxNode(0)).directives); if (CompilerDirectives.Count != 0) prepr.CompilerDirectives.AddRange(CompilerDirectives); } return _compilation_unit; } case RuleConstants.RULE_PREPROCESSOR_LEXEMS : //<preprocessor_lexems> ::= <_preprocessor_lexems> return LRParser.GetReductionSyntaxNode(0); case RuleConstants.RULE_PREPROCESSOR_LEXEMS2 : //<preprocessor_lexems> ::= //NONTERMINAL:<preprocessor_lexems> ::= return null; //ENDNONTERMINAL case RuleConstants.RULE__PREPROCESSOR_LEXEMS : //<_preprocessor_lexems> ::= <preprocessor_lexem> <empty> { compiler_directive_list _compiler_directive_list = new compiler_directive_list(); if (LRParser.GetReductionSyntaxNode(0) is compiler_directive) _compiler_directive_list.directives.Add((compiler_directive)LRParser.GetReductionSyntaxNode(0)); parsertools.create_source_context(_compiler_directive_list, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(0)); return _compiler_directive_list; } case RuleConstants.RULE__PREPROCESSOR_LEXEMS2 : //<_preprocessor_lexems> ::= <preprocessor_lexems> <preprocessor_lexem> { compiler_directive_list _compiler_directive_list = (compiler_directive_list)LRParser.GetReductionSyntaxNode(0); if (LRParser.GetReductionSyntaxNode(1) is compiler_directive) _compiler_directive_list.directives.Add((compiler_directive)LRParser.GetReductionSyntaxNode(1)); parsertools.create_source_context(_compiler_directive_list, LRParser.GetReductionSyntaxNode(0), LRParser.GetReductionSyntaxNode(1)); return _compiler_directive_list; } case RuleConstants.RULE_PREPROCESSOR_LEXEM_TK_NEWLINE : //<preprocessor_lexem> ::= 'TK_NEWLINE' return LRParser.GetReductionSyntaxNode(0); case RuleConstants.RULE_PREPROCESSOR_LEXEM_TK_SLASH : //<preprocessor_lexem> ::= 'TK_SLASH' { if (prepr.sm.AllowWrite()) prepr.WriteToStream(((token_info)LRParser.GetReductionSyntaxNode(0)).source_context, ((token_info)LRParser.GetReductionSyntaxNode(0)).text); return LRParser.GetReductionSyntaxNode(0); } case RuleConstants.RULE_PREPROCESSOR_LEXEM_TK_SLASHEKV : //<preprocessor_lexem> ::= 'TK_SLASHEKV' { if (prepr.sm.AllowWrite()) prepr.WriteToStream(((token_info)LRParser.GetReductionSyntaxNode(0)).source_context, ((token_info)LRParser.GetReductionSyntaxNode(0)).text); return LRParser.GetReductionSyntaxNode(0); } case RuleConstants.RULE_PREPROCESSOR_LEXEM_TK_AP : //<preprocessor_lexem> ::= 'TK_AP' { if (prepr.sm.AllowWrite()) prepr.WriteToStream(((token_info)LRParser.GetReductionSyntaxNode(0)).source_context, ((token_info)LRParser.GetReductionSyntaxNode(0)).text); return LRParser.GetReductionSyntaxNode(0); } case RuleConstants.RULE_PREPROCESSOR_LEXEM_TK_KAV : //<preprocessor_lexem> ::= 'TK_KAV' { if (prepr.sm.AllowWrite()) prepr.WriteToStream(((token_info)LRParser.GetReductionSyntaxNode(0)).source_context, ((token_info)LRParser.GetReductionSyntaxNode(0)).text); return LRParser.GetReductionSyntaxNode(0); } case RuleConstants.RULE_PREPROCESSOR_LEXEM_TK_PROGRAM_LINE : //<preprocessor_lexem> ::= 'TK_PROGRAM_LINE' { if (prepr.sm.AllowWrite()) prepr.WriteToStream(((token_info)LRParser.GetReductionSyntaxNode(0)).source_context, ((token_info)LRParser.GetReductionSyntaxNode(0)).text); return LRParser.GetReductionSyntaxNode(0); } case RuleConstants.RULE_PREPROCESSOR_LEXEM_TK_DIRECTIVE : //<preprocessor_lexem> ::= 'TK_DIRECTIVE' <empty> { bool inline = ( ((token_info)LRParser.GetReductionSyntaxNode(0)).source_context.begin_position.line_num - ((token_info)LRParser.GetReductionSyntaxNode(0)).source_context.end_position.line_num == 0 ); string token_text = ((token_info)LRParser.GetReductionSyntaxNode(0)).text; if (token_text[1] == '$' && inline) { compiler_directive _compiler_directive = (compiler_directive)pascal_parsertools.MakeDirective((token_info)LRParser.GetReductionSyntaxNode(0)); _compiler_directive.source_context.FileName = prepr.CurrentFileName; prepr.CurrentFileName = _compiler_directive.source_context.FileName; //INCLUDE if (_compiler_directive.Name.text == prepr.INCLUDE) { if (prepr.sm.AllowWrite()) { string IncludeFileName = _compiler_directive.Directive.text; if (prepr.ProcessedFileNames.Contains(IncludeFileName) || Path.GetFileName(prepr.CurrentFileName) == Path.GetFileName(IncludeFileName)) { prepr.Errors.Add(new CircularInclude(prepr.CurrentFileName, _compiler_directive.source_context, null, IncludeFileName)); } else { if (!(bool)prepr.SourceFilesProvider(IncludeFileName, SourceFileOperation.Exists)) prepr.Errors.Add(new IncludeFileNotFound(prepr.CurrentFileName, _compiler_directive.source_context, null, IncludeFileName)); string b = prepr.CurrentFileName; //string t = prepr.SourceText; //string[] sl = prepr.SourceLines; prepr.ProcessFile(IncludeFileName); prepr.CurrentFileName = b; //prepr.SourceText = t; //prepr.SourceLines = sl; prepr.ProcessedFileNames.Remove(IncludeFileName); } } return _compiler_directive; } //DEFINE if (_compiler_directive.Name.text == prepr.DEFINE) { if (prepr.sm.AllowWrite()) { string directive = _compiler_directive.Directive.text; string name = prepr.getFirstIdent(directive); string text = prepr.getSecondIdent(directive); prepr.AddDefineDirective(name, text, _compiler_directive); } return _compiler_directive; } //UNDEF if (_compiler_directive.Name.text == prepr.UNDEF) { if (prepr.sm.AllowWrite()) { string directive = _compiler_directive.Directive.text; string name = prepr.getFirstIdent(directive); if (name != null) if (prepr.DefineDirectiveDefinded(name)) prepr.DeleteDefineDirective(name, _compiler_directive); } return _compiler_directive; } //IFDEF if (_compiler_directive.Name.text == prepr.IFDEF) { string directive = _compiler_directive.Directive.text; if (prepr.sm.AllowWrite()) { if (directive != null) { if (!prepr.DefineDirectiveDefinded(directive)) prepr.sm.ChangeState(false, 1); else prepr.sm.ChangeState(true, 1); } } else prepr.sm.ChangeState(false, -1); return _compiler_directive; } //IFNDEF if (_compiler_directive.Name.text == prepr.IFNDEF) { string directive = _compiler_directive.Directive.text; if (prepr.sm.AllowWrite()) { if (directive != null) { if (prepr.DefineDirectiveDefinded(directive)) prepr.sm.ChangeState(false, 1); else prepr.sm.ChangeState(true, 1); } } else prepr.sm.ChangeState(false, -1); return _compiler_directive; } //ELSE if (_compiler_directive.Name.text == prepr.ELSE) { if (prepr.sm.GetEndifCount() == 0 || prepr.sm.AllowElse() == false) { prepr.Errors.Add(new UnexpectedElse(prepr.CurrentFileName, _compiler_directive.source_context)); } else { if (prepr.sm.AllowWrite()) prepr.sm.ChangeState(false, false); else { if (prepr.sm.LastCondition() == 1) prepr.sm.ChangeState(true, false); else prepr.sm.ChangeState(false, false); } } return _compiler_directive; } //ENDIF if (_compiler_directive.Name.text == prepr.ENDIF) { if (prepr.sm.GetEndifCount() == 0) { prepr.Errors.Add(new UnexpectedEndif(prepr.CurrentFileName, _compiler_directive.source_context)); } else { if (prepr.sm.AllowWrite()) prepr.sm.ChangeState(true, true); else { if (prepr.sm.LastEndifCondition() == 1) prepr.sm.ChangeState(true, true); else prepr.sm.ChangeState(false, true); } } return _compiler_directive; } return _compiler_directive; } return LRParser.GetReductionSyntaxNode(0); } case RuleConstants.RULE_EMPTY : //<empty> ::= //NONTERMINAL:<empty> ::= return null; //ENDNONTERMINAL } throw new RuleException("Unknown rule"); }
public void read_compiler_directive_list(compiler_directive_list _compiler_directive_list) { read_compiler_directive(_compiler_directive_list); if (br.ReadByte() == 0) { _compiler_directive_list.directives = null; } else { _compiler_directive_list.directives = new List<compiler_directive>(); Int32 ssyy_count = br.ReadInt32(); for(Int32 ssyy_i = 0; ssyy_i < ssyy_count; ssyy_i++) { _compiler_directive_list.directives.Add(_read_node() as compiler_directive); } } }
public void visit(compiler_directive_list _compiler_directive_list) { read_compiler_directive_list(_compiler_directive_list); }
public override void visit(compiler_directive_list node) { prepare_collection(node.directives, "directives"); }
public override void visit(compiler_directive_list _compiler_directive_list) { throw new NotImplementedException(); }
public Object CreateNonTerminalObject() { switch ((RuleConstants) LRParser.ReductionRule.Index) { case RuleConstants.RULE_PREPROCESSOR_PROGRAM : //<preprocessor_program> ::= <directive_groups> <empty> { compilation_unit _compilation_unit=new compilation_unit(); _compilation_unit.Language=LanguageId.PascalABCNET; if(LRParser.GetReductionSyntaxNode(0)!=null){ parsertools.create_source_context(_compilation_unit,LRParser.GetReductionSyntaxNode(0),LRParser.GetReductionSyntaxNode(0)); CompilerDirectives.AddRange(((compiler_directive_list)LRParser.GetReductionSyntaxNode(0)).directives); } return _compilation_unit; } case RuleConstants.RULE_DIRECTIVE_GROUPS : //<directive_groups> ::= <_directive_groups> return LRParser.GetReductionSyntaxNode(0); case RuleConstants.RULE_DIRECTIVE_GROUPS2 : //<directive_groups> ::= //NONTERMINAL:<directive_groups> ::= return null; //ENDNONTERMINAL case RuleConstants.RULE__DIRECTIVE_GROUPS : //<_directive_groups> ::= <directive_group> <empty> { compiler_directive_list _compiler_directive_list=new compiler_directive_list(); if(LRParser.GetReductionSyntaxNode(0) is compiler_directive) _compiler_directive_list.directives.Add((compiler_directive)LRParser.GetReductionSyntaxNode(0)); parsertools.create_source_context(_compiler_directive_list,LRParser.GetReductionSyntaxNode(0),LRParser.GetReductionSyntaxNode(0)); return _compiler_directive_list; } case RuleConstants.RULE__DIRECTIVE_GROUPS2 : //<_directive_groups> ::= <directive_groups> <directive_group> { compiler_directive_list _compiler_directive_list=(compiler_directive_list)LRParser.GetReductionSyntaxNode(0); if(LRParser.GetReductionSyntaxNode(1) is compiler_directive) _compiler_directive_list.directives.Add((compiler_directive)LRParser.GetReductionSyntaxNode(1)); parsertools.create_source_context(_compiler_directive_list,LRParser.GetReductionSyntaxNode(0),LRParser.GetReductionSyntaxNode(1)); return _compiler_directive_list; } case RuleConstants.RULE_DIRECTIVE_GROUP_TKNEWLINE : //<directive_group> ::= 'TKNEWLINE' return LRParser.GetReductionSyntaxNode(0); case RuleConstants.RULE_DIRECTIVE_GROUP_TKPROGRAM_LINE_PART : //<directive_group> ::= 'TKPROGRAM_LINE_PART' return LRParser.GetReductionSyntaxNode(0); case RuleConstants.RULE_DIRECTIVE_GROUP_TKDIRECTIVE : //<directive_group> ::= 'TKDIRECTIVE' <empty> { compiler_directive _compiler_directive=(compiler_directive)pascal_parsertools.MakeDirective((token_info)LRParser.GetReductionSyntaxNode(0)); return _compiler_directive; } case RuleConstants.RULE_EMPTY : //<empty> ::= //NONTERMINAL:<empty> ::= return null; //ENDNONTERMINAL } throw new RuleException("Unknown rule"); }