Hi,
I'm new user into this group and i have a problem.
I'm update to version 3.0 from 3.1.1 a grammar, and the same grammar
file have a problem.
The 3.1.1 generate C# code return the following error:
error(208): C:\Projects\C_Sharp\Test_Parse_New\Test_Parse\grammatica
\test.g:172:1: The following token definitions can never be matched
because prior tokens match the same input:
PUNTOVIRGOLA,VARIABILENUMERO,VARIABILESTRINGA
but with 3.0 generation code return only a warning.
This grammar should identify the following expression type:
XESCTIPSC EQ 221 ; 222 ; 224 ; 225
(XXCAMPO > 25 AND (XXFILIALE = 000 OR XXFILIALE > 200 ))
Can you help me?
Thanks.
dvign72
GRAMMAR FILE
grammar test;
options
{
output = AST;
ASTLabelType = CommonTree;
backtrack = true;
language = CSharp2;
k=1 ;
}
tokens {
GT = '>';
GT1 = 'GT';
LT = '<';
LT1 = 'LT';
EQ = '=';
EQ1 = 'EQ';
GE = '>=';
GE1 = 'GE';
LE = '<=';
LE1 = 'LE';
NE = '!=';
NE1 = 'NE';
APRITONDA = '(';
CHIUDITONDA = ')';
PUNTOVIRG = ';';
}
@lexer::namespace
{
ts.lexer
}
@parser::namespace
{
ts.parser
}
@members {
ArrayList exceptions = new ArrayList();
public override void ReportError(RecognitionException e)
{
exceptions.Add(e);
}
public bool HasError
{
get { return exceptions.Count > 0; }
}
public string ErrorMessage
{
get
{
if (HasError)
return this.GetErrorMessage(exceptions[0] as
RecognitionException,
this.TokenNames);
return "";
}
}
public string ErrorPosition
{
get
{
if (HasError)
return this.GetErrorHeader(exceptions[0] as
RecognitionException);
return "";
}
}
}
@header {
using System.Text;
}
expr : sequenza EOF!
{Console.WriteLine("fine sequenza");}
; //!significa : non imporatre nell'albero sintattico
AND : 'AND'
;
OR : 'OR'
;
sequenza : requisito (AND^ requisito)* (OR^ sequenza)*
{Console.WriteLine("sequenza");}
;
requisito : CAMPO operatore^ VARIABI {Console.WriteLine
("requisito");}
| CAMPO operatoreeq^ VARIABILE
{Console.WriteLine("requisito eq
");}
| APRITONDA! sequenza CHIUDITONDA!
{Console.WriteLine("requisito tonda");}
;
operatore : GT {Console.WriteLine("Operatore GT");}
| GT1 {Console.WriteLine("Operatore
GT1");}
| LT {Console.WriteLine("Operatore
LT");}
| LT1 {Console.WriteLine("Operatore
LT1");}
| GE {Console.WriteLine("Operatore
GE");}
| GE1 {Console.WriteLine("Operatore
GE1");}
| LE {Console.WriteLine("Operatore
LE");}
| LE1 {Console.WriteLine("Operatore
LE1");}
| NE {Console.WriteLine("Operatore
NE");}
| NE1 {Console.WriteLine("Operatore
NE1");}
| EQ {Console.WriteLine("Operatore
QE");}
| EQ1 {Console.WriteLine("Operatore
QE1");}
;
operatoreeq : NE {Console.WriteLine("Operatore NE");}
| NE1 {Console.WriteLine("Operatore
NE1");}
| EQ {Console.WriteLine("Operatore
QE");}
| EQ1 {Console.WriteLine("Operatore
QE1");}
;
PUNTOVIRGOLA : PUNTOVIRG
{Console.WriteLine("PUNTOVIRGOLA");}
;
// Definisco i CAMPI (alfabetici)
CAMPO : (CHAR)+
{Console.WriteLine("CAMPO");}
;
// Definisco le VARIABILI (alfanumeriche)
VARIABILE : VARIABI (PUNTOVIRGOLA VARIABI)+
{Console.WriteLine("VARIABILE");}
;
VARIABI : (' ')* VARIABILENUMERO (' ')*
{Console.WriteLine("VARIABI-N");}
| (' ')* VARIABILESTRINGA (' ')*
{Console.WriteLine("VARIABI-S");}
;
VARIABILENUMERO : (NUMERO)+
{Console.WriteLine("VARIABILENUMERO");}
;
VARIABILESTRINGA : '\''(CHAR)+'\''
{Console.WriteLine("VARIABILESTRINGA");}
;
// Definisco gli elementi base
fragment NUMERO : '0'..'9'
//
{Console.WriteLine("NUMERO");}
;
fragment CHAR : 'A'..'Z'
//
{Console.WriteLine("CHAR");}
;
WS : (' '|'\r'|'\t'|'\u000C'|'\n') {$channel=HIDDEN;}
{Console.WriteLine("HIDDEN");}
;
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---