context [/report INTERNAL_ERROR] 1:17 attribute arg isn't defined
error(20): internal error:
grammar Hask;
////////////////Syntax Rulesprog : stat+;
stat : decFunc NL | impFunc NL ;
decFunc : expr ;
expr : ID '::' dec;
dec : ('[' 'Int' ']' | '[' '[' 'Int' ']' ']') ARROW | dec ;
impFunc : ID+ '=' hr;
hr : 'map' '(' hr INT ')' hr | 'zipWith' '(' ( '*' | '/' | '+' | '-' ) ')' | 'foldr1' '(' ( '*' | '/' | '+' | '-' ) ')' | hr op=('*'| '/') hr | hr op=('+'| '-') hr | '(' hr ')' | ID ;
/////////////Lex Rules
NL : '\r'? '\n' ; INT : [0-9]+ ; WS : [ \t]+ -> skip ;ID : [a-zA-Z]+ ; MUL : '*' ; DIV : '/' ;ADD : '+' ;SUB : '-' ;ARROW : '->' ;hi I got this Error when I used ANTLR and I tried for hours to fix it. I hope some one could help.
context [/report INTERNAL_ERROR] 1:17 attribute arg isn't defined
error(20): internal error:
my Grammar
grammar Hask;////////////////Syntax Rulesprog : stat+;stat : decFunc NL| impFunc NL;decFunc : expr ;expr : ID '::' dec;dec : ('[' 'Int' ']' | '[' '[' 'Int' ']' ']') ARROW| dec;impFunc : ID+ '=' hr;hr : 'map' '(' hr INT ')' hr
| 'zipWith' '(' SYM ')'| 'foldr1' '(' SYM ')'
| hr op=('*'| '/') hr| hr op=('+'| '-') hr| '(' hr ')'| ID;/////////////Lex RulesNL : '\r'? '\n' ;INT : [0-9]+ ;
SYM : '*' | '/' | '+' | '-';
WS : [ \t]+ -> skip ;ID : [a-zA-Z]+ ;MUL : '*' ;DIV : '/' ;ADD : '+' ;SUB : '-' ;ARROW : '->' ;
--
Thank you
You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
('[' 'Int' ']' | '[' '['
'Int' ']' ']') ARROW ;
and so you have infinitely many empty defs ending with a
single phrase. infinite recursion.
Hope this helps....
-jbb
prog : stat+;
stat : decFunc | impFunc ;
decFunc : ID '::' singleIn+ NL;
singleIn : 'Int'
|'[' 'Int' ']'
| '[' '[' 'Int' ']' ']'
| ('[' 'Int' ']' ARROW)
| ('[' '[' 'Int' ']' ']' ARROW)
;
impFunc : ID+ '=' hr NL;
hr : 'map' '(' ID* ')' ID*
| 'zipWith' '(' ('*' |'/' |'+' |'-') ')' ID+
| 'foldr' '(' ('*' |'/' |'+' |'-') ')' ID+
| hr op=('*'| '/') hr
| hr op=('+'| '-') hr
| '(' hr ')'
| ID '(' ID* ')'
;
Thank you,
Thank you jbb.I fixed the grammar. However, I wonder. How to check the previous line of code. For example0 myFunction :: Int -> Int1 myFunction x = x+3
I have a function declaration that has a name (myFunction), one Int input, and one Int output. When I parse the next line #1 how check the name of the function and that it has only one variable which is x.
this is my improved grammar:
prog : stat+;
stat : decFunc | impFunc ;
decFunc : ID '::' singleIn+ NL;
singleIn : 'Int'
|'[' 'Int' ']'
| '[' '[' 'Int' ']' ']'
| ('[' 'Int' ']' ARROW)
| ('[' '[' 'Int' ']' ']' ARROW)
;
impFunc : ID+ '=' hr NL;
hr : 'map' '(' ID* ')' ID*
| 'zipWith' '(' ('*' |'/' |'+' |'-') ')' ID+
| 'foldr' '(' ('*' |'/' |'+' |'-') ')' ID+
| hr op=('*'| '/') hr
| hr op=('+'| '-') hr
| '(' hr ')'
| ID '(' ID* ')'
;
Thank you,
--
You received this message because you are subscribed to a topic in the Google Groups "antlr-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/antlr-discussion/PpdEcOBIlqQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to antlr-discussi...@googlegroups.com.
You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussi...@googlegroups.com.
To unsubscribe from this group and all its topics, send an email to antlr-discussion+unsubscribe@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussion+unsubscribe@googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "antlr-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/antlr-discussion/PpdEcOBIlqQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to antlr-discussion+unsubscribe@googlegroups.com.
To unsubscribe from this group and all its topics, send an email to antlr-discussi...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussi...@googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "antlr-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/antlr-discussion/PpdEcOBIlqQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to antlr-discussi...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussi...@googlegroups.com.
Hi All,
I’m working on a C# Project using Antlr 4 and StringTemplate 4. The Antlr 4 stuff is working like a charm, but my question is related to the StringTemplate stuff. Sorry if I’m posting on the wrong list…
I want to put several template files on a directory named "Templates", relative to the executable of my application, and use them. One template file, for instance, is named "CGlobals.stg".
That way, I created a TemplateGroupDirectory and loaded the template:
var group = new TemplateGroupDirectory("Templates");
var tmpl = group.GetInstanceOf("CGlobals");
On trying to get the instance of the template I've got a message saying that occurs a NullReferenceException.
The CGlobals.stg contains:
// Global definitions
CGlobals(date,name,device) ::=
<<
// Some code here…
>>
What am I missing?
TIA,
Nilo Paim
Thanks the prompt answer, Ter.
I changed the original code, supplying the complete path to the directory.
Anyway, same error… stack trace follows…
em Antlr4.StringTemplate.TemplateGroup.LoadTemplateFile(String prefix, String unqualifiedFileName, ICharStream templateStream) na c:\dev\stringtemplate_main\antlrcs\main\Antlr4.StringTemplate\TemplateGroup.cs:linha 974
em Antlr4.StringTemplate.TemplateGroupDirectory.LoadTemplateFile(String prefix, String unqualifiedFileName) na c:\dev\stringtemplate_main\antlrcs\main\Antlr4.StringTemplate\TemplateGroupDirectory.cs:linha 239
em Antlr4.StringTemplate.TemplateGroupDirectory.Load(String name) na c:\dev\stringtemplate_main\antlrcs\main\Antlr4.StringTemplate\TemplateGroupDirectory.cs:linha 168
em Antlr4.StringTemplate.TemplateGroup.LookupTemplate(String name) na c:\dev\stringtemplate_main\antlrcs\main\Antlr4.StringTemplate\TemplateGroup.cs:linha 396
em Antlr4.StringTemplate.TemplateGroup.GetInstanceOf(String name) na c:\dev\stringtemplate_main\antlrcs\main\Antlr4.StringTemplate\TemplateGroup.cs:linha 312
em DDLCompiler.DDLCompiler.DoCompilation(AntlrInputStream input) na D:\CTS\DDLCompiler\DDLCompiler\DDLCompiler.cs:linha 71
em DDLCompiler.DDLCompiler.Compile(RichTextBox txtbox) na D:\CTS\DDLCompiler\DDLCompiler\DDLCompiler.cs:linha 36
em DDLStudio.Form1.button1_Click(Object sender, EventArgs e) na D:\CTS\DDLCompiler\DDLStudio\Form1.cs:linha 22
em System.Windows.Forms.Control.OnClick(EventArgs e)
em System.Windows.Forms.Button.OnClick(EventArgs e)
em System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
em System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
em System.Windows.Forms.Control.WndProc(Message& m)
em System.Windows.Forms.ButtonBase.WndProc(Message& m)
em System.Windows.Forms.Button.WndProc(Message& m)
em System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
em System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
em System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
em System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
em System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
em System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
em System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
em System.Windows.Forms.Application.Run(Form mainForm)
em DDLStudio.Program.Main() na D:\CTS\DDLCompiler\DDLStudio\Program.cs:linha 18
em System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
em System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
em Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
em System.Threading.ThreadHelper.ThreadStart_Context(Object state)
em System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
em System.Threading.ThreadHelper.ThreadStart()
TIA,
Nilo
P.S.: I’m a big fan of Antlr since version 2. Congrats on this great piece of software. Thanks to Sam and others too.
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2015.0.5941 / Virus Database: 4342/9816 - Release Date: 05/19/15