[antlr-interest] Grammar for Predicate Logic (FOL)

Stephan Opfer stephan.opfer at gmx.net
Thu Apr 19 14:37:21 PDT 2012


Oh! Thanks Jim! That was easy :)

On 04/19/2012 11:16 PM, Jim Idle wrote:
> language=Java; // Case sensitive.
> 
> Jim
> 
>> -----Original Message-----
>> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
>> bounces at antlr.org] On Behalf Of Stephan Opfer
>> Sent: Thursday, April 19, 2012 1:41 PM
>> To: antlr-interest at antlr.org
>> Subject: [antlr-interest] Grammar for Predicate Logic (FOL)
>>
>> Hi ANTLR Community,
>>
>> I need a grammar for first order logic fomulas. I thought I could find
>> one on the antlr website, but I didnt. So now I started to write one by
>> myself and got some errors by antlrworks (version 1.4.3, java
>> openjdk7):
>>
>> [22:39:03] error(10):  internal error: /home/user/Desktop/FOL.g :
>> java.lang.IllegalArgumentException: No such group file:
>> org/antlr/codegen/templates/java/java.stg
>> org.stringtemplate.v4.STGroupFile.<init>(STGroupFile.java:69)
>> org.stringtemplate.v4.STGroupFile.<init>(STGroupFile.java:48)
>> org.antlr.codegen.CodeGenerator.loadTemplates(CodeGenerator.java:186)
>> org.antlr.codegen.CodeGenerator.genRecognizer(CodeGenerator.java:283)
>> org.antlr.Tool.generateRecognizer(Tool.java:655)
>> org.antlr.Tool.process(Tool.java:468)
>> org.antlr.works.generate.CodeGenerate.generate(CodeGenerate.java:104)
>> org.antlr.works.debugger.local.DBLocal.generateGrammar(DBLocal.java:398
>> )
>> org.antlr.works.debugger.local.DBLocal.generateAndCompileGrammar(DBLoca
>> l.java:372)
>> org.antlr.works.debugger.local.DBLocal.run(DBLocal.java:222)
>> java.lang.Thread.run(Thread.java:722)
>>
>>
>> My first order grammar should support everything except quantifiers:
>>
>> grammar FOL;
>>
>> options{
>> 	language=java;
>> 	output=AST;
>> }
>>
>> tokens{
>> 	LPAREN='(';
>> 	RPAREN= ')';
>> 	AND= '&';
>> 	OR= '|';
>> 	NOT= '!';
>> }
>>
>> /*------------------------------------------------------------------
>>  * PARSER RULES
>>  *------------------------------------------------------------------*/
>>
>> condition: formula EOF!;
>>
>> formula: disjunction (AND^ disjunction)*;
>>
>> disjunction: element (OR^ element)*;
>>
>> element	: predicate
>> 	| NOT^? LPAREN! formula RPAREN!
>> 	;
>>
>> predicate
>> 	: ID TUPLE
>> 	| NOT^ ID TUPLE
>> 	| CONSTANT
>> 	| NOT^ CONSTANT;
>>
>> /*------------------------------------------------------------------
>>  * LEXER RULES
>>  *------------------------------------------------------------------*/
>>
>> VARIABLE: '?' CHARACTER+;
>>
>> CONSTANT: ('a'..'z') CHARACTER*;
>>
>> ID: ('A'..'Z') CHARACTER*;
>>
>> TUPLE: LPAREN (CONSTANT | VARIABLE) (','(CONSTANT | VARIABLE))* RPAREN;
>>
>> CHARACTER: ('0'..'9' | 'a'..'z' | 'A'..'Z' | '_');
>>
>> WS : (' ' | '\t' | '\r' | '\n')+ {$channel = HIDDEN;};
>>
>> Do someone have a clue, why I get this error? I would provide this
>> grammar to the community, if it is finished.
>>
>> Best Regards,
>>   Stephan
>>
>> 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
> 



More information about the antlr-interest mailing list