[il-antlr-interest: 32988] [antlr-interest] rule parameter question
Hello, I am trying to do what I think is a simple parameter passing to a rule in Antlr 3.3: --- grammar rule_params; options { output = AST; } rule_params : outer; outer: outer_id '[' inner[$outer_id.tree] ']'; inner[CommonTree parent]: inner_id '[' ']'; outer_id: '#'! ID; inner_id: '$'! ID ; ID : ('a'..'z' | 'A'..'Z') ('a'..'z' | 'A'..'Z' | '0'..'9' | '_' )* ; - However the inner[CommonTree parent] generates the following: *** inner4=inner((outer_id2!=null?((Object)outer_id2.tree):null)); Resulting in this error: *** The method inner(CommonTree) in the type rule_paramsParser is not applicable for the arguments (Object) As best I can tell, this is the exact same as the example in the Antrl book: classDefinition[CommonTree mod] (Kindle Location 3993) - sorry I don't know the page number but it is in the middle of the book in chapter 9, section labeled Creating Nodes with Arbitrary Actions. Thanks for any help. Mark Truluck COGITON, Inc. List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups il-antlr-interest group. To post to this group, send email to il-antlr-inter...@googlegroups.com. To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
[il-antlr-interest: 32989] Re: [antlr-interest] rule parameter question
Hi Mark, I presume you didn't see my answer on Stackoverflow: http://stackoverflow.com/questions/6529359/how-to-pass-commontree-parameter-to-an-antlr-rule ? If you did, is there anything that wasn't clear? Regards, Bart. On Thu, Jun 30, 2011 at 2:26 PM, Mark Truluck mark.trul...@cogiton.comwrote: Hello, I am trying to do what I think is a simple parameter passing to a rule in Antlr 3.3: --- grammar rule_params; options { output = AST; } rule_params : outer; outer: outer_id '[' inner[$outer_id.tree] ']'; inner[CommonTree parent]: inner_id '[' ']'; outer_id: '#'! ID; inner_id: '$'! ID ; ID : ('a'..'z' | 'A'..'Z') ('a'..'z' | 'A'..'Z' | '0'..'9' | '_' )* ; - However the inner[CommonTree parent] generates the following: *** inner4=inner((outer_id2!=null?((Object)outer_id2.tree):null)); Resulting in this error: *** The method inner(CommonTree) in the type rule_paramsParser is not applicable for the arguments (Object) As best I can tell, this is the exact same as the example in the Antrl book: classDefinition[CommonTree mod] (Kindle Location 3993) - sorry I don't know the page number but it is in the middle of the book in chapter 9, section labeled Creating Nodes with Arbitrary Actions. Thanks for any help. Mark Truluck COGITON, Inc. List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups il-antlr-interest group. To post to this group, send email to il-antlr-inter...@googlegroups.com. To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
[il-antlr-interest: 32990] Re: [antlr-interest] rule parameter question
Hi Bart sorry thought I'd get an email from them. That worked perfectly thanks very much. Mark From: Bart Kiers bki...@gmail.com Date: Thu, 30 Jun 2011 14:42:53 +0200 To: Mark Truluck mark.trul...@cogiton.com Cc: antlr-interest@antlr.org interest antlr-interest@antlr.org Subject: Re: [antlr-interest] rule parameter question Hi Mark, I presume you didn't see my answer on Stackoverflow: http://stackoverflow.com/questions/6529359/how-to-pass-commontree-parameter- to-an-antlr-rule ? If you did, is there anything that wasn't clear? Regards, Bart. On Thu, Jun 30, 2011 at 2:26 PM, Mark Truluck mark.trul...@cogiton.com wrote: Hello, I am trying to do what I think is a simple parameter passing to a rule in Antlr 3.3: --- grammar rule_params; options { output = AST; } rule_params : outer; outer: outer_id '[' inner[$outer_id.tree] ']'; inner[CommonTree parent]: inner_id '[' ']'; outer_id: '#'! ID; inner_id: '$'! ID ; ID : ('a'..'z' | 'A'..'Z') ('a'..'z' | 'A'..'Z' | '0'..'9' | '_' )* ; - However the inner[CommonTree parent] generates the following: *** inner4=inner((outer_id2!=null?((Object)outer_id2.tree):null)); Resulting in this error: *** The method inner(CommonTree) in the type rule_paramsParser is not applicable for the arguments (Object) As best I can tell, this is the exact same as the example in the Antrl book: classDefinition[CommonTree mod] (Kindle Location 3993) - sorry I don't know the page number but it is in the middle of the book in chapter 9, section labeled Creating Nodes with Arbitrary Actions. Thanks for any help. Mark Truluck COGITON, Inc. List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups il-antlr-interest group. To post to this group, send email to il-antlr-inter...@googlegroups.com. To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
[il-antlr-interest: 32991] Re: [antlr-interest] rule parameter question
No problem: SO _does_ work with notifications, but they only go out once a day or so by default. Good to hear it worked. Regards, Bart. On Thu, Jun 30, 2011 at 3:16 PM, Mark Truluck mark.trul...@cogiton.comwrote: Hi Bart – sorry – thought I'd get an email from them. That worked perfectly – thanks very much. Mark From: Bart Kiers bki...@gmail.com Date: Thu, 30 Jun 2011 14:42:53 +0200 To: Mark Truluck mark.trul...@cogiton.com Cc: antlr-interest@antlr.org interest antlr-interest@antlr.org Subject: Re: [antlr-interest] rule parameter question Hi Mark, I presume you didn't see my answer on Stackoverflow: http://stackoverflow.com/questions/6529359/how-to-pass-commontree-parameter-to-an-antlr-rule ? If you did, is there anything that wasn't clear? Regards, Bart. On Thu, Jun 30, 2011 at 2:26 PM, Mark Truluck mark.trul...@cogiton.comwrote: Hello, I am trying to do what I think is a simple parameter passing to a rule in Antlr 3.3: --- grammar rule_params; options { output = AST; } rule_params : outer; outer: outer_id '[' inner[$outer_id.tree] ']'; inner[CommonTree parent]: inner_id '[' ']'; outer_id: '#'! ID; inner_id: '$'! ID ; ID : ('a'..'z' | 'A'..'Z') ('a'..'z' | 'A'..'Z' | '0'..'9' | '_' )* ; - However the inner[CommonTree parent] generates the following: *** inner4=inner((outer_id2!=null?((Object)outer_id2.tree):null)); Resulting in this error: *** The method inner(CommonTree) in the type rule_paramsParser is not applicable for the arguments (Object) As best I can tell, this is the exact same as the example in the Antrl book: classDefinition[CommonTree mod] (Kindle Location 3993) - sorry I don't know the page number but it is in the middle of the book in chapter 9, section labeled Creating Nodes with Arbitrary Actions. Thanks for any help. Mark Truluck COGITON, Inc. List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups il-antlr-interest group. To post to this group, send email to il-antlr-inter...@googlegroups.com. To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
[il-antlr-interest: 32992] Re: [antlr-interest] rule parameter question
Just for the record, in case someone stumbles upon this post, the answer from SO: - If you don't explicitly specify the tree to be used in your grammar, .tree (which is short forgetTree()) will return a java.lang.Object and a CommonTree will be used as default Treeimplementation. To avoid casting, set the type of tree in your options { ... } section: options { output=AST; ASTLabelType=CommonTree; } On Thu, Jun 30, 2011 at 3:20 PM, Bart Kiers bki...@gmail.com wrote: No problem: SO _does_ work with notifications, but they only go out once a day or so by default. Good to hear it worked. Regards, Bart. On Thu, Jun 30, 2011 at 3:16 PM, Mark Truluck mark.trul...@cogiton.comwrote: Hi Bart – sorry – thought I'd get an email from them. That worked perfectly – thanks very much. Mark From: Bart Kiers bki...@gmail.com Date: Thu, 30 Jun 2011 14:42:53 +0200 To: Mark Truluck mark.trul...@cogiton.com Cc: antlr-interest@antlr.org interest antlr-interest@antlr.org Subject: Re: [antlr-interest] rule parameter question Hi Mark, I presume you didn't see my answer on Stackoverflow: http://stackoverflow.com/questions/6529359/how-to-pass-commontree-parameter-to-an-antlr-rule ? If you did, is there anything that wasn't clear? Regards, Bart. On Thu, Jun 30, 2011 at 2:26 PM, Mark Truluck mark.trul...@cogiton.comwrote: Hello, I am trying to do what I think is a simple parameter passing to a rule in Antlr 3.3: --- grammar rule_params; options { output = AST; } rule_params : outer; outer: outer_id '[' inner[$outer_id.tree] ']'; inner[CommonTree parent]: inner_id '[' ']'; outer_id: '#'! ID; inner_id: '$'! ID ; ID : ('a'..'z' | 'A'..'Z') ('a'..'z' | 'A'..'Z' | '0'..'9' | '_' )* ; - However the inner[CommonTree parent] generates the following: *** inner4=inner((outer_id2!=null?((Object)outer_id2.tree):null)); Resulting in this error: *** The method inner(CommonTree) in the type rule_paramsParser is not applicable for the arguments (Object) As best I can tell, this is the exact same as the example in the Antrl book: classDefinition[CommonTree mod] (Kindle Location 3993) - sorry I don't know the page number but it is in the middle of the book in chapter 9, section labeled Creating Nodes with Arbitrary Actions. Thanks for any help. Mark Truluck COGITON, Inc. List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups il-antlr-interest group. To post to this group, send email to il-antlr-inter...@googlegroups.com. To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
[il-antlr-interest: 32997] [antlr-interest] Ignore Mismatched input and No viable alternative
Hi all, I'm trying to parse a text file created by an application. There are lines in this text file that I know perfectly their contents and format, and these lines are correctly parsed. Otherwise, there are lines that can be recognized by any syntax I can think about. When I parse the file with my syntax, I'm getting several occurrences of Mismatched input and No viable alternative on the lines that I can't recognize. What I want is simply throw away these invalid lines, as if them would be absent from the text file. For my purposes, these lines are invisibles. How can I do that, ignoring the lexer/parser errors? TIA Nilo - Brasil List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups il-antlr-interest group. To post to this group, send email to il-antlr-inter...@googlegroups.com. To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
[il-antlr-interest: 32998] Re: [antlr-interest] Ignore Mismatched input and No viable alternative
Can you give an example of your input, and explain what line you want to ignore? Regards, Bart. On Thu, Jun 30, 2011 at 10:33 PM, Nilo Roberto C Paim nilop...@gmail.comwrote: Hi all, I'm trying to parse a text file created by an application. There are lines in this text file that I know perfectly their contents and format, and these lines are correctly parsed. Otherwise, there are lines that can be recognized by any syntax I can think about. When I parse the file with my syntax, I'm getting several occurrences of Mismatched input and No viable alternative on the lines that I can't recognize. What I want is simply throw away these invalid lines, as if them would be absent from the text file. For my purposes, these lines are invisibles. How can I do that, ignoring the lexer/parser errors? TIA Nilo - Brasil List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups il-antlr-interest group. To post to this group, send email to il-antlr-inter...@googlegroups.com. To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
[il-antlr-interest: 32999] Re: [antlr-interest] Ignore Mismatched input and No viable alternative
You could use the filter=true grammar option to discard tokens that don't match anything On Thu, Jun 30, 2011 at 10:36 PM, Bart Kiers bki...@gmail.com wrote: Can you give an example of your input, and explain what line you want to ignore? Regards, Bart. On Thu, Jun 30, 2011 at 10:33 PM, Nilo Roberto C Paim nilop...@gmail.com wrote: Hi all, I'm trying to parse a text file created by an application. There are lines in this text file that I know perfectly their contents and format, and these lines are correctly parsed. Otherwise, there are lines that can be recognized by any syntax I can think about. When I parse the file with my syntax, I'm getting several occurrences of Mismatched input and No viable alternative on the lines that I can't recognize. What I want is simply throw away these invalid lines, as if them would be absent from the text file. For my purposes, these lines are invisibles. How can I do that, ignoring the lexer/parser errors? TIA Nilo - Brasil List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups il-antlr-interest group. To post to this group, send email to il-antlr-inter...@googlegroups.com. To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
[il-antlr-interest: 33000] Re: [antlr-interest] Ignore Mismatched input and No viable alternative
Perhaps, but Nilo is talking about discarding complete lines. Chances are that somewhere in these ignored-lines, text exists that looks like a token that _do_ need to be kept. That's why I asked for more info. Regards, Bart. On Thu, Jun 30, 2011 at 10:40 PM, Robin diabete...@gmail.com wrote: You could use the filter=true grammar option to discard tokens that don't match anything On Thu, Jun 30, 2011 at 10:36 PM, Bart Kiers bki...@gmail.com wrote: Can you give an example of your input, and explain what line you want to ignore? Regards, Bart. On Thu, Jun 30, 2011 at 10:33 PM, Nilo Roberto C Paim nilop...@gmail.com wrote: Hi all, I'm trying to parse a text file created by an application. There are lines in this text file that I know perfectly their contents and format, and these lines are correctly parsed. Otherwise, there are lines that can be recognized by any syntax I can think about. When I parse the file with my syntax, I'm getting several occurrences of Mismatched input and No viable alternative on the lines that I can't recognize. What I want is simply throw away these invalid lines, as if them would be absent from the text file. For my purposes, these lines are invisibles. How can I do that, ignoring the lexer/parser errors? TIA Nilo - Brasil List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups il-antlr-interest group. To post to this group, send email to il-antlr-inter...@googlegroups.com. To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
[il-antlr-interest: 33001] Re: [antlr-interest] Ignore Mismatched input and No viable alternative
Good point :-) On Thu, Jun 30, 2011 at 10:44 PM, Bart Kiers bki...@gmail.com wrote: Perhaps, but Nilo is talking about discarding complete lines. Chances are that somewhere in these ignored-lines, text exists that looks like a token that _do_ need to be kept. That's why I asked for more info. Regards, Bart. On Thu, Jun 30, 2011 at 10:40 PM, Robin diabete...@gmail.com wrote: You could use the filter=true grammar option to discard tokens that don't match anything On Thu, Jun 30, 2011 at 10:36 PM, Bart Kiers bki...@gmail.com wrote: Can you give an example of your input, and explain what line you want to ignore? Regards, Bart. On Thu, Jun 30, 2011 at 10:33 PM, Nilo Roberto C Paim nilop...@gmail.com wrote: Hi all, I'm trying to parse a text file created by an application. There are lines in this text file that I know perfectly their contents and format, and these lines are correctly parsed. Otherwise, there are lines that can be recognized by any syntax I can think about. When I parse the file with my syntax, I'm getting several occurrences of Mismatched input and No viable alternative on the lines that I can't recognize. What I want is simply throw away these invalid lines, as if them would be absent from the text file. For my purposes, these lines are invisibles. How can I do that, ignoring the lexer/parser errors? TIA Nilo - Brasil List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups il-antlr-interest group. To post to this group, send email to il-antlr-inter...@googlegroups.com. To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
[il-antlr-interest: 33002] [antlr-interest] RES: Ignore Mismatched input and No viable alternative
Bart is right... I need to discard complete lines and not just some unrecognized tokens. And really exists recognized tokens on lines I want to discard, 'cause these tokens are in invalid places on the line... I'm thinking in change the text file format, putting a discard token on the beginning of the lines I want to discard (something like a comment line), but these will take a little more time... Thanks Bart and Robin for answering. Regards, Nilo - Brazil -Mensagem original- De: antlr-interest-boun...@antlr.org [mailto:antlr-interest-boun...@antlr.org] Em nome de Robin Enviada em: quinta-feira, 30 de junho de 2011 17:46 Para: Bart Kiers Cc: antlr-interest@antlr.org interest Assunto: Re: [antlr-interest] Ignore Mismatched input and No viable alternative Good point :-) On Thu, Jun 30, 2011 at 10:44 PM, Bart Kiers bki...@gmail.com wrote: Perhaps, but Nilo is talking about discarding complete lines. Chances are that somewhere in these ignored-lines, text exists that looks like a token that _do_ need to be kept. That's why I asked for more info. Regards, Bart. On Thu, Jun 30, 2011 at 10:40 PM, Robin diabete...@gmail.com wrote: You could use the filter=true grammar option to discard tokens that don't match anything On Thu, Jun 30, 2011 at 10:36 PM, Bart Kiers bki...@gmail.com wrote: Can you give an example of your input, and explain what line you want to ignore? Regards, Bart. On Thu, Jun 30, 2011 at 10:33 PM, Nilo Roberto C Paim nilop...@gmail.com wrote: Hi all, I'm trying to parse a text file created by an application. There are lines in this text file that I know perfectly their contents and format, and these lines are correctly parsed. Otherwise, there are lines that can be recognized by any syntax I can think about. When I parse the file with my syntax, I'm getting several occurrences of Mismatched input and No viable alternative on the lines that I can't recognize. What I want is simply throw away these invalid lines, as if them would be absent from the text file. For my purposes, these lines are invisibles. How can I do that, ignoring the lexer/parser errors? TIA Nilo - Brasil List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups il-antlr-interest group. To post to this group, send email to il-antlr-inter...@googlegroups.com. To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.