antlr

Validate antlr-grammar online [closed]

寵の児 提交于 2019-12-06 17:00:47
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . Does anyone know if there exists some kind of online-testing environment for antlr-grammars where i can validate and test a given grammar against some input strings...? Would be glad for any help! 来源: https://stackoverflow.com/questions/17780699/validate-antlr-grammar-online

When rewriting tree on ANTLR, java.lang.NullPointerException is thrown

百般思念 提交于 2019-12-06 14:40:38
I'm trying to create a parser for QuickBasic and this is my attempt to get the comments: grammar QuickBasic; options { language = 'CSharp2'; output = AST; } tokens { COMMENT; } parse : .* EOF ; // DOESN'T WORK Comment : R E M t=~('\n')* { Text = $t; } -> ^(COMMENT $t) | Quote t=~('\n')* { Text = $t; } -> ^(COMMENT $t) ; Space : (' ' | '\t' | '\r' | '\n' | '\u000C') { Skip(); } ; fragment Quote : '\''; fragment E : 'E' | 'e'; fragment M : 'M' | 'm'; fragment R : 'R' | 'r'; Even if I rewrite using only the token COMMENT and nothing more, I still get the same error. // It DOESN'T WORK EITHER

Hints regarding the use of ANTLR v3 generated files in Flash Builder 4.5.1

淺唱寂寞╮ 提交于 2019-12-06 13:38:29
According to these instructions , I'm trying to use ANTLR generated *.as files in a current Flash Builder 4.5.1 project. Therefore, I added this ANTLR's Actionscript runtime to my project - without problems. I compiled lexer/parser specs using ANTLRWorks without problems too. I added the language option to the source *.g file to make ANTLR generate Actionscript sources: options { backtrack = true; memoize = true; k=2; output = AST; language=ActionScript; // Added this ASTLabelType = CommonTree; } Unfortunately, the ANTLR/ANTLRworks generated Actionscript code is buggy: Catch statements read

How Lexer lookahead works with greedy and non-greedy matching in ANTLR3 and ANTLR4?

五迷三道 提交于 2019-12-06 12:49:41
问题 If someone would clear my mind from the confusion behind look-ahead relation to tokenizing involving greery/non-greedy matching i'd be more than glad. Be ware this is a slightly long post because it's following my thought process behind. I'm trying to write antlr3 grammar that allows me to match input such as: "identifierkeyword" I came up with a grammar like so in Antlr 3.4: KEYWORD: 'keyword' ; IDENTIFIER : (options {greedy=false;}: (LOWCHAR|HIGHCHAR))+ ; /** lowercase letters */ fragment

Generate BNF diagrams from an antlr grammar?

拈花ヽ惹草 提交于 2019-12-06 11:54:31
I may well be asking something not achievable here.. Maybe someone can point out either (a) What would be some steps (/tools?) to at least partially achieve creation of bnf diagrams from a (rather complex) antlr grammar (b) why (if it were the case) this simply can not be achieved. E.g. maybe since antlr is extended BNF and its recursive structure differs from bnf requirements.. Along those lines. ANTLRWorks 1 works for generating diagrams, one at a time, for rule. for v4, ANTLRWorks 2 also generates them though I'm not sure it can save them to disk. Ter If it is an ANTLR 3 grammar, you could

Working example of wikitext-to-HTML in ANTLR 3

*爱你&永不变心* 提交于 2019-12-06 11:47:35
问题 I'm trying to flesh out a wikitext-to-HTML translator in ANTLR 3, but I keep getting stuck. Do you know of a working example that I can inspect? I tried the MediaWiki ANTLR grammar and the Wiki Creole grammar, but I can't get them to generate the lexer & parser in ANTLR 3. Here are the links to two grammars I've tried using: http://www.mediawiki.org/wiki/Markup_spec/ANTLR http://www.wikicreole.org/wiki/EBNFGrammarForCreole1.0 I can't get any of these two to generate my Java Lexer and Parser.

Using antlr to parse lua IF statements in specific functions

邮差的信 提交于 2019-12-06 11:30:52
I generated a Lua Parser using the Lua.g grammar with antlr in java. My lua code which i wish to parse basically looks like this function uniqueid_some_event (e) if (e:HasString("string1")) then -- do something end if (e:HasString("string2")) then -- do something end end I have hundred of these events in different files for specific actor bindings. Now i want to parse these files and gather for each what conditions are checked - in the above case - i want to extract "string1" and "string2" as event triggers. (To be more precise, i want to create a report that will display just the triggers for

Parse and return a list of doubles using ANTLR4

江枫思渺然 提交于 2019-12-06 11:04:38
问题 How can I parse a file containing a decimal numbers into a List<double> in C# using ANTLR4? A complete, working example would illustrate how all the pieces go together. The input file looks like this: 12.34 45.67 89.10 回答1: This is an updated version of an older answer to a different question, showing one way to do this task using C# and ANTLR4. The Grammar grammar Values; parse : (number ( LINEBREAK | EOF ) )* ; number : NUMBER ; NUMBER : DIGIT '.' DIGIT ; DIGIT : [0-9]+ ; WS : [ \t] ->

simple criteria expression parser with antlr3

故事扮演 提交于 2019-12-06 10:36:44
I want to create a simple criteria expression parser with antlr3 Updated: separate AND OR expression rules to support AND/OR different hierarchy, but got another problems: if the expression is something like: a = 1 and b = 2 and c = 3 The tree should be as following according to current implement: = = (a = 1)(b = 2)(c = 3) But I want to generate it as follows: = = (a = 1)(b = 2) (c = 3) First "and" should be higher priority than another, because I want to parse all the expression as left exp and right exp. I think I need to re-write the rule in the "subcond" To make a = 1 and b = 2 and c = 3 -

OutOfMemoryError when parsing incorrect input in ANTLR

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 09:29:58
Actually this issue is related with my previous question Catching ANTLR's NoViableAltException in Java and ANTLRWorks Debugger , but I decided to split them because of different symptoms. The issue is about feeding to ANTLR input text, which contains unknown tokens. Consider for example, that our grammar doesn't known anything about tokens which start with @ symbol. If we will try to feed such text to ANTLRWorks interpreter, we will receive NoViableAltException in result graph. But if we will take generated and compiled grammar in Java and try to parse such invalid text with it, we can receive