LightJason - AgentSpeak(L++)
CParserAgent.java
Go to the documentation of this file.
1 /*
2  * @cond LICENSE
3  * ######################################################################################
4  * # LGPL License #
5  * # #
6  * # This file is part of the LightJason AgentSpeak(L++) #
7  * # Copyright (c) 2015-19, LightJason (info@lightjason.org) #
8  * # This program is free software: you can redistribute it and/or modify #
9  * # it under the terms of the GNU Lesser General Public License as #
10  * # published by the Free Software Foundation, either version 3 of the #
11  * # License, or (at your option) any later version. #
12  * # #
13  * # This program is distributed in the hope that it will be useful, #
14  * # but WITHOUT ANY WARRANTY; without even the implied warranty of #
15  * # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
16  * # GNU Lesser General Public License for more details. #
17  * # #
18  * # You should have received a copy of the GNU Lesser General Public License #
19  * # along with this program. If not, see http://www.gnu.org/licenses/ #
20  * ######################################################################################
21  * @endcond
22  */
23 
24 package org.lightjason.agentspeak.grammar;
25 
27 
28 import javax.annotation.Nonnull;
29 import java.io.InputStream;
30 import java.util.Set;
31 
32 
36 public final class CParserAgent extends IBaseParser<IASTVisitorAgent, AgentLexer, AgentParser>
37 {
41  private final Set<IAction> m_actions;
42 
49  public CParserAgent( @Nonnull final Set<IAction> p_actions ) throws NoSuchMethodException
50  {
51  super( new CErrorListener() );
52  m_actions = p_actions;
53  }
54 
55  @Nonnull
56  @Override
57  public final IASTVisitorAgent parse( final InputStream p_stream ) throws Exception
58  {
59  final IASTVisitorAgent l_visitor = new CASTVisitorAgent( m_actions );
60  l_visitor.visit( this.parser( p_stream ).agent() );
61  return l_visitor;
62  }
63 
64  @Override
65  protected final Class<AgentLexer> lexerclass()
66  {
67  return AgentLexer.class;
68  }
69 
70  @Override
71  protected final Class<AgentParser> parserclass()
72  {
73  return AgentParser.class;
74  }
75 
76 }
CParserAgent( @Nonnull final Set< IAction > p_actions)
ctor
final IASTVisitorAgent parse(final InputStream p_stream)
final Set< IAction > m_actions
set with actions
AntLR error lister to catch parser and lexer errors with individual error handling and language trans...
visitor interface of the abstract-syntax-tree (AST) for an agent
default abstract-syntax-tree (AST) visitor for agent scripts
external action interface
Definition: IAction.java:38
final Class< AgentParser > parserclass()
final P parser(@Nonnull final InputStream p_stream)
returns a parser component