public static void SetUp(Module module, Grammar grammar) { if (pattern == null) { BlockCommentPrototype.pattern = new AbstractPattern(null, "BlockCommentPrototype"); BlockCommentPrototype.pattern.SetType(typeof(BlockCommentPrototype)); grammar.PatternDefined(BlockCommentPrototype.pattern); string expression = "s('/*' *(s(!('*/') a(0 any))) '*/')"; ParseGraphNode parseGraph = BootstrapParser.Parse(expression, new Pattern[]{BlockCommentPrototype.pattern}); pattern = new ConcretePattern(null, "BlockComment", parseGraph); pattern.SetType(typeof(BlockComment)); BlockCommentPrototype.pattern.AddAltPattern(pattern); } module.SetName("BlockComment", typeof(BlockComment)); grammar.PatternDefined(pattern); }
public void Restart() { // Also called by constructor changingRoots = false; length = text.Length; whitespace = Base.Whitespace.pattern; }
public PatternNode(Source source, Pattern pattern, bool simple) : base(source) { if (pattern == null) throw new ArgumentNullException(); this.pattern = pattern; this.simple = simple; }
public override bool Update(Pattern updated) { bool updates = body.Update(updated); if (updates) Updated(); return updates; }
public virtual bool Update(Pattern updated) { bool updates = ParseGraph.Update(updated); if (updates) Updated(); return updates; }
public static void SetUp(Module module, Grammar grammar) { if (pattern == null) { string expression = "l(text o((whitespace null) t( s( '\\\"' *( a( s( !(a('\\\\' '\\\"')) any ) s('\\\\' a('\\\\' 'r' 'n' 't' '\\\"' '\\\'' '0') ) ) ) '\\\"' ) ) ) )"; ParseGraphNode parseGraph = BootstrapParser.Parse(expression, null); pattern = new ConcretePattern(null, "String", parseGraph); pattern.SetType(typeof(String)); } module.SetName("String", typeof(String)); grammar.PatternDefined(pattern); }
public static void SetUp(Module module, Grammar grammar) { if (pattern == null) { string expression = "l(number o((whitespace null) t(s(+(r('0' '9')) ?(s('.' +(r('0' '9'))))))))"; ParseGraphNode parseGraph = BootstrapParser.Parse(expression, null); pattern = new ConcretePattern(null, "Number", parseGraph); pattern.SetType(typeof(Number)); } module.SetName("Number", typeof(Number)); grammar.PatternDefined(pattern); }
public static void SetUp(Module module, Grammar grammar) { if (pattern == null) { string expression = "+(a(' ' '\\t' s('\\r' ?('\\n')) '\\n'))"; ParseGraphNode parseGraph = BootstrapParser.Parse(expression, null); pattern = new ConcretePattern(null, "DefaultWhitespace", parseGraph); pattern.SetType(typeof(DefaultWhitespace)); } module.SetName("DefaultWhitespace", typeof(DefaultWhitespace)); grammar.PatternDefined(pattern); }
public override bool Update(Pattern updated) { bool updates = false; foreach (ParseGraphNode node in nodes) { if (node.Update(updated)) updates = true; } if (updates) Updated(); return updates; }
public new static void SetUp(Module module, Grammar grammar) { if (pattern == null) { ParseGraphNode parseGraph = BootstrapParser.Parse("'.'", null); pattern = new ConcretePattern(null, "AnyPatternExpression", parseGraph); pattern.SetType(typeof(AnyPatternExpression)); PatternExpression.pattern.AddAltPattern(pattern); } module.SetName("AnyPatternExpression", typeof(AnyPatternExpression)); grammar.PatternDefined(pattern); }
public static void SetUp(Module module, Grammar grammar) { if (pattern == null) { string expression = "s('//' *(s(!(a( s('\r' ?('\n')) '\n' )) any)))"; ParseGraphNode parseGraph = BootstrapParser.Parse(expression, null); pattern = new ConcretePattern(null, "LineComment", parseGraph); pattern.SetType(typeof(LineComment)); } module.SetName("LineComment", typeof(LineComment)); grammar.PatternDefined(pattern); }
public static void SetUp(Module module, Grammar grammar) { if (pattern == null) { string expression = "+(a(0 1 2))"; Pattern[] patterns = {LineComment.pattern, BlockComment.pattern, DefaultWhitespace.pattern}; ParseGraphNode parseGraph = BootstrapParser.Parse(expression, patterns); pattern = new ConcretePattern(null, "Whitespace", parseGraph); pattern.SetType(typeof(Whitespace)); } module.SetName("Whitespace", typeof(Whitespace)); grammar.PatternDefined(pattern); }
public new static void SetUp(Module module, Grammar grammar) { if (pattern == null) { string expression = "s('option' l(optionKey 0) ?(s('=' o((dropPrecedence true) l(optionValue 1)))) ';')"; Pattern[] patterns = {Name.pattern, Expression.pattern}; ParseGraphNode parseGraph = BootstrapParser.Parse(expression, patterns); pattern = new ConcretePattern(null, "Option", parseGraph); pattern.SetType(typeof(Option)); } module.SetName("Option", typeof(Option)); grammar.PatternDefined(pattern); }
public static void SetUp(Module module, Grammar grammar) { if (pattern == null) { string expression = "o((whitespace 0) l(statements *(1)))"; Pattern[] patterns = {Whitespace.pattern, TopLevelStatement.pattern}; ParseGraphNode parseGraph = BootstrapParser.Parse(expression, patterns); pattern = new ConcretePattern(null, "Program", parseGraph); pattern.SetType(typeof(Program)); } module.SetName("Program", typeof(Program)); grammar.PatternDefined(pattern); }
public PatternTrampoline(Pattern pattern, Runtime runtime, StateForCompiler state) { this.pattern = pattern; this.runtime = runtime; this.state = state; callBlock = new ParserBlock(); callBlock.Comment("start of call to " + pattern.Type.Name + " -------------"); callBlock.Load(this); callBlock.GetProperty(typeof(PatternTrampoline).GetProperty("Implementation")); callBlock.LoadLexer(); callBlock.LoadState(); callBlock.Call(typeof(ParseDelegate).GetMethod("Invoke")); callBlock.Comment("end of call to " + pattern.Type.Name + " -------------"); }
public new static void SetUp(Module module, Grammar grammar) { if (pattern == null) { string expression = "l(statement 0)"; Pattern[] parameters = {Statement.pattern}; ParseGraphNode parseGraph = BootstrapParser.Parse(expression, parameters); pattern = new ConcretePattern(null, "TopLevelStatement", parseGraph); pattern.SetType(typeof(TopLevelStatement)); } module.SetName("TopLevelStatement", typeof(TopLevelStatement)); grammar.PatternDefined(pattern); }
public new static void SetUp(Module module, Grammar grammar) { if (pattern == null) { string expression = "l(name 0)"; Pattern[] parameters = {Name.pattern}; ParseGraphNode parseGraph = BootstrapParser.Parse(expression, parameters); pattern = new ConcretePattern(null, "NameExpression", parseGraph); pattern.SetType(typeof(NameExpression)); Expression.pattern.AddAltPattern(pattern); } module.SetName("NameExpression", typeof(NameExpression)); grammar.PatternDefined(pattern); }
public new static void SetUp(Module module, Grammar grammar) { if (pattern == null) { string expression = "s('throw' l(exception 0) ';')"; Pattern[] parameters = {Expression.pattern}; ParseGraphNode parseGraph = BootstrapParser.Parse(expression, parameters); pattern = new ConcretePattern(null, "ThrowStatement", parseGraph); pattern.SetType(typeof(ThrowStatement)); Statement.pattern.AddAltPattern(pattern); } module.SetName("ThrowStatement", typeof(ThrowStatement)); grammar.PatternDefined(pattern); }
public new static void SetUp(Module module, Grammar grammar) { if (pattern == null) { string expression = "o((leftRecursive true) s(l(callable 0) '(' o((dropPrecedence true) l(parameters ?(s(0 *(s(',' 0)))))) ')'))"; Pattern[] parameters = {Expression.pattern}; ParseGraphNode parseGraph = BootstrapParser.Parse(expression, parameters); pattern = new ConcretePattern(null, "CallExpression", parseGraph); pattern.SetType(typeof(CallExpression)); Expression.pattern.AddAltPattern(pattern); } module.SetName("CallExpression", typeof(CallExpression)); grammar.PatternDefined(pattern); }
public new static void SetUp(Module module, Grammar grammar) { if (pattern == null) { string expression = "s('{' l(options *(0)) o((dropPrecedence true) l(body 1)) '}')"; Pattern[] patterns = {Option.pattern, PatternExpression.pattern}; ParseGraphNode parseGraph = BootstrapParser.Parse(expression, patterns); pattern = new ConcretePattern(null, "BlockPatternExpression", parseGraph); pattern.SetType(typeof(BlockPatternExpression)); PatternExpression.pattern.AddAltPattern(pattern); } module.SetName("BlockPatternExpression", typeof(BlockPatternExpression)); grammar.PatternDefined(pattern); }
public new static void SetUp(Module module, Grammar grammar) { if (pattern == null) { string expression = "s('if' '(' l(condition 0) ')' l(trueBody 1) ?(s('else' l(falseBody 1))))"; Pattern[] parameters = {Expression.pattern, Statement.pattern}; ParseGraphNode parseGraph = BootstrapParser.Parse(expression, parameters); pattern = new ConcretePattern(null, "IfStatement", parseGraph); pattern.SetType(typeof(IfStatement)); Statement.pattern.AddAltPattern(pattern); } module.SetName("IfStatement", typeof(IfStatement)); grammar.PatternDefined(pattern); }
public new static void SetUp(Module module, Grammar grammar) { if (pattern == null) { string expression = "s('try' l(tryBody 0) 'catch' ?(s('(' l(catchVariable 1) ')')) l(catchBody 0))"; Pattern[] parameters = {Statement.pattern, Expression.pattern}; ParseGraphNode parseGraph = BootstrapParser.Parse(expression, parameters); pattern = new ConcretePattern(null, "TryStatement", parseGraph); pattern.SetType(typeof(TryStatement)); Statement.pattern.AddAltPattern(pattern); } module.SetName("TryStatement", typeof(TryStatement)); grammar.PatternDefined(pattern); }
public new static void SetUp(Module module, Grammar grammar) { if (pattern == null) { string expression = "o((rightRecursive true) s('&' l(body 0)))"; Pattern[] patterns = {PatternExpression.pattern}; ParseGraphNode parseGraph = BootstrapParser.Parse(expression, patterns); pattern = new ConcretePattern(null, "AndPatternExpression", parseGraph); pattern.SetType(typeof(AndPatternExpression)); PatternExpression.pattern.AddAltPattern(pattern); } module.SetName("AndPatternExpression", typeof(AndPatternExpression)); grammar.PatternDefined(pattern); }
public new static void SetUp(Module module, Grammar grammar) { if (pattern == null) { string expression = "o((leftRecursive true) s(l(a 0) '>=' l(b 0)))"; Pattern[] parameters = {Expression.pattern}; ParseGraphNode parseGraph = BootstrapParser.Parse(expression, parameters); pattern = new ConcretePattern(null, "GreaterOrEqualExpression", parseGraph); pattern.SetType(typeof(GreaterOrEqualExpression)); ComparisonExpression.pattern.AddAltPattern(pattern); } module.SetName("GreaterOrEqualExpression", typeof(GreaterOrEqualExpression)); grammar.PatternDefined(pattern); }
public new static void SetUp(Module module, Grammar grammar) { if (pattern == null) { string expression = "s('(' o((dropPrecedence true) l(body 0)) ')')"; Pattern[] parameters = {Expression.pattern}; ParseGraphNode parseGraph = BootstrapParser.Parse(expression, parameters); pattern = new ConcretePattern(null, "ParenExpression", parseGraph); pattern.SetType(typeof(ParenExpression)); Expression.pattern.AddAltPattern(pattern); } module.SetName("ParenExpression", typeof(ParenExpression)); grammar.PatternDefined(pattern); }
public new static void SetUp(Module module, Grammar grammar) { if (pattern == null) { string expression = "o((leftRecursive true) s(l(obj 0) 'is' l(type 0)))"; Pattern[] parameters = {Expression.pattern}; ParseGraphNode parseGraph = BootstrapParser.Parse(expression, parameters); pattern = new ConcretePattern(null, "IsExpression", parseGraph); pattern.SetType(typeof(IsExpression)); TypeExpression.pattern.AddAltPattern(pattern); } module.SetName("IsExpression", typeof(IsExpression)); grammar.PatternDefined(pattern); }
public new static void SetUp(Module module, Grammar grammar) { if (pattern == null) { string expression = "s('new' l(type o((exclude 1) 0)) '(' o((dropPrecedence true) l(parameters ?(s(0 *(s(',' 0)))))) ')')"; Pattern[] parameters = {Expression.pattern, CallExpression.pattern}; ParseGraphNode parseGraph = BootstrapParser.Parse(expression, parameters); pattern = new ConcretePattern(null, "NewExpression", parseGraph); pattern.SetType(typeof(NewExpression)); Expression.pattern.AddAltPattern(pattern); } module.SetName("NewExpression", typeof(NewExpression)); grammar.PatternDefined(pattern); }
public new static void SetUp(Module module, Grammar grammar) { if (pattern == null) { string expression = "s('field' l(name 0) ';')"; Pattern[] patterns = {Name.pattern}; ParseGraphNode parseGraph = BootstrapParser.Parse(expression, patterns); pattern = new ConcretePattern(null, "FieldMember", parseGraph); pattern.SetType(typeof(FieldMember)); Member.pattern.AddAltPattern(pattern); } module.SetName("FieldMember", typeof(FieldMember)); grammar.PatternDefined(pattern); }
public new static void SetUp(Module module, Grammar grammar) { if (pattern == null) { string expression = "s('token' l(body 0))"; Pattern[] patterns = {BlockPatternExpression.pattern}; ParseGraphNode parseGraph = BootstrapParser.Parse(expression, patterns); pattern = new ConcretePattern(null, "TokenPatternExpression", parseGraph); pattern.SetType(typeof(TokenPatternExpression)); PatternExpression.pattern.AddAltPattern(pattern); } module.SetName("TokenPatternExpression", typeof(TokenPatternExpression)); grammar.PatternDefined(pattern); }
public new static void SetUp(Module module, Grammar grammar) { if (pattern == null) { string expression = "s('{' l(body *(0)) '}')"; Pattern[] patterns = {Statement.pattern}; ParseGraphNode parseGraph = BootstrapParser.Parse(expression, patterns); pattern = new ConcretePattern(null, "CompoundStatement", parseGraph); pattern.SetType(typeof(CompoundStatement)); Statement.pattern.AddAltPattern(pattern); } module.SetName("CompoundStatement", typeof(CompoundStatement)); grammar.PatternDefined(pattern); }
public void PatternDefined(Pattern pattern) { patterns.Add(pattern); trace.PatternDefined(pattern); }
public override bool Update(Pattern updated) { return(pattern == updated); }