4
I Use This!
Activity Not Available

News

Analyzed about 1 year ago. based on code collected about 1 year ago.
Posted over 9 years ago by dhoepelman
Reduce-reduce means there's more than one way some sentence (code) can be parsed (this is called ambiguity). In this case there a sentence where the parser can't decide if the preceding part should be a Expression or a Unary Expression. I don't ... [More] immediately see the problem, but the problematic state is hit with +1++;. However this shouldn't be a problem because ++ has a higher precedence than +. [Less]
Posted over 9 years ago by WiredWiz
The language I'm building a grammar for is generating a reduce-reduce conflict and I'm not sure how to read the conflict. I'm assuming in this case I should insert a ReduceHere() call somewhere in my grammar to clear up the conflict but I lack the ... [More] understanding currently to know where this goes and exactly why (I assume it to be a conflict between potential expressions using , , -- and -). The conflict message is as follows: State S53 (Inadequate) Reduce-reduce conflicts on inputs: -- < || && ^ == != > <= >= << >> - * / % in Reduce items: Unary Expression -> Unary Operator Primary Expression · [ -- < || && ^ == != > <= >= << >> - * / % in Semicolon Comma }] Expression -> Primary Expression · [ -- < || && ^ == != > <= >= << >> - * / % in] Transitions: My grammar includes operators common to C# such as , --, ==, !=, etc. as you can see. I used the example C# grammar in irony as a starting point. I actually ran into a number of conflicts initially, so I stripped the grammar down to a simplified version with the intention of slowly adding grammar parts back until I hit a conflict and then solving the conflict. I'm hoping by better understanding this conflict and the proper solution I can apply that knowledge to future conflicts and not nag folks with questions ;). In the current stripped down state the entire grammar is as follows: using System; using Irony.Parsing; namespace Org.Edgerunner.MooSharp.Parser { [Language("Moo#", "1.0", "The Moo# programming language, an extended version of the original Moo language")] public class MooSharpGrammar : Irony.Parsing.Grammar { /// <summary> /// Initializes a new instance of the <see cref="MooSharpGrammar"/> class. /// </summary> public MooSharpGrammar() : base(false) { #region declarations StringLiteral stringLiteral = MooTerminalFactory.CreateMooString("StringLiteral"); Irony.Parsing.NumberLiteral number = MooTerminalFactory.CreateMooNumber("Number"); ObjectLiteral objectLiteral = new ObjectLiteral("Object"); ErrorTerminal error = new ErrorTerminal("ErrorCode", typeof(string)); IdentifierTerminal identifier = MooTerminalFactory.CreateMooIdentifier("Identifier"); KeyTerm lcbr = ToTerm("{"); KeyTerm rcbr = ToTerm("}"); KeyTerm comma = ToTerm(",", "Comma"); KeyTerm semi = ToTerm(";", "Semicolon"); KeyTerm at = ToTerm("@", "at"); CommentTerminal singleLineComment = new CommentTerminal("SingleLineComment", "//", "\r", "\n", "\u2085", "\u2028", "\u2029"); CommentTerminal delimitedComment = new CommentTerminal("DelimitedComment", "/*", "*/"); NonGrammarTerminals.Add(singleLineComment); NonGrammarTerminals.Add(delimitedComment); var literal = new NonTerminal("Literal"); var incrOrDecr = new NonTerminal("Incr Or Decr"); var incrOrDecrOpt = new NonTerminal("Incr Or Decr Opt"); var preIncrDecrExpression = new NonTerminal("Pre Incr Decr Expression"); var postIncrDecrExpression = new NonTerminal("Post Incr Decr Expression"); var expression = new NonTerminal("Expression"); var primaryExpression = new NonTerminal("Primary Expression"); var listLiteral = new NonTerminal("List Literal"); var unaryOperator = new NonTerminal("Unary Operator"); var unaryExpression = new NonTerminal("Unary Expression"); var spliceExpression = new NonTerminal("Splice Expression"); var listMemberExpression = new NonTerminal("List Member Expression"); var listMemberExpressionListOpt = new NonTerminal("List Member Expression List Optional"); var binOpExpression = new NonTerminal("Binary Operation Expression"); var binOp = new NonTerminal("Binary Operator", "operator symbol"); var statement = new NonTerminal("Statement"); var simpleStatement = new NonTerminal("Simple Statement"); var simpleStatementOpt = new NonTerminal("Simple Statement Optional"); var statementList = new NonTerminal("Statement List"); var CodeBody = new NonTerminal("Code Body"); #endregion RegisterOperators(1, "||"); RegisterOperators(2, "&&"); RegisterOperators(4, "^"); RegisterOperators(6, "==", "!="); RegisterOperators(7, "<", ">", "<=", ">="); RegisterOperators(8, "<<", ">>"); RegisterOperators(9, " ", "-"); RegisterOperators(10, "*", "/", "%"); RegisterOperators(11, ".", ":", "in", "@"); RegisterOperators(12, " ", "--"); RegisterOperators(-3, "=", " =", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "<<=", ">>="); RegisterOperators(-2, "?"); this.MarkPunctuation(";", ",", "(", ")", "{", "}", "[", "]"); Root = CodeBody; expression.Rule = primaryExpression | binOpExpression; spliceExpression.Rule = at expression; listMemberExpression.Rule = spliceExpression | expression; listMemberExpressionListOpt.Rule = MakeStarRule(listMemberExpressionListOpt, comma, listMemberExpression); listLiteral.Rule = lcbr listMemberExpressionListOpt rcbr; literal.Rule = stringLiteral | error | objectLiteral | number | "true" | "false" | listLiteral; incrOrDecrOpt.Rule = Empty | ToTerm(" ") | "--"; incrOrDecr.Rule = ToTerm(" ") | "--"; preIncrDecrExpression.Rule = incrOrDecr expression; postIncrDecrExpression.Rule = expression incrOrDecr; binOp.Rule = ToTerm("<") | "||" | "&&" | "^" | "==" | "!=" | ">" | "<=" | ">=" | "<<" | ">>" | " " | "-" | "*" | "/" | "%" | "in"; binOpExpression.Rule = expression binOp expression; primaryExpression.Rule = identifier | unaryExpression | preIncrDecrExpression | postIncrDecrExpression | literal; unaryOperator.Rule = ToTerm(" ") | "-" | "!" | "~" | "*"; unaryExpression.Rule = unaryOperator primaryExpression; simpleStatementOpt.Rule = expression | Empty; simpleStatement.Rule = simpleStatementOpt semi; statement.Rule = simpleStatement; statementList.Rule = MakePlusRule(statementList, null, statement); CodeBody.Rule = Empty | statementList; } } } [Less]
Posted over 9 years ago by WiredWiz
I have found the root of my problem. I had the NoDotAfterInt flag specified in there. Silly mistake.
Posted over 9 years ago by WiredWiz
I'm putting together a grammar for an existing language that has an object literal. All objects are numbered and represented as #<number>, e.g. #52 (I represent this as a numeric literal of int only, prefixed by #). The language also features ... [More] basic integer and floating point numbers, represented by a basic numeric literal. Objects in this language can have properties and methods. The conflict I run into is that when I try to parse the expression "#3.foo", the parser seems to decide that I must be trying to represent a floating point number and gives me the error "invalid character: '#'". This occurs even though I have the property member access defined in the language. If I use a variable (assuming it represents an object), such as "foo.bar", the parser works just fine. Is there a way to indicate to the parser that my object literal should take precedence over the numeric literal, so that referencing the property on an object literal will work? Of course feel free to point out a more proper solution if you have one. Thank you in advance for any help :). [Less]
Posted over 9 years ago by dhoepelman
Hi, I'm one of the authors of XLParser, a C# Excel Formula parser based on Irony. If someone with experience in Irony (hi @rivantsov) wants to check it out and provide feedback, feel free!
Posted over 9 years ago by nekomatic
I guess the reason Microsoft's makes the state of the workflow obfuscated is simply security, imagine certain variable contains credit card or bank details... But that's why I don't want to go this route, this would make really hard to add any ... [More] detailed monitoring to the process..... I believe I simply need to limit the grammar a bit al allow only simple sequential execution with just a single level scope, and try to add presistance to each step... I'll see how it goes. Thanks for all your input, it helped me re-evaluate my requirements :) Thanks [Less]
Posted over 9 years ago by rivantsov
these kind of things (sections appearing once, etc) are actually more semantic rules - so they should be ignored in grammar rules, but later checked in code, after parsing by running thru syntax tree.
Posted over 9 years ago by Normski99
So basically the syntax for is roughly FORMAT <---- Mandory ON EVERY ROW <---- Optional Section but only can appear once STATEMENTS PAGE HEADER <---- Optional Section but only can appear once STATMENTS.... AFTER GROUP OF ... [More] ColumnName <---- Optional Section but only can appear more than once but can't have the same column name STATMENTS.... END One interesting fact is that Sections don't have and END terminator but FORMAT does. These sections can appear in any order. [Less]
Posted over 9 years ago by rivantsov
It seems all these headers are just another kind of statement - just add them to Statement definition
Posted over 9 years ago by Normski99
Thanks Roman that worked, I've almost complete the Informix ACE Report grammer. Last final question I have the following, I need any of theme terms in any order i'm struggle to express this in Irony. Can you advise please. ... [More] ON_EVERY_RECORD.Rule = Empty | "ON EVERY ROW" + LINES; ON_EVERY_ROW.Rule = Empty | "ON EVERY ROW" + LINES; FIRST_PAGE_HEADER.Rule = Empty | "FIRST PAGE HEADER" + LINES; PAGE_TRAILER.Rule = Empty | "PAGE TRAILER" + LINES; PAGE_HEADER.Rule = Empty | "PAGE HEADER" + LINES; ON_LAST_ROW.Rule = Empty | "ON LAST ROW" + LINES; formatSubSection.Rule = PAGE_HEADER + PAGE_TRAILER + ON_EVERY_RECORD + FIRST_PAGE_HEADER + ON_LAST_ROW; formatSection.Rule = "FORMAT" + NewLinePlus + formatSubSection + "END" + NewLinePlus; this.Root = formatSection; Now an example code syntax would be FORMAT <- MANDATORY ON_EVERY_RECORD statments.... PAGE_HEADER. statments.... END [Less]