org.sweble.wikitext.lazy.parser.State.rats Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of swc-parser-lazy Show documentation
Show all versions of swc-parser-lazy Show documentation
A parser for MediaWiki's Wikitext.
/**
* Copyright 2011 The Open Source Research Group,
* University of Erlangen-Nürnberg
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*!
*
* State
* -----
*
* Manage parser state.
*
*/
module org.sweble.wikitext.lazy.parser.State;
import org.sweble.wikitext.lazy.utils.StateAwareMemoization;
import org.sweble.wikitext.lazy.utils.Trickery;
// -- Header / Body / Footer ---------------------------------------------------
body
{
static final int noEolScopes;
static
{
int sc = 0;
for (ParserScopes s : ParserScopes.values())
{
if (s.isNoEolScope())
sc |= 1 << s.ordinal();
}
noEolScopes = sc;
}
// ===========================================================================
public LazyParserState getState()
{
return yyState;
}
private LazyParserContext getContext()
{
return getState().getTop();
}
public AstNode getEntity(int id)
{
return getState().getEntity(id);
}
// ===========================================================================
private boolean acceptEol()
{
return 0 == (noEolScopes & getContext().getStickingScopes());
}
private boolean accept(ParserAtoms atom)
{
return getState().accepts(atom);
}
private void enter(ParserScopes scope)
{
getState().setScope(scope);
}
private boolean inScope(ParserScopes scope)
{
return getState().inScope(scope);
}
// ===========================================================================
private boolean isWarningsEnabled()
{
return getState().isWarnignsEnabled();
}
private boolean isAutoCorrect(WarningSeverity severity)
{
return getState().isAutoCorrect() && isWarningLevelEnabled(severity);
}
private boolean isWarningLevelEnabled(WarningSeverity severity)
{
return getState().getConfig().isWarningLevelEnabled(severity);
}
@SuppressWarnings("unused")
private boolean isValidXmlEntityRef(String name)
{
return getState().getConfig().isValidXmlEntityRef(name);
}
private boolean isMagicWord(String word)
{
return getState().getConfig().isMagicWord(word);
}
}
option stateful(LazyParserState);
// -- End of file --------------------------------------------------------------