public class BParser
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
EXPRESSION_PREFIX |
static java.lang.String |
FORMULA_PREFIX |
static java.lang.String |
OPERATION_PATTERN_PREFIX |
static java.lang.String |
PREDICATE_PREFIX |
static java.lang.String |
SUBSTITUTION_PREFIX |
Constructor and Description |
---|
BParser() |
BParser(java.lang.String fileName) |
BParser(java.lang.String fileName,
ParseOptions parseOptions) |
Modifier and Type | Method and Description |
---|---|
Start |
eparse(java.lang.String input,
IDefinitions context) |
int |
fullParsing(java.io.File bfile,
ParsingBehaviour parsingBehaviour,
java.io.PrintStream out,
java.io.PrintStream err) |
static java.lang.String |
getBuildRevision() |
IDefinitionFileProvider |
getContentProvider() |
IDefinitions |
getDefinitions() |
java.util.List<java.lang.String> |
getDoneDefFiles() |
java.lang.String |
getFileName() |
static java.lang.String |
getGitSha() |
ParseOptions |
getOptions() |
static java.lang.String |
getVersion() |
static Start |
parse(java.lang.String input)
Use this method, if you only need to parse small inputs.
|
Start |
parse(java.lang.String input,
boolean debugOutput)
Like
parse(String, boolean, IFileContentProvider) , but with
NoContentProvider as last parameter, i.e., loading of referenced
files is not enabled. |
Start |
parse(java.lang.String input,
boolean debugOutput,
IFileContentProvider contentProvider)
Parses the input string.
|
Start |
parseExpression(java.lang.String input) |
Start |
parseFile(java.io.File machineFile,
boolean verbose)
Parses the input file.
|
Start |
parseFile(java.io.File machineFile,
boolean verbose,
IFileContentProvider contentProvider)
Parses the input file.
|
Start |
parseFormula(java.lang.String input) |
Start |
parsePredicate(java.lang.String input) |
Start |
parseSubstitution(java.lang.String input) |
Start |
parseTranstion(java.lang.String input) |
static void |
printASTasProlog(java.io.PrintStream out,
BParser parser,
java.io.File bfile,
Start tree,
ParsingBehaviour parsingBehaviour,
IDefinitionFileProvider contentProvider) |
void |
setDefinitions(IDefinitions definitions) |
void |
setDirectory(java.io.File directory) |
void |
setDoneDefFiles(java.util.List<java.lang.String> doneDefFiles) |
void |
setParseOptions(ParseOptions options) |
public static final java.lang.String EXPRESSION_PREFIX
public static final java.lang.String PREDICATE_PREFIX
public static final java.lang.String FORMULA_PREFIX
public static final java.lang.String SUBSTITUTION_PREFIX
public static final java.lang.String OPERATION_PATTERN_PREFIX
public BParser()
public BParser(java.lang.String fileName)
public BParser(java.lang.String fileName, ParseOptions parseOptions)
public static java.lang.String getVersion()
public static java.lang.String getGitSha()
public IDefinitionFileProvider getContentProvider()
public static void printASTasProlog(java.io.PrintStream out, BParser parser, java.io.File bfile, Start tree, ParsingBehaviour parsingBehaviour, IDefinitionFileProvider contentProvider) throws BCompoundException
BCompoundException
public Start parseFile(java.io.File machineFile, boolean verbose) throws java.io.IOException, BCompoundException
machineFile
- the machine file to be parsedverbose
- print debug informationjava.io.IOException
- if the file cannot be readBCompoundException
- if the file cannot be parsedparse(String, boolean, IFileContentProvider)
public Start parseFile(java.io.File machineFile, boolean verbose, IFileContentProvider contentProvider) throws java.io.IOException, BCompoundException
machineFile
- the machine file to be parsedverbose
- print debug informationcontentProvider
- used to get the content of filesjava.io.IOException
- if the file cannot be readBCompoundException
- if the file cannot be parsedparse(String, boolean)
public static Start parse(java.lang.String input) throws BCompoundException
input
- the B machine as input stringBCompoundException
- if the B machine can not be parsedpublic Start parseFormula(java.lang.String input) throws BCompoundException
BCompoundException
public Start parseExpression(java.lang.String input) throws BCompoundException
BCompoundException
public Start parseSubstitution(java.lang.String input) throws BCompoundException
BCompoundException
public Start parseTranstion(java.lang.String input) throws BCompoundException
BCompoundException
public Start parsePredicate(java.lang.String input) throws BCompoundException
BCompoundException
public Start eparse(java.lang.String input, IDefinitions context) throws BCompoundException, LexerException, java.io.IOException
BCompoundException
LexerException
java.io.IOException
public Start parse(java.lang.String input, boolean debugOutput) throws BCompoundException
parse(String, boolean, IFileContentProvider)
, but with
NoContentProvider
as last parameter, i.e., loading of referenced
files is not enabled.
Use parse(String, boolean, IFileContentProvider)
instead to be
able to control loading of referenced files.input
- the B machine as input stringdebugOutput
- print debug informationBCompoundException
- if the B machine cannot be parsedpublic Start parse(java.lang.String input, boolean debugOutput, IFileContentProvider contentProvider) throws BCompoundException
input
- The String
to be parseddebugOutput
- output debug messages on standard out?contentProvider
- A IFileContentProvider
that is able to load content of
referenced files during the parsing process. The content
provider is used for referenced definition files for example.BCompoundException
- The BCompoundException
class stores all
BException
s occurred during the parsing process. The
BException
class stores the actual exception as
delegate and forwards all method calls to it. So it is save
for tools to just use this exception if they want to extract
an error message. If the tools needs to extract additional
information, such as a source code position or involved
tokens respectively nodes, it needs to retrieve the delegate
exception. The BException
class offers a
BException.getCause()
method for this, which returns
the delegate exception.
Internal exceptions:
PreParseException
: This exception contains errors
that occur during the preparsing. If possible it supplies a
token, where the error occurred.BLexerException
: If any error occurs in the
generated or customized lexer a LexerException
is
thrown. Usually the lexer classes just throw a
LexerException
. But this class unfortunately does not
contain any explicit information about the source code
position where the error occurred. Using aspect-oriented
programming we intercept the throwing of these exceptions to
replace them by our own exception. In our own exception we
provide the source code position of the last characters that
were read from the input.BParseException
: This exception is thrown in two
situations. On the one hand if the parser throws a
ParserException
we convert it into a
BParseException
. On the other hand it can be thrown
if any error is found during the AST transformations after
the parser has finished.CheckException
: If any problem occurs while
performing semantic checks, a CheckException
is
thrown. We provide one or more nodes that are involved in the
problem. For example, if we find duplicate machine clauses,
we will list all occurrences in the exception.public java.lang.String getFileName()
public IDefinitions getDefinitions()
public void setDefinitions(IDefinitions definitions)
public static java.lang.String getBuildRevision()
public java.util.List<java.lang.String> getDoneDefFiles()
public void setDoneDefFiles(java.util.List<java.lang.String> doneDefFiles)
public ParseOptions getOptions()
public void setParseOptions(ParseOptions options)
public int fullParsing(java.io.File bfile, ParsingBehaviour parsingBehaviour, java.io.PrintStream out, java.io.PrintStream err)
public void setDirectory(java.io.File directory)