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
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:
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
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
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
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
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
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
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
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:
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
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
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
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)
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
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)
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
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
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
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
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
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
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
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
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
:
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
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
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
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
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
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:
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
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
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:
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
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
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
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
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
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
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
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
42 matches
Mail list logo