[il-antlr-interest: 34906] Re: [antlr-interest] init bug

2011-11-15 Thread Douglas Godfrey
create a testParser.cpp file which consists of 1 line #include testParser.c When your project compiles testParser.cpp the generated code for declaring flag will work. NOTE: you cannot use the variable flag in any predicate or production before the first token is consumed. code before the

[il-antlr-interest: 34907] Re: [antlr-interest] missing MATCHRANGE macro

2011-11-15 Thread Douglas Godfrey
try using the Number lexer rule from the Sun Java lexer posted on the Antlr site. The Number rule handles Float and Int as well as hex and octal values. The resulting tokens are Float or Int. On 11/7/11 4:47 PM, John B. Brodie j...@acm.org wrote: On 11/07/2011 12:32 PM, Jim Idle wrote:

[il-antlr-interest: 34427] Re: [antlr-interest] Rewrite action causing error in parser?

2011-10-16 Thread Douglas Godfrey
The reason why you cannot reference a local rule variable from a predicate is because the predicate MAY be hoisted to a parent rule for lookahead. This only happens for a predicate that occurs before the first token or alternative selection. The predicate executes in the context of the parent rule

[il-antlr-interest: 34343] Re: [antlr-interest] ISO SQL 2003 Grammar

2011-10-10 Thread Douglas Godfrey
parser has some errors. The critical problem - I think - is that the parser has duplicated (identical) case in some switch statements. So I posted these thoughts. Douglas Godfrey, I appreciate your work on SQL2003 parser. But I couldn't see the work result. Could you write your environment? Antlr

[il-antlr-interest: 34326] Re: [antlr-interest] ISO SQL 2003 Grammar

2011-10-09 Thread Douglas Godfrey
To be able to build this grammar you must use Java 1.6 64bit with a java heap size of 8GB. This requires a 64bit CPU OS and more than 8GB or system memory. This is documented in the comments at the top of the parser grammar. I have also posted numerous notes on how to transform this grammar so

[il-antlr-interest: 34272] Re: [antlr-interest] distinguish 3 + 4 from 3 +4

2011-10-05 Thread Douglas Godfrey
define a Number lexer rule that parses signed numbers with no intervening whitespace between the + or - and the digits. Then the parser will receive Number Number instead of Number Plus Number. The Plus rule will succeed any time there is whitespace between the sign and the number. On 10/5/11

[il-antlr-interest: 34191] Re: [antlr-interest] [C] code to change Token type, use char* and loose data when buffer destroyed

2011-09-27 Thread Douglas Godfrey
You need to modify your string lexing rules to use sub-rules for the elementary strings and return the concatenated string as the lexer token value. The value of StringConstant: QuotedString {RemoveQuotePairs($QuotedString);}; fragment QuotedString: ( StringTerm )+; fragment

[il-antlr-interest: 34195] Re: [antlr-interest] [C] code to change Token type, use char* and loose data when buffer destroyed

2011-09-27 Thread Douglas Godfrey
problem with a function to eliminate the duplicate quotes. On 9/27/11 6:34 PM, Ruslan Zasukhin ruslan_zasuk...@valentina-db.com wrote: On 9/28/11 12:46 AM, Douglas Godfrey douglasgodf...@gmail.com wrote: Hi Douglas, Yes, I have thinked about this way also. But in your solution you use helper

[il-antlr-interest: 34148] Re: [antlr-interest] Custom object tree from tree parser?

2011-09-25 Thread Douglas Godfrey
I have built a parser that directly emitted XML. The XML was then passed to a XML treewalker. Emitting XML from the parser instead of an Antlr common tree structure is quite simple to do. On 9/25/11 9:32 AM, Jeremy Long jeremy.l...@gmail.com wrote: Mari, Did you ever get an answer to this? I

[il-antlr-interest: 34092] [antlr-interest] Antlr AntlrWorks feature request

2011-09-17 Thread Douglas Godfrey
How about an Antlr option to export the AST as an XML file at the end of a successful parse and an AntlrWords option to get the AST from Antlr when Generate is done. List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe:

[il-antlr-interest: 34022] Re: [antlr-interest] For getCharPositionInLine(), is there a way to make tab count for 8 chars instead of 1?

2011-09-13 Thread Douglas Godfrey
frontend Antlr with a preprocessing step that expands TAB characters to the desired tab stop size then pass the processed text to the lexer and all column positions will be correct. On 9/8/11 1:23 PM, Sam Harwell sharw...@pixelminegames.com wrote: I actually asked Dr. Parr recently about why the

[il-antlr-interest: 34023] Re: [antlr-interest] ANTLRWorks 2 (for ANTLR v4)

2011-09-13 Thread Douglas Godfrey
specify the appropriate error message. Ter On Sep 8, 2011, at 5:45 AM, Douglas Godfrey wrote: How about a direct language feature to issue a warning or error on parsing a rule... I.e. you have a grammar where certain improper syntax is expected. You make a rule that will recognize

[il-antlr-interest: 34024] Re: [antlr-interest] ANTLRWorks 2 (for ANTLR v4)

2011-09-13 Thread Douglas Godfrey
The Netbeans integration module that is available on the Netbeans Pluggin site has not been maintained and does not install on Netbeans 6.9 or later releases. On 9/9/11 2:57 PM, Terence Parr pa...@cs.usfca.edu wrote: On Sep 9, 2011, at 5:45 AM, Andreas Stefik wrote: On the last point from

[il-antlr-interest: 33913] Re: [antlr-interest] ANTLRWorks 2 (for ANTLR v4)

2011-09-06 Thread Douglas Godfrey
1) Extend the Refactor:RemoveLeftRecursion function to either assist in removing or automatically remove left recursion loops that involve more than 1 rule 2) Tighter integration between AntlrWorks and Antlr to report the source of ambiguities found during code generation and resolve them 3)

[il-antlr-interest: 33201] Re: [antlr-interest] Hi! about making a target for ANTLR

2011-07-16 Thread Douglas Godfrey
How about a generalized Antlr Target builder based on a TreeParser grammar that processes the AST generated by Antlr that uses String Templates to emit the source code for the target language. The task of building a new target then is reduced to completing the String Template productions and

[il-antlr-interest: 33132] Re: [antlr-interest] Can one identify the type of parser needed for a given BNF grammar

2011-07-12 Thread Douglas Godfrey
You can always resolve an inline declaration like the one below either by the syntax of the statement or by the SymbolTable or by the default rule that ambiguous statements that look like a declaration are a declaration. The SymbolTable is required but an AST and TreeParser is not. TBuffer(123)

[il-antlr-interest: 33111] Re: [antlr-interest] Can one identify the type of parser needed for a given BNF grammar

2011-07-11 Thread Douglas Godfrey
Antlr plus a SymbolTable is much more powerful and expressive than Antlr alone. I believe that C++ CAN be parsed by Antlr if you have a good set of SymbolTable classes. All of the constructor vs function and namespace ambiguities as well as templates and inheritance can be resolved by the

[il-antlr-interest: 33123] Re: [antlr-interest] Can one identify the type of parser needed for a given BNF grammar

2011-07-11 Thread Douglas Godfrey
When I converted the ISO SQL grammar from EBNF to Antlr, I handled multiple alternate character set rules by using semantic predicates in the Lexer. The rule for a SQL Identifier has 8 variations depending on which SQL variant you are parsing [each has a predicate]. The same predicate functions

[il-antlr-interest: 33128] Re: [antlr-interest] Can one identify the type of parser needed for a given BNF grammar

2011-07-11 Thread Douglas Godfrey
For some time I have been proposing that a full function SymbolTable class be added to Antlr itself and made available as direct operations in the Antlr grammar. Instead of having to use target language specific productions, you would use target language independent SymbolTable class functions

[il-antlr-interest: 32953] Re: [antlr-interest] ANTLRWorks Interpreter

2011-06-25 Thread Douglas Godfrey
The SQL2003 grammar requires a 64bit OS and Java and 8GB of heap to run at all. See the comments at the beginning of the Sql2003Parser.g file. On Sat, Jun 25, 2011 at 4:25 PM, Mike Kappel mkap...@appfluent.com wrote: I just downloaded ANTLRWorks and tried the example expression grammar. I

[il-antlr-interest: 32923] Re: [antlr-interest] Match a repetition of characters

2011-06-24 Thread Douglas Godfrey
underline returns [char symbol] : underlineAtom {$symbol=$underlineAtom.text} {$symbol}+ LINE_BREAK ; underlineAtom : ( UNDERSCORE UNDERSCORE UNDERSCORE UNDERSCORE+ ) | ( STAR STAR STAR STAR+ ) | ( PIPE PIPE PIPE PIPE+ ) | ( BACKTICK BACKTICK BACKTICK BACKTICK+ ) | ( COLUMN COLUMN COLUMN

[il-antlr-interest: 32825] Re: [antlr-interest] Question: ANTLR and LLVM ... + Clang

2011-06-18 Thread Douglas Godfrey
The SemanticDesigns C++ frontend, like all of their frontend(s) is intended for code analysis and transformation, not compiling. Semantic Designs' tools are based on the old Reasoning Systems Inc. tools: Refine and Intervista. Semantic Designs' tools parse a source language into an Symbol Table

[il-antlr-interest: 32710] Re: [antlr-interest] [CSharp3] rule visibility in composite grammars

2011-06-09 Thread Douglas Godfrey
then declare a user-definable method with the appropriate parameter types. The Java and CSharp2 targets could create an abstract method, the CSharp3 target could create a partial method, and a C/C++ targets could declare the method in a generated header. Sam *From:* Douglas Godfrey

[il-antlr-interest: 32694] Re: [antlr-interest] [CSharp3] rule visibility in composite grammars

2011-06-07 Thread Douglas Godfrey
2 months ago I submitted a feature request for an Antlr built-in symbol table to support the common requirements of the majority of block-structured languages. By making the SymbolTable part of the Antlr grammar language the interface can be much cleaner. The implementation of the SymbolTable

[il-antlr-interest: 32662] Re: [antlr-interest] New Guy Question...

2011-06-05 Thread Douglas Godfrey
You have to handle case insensitivity the hard way: fragment A :'A' | 'a'; fragment B :'B' | 'b'; fragment C :'C' | 'c'; fragment D :'D' | 'd'; fragment E :'E' | 'e'; fragment F :'F' | 'f'; fragment G :'G' | 'g'; fragment H :

[il-antlr-interest: 32642] Re: [antlr-interest] Accentuated chars in brazilian portuguese

2011-06-02 Thread Douglas Godfrey
Lookup the latin Unicode code pages on Wikipedia and add the Unicode code points for accented Latin1 to your rule WORD. fragmen Latin1_Supplement : '\u00A0' .. '\u00FF'; fragment Latin_ExtendedA : '\u0100' .. '\u017F'; fragment Latin_ExtendedB

[il-antlr-interest: 32421] [antlr-interest] Feature Request - Visualize the Parse Graph for multiple rules by Rule Decisions and Tokens consumed

2011-05-09 Thread Douglas Godfrey
Feature Request: A way to visualize the Parse Graph of a grammar by the sequence of Tokens consumed by the rules. The Parse Graph should be generated by selecting a rule or rule decision and using the contextual menu or the Grammar menu. The root of the Parse Graph should be the start of the

[il-antlr-interest: 32354] [antlr-interest] AntlrWorks feature request

2011-05-01 Thread Douglas Godfrey
Please add an option for AntlrWorks [and Antlr called by AntlrWorks] to use the 64bit Java run-time. On Mac OS X 10.5 or later use -d64 on the Antlr command line before -jar or add JVMArchs to the Java section of the AntlrWorks info.plist file: keyJava/key dict keyClassPath/key

[il-antlr-interest: 32255] Re: [antlr-interest] sql 2003 grammars

2011-04-19 Thread Douglas Godfrey
You need to specify the heap size separately for both AntlrWorks and for Antlr [when it is run by AntlrWorks] specify -Xms128m -Xmx1G on the Java command line for invoking AntlrWorks specify -Xms128m -Xmx1G in AntlrWorks::Preferences::General::ANTLR_options see

[il-antlr-interest: 31736] [antlr-interest] Question about the cost of implementing case insensitivity in an Antlr Lexer

2011-03-05 Thread Douglas Godfrey
What is the relative cost for implementing case insensitive lexer tokens [as shown below] versus case sensitive tokens? // case sensitive keywords GRAPH: 'GRAPH'; DIGRAPH: 'DIGRAPH'; STRICT: 'STRICT'; NODE: 'NODE'; EDGE: 'EDGE'; SUBGRAPH: 'SUBGRAPH'; // case-insensitive keywords GRAPH: G R A P

[il-antlr-interest: 31681] [antlr-interest] Question: how to increase max heap size for AntlrWorks on Mac OS X

2011-03-01 Thread Douglas Godfrey
I have tried several methods to increase the Heap size for AntlrWorks but none of them have worked. AntlrWorks Preferences:General:Antlr options = [ -Xms128m -Xmx1024m ] AntlrWorks-1.4.2.app/Contents/Info.plist Plist entry: Root:Java:VMOptions:-Xms [String] = 128m Plist entry:

[il-antlr-interest: 31683] [antlr-interest] AntlrWorks Feature Request

2011-03-01 Thread Douglas Godfrey
Add an AntlrWorks Options field to the General Tab of AntlrWorks's preferences dialog. When the user clicks apply, set the VMOptions value in AntlrWorks info.plist file. i.e. AntlrWorks Options string = -Xms1G Info.plist file VMOptions value set to the following: ?xml version=1.0

[il-antlr-interest: 31657] [antlr-interest] Bug in AntlrWorks 1.4.2

2011-02-28 Thread Douglas Godfrey
A set of rules have mutual left recursion. The rules are all copied into one contiguous set in one place in the grammar file so they can be refactored. The original rules are all commented out using /* */. AntlrWorks reports the mutual recursion errors for the original [commented out] rules and

[il-antlr-interest: 31660] [antlr-interest] Another pair of bug in AntlrWorks 1.4.2

2011-02-28 Thread Douglas Godfrey
1) with a somewhat large grammar [8K lines] grammar, AntlrWorks sometimes gets lost when processing edit:undo and undoes the wrong lines. 2) with the same grammar after 20-30 cutpaste operations, syntax highlighting becomes garbled with partially highlighted tokens. List:

[il-antlr-interest: 31638] [antlr-interest] strange bug in AntlrWorks

2011-02-26 Thread Douglas Godfrey
I have a large combined grammar for SQL:2003 that I have just converted from the ISO BNF grammar. When I put the cursor over a Parser rule I get the normal syntax diagram. When I put the cursor over a Lexer rule I get the message: Cannot display rule because start state not found. The

[il-antlr-interest: 31615] [antlr-interest] Can Antlr use a variable in a lexer pattern?

2011-02-25 Thread Douglas Godfrey
in the snippet below, can escape_character be a variable? it seems that this would not work because the escape_character is not known until it is too late. the alternate form below might work if the Antlr Lexer can use a variable in the pattern match. can the lexer apply the escape character as a

[il-antlr-interest: 31624] [antlr-interest] AntlrWorks FEATURE REQUEST

2011-02-25 Thread Douglas Godfrey
Please add an option to turn off the parse as you type syntax checking with a toolbar button to refresh the parse. When I am converting a grammar from BNF to Antlr the grammar may start out with thousands of errors. AntlrWorks GUI becomes unresponsive if the errors cause an exception in the

[il-antlr-interest: 31592] Re: [antlr-interest] ast rewrites in left-recursive rules

2011-02-24 Thread Douglas Godfrey
Each parse state where a binary operator is encountered there must be a left and right sub-expression. For the Antlr grammar something like $lhs and $rhs would be a natural expression of these sub-expressions: e : ( e '.' ID- ^( '.' e ID) | e '.' 'this'- ^( '.' e

[il-antlr-interest: 31477] Re: [antlr-interest] what would ANTLR ref guide revised edition have?

2011-02-16 Thread Douglas Godfrey
How about an example Symbol Table class that can handle C++ or Java style languages with nested scopes and drill down access to nested classes via name spaces and compound names. On Tue, Feb 15, 2011 at 6:36 PM, Terence Parr pa...@cs.usfca.edu wrote: Howdy. I'm thinking about revising the ref

[il-antlr-interest: 30461] [antlr-interest] return value struct from start rule not generated when OUTPUT=AST not specified

2010-11-03 Thread Douglas Godfrey
The following code does not generate the return value struct for the start rule: robotC_Parser_robotC_parser_return_struct. The return value XmlNodeTreePtr cannot be accessed by the main program. If output=AST is specified, the return value struct is generated and un-needed code is also generated

[il-antlr-interest: 30452] [antlr-interest] Decision can match input such as ... using multiple alternatives / Semantic predicates were present but were hidden by actions.

2010-11-01 Thread Douglas Godfrey
The warning Semantic predicates were present but were hidden by actions. is issued without any line# if any rule has a semantic predicate before the first token and the predicate is preceeded by any action. In a large grammar this can be very difficult to locate. This message is also incorrect

[il-antlr-interest: 30141] [antlr-interest] how to find the grammar line in error for [error(104): cannot find an attribute name in attribute declaration]

2010-09-13 Thread Douglas Godfrey
I get multiple instances of error 104 followed by a crash whenever I try to generate my grammar. The grammar is 1200 lines and uses many rule input and return values. How do I identify the line that is causing the error. [02:48:17] error(104): cannot find an attribute name in attribute