本文整理汇总了Java中com.fujitsu.vdmj.lex.LexException类的典型用法代码示例。如果您正苦于以下问题:Java LexException类的具体用法?Java LexException怎么用?Java LexException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LexException类属于com.fujitsu.vdmj.lex包,在下文中一共展示了LexException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractInformationByVDMJ
import com.fujitsu.vdmj.lex.LexException; //导入依赖的package包/类
public static void extractInformationByVDMJ() throws LexException, ParserException {
LexTokenReader ltr = new LexTokenReader(new File("BWDM/vdm_files/Arg2.vdmpp"), Dialect.VDM_PP);
DefinitionReader dr = new DefinitionReader(ltr);
ASTDefinitionList astDefinitionList = dr.readDefinitions();
astDefinitionList.forEach(_astDefinition -> {
if(_astDefinition.kind().equals("explicit function")) {
TCExplicitFunctionDefinition tcExplicitFunctionDefinition = null;
try {
tcExplicitFunctionDefinition = ClassMapper.getInstance(TCExplicitFunctionDefinition.MAPPINGS).init().convert(_astDefinition);
} catch (Exception e) {
e.printStackTrace();
}
/* koituga if-shiki no kouzou wo motteru! ashita ha kokokara!*/
ifExpression = (TCIfExpression) tcExplicitFunctionDefinition.body;
TCFunctionType tcft = tcExplicitFunctionDefinition.type;
TCTypeList tct = tcft.parameters;
System.out.println(tct.toString());
}
});
}
示例2: readTypeBind
import com.fujitsu.vdmj.lex.LexException; //导入依赖的package包/类
public ASTTypeBind readTypeBind() throws LexException, ParserException
{
ASTPattern pattern = getPatternReader().readPattern();
ASTTypeBind tb = null;
if (lastToken().is(Token.COLON))
{
nextToken();
tb = new ASTTypeBind(pattern, getTypeReader().readType());
}
else
{
throwMessage(2002, "Expecting ':' in type bind");
}
return tb;
}
示例3: readNonDetStatement
import com.fujitsu.vdmj.lex.LexException; //导入依赖的package包/类
private ASTStatement readNonDetStatement(LexLocation token)
throws ParserException, LexException
{
checkFor(Token.PIPEPIPE, 2200, "Expecting '||'");
checkFor(Token.BRA, 2201, "Expecting '(' after '||'");
ASTNonDeterministicStatement block = new ASTNonDeterministicStatement(token);
block.add(readStatement()); // Must be one
while (ignore(Token.COMMA))
{
block.add(readStatement());
}
checkFor(Token.KET, 2202, "Expecting ')' at end of '||' block");
return block;
}
示例4: readAtomicStatement
import com.fujitsu.vdmj.lex.LexException; //导入依赖的package包/类
private ASTStatement readAtomicStatement(LexLocation token)
throws ParserException, LexException
{
checkFor(Token.ATOMIC, 2203, "Expecting 'atomic'");
checkFor(Token.BRA, 2204, "Expecting '(' after 'atomic'");
ASTAssignmentStatementList assignments = new ASTAssignmentStatementList();
assignments.add(readAssignmentStatement(lastToken().location));
ignore(Token.SEMICOLON); // Every statement has an ignorable semicolon
while (lastToken().isNot(Token.KET))
{
assignments.add(readAssignmentStatement(lastToken().location));
ignore(Token.SEMICOLON);
}
checkFor(Token.KET, 2205, "Expecting ')' after atomic assignments");
return new ASTAtomicStatement(token, assignments);
}
示例5: readSimpleCallStatement
import com.fujitsu.vdmj.lex.LexException; //导入依赖的package包/类
private ASTStatement readSimpleCallStatement()
throws ParserException, LexException
{
LexNameToken name =
readNameToken("Expecting operation name in call statement");
checkFor(Token.BRA, 2206, "Expecting '(' after call operation name");
ASTExpressionList args = new ASTExpressionList();
ExpressionReader er = getExpressionReader();
if (lastToken().isNot(Token.KET))
{
args.add(er.readExpression());
while (ignore(Token.COMMA))
{
args.add(er.readExpression());
}
}
checkFor(Token.KET, 2124, "Expecting ')' after args");
return new ASTCallStatement(name, args);
}
示例6: readLetBeStExpression
import com.fujitsu.vdmj.lex.LexException; //导入依赖的package包/类
private ASTLetBeStExpression readLetBeStExpression(LexLocation start)
throws ParserException, LexException
{
ASTMultipleBind bind = getBindReader().readMultipleBind();
ASTExpression stexp = null;
if (lastToken().is(Token.BE))
{
nextToken();
checkFor(Token.ST, 2151, "Expecting 'st' after 'be' in let expression");
stexp = readExpression();
}
checkFor(Token.IN, 2152, "Expecting 'in' after bind in let expression");
// Note we read a Connective expression for the body, so that |->
// terminates the parse.
return new ASTLetBeStExpression(start, bind, stexp, readConnectiveExpression());
}
示例7: readForIndexStatement
import com.fujitsu.vdmj.lex.LexException; //导入依赖的package包/类
private ASTStatement readForIndexStatement(LexLocation token)
throws ParserException, LexException
{
LexIdentifierToken var = readIdToken("Expecting variable identifier");
checkFor(Token.EQUALS, 2216, "Expecting '=' after for variable");
ASTExpression from = getExpressionReader().readExpression();
checkFor(Token.TO, 2217, "Expecting 'to' after from expression");
ASTExpression to = getExpressionReader().readExpression();
ASTExpression by = null;
if (lastToken().is(Token.BY))
{
nextToken();
by = getExpressionReader().readExpression();
}
checkFor(Token.DO, 2218, "Expecting 'do' before loop statement");
ASTStatement body = getStatementReader().readStatement();
return new ASTForIndexStatement(token, idToName(var), from, to, by, body);
}
示例8: readConditionalStatement
import com.fujitsu.vdmj.lex.LexException; //导入依赖的package包/类
private ASTStatement readConditionalStatement(LexLocation token)
throws ParserException, LexException
{
ASTExpression exp = getExpressionReader().readExpression();
checkFor(Token.THEN, 2219, "Missing 'then'");
ASTStatement thenStmt = readStatement();
ASTElseIfStatementList elseIfList = new ASTElseIfStatementList();
while (lastToken().is(Token.ELSEIF))
{
LexToken elseif = lastToken();
nextToken();
elseIfList.add(readElseIfStatement(elseif.location));
}
ASTStatement elseStmt = null;
if (lastToken().is(Token.ELSE))
{
nextToken();
elseStmt = readStatement();
}
return new ASTIfStatement(token, exp, thenStmt, elseIfList, elseStmt);
}
示例9: lastIdToken
import com.fujitsu.vdmj.lex.LexException; //导入依赖的package包/类
/**
* Return the last token, converted to a {@link LexIdentifierToken}. If
* the last token is not an identifier token, an exception is thrown
* with the message passed in.
*
* @return The last token as a LexIdentifierToken.
* @throws LexException
*/
protected LexIdentifierToken lastIdToken()
throws ParserException, LexException
{
LexToken tok = reader.getLast();
if (tok.type == Token.IDENTIFIER)
{
LexIdentifierToken id = (LexIdentifierToken)tok;
if (id.old)
{
throwMessage(2295, "Can't use old name here", tok);
}
return id;
}
throwMessage(2058, "Expecting Identifier");
return null;
}
示例10: readType
import com.fujitsu.vdmj.lex.LexException; //导入依赖的package包/类
public ASTType readType()
throws ParserException, LexException
{
ASTType type = readUnionType();
if (lastToken().is(Token.ARROW) ||
lastToken().is(Token.TOTAL_FUNCTION))
{
LexToken token = lastToken();
nextToken();
ASTType result = readType();
if (result instanceof ASTVoidType)
{
throwMessage(2070, "Function type cannot return void type");
}
type = new ASTFunctionType(token.location,
token.is(Token.ARROW), productExpand(type), result);
}
return type;
}
示例11: readLetBeStStatement
import com.fujitsu.vdmj.lex.LexException; //导入依赖的package包/类
private ASTLetBeStStatement readLetBeStStatement(LexLocation token)
throws ParserException, LexException
{
ASTMultipleBind bind = getBindReader().readMultipleBind();
ASTExpression stexp = null;
if (lastToken().is(Token.BE))
{
nextToken();
checkFor(Token.ST, 2232, "Expecting 'st' after 'be' in let statement");
stexp = getExpressionReader().readExpression();
}
checkFor(Token.IN, 2233, "Expecting 'in' after bind in let statement");
return new ASTLetBeStStatement(token, bind, stexp, readStatement());
}
示例12: readDefStatement
import com.fujitsu.vdmj.lex.LexException; //导入依赖的package包/类
private ASTDefStatement readDefStatement(LexLocation token)
throws ParserException, LexException
{
checkFor(Token.DEF, 2239, "Expecting 'def'");
DefinitionReader dr = getDefinitionReader();
ASTDefinitionList equalsDefs = new ASTDefinitionList();
while (lastToken().isNot(Token.IN))
{
equalsDefs.add(dr.readEqualsDefinition());
ignore(Token.SEMICOLON);
}
checkFor(Token.IN, 2240, "Expecting 'in' after equals definitions");
return new ASTDefStatement(token, equalsDefs, readStatement());
}
示例13: readExportsFromModule
import com.fujitsu.vdmj.lex.LexException; //导入依赖的package包/类
private ASTExportList readExportsFromModule() throws ParserException, LexException
{
ASTExportList types = new ASTExportList();
if (lastToken().is(Token.ALL))
{
LexNameToken all = new LexNameToken(getCurrentModule(), "all", lastToken().location);
types.add(new ASTExportAll(all.location));
nextToken();
return types;
}
types.addAll(readExportsOfOneType());
while (newType())
{
types.addAll(readExportsOfOneType());
}
return types;
}
示例14: getMkTypeName
import com.fujitsu.vdmj.lex.LexException; //导入依赖的package包/类
private LexNameToken getMkTypeName(LexNameToken mktoken)
throws ParserException, LexException
{
String typename = mktoken.name.substring(3); // mk_... or is_...
String[] parts = typename.split("`");
switch (parts.length)
{
case 1:
return new LexNameToken(getCurrentModule(), parts[0], mktoken.location);
case 2:
return new LexNameToken(parts[0], parts[1], mktoken.location, false, true);
default:
throwMessage(2037, "Malformed mk_<type> name " + typename);
}
return null;
}
示例15: readNarrowExpression
import com.fujitsu.vdmj.lex.LexException; //导入依赖的package包/类
private ASTExpression readNarrowExpression(ASTVariableExpression ve)
throws LexException, ParserException
{
ASTNarrowExpression exp = null;
ASTExpression test = readExpression();
checkFor(Token.COMMA, 2301, "Expecting narrow_(expression, type)");
TypeReader tr = getTypeReader();
ASTType type = tr.readType();
if (type instanceof ASTUnresolvedType)
{
ASTUnresolvedType nt = (ASTUnresolvedType)type;
exp = new ASTNarrowExpression(ve.location, nt.typename, test);
}
else
{
exp = new ASTNarrowExpression(ve.location, type, test);
}
checkFor(Token.KET, 2302, "Expecting ')' after narrow_ expression");
return exp;
}