repo
stringlengths
1
191
file
stringlengths
23
351
code
stringlengths
0
5.32M
file_length
int64
0
5.32M
avg_line_length
float64
0
2.9k
max_line_length
int64
0
288k
extension_type
stringclasses
1 value
jkind
jkind-master/jkind-common/src/jkind/lustre/Ast.java
package jkind.lustre; import jkind.Assert; import jkind.lustre.visitors.AstVisitor; import jkind.lustre.visitors.PrettyPrintVisitor; public abstract class Ast { public final Location location; public Ast(Location location) { Assert.isNotNull(location); this.location = location; } @Override public String toString() { PrettyPrintVisitor visitor = new PrettyPrintVisitor(); accept(visitor); return visitor.toString(); } public abstract <T, S extends T> T accept(AstVisitor<T, S> visitor); }
512
20.375
69
java
jkind
jkind-master/jkind-common/src/jkind/lustre/VarDecl.java
package jkind.lustre; import jkind.Assert; import jkind.lustre.visitors.AstVisitor; public class VarDecl extends Ast { public final String id; public final Type type; public VarDecl(Location location, String id, Type type) { super(location); Assert.isNotNull(id); Assert.isNotNull(type); this.id = id; this.type = type; } public VarDecl(String id, Type type) { this(Location.NULL, id, type); } @Override public <T, S extends T> T accept(AstVisitor<T, S> visitor) { return visitor.visit(this); } }
524
19.192308
61
java
jkind
jkind-master/jkind-common/src/jkind/lustre/IdExpr.java
package jkind.lustre; import jkind.Assert; import jkind.lustre.visitors.ExprVisitor; public class IdExpr extends Expr { public final String id; public IdExpr(Location location, String id) { super(location); Assert.isNotNull(id); this.id = id; } public IdExpr(String id) { this(Location.NULL, id); } @Override public <T> T accept(ExprVisitor<T> visitor) { return visitor.visit(this); } }
410
16.125
46
java
jkind
jkind-master/jkind-common/src/jkind/lustre/FunctionCallExpr.java
package jkind.lustre; import java.util.Arrays; import java.util.List; import jkind.Assert; import jkind.lustre.visitors.ExprVisitor; import jkind.util.Util; public class FunctionCallExpr extends Expr { public final String function; public final List<Expr> args; public FunctionCallExpr(Location loc, String function, List<Expr> args) { super(loc); Assert.isNotNull(function); this.function = function; this.args = Util.safeList(args); } public FunctionCallExpr(String node, List<Expr> args) { this(Location.NULL, node, args); } public FunctionCallExpr(String node, Expr... args) { this(Location.NULL, node, Arrays.asList(args)); } @Override public <T> T accept(ExprVisitor<T> visitor) { return visitor.visit(this); } }
750
21.757576
74
java
jkind
jkind-master/jkind-common/src/jkind/lustre/SubrangeIntType.java
package jkind.lustre; import java.math.BigInteger; import jkind.Assert; import jkind.lustre.visitors.TypeVisitor; public class SubrangeIntType extends Type { public final BigInteger low; public final BigInteger high; public SubrangeIntType(Location location, BigInteger low, BigInteger high) { super(location); Assert.isNotNull(low); Assert.isNotNull(high); Assert.isTrue(low.compareTo(high) <= 0); this.low = low; this.high = high; } public SubrangeIntType(BigInteger low, BigInteger high) { this(Location.NULL, low, high); } @Override public String toString() { return "subrange [" + low + ", " + high + "] of int"; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((high == null) ? 0 : high.hashCode()); result = prime * result + ((low == null) ? 0 : low.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof SubrangeIntType)) { return false; } SubrangeIntType other = (SubrangeIntType) obj; if (high == null) { if (other.high != null) { return false; } } else if (!high.equals(other.high)) { return false; } if (low == null) { if (other.low != null) { return false; } } else if (!low.equals(other.low)) { return false; } return true; } @Override public <T> T accept(TypeVisitor<T> visitor) { return visitor.visit(this); } }
1,508
19.958333
77
java
jkind
jkind-master/jkind-common/src/jkind/lustre/parsing/LustreParseExceptionErrorListener.java
package jkind.lustre.parsing; import jkind.lustre.Location; import org.antlr.v4.runtime.BaseErrorListener; import org.antlr.v4.runtime.RecognitionException; import org.antlr.v4.runtime.Recognizer; public class LustreParseExceptionErrorListener extends BaseErrorListener { @Override public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) { throw new LustreParseException(new Location(line, charPositionInLine), msg); } }
523
31.75
111
java
jkind
jkind-master/jkind-common/src/jkind/lustre/parsing/LustreParser.java
// Generated from Lustre.g4 by ANTLR 4.4 package jkind.lustre.parsing; import org.antlr.v4.runtime.atn.*; import org.antlr.v4.runtime.dfa.DFA; import org.antlr.v4.runtime.*; import org.antlr.v4.runtime.misc.*; import org.antlr.v4.runtime.tree.*; import java.util.List; import java.util.Iterator; import java.util.ArrayList; @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) public class LustreParser extends Parser { static { RuntimeMetaData.checkVersion("4.4", RuntimeMetaData.VERSION); } protected static final DFA[] _decisionToDFA; protected static final PredictionContextCache _sharedContextCache = new PredictionContextCache(); public static final int T__54=1, T__53=2, T__52=3, T__51=4, T__50=5, T__49=6, T__48=7, T__47=8, T__46=9, T__45=10, T__44=11, T__43=12, T__42=13, T__41=14, T__40=15, T__39=16, T__38=17, T__37=18, T__36=19, T__35=20, T__34=21, T__33=22, T__32=23, T__31=24, T__30=25, T__29=26, T__28=27, T__27=28, T__26=29, T__25=30, T__24=31, T__23=32, T__22=33, T__21=34, T__20=35, T__19=36, T__18=37, T__17=38, T__16=39, T__15=40, T__14=41, T__13=42, T__12=43, T__11=44, T__10=45, T__9=46, T__8=47, T__7=48, T__6=49, T__5=50, T__4=51, T__3=52, T__2=53, T__1=54, T__0=55, REAL=56, BOOL=57, INT=58, ID=59, WS=60, SL_COMMENT=61, ML_COMMENT=62, ERROR=63; public static final String[] tokenNames = { "<INVALID>", "'{'", "'='", "'int'", "'('", "','", "'var'", "'const'", "'mod'", "'>='", "'<'", "'pre'", "'assert'", "']'", "'node'", "'type'", "'<>'", "'let'", "'returns'", "'tel'", "'function'", "'floor'", "'then'", "'+'", "'struct'", "'/'", "'of'", "'--%REALIZABLE'", "';'", "'--%PROPERTY'", "'}'", "'if'", "':='", "'enum'", "'<='", "'--%MAIN'", "'condact'", "'*'", "'.'", "'->'", "':'", "'--%IVC'", "'['", "'>'", "'bool'", "'xor'", "'or'", "'subrange'", "'=>'", "'div'", "'else'", "')'", "'and'", "'not'", "'-'", "'real'", "REAL", "BOOL", "INT", "ID", "WS", "SL_COMMENT", "ML_COMMENT", "ERROR" }; public static final int RULE_program = 0, RULE_typedef = 1, RULE_constant = 2, RULE_node = 3, RULE_function = 4, RULE_varDeclList = 5, RULE_varDeclGroup = 6, RULE_topLevelType = 7, RULE_type = 8, RULE_bound = 9, RULE_property = 10, RULE_realizabilityInputs = 11, RULE_ivc = 12, RULE_main = 13, RULE_assertion = 14, RULE_equation = 15, RULE_lhs = 16, RULE_expr = 17, RULE_eID = 18; public static final String[] ruleNames = { "program", "typedef", "constant", "node", "function", "varDeclList", "varDeclGroup", "topLevelType", "type", "bound", "property", "realizabilityInputs", "ivc", "main", "assertion", "equation", "lhs", "expr", "eID" }; @Override public String getGrammarFileName() { return "Lustre.g4"; } @Override public String[] getTokenNames() { return tokenNames; } @Override public String[] getRuleNames() { return ruleNames; } @Override public String getSerializedATN() { return _serializedATN; } @Override public ATN getATN() { return _ATN; } public LustreParser(TokenStream input) { super(input); _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); } public static class ProgramContext extends ParserRuleContext { public TypedefContext typedef(int i) { return getRuleContext(TypedefContext.class,i); } public List<ConstantContext> constant() { return getRuleContexts(ConstantContext.class); } public TerminalNode EOF() { return getToken(LustreParser.EOF, 0); } public FunctionContext function(int i) { return getRuleContext(FunctionContext.class,i); } public List<TypedefContext> typedef() { return getRuleContexts(TypedefContext.class); } public ConstantContext constant(int i) { return getRuleContext(ConstantContext.class,i); } public NodeContext node(int i) { return getRuleContext(NodeContext.class,i); } public List<NodeContext> node() { return getRuleContexts(NodeContext.class); } public List<FunctionContext> function() { return getRuleContexts(FunctionContext.class); } public ProgramContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_program; } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitProgram(this); else return visitor.visitChildren(this); } } public final ProgramContext program() throws RecognitionException { ProgramContext _localctx = new ProgramContext(_ctx, getState()); enterRule(_localctx, 0, RULE_program); int _la; try { enterOuterAlt(_localctx, 1); { setState(44); _errHandler.sync(this); _la = _input.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__48) | (1L << T__41) | (1L << T__40) | (1L << T__35))) != 0)) { { setState(42); switch (_input.LA(1)) { case T__40: { setState(38); typedef(); } break; case T__48: { setState(39); constant(); } break; case T__41: { setState(40); node(); } break; case T__35: { setState(41); function(); } break; default: throw new NoViableAltException(this); } } setState(46); _errHandler.sync(this); _la = _input.LA(1); } setState(47); match(EOF); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class TypedefContext extends ParserRuleContext { public TerminalNode ID() { return getToken(LustreParser.ID, 0); } public TopLevelTypeContext topLevelType() { return getRuleContext(TopLevelTypeContext.class,0); } public TypedefContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_typedef; } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitTypedef(this); else return visitor.visitChildren(this); } } public final TypedefContext typedef() throws RecognitionException { TypedefContext _localctx = new TypedefContext(_ctx, getState()); enterRule(_localctx, 2, RULE_typedef); try { enterOuterAlt(_localctx, 1); { setState(49); match(T__40); setState(50); match(ID); setState(51); match(T__53); setState(52); topLevelType(); setState(53); match(T__27); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class ConstantContext extends ParserRuleContext { public TerminalNode ID() { return getToken(LustreParser.ID, 0); } public ExprContext expr() { return getRuleContext(ExprContext.class,0); } public TypeContext type() { return getRuleContext(TypeContext.class,0); } public ConstantContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_constant; } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitConstant(this); else return visitor.visitChildren(this); } } public final ConstantContext constant() throws RecognitionException { ConstantContext _localctx = new ConstantContext(_ctx, getState()); enterRule(_localctx, 4, RULE_constant); int _la; try { enterOuterAlt(_localctx, 1); { setState(55); match(T__48); setState(56); match(ID); setState(59); _la = _input.LA(1); if (_la==T__15) { { setState(57); match(T__15); setState(58); type(0); } } setState(61); match(T__53); setState(62); expr(0); setState(63); match(T__27); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class NodeContext extends ParserRuleContext { public VarDeclListContext input; public VarDeclListContext output; public VarDeclListContext local; public AssertionContext assertion(int i) { return getRuleContext(AssertionContext.class,i); } public RealizabilityInputsContext realizabilityInputs(int i) { return getRuleContext(RealizabilityInputsContext.class,i); } public List<VarDeclListContext> varDeclList() { return getRuleContexts(VarDeclListContext.class); } public List<RealizabilityInputsContext> realizabilityInputs() { return getRuleContexts(RealizabilityInputsContext.class); } public TerminalNode ID() { return getToken(LustreParser.ID, 0); } public PropertyContext property(int i) { return getRuleContext(PropertyContext.class,i); } public List<EquationContext> equation() { return getRuleContexts(EquationContext.class); } public EquationContext equation(int i) { return getRuleContext(EquationContext.class,i); } public List<MainContext> main() { return getRuleContexts(MainContext.class); } public VarDeclListContext varDeclList(int i) { return getRuleContext(VarDeclListContext.class,i); } public IvcContext ivc(int i) { return getRuleContext(IvcContext.class,i); } public List<AssertionContext> assertion() { return getRuleContexts(AssertionContext.class); } public MainContext main(int i) { return getRuleContext(MainContext.class,i); } public List<PropertyContext> property() { return getRuleContexts(PropertyContext.class); } public List<IvcContext> ivc() { return getRuleContexts(IvcContext.class); } public NodeContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_node; } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitNode(this); else return visitor.visitChildren(this); } } public final NodeContext node() throws RecognitionException { NodeContext _localctx = new NodeContext(_ctx, getState()); enterRule(_localctx, 6, RULE_node); int _la; try { enterOuterAlt(_localctx, 1); { setState(65); match(T__41); setState(66); match(ID); setState(67); match(T__51); setState(69); _la = _input.LA(1); if (_la==ID) { { setState(68); ((NodeContext)_localctx).input = varDeclList(); } } setState(71); match(T__4); setState(72); match(T__37); setState(73); match(T__51); setState(75); _la = _input.LA(1); if (_la==ID) { { setState(74); ((NodeContext)_localctx).output = varDeclList(); } } setState(77); match(T__4); setState(78); match(T__27); setState(83); _la = _input.LA(1); if (_la==T__49) { { setState(79); match(T__49); setState(80); ((NodeContext)_localctx).local = varDeclList(); setState(81); match(T__27); } } setState(85); match(T__38); setState(94); _errHandler.sync(this); _la = _input.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__51) | (1L << T__43) | (1L << T__28) | (1L << T__26) | (1L << T__20) | (1L << T__14) | (1L << ID))) != 0)) { { setState(92); switch (_input.LA(1)) { case T__51: case ID: { setState(86); equation(); } break; case T__26: { setState(87); property(); } break; case T__43: { setState(88); assertion(); } break; case T__20: { setState(89); main(); } break; case T__28: { setState(90); realizabilityInputs(); } break; case T__14: { setState(91); ivc(); } break; default: throw new NoViableAltException(this); } } setState(96); _errHandler.sync(this); _la = _input.LA(1); } setState(97); match(T__36); setState(99); _la = _input.LA(1); if (_la==T__27) { { setState(98); match(T__27); } } } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class FunctionContext extends ParserRuleContext { public VarDeclListContext input; public VarDeclListContext output; public EIDContext eID() { return getRuleContext(EIDContext.class,0); } public List<VarDeclListContext> varDeclList() { return getRuleContexts(VarDeclListContext.class); } public VarDeclListContext varDeclList(int i) { return getRuleContext(VarDeclListContext.class,i); } public FunctionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_function; } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitFunction(this); else return visitor.visitChildren(this); } } public final FunctionContext function() throws RecognitionException { FunctionContext _localctx = new FunctionContext(_ctx, getState()); enterRule(_localctx, 8, RULE_function); int _la; try { enterOuterAlt(_localctx, 1); { setState(101); match(T__35); setState(102); eID(0); setState(103); match(T__51); setState(105); _la = _input.LA(1); if (_la==ID) { { setState(104); ((FunctionContext)_localctx).input = varDeclList(); } } setState(107); match(T__4); setState(108); match(T__37); setState(109); match(T__51); setState(111); _la = _input.LA(1); if (_la==ID) { { setState(110); ((FunctionContext)_localctx).output = varDeclList(); } } setState(113); match(T__4); setState(114); match(T__27); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class VarDeclListContext extends ParserRuleContext { public VarDeclGroupContext varDeclGroup(int i) { return getRuleContext(VarDeclGroupContext.class,i); } public List<VarDeclGroupContext> varDeclGroup() { return getRuleContexts(VarDeclGroupContext.class); } public VarDeclListContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_varDeclList; } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitVarDeclList(this); else return visitor.visitChildren(this); } } public final VarDeclListContext varDeclList() throws RecognitionException { VarDeclListContext _localctx = new VarDeclListContext(_ctx, getState()); enterRule(_localctx, 10, RULE_varDeclList); try { int _alt; enterOuterAlt(_localctx, 1); { setState(116); varDeclGroup(); setState(121); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,11,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { setState(117); match(T__27); setState(118); varDeclGroup(); } } } setState(123); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,11,_ctx); } } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class VarDeclGroupContext extends ParserRuleContext { public List<EIDContext> eID() { return getRuleContexts(EIDContext.class); } public EIDContext eID(int i) { return getRuleContext(EIDContext.class,i); } public TypeContext type() { return getRuleContext(TypeContext.class,0); } public VarDeclGroupContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_varDeclGroup; } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitVarDeclGroup(this); else return visitor.visitChildren(this); } } public final VarDeclGroupContext varDeclGroup() throws RecognitionException { VarDeclGroupContext _localctx = new VarDeclGroupContext(_ctx, getState()); enterRule(_localctx, 12, RULE_varDeclGroup); int _la; try { enterOuterAlt(_localctx, 1); { setState(124); eID(0); setState(129); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__50) { { { setState(125); match(T__50); setState(126); eID(0); } } setState(131); _errHandler.sync(this); _la = _input.LA(1); } setState(132); match(T__15); setState(133); type(0); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class TopLevelTypeContext extends ParserRuleContext { public TopLevelTypeContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_topLevelType; } public TopLevelTypeContext() { } public void copyFrom(TopLevelTypeContext ctx) { super.copyFrom(ctx); } } public static class RecordTypeContext extends TopLevelTypeContext { public List<TerminalNode> ID() { return getTokens(LustreParser.ID); } public TypeContext type(int i) { return getRuleContext(TypeContext.class,i); } public TerminalNode ID(int i) { return getToken(LustreParser.ID, i); } public List<TypeContext> type() { return getRuleContexts(TypeContext.class); } public RecordTypeContext(TopLevelTypeContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitRecordType(this); else return visitor.visitChildren(this); } } public static class EnumTypeContext extends TopLevelTypeContext { public List<TerminalNode> ID() { return getTokens(LustreParser.ID); } public TerminalNode ID(int i) { return getToken(LustreParser.ID, i); } public EnumTypeContext(TopLevelTypeContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitEnumType(this); else return visitor.visitChildren(this); } } public static class PlainTypeContext extends TopLevelTypeContext { public TypeContext type() { return getRuleContext(TypeContext.class,0); } public PlainTypeContext(TopLevelTypeContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitPlainType(this); else return visitor.visitChildren(this); } } public final TopLevelTypeContext topLevelType() throws RecognitionException { TopLevelTypeContext _localctx = new TopLevelTypeContext(_ctx, getState()); enterRule(_localctx, 14, RULE_topLevelType); int _la; try { setState(164); switch (_input.LA(1)) { case T__52: case T__11: case T__8: case T__0: case ID: _localctx = new PlainTypeContext(_localctx); enterOuterAlt(_localctx, 1); { setState(135); type(0); } break; case T__31: _localctx = new RecordTypeContext(_localctx); enterOuterAlt(_localctx, 2); { setState(136); match(T__31); setState(137); match(T__54); { setState(138); match(ID); setState(139); match(T__15); setState(140); type(0); } setState(148); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__27) { { { setState(142); match(T__27); setState(143); match(ID); setState(144); match(T__15); setState(145); type(0); } } setState(150); _errHandler.sync(this); _la = _input.LA(1); } setState(151); match(T__25); } break; case T__22: _localctx = new EnumTypeContext(_localctx); enterOuterAlt(_localctx, 3); { setState(153); match(T__22); setState(154); match(T__54); setState(155); match(ID); setState(160); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__50) { { { setState(156); match(T__50); setState(157); match(ID); } } setState(162); _errHandler.sync(this); _la = _input.LA(1); } setState(163); match(T__25); } break; default: throw new NoViableAltException(this); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class TypeContext extends ParserRuleContext { public TypeContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_type; } public TypeContext() { } public void copyFrom(TypeContext ctx) { super.copyFrom(ctx); } } public static class ArrayTypeContext extends TypeContext { public TypeContext type() { return getRuleContext(TypeContext.class,0); } public TerminalNode INT() { return getToken(LustreParser.INT, 0); } public ArrayTypeContext(TypeContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitArrayType(this); else return visitor.visitChildren(this); } } public static class RealTypeContext extends TypeContext { public RealTypeContext(TypeContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitRealType(this); else return visitor.visitChildren(this); } } public static class SubrangeTypeContext extends TypeContext { public BoundContext bound(int i) { return getRuleContext(BoundContext.class,i); } public List<BoundContext> bound() { return getRuleContexts(BoundContext.class); } public SubrangeTypeContext(TypeContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitSubrangeType(this); else return visitor.visitChildren(this); } } public static class IntTypeContext extends TypeContext { public IntTypeContext(TypeContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitIntType(this); else return visitor.visitChildren(this); } } public static class UserTypeContext extends TypeContext { public TerminalNode ID() { return getToken(LustreParser.ID, 0); } public UserTypeContext(TypeContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitUserType(this); else return visitor.visitChildren(this); } } public static class BoolTypeContext extends TypeContext { public BoolTypeContext(TypeContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitBoolType(this); else return visitor.visitChildren(this); } } public final TypeContext type() throws RecognitionException { return type(0); } private TypeContext type(int _p) throws RecognitionException { ParserRuleContext _parentctx = _ctx; int _parentState = getState(); TypeContext _localctx = new TypeContext(_ctx, _parentState); TypeContext _prevctx = _localctx; int _startState = 16; enterRecursionRule(_localctx, 16, RULE_type, _p); try { int _alt; enterOuterAlt(_localctx, 1); { setState(180); switch (_input.LA(1)) { case T__52: { _localctx = new IntTypeContext(_localctx); _ctx = _localctx; _prevctx = _localctx; setState(167); match(T__52); } break; case T__8: { _localctx = new SubrangeTypeContext(_localctx); _ctx = _localctx; _prevctx = _localctx; setState(168); match(T__8); setState(169); match(T__13); setState(170); bound(); setState(171); match(T__50); setState(172); bound(); setState(173); match(T__42); setState(174); match(T__29); setState(175); match(T__52); } break; case T__11: { _localctx = new BoolTypeContext(_localctx); _ctx = _localctx; _prevctx = _localctx; setState(177); match(T__11); } break; case T__0: { _localctx = new RealTypeContext(_localctx); _ctx = _localctx; _prevctx = _localctx; setState(178); match(T__0); } break; case ID: { _localctx = new UserTypeContext(_localctx); _ctx = _localctx; _prevctx = _localctx; setState(179); match(ID); } break; default: throw new NoViableAltException(this); } _ctx.stop = _input.LT(-1); setState(188); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,17,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { if ( _parseListeners!=null ) triggerExitRuleEvent(); _prevctx = _localctx; { { _localctx = new ArrayTypeContext(new TypeContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_type); setState(182); if (!(precpred(_ctx, 2))) throw new FailedPredicateException(this, "precpred(_ctx, 2)"); setState(183); match(T__13); setState(184); match(INT); setState(185); match(T__42); } } } setState(190); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,17,_ctx); } } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { unrollRecursionContexts(_parentctx); } return _localctx; } public static class BoundContext extends ParserRuleContext { public TerminalNode INT() { return getToken(LustreParser.INT, 0); } public BoundContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_bound; } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitBound(this); else return visitor.visitChildren(this); } } public final BoundContext bound() throws RecognitionException { BoundContext _localctx = new BoundContext(_ctx, getState()); enterRule(_localctx, 18, RULE_bound); int _la; try { enterOuterAlt(_localctx, 1); { setState(192); _la = _input.LA(1); if (_la==T__1) { { setState(191); match(T__1); } } setState(194); match(INT); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class PropertyContext extends ParserRuleContext { public EIDContext eID() { return getRuleContext(EIDContext.class,0); } public PropertyContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_property; } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitProperty(this); else return visitor.visitChildren(this); } } public final PropertyContext property() throws RecognitionException { PropertyContext _localctx = new PropertyContext(_ctx, getState()); enterRule(_localctx, 20, RULE_property); try { enterOuterAlt(_localctx, 1); { setState(196); match(T__26); setState(197); eID(0); setState(198); match(T__27); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class RealizabilityInputsContext extends ParserRuleContext { public List<TerminalNode> ID() { return getTokens(LustreParser.ID); } public TerminalNode ID(int i) { return getToken(LustreParser.ID, i); } public RealizabilityInputsContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_realizabilityInputs; } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitRealizabilityInputs(this); else return visitor.visitChildren(this); } } public final RealizabilityInputsContext realizabilityInputs() throws RecognitionException { RealizabilityInputsContext _localctx = new RealizabilityInputsContext(_ctx, getState()); enterRule(_localctx, 22, RULE_realizabilityInputs); int _la; try { enterOuterAlt(_localctx, 1); { setState(200); match(T__28); setState(209); _la = _input.LA(1); if (_la==ID) { { setState(201); match(ID); setState(206); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__50) { { { setState(202); match(T__50); setState(203); match(ID); } } setState(208); _errHandler.sync(this); _la = _input.LA(1); } } } setState(211); match(T__27); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class IvcContext extends ParserRuleContext { public List<EIDContext> eID() { return getRuleContexts(EIDContext.class); } public EIDContext eID(int i) { return getRuleContext(EIDContext.class,i); } public IvcContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_ivc; } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitIvc(this); else return visitor.visitChildren(this); } } public final IvcContext ivc() throws RecognitionException { IvcContext _localctx = new IvcContext(_ctx, getState()); enterRule(_localctx, 24, RULE_ivc); int _la; try { enterOuterAlt(_localctx, 1); { setState(213); match(T__14); setState(222); _la = _input.LA(1); if (_la==ID) { { setState(214); eID(0); setState(219); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__50) { { { setState(215); match(T__50); setState(216); eID(0); } } setState(221); _errHandler.sync(this); _la = _input.LA(1); } } } setState(224); match(T__27); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class MainContext extends ParserRuleContext { public MainContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_main; } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitMain(this); else return visitor.visitChildren(this); } } public final MainContext main() throws RecognitionException { MainContext _localctx = new MainContext(_ctx, getState()); enterRule(_localctx, 26, RULE_main); int _la; try { enterOuterAlt(_localctx, 1); { setState(226); match(T__20); setState(228); _la = _input.LA(1); if (_la==T__27) { { setState(227); match(T__27); } } } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class AssertionContext extends ParserRuleContext { public ExprContext expr() { return getRuleContext(ExprContext.class,0); } public AssertionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_assertion; } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitAssertion(this); else return visitor.visitChildren(this); } } public final AssertionContext assertion() throws RecognitionException { AssertionContext _localctx = new AssertionContext(_ctx, getState()); enterRule(_localctx, 28, RULE_assertion); try { enterOuterAlt(_localctx, 1); { setState(230); match(T__43); setState(231); expr(0); setState(232); match(T__27); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class EquationContext extends ParserRuleContext { public ExprContext expr() { return getRuleContext(ExprContext.class,0); } public LhsContext lhs() { return getRuleContext(LhsContext.class,0); } public EquationContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_equation; } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitEquation(this); else return visitor.visitChildren(this); } } public final EquationContext equation() throws RecognitionException { EquationContext _localctx = new EquationContext(_ctx, getState()); enterRule(_localctx, 30, RULE_equation); int _la; try { enterOuterAlt(_localctx, 1); { setState(240); switch (_input.LA(1)) { case ID: { setState(234); lhs(); } break; case T__51: { setState(235); match(T__51); setState(237); _la = _input.LA(1); if (_la==ID) { { setState(236); lhs(); } } setState(239); match(T__4); } break; default: throw new NoViableAltException(this); } setState(242); match(T__53); setState(243); expr(0); setState(244); match(T__27); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class LhsContext extends ParserRuleContext { public List<EIDContext> eID() { return getRuleContexts(EIDContext.class); } public EIDContext eID(int i) { return getRuleContext(EIDContext.class,i); } public LhsContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_lhs; } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitLhs(this); else return visitor.visitChildren(this); } } public final LhsContext lhs() throws RecognitionException { LhsContext _localctx = new LhsContext(_ctx, getState()); enterRule(_localctx, 32, RULE_lhs); int _la; try { enterOuterAlt(_localctx, 1); { setState(246); eID(0); setState(251); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__50) { { { setState(247); match(T__50); setState(248); eID(0); } } setState(253); _errHandler.sync(this); _la = _input.LA(1); } } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; } public static class ExprContext extends ParserRuleContext { public ExprContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_expr; } public ExprContext() { } public void copyFrom(ExprContext ctx) { super.copyFrom(ctx); } } public static class RecordExprContext extends ExprContext { public List<TerminalNode> ID() { return getTokens(LustreParser.ID); } public List<ExprContext> expr() { return getRuleContexts(ExprContext.class); } public ExprContext expr(int i) { return getRuleContext(ExprContext.class,i); } public TerminalNode ID(int i) { return getToken(LustreParser.ID, i); } public RecordExprContext(ExprContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitRecordExpr(this); else return visitor.visitChildren(this); } } public static class IntExprContext extends ExprContext { public TerminalNode INT() { return getToken(LustreParser.INT, 0); } public IntExprContext(ExprContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitIntExpr(this); else return visitor.visitChildren(this); } } public static class ArrayExprContext extends ExprContext { public List<ExprContext> expr() { return getRuleContexts(ExprContext.class); } public ExprContext expr(int i) { return getRuleContext(ExprContext.class,i); } public ArrayExprContext(ExprContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitArrayExpr(this); else return visitor.visitChildren(this); } } public static class CastExprContext extends ExprContext { public Token op; public ExprContext expr() { return getRuleContext(ExprContext.class,0); } public CastExprContext(ExprContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitCastExpr(this); else return visitor.visitChildren(this); } } public static class RealExprContext extends ExprContext { public TerminalNode REAL() { return getToken(LustreParser.REAL, 0); } public RealExprContext(ExprContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitRealExpr(this); else return visitor.visitChildren(this); } } public static class IfThenElseExprContext extends ExprContext { public List<ExprContext> expr() { return getRuleContexts(ExprContext.class); } public ExprContext expr(int i) { return getRuleContext(ExprContext.class,i); } public IfThenElseExprContext(ExprContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitIfThenElseExpr(this); else return visitor.visitChildren(this); } } public static class BinaryExprContext extends ExprContext { public Token op; public List<ExprContext> expr() { return getRuleContexts(ExprContext.class); } public ExprContext expr(int i) { return getRuleContext(ExprContext.class,i); } public BinaryExprContext(ExprContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitBinaryExpr(this); else return visitor.visitChildren(this); } } public static class PreExprContext extends ExprContext { public ExprContext expr() { return getRuleContext(ExprContext.class,0); } public PreExprContext(ExprContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitPreExpr(this); else return visitor.visitChildren(this); } } public static class RecordAccessExprContext extends ExprContext { public TerminalNode ID() { return getToken(LustreParser.ID, 0); } public ExprContext expr() { return getRuleContext(ExprContext.class,0); } public RecordAccessExprContext(ExprContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitRecordAccessExpr(this); else return visitor.visitChildren(this); } } public static class NegateExprContext extends ExprContext { public ExprContext expr() { return getRuleContext(ExprContext.class,0); } public NegateExprContext(ExprContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitNegateExpr(this); else return visitor.visitChildren(this); } } public static class NotExprContext extends ExprContext { public ExprContext expr() { return getRuleContext(ExprContext.class,0); } public NotExprContext(ExprContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitNotExpr(this); else return visitor.visitChildren(this); } } public static class CondactExprContext extends ExprContext { public List<ExprContext> expr() { return getRuleContexts(ExprContext.class); } public ExprContext expr(int i) { return getRuleContext(ExprContext.class,i); } public CondactExprContext(ExprContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitCondactExpr(this); else return visitor.visitChildren(this); } } public static class ArrayAccessExprContext extends ExprContext { public List<ExprContext> expr() { return getRuleContexts(ExprContext.class); } public ExprContext expr(int i) { return getRuleContext(ExprContext.class,i); } public ArrayAccessExprContext(ExprContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitArrayAccessExpr(this); else return visitor.visitChildren(this); } } public static class ArrayUpdateExprContext extends ExprContext { public List<ExprContext> expr() { return getRuleContexts(ExprContext.class); } public ExprContext expr(int i) { return getRuleContext(ExprContext.class,i); } public ArrayUpdateExprContext(ExprContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitArrayUpdateExpr(this); else return visitor.visitChildren(this); } } public static class BoolExprContext extends ExprContext { public TerminalNode BOOL() { return getToken(LustreParser.BOOL, 0); } public BoolExprContext(ExprContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitBoolExpr(this); else return visitor.visitChildren(this); } } public static class CallExprContext extends ExprContext { public List<ExprContext> expr() { return getRuleContexts(ExprContext.class); } public ExprContext expr(int i) { return getRuleContext(ExprContext.class,i); } public EIDContext eID() { return getRuleContext(EIDContext.class,0); } public CallExprContext(ExprContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitCallExpr(this); else return visitor.visitChildren(this); } } public static class TupleExprContext extends ExprContext { public List<ExprContext> expr() { return getRuleContexts(ExprContext.class); } public ExprContext expr(int i) { return getRuleContext(ExprContext.class,i); } public TupleExprContext(ExprContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitTupleExpr(this); else return visitor.visitChildren(this); } } public static class RecordUpdateExprContext extends ExprContext { public TerminalNode ID() { return getToken(LustreParser.ID, 0); } public List<ExprContext> expr() { return getRuleContexts(ExprContext.class); } public ExprContext expr(int i) { return getRuleContext(ExprContext.class,i); } public RecordUpdateExprContext(ExprContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitRecordUpdateExpr(this); else return visitor.visitChildren(this); } } public static class IdExprContext extends ExprContext { public TerminalNode ID() { return getToken(LustreParser.ID, 0); } public IdExprContext(ExprContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitIdExpr(this); else return visitor.visitChildren(this); } } public final ExprContext expr() throws RecognitionException { return expr(0); } private ExprContext expr(int _p) throws RecognitionException { ParserRuleContext _parentctx = _ctx; int _parentState = getState(); ExprContext _localctx = new ExprContext(_ctx, _parentState); ExprContext _prevctx = _localctx; int _startState = 34; enterRecursionRule(_localctx, 34, RULE_expr, _p); int _la; try { int _alt; enterOuterAlt(_localctx, 1); { setState(340); switch ( getInterpreter().adaptivePredict(_input,33,_ctx) ) { case 1: { _localctx = new PreExprContext(_localctx); _ctx = _localctx; _prevctx = _localctx; setState(255); match(T__44); setState(256); expr(14); } break; case 2: { _localctx = new NotExprContext(_localctx); _ctx = _localctx; _prevctx = _localctx; setState(257); match(T__2); setState(258); expr(13); } break; case 3: { _localctx = new NegateExprContext(_localctx); _ctx = _localctx; _prevctx = _localctx; setState(259); match(T__1); setState(260); expr(12); } break; case 4: { _localctx = new IdExprContext(_localctx); _ctx = _localctx; _prevctx = _localctx; setState(261); match(ID); } break; case 5: { _localctx = new IntExprContext(_localctx); _ctx = _localctx; _prevctx = _localctx; setState(262); match(INT); } break; case 6: { _localctx = new RealExprContext(_localctx); _ctx = _localctx; _prevctx = _localctx; setState(263); match(REAL); } break; case 7: { _localctx = new BoolExprContext(_localctx); _ctx = _localctx; _prevctx = _localctx; setState(264); match(BOOL); } break; case 8: { _localctx = new CastExprContext(_localctx); _ctx = _localctx; _prevctx = _localctx; setState(265); ((CastExprContext)_localctx).op = _input.LT(1); _la = _input.LA(1); if ( !(_la==T__34 || _la==T__0) ) { ((CastExprContext)_localctx).op = (Token)_errHandler.recoverInline(this); } consume(); setState(266); match(T__51); setState(267); expr(0); setState(268); match(T__4); } break; case 9: { _localctx = new CallExprContext(_localctx); _ctx = _localctx; _prevctx = _localctx; setState(270); eID(0); setState(271); match(T__51); setState(280); _la = _input.LA(1); if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__51) | (1L << T__44) | (1L << T__34) | (1L << T__24) | (1L << T__19) | (1L << T__13) | (1L << T__2) | (1L << T__1) | (1L << T__0) | (1L << REAL) | (1L << BOOL) | (1L << INT) | (1L << ID))) != 0)) { { setState(272); expr(0); setState(277); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__50) { { { setState(273); match(T__50); setState(274); expr(0); } } setState(279); _errHandler.sync(this); _la = _input.LA(1); } } } setState(282); match(T__4); } break; case 10: { _localctx = new CondactExprContext(_localctx); _ctx = _localctx; _prevctx = _localctx; setState(284); match(T__19); setState(285); match(T__51); setState(286); expr(0); setState(289); _errHandler.sync(this); _la = _input.LA(1); do { { { setState(287); match(T__50); setState(288); expr(0); } } setState(291); _errHandler.sync(this); _la = _input.LA(1); } while ( _la==T__50 ); setState(293); match(T__4); } break; case 11: { _localctx = new IfThenElseExprContext(_localctx); _ctx = _localctx; _prevctx = _localctx; setState(295); match(T__24); setState(296); expr(0); setState(297); match(T__33); setState(298); expr(0); setState(299); match(T__5); setState(300); expr(0); } break; case 12: { _localctx = new RecordExprContext(_localctx); _ctx = _localctx; _prevctx = _localctx; setState(302); match(ID); setState(303); match(T__54); setState(304); match(ID); setState(305); match(T__53); setState(306); expr(0); setState(313); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__27) { { { setState(307); match(T__27); setState(308); match(ID); setState(309); match(T__53); setState(310); expr(0); } } setState(315); _errHandler.sync(this); _la = _input.LA(1); } setState(316); match(T__25); } break; case 13: { _localctx = new ArrayExprContext(_localctx); _ctx = _localctx; _prevctx = _localctx; setState(318); match(T__13); setState(319); expr(0); setState(324); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__50) { { { setState(320); match(T__50); setState(321); expr(0); } } setState(326); _errHandler.sync(this); _la = _input.LA(1); } setState(327); match(T__42); } break; case 14: { _localctx = new TupleExprContext(_localctx); _ctx = _localctx; _prevctx = _localctx; setState(329); match(T__51); setState(330); expr(0); setState(335); _errHandler.sync(this); _la = _input.LA(1); while (_la==T__50) { { { setState(331); match(T__50); setState(332); expr(0); } } setState(337); _errHandler.sync(this); _la = _input.LA(1); } setState(338); match(T__4); } break; } _ctx.stop = _input.LT(-1); setState(387); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,35,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { if ( _parseListeners!=null ) triggerExitRuleEvent(); _prevctx = _localctx; { setState(385); switch ( getInterpreter().adaptivePredict(_input,34,_ctx) ) { case 1: { _localctx = new BinaryExprContext(new ExprContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expr); setState(342); if (!(precpred(_ctx, 11))) throw new FailedPredicateException(this, "precpred(_ctx, 11)"); setState(343); ((BinaryExprContext)_localctx).op = _input.LT(1); _la = _input.LA(1); if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__47) | (1L << T__30) | (1L << T__18) | (1L << T__6))) != 0)) ) { ((BinaryExprContext)_localctx).op = (Token)_errHandler.recoverInline(this); } consume(); setState(344); expr(12); } break; case 2: { _localctx = new BinaryExprContext(new ExprContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expr); setState(345); if (!(precpred(_ctx, 10))) throw new FailedPredicateException(this, "precpred(_ctx, 10)"); setState(346); ((BinaryExprContext)_localctx).op = _input.LT(1); _la = _input.LA(1); if ( !(_la==T__32 || _la==T__1) ) { ((BinaryExprContext)_localctx).op = (Token)_errHandler.recoverInline(this); } consume(); setState(347); expr(11); } break; case 3: { _localctx = new BinaryExprContext(new ExprContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expr); setState(348); if (!(precpred(_ctx, 9))) throw new FailedPredicateException(this, "precpred(_ctx, 9)"); setState(349); ((BinaryExprContext)_localctx).op = _input.LT(1); _la = _input.LA(1); if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__53) | (1L << T__46) | (1L << T__45) | (1L << T__39) | (1L << T__21) | (1L << T__12))) != 0)) ) { ((BinaryExprContext)_localctx).op = (Token)_errHandler.recoverInline(this); } consume(); setState(350); expr(10); } break; case 4: { _localctx = new BinaryExprContext(new ExprContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expr); setState(351); if (!(precpred(_ctx, 8))) throw new FailedPredicateException(this, "precpred(_ctx, 8)"); setState(352); ((BinaryExprContext)_localctx).op = match(T__3); setState(353); expr(9); } break; case 5: { _localctx = new BinaryExprContext(new ExprContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expr); setState(354); if (!(precpred(_ctx, 7))) throw new FailedPredicateException(this, "precpred(_ctx, 7)"); setState(355); ((BinaryExprContext)_localctx).op = _input.LT(1); _la = _input.LA(1); if ( !(_la==T__10 || _la==T__9) ) { ((BinaryExprContext)_localctx).op = (Token)_errHandler.recoverInline(this); } consume(); setState(356); expr(8); } break; case 6: { _localctx = new BinaryExprContext(new ExprContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expr); setState(357); if (!(precpred(_ctx, 6))) throw new FailedPredicateException(this, "precpred(_ctx, 6)"); setState(358); ((BinaryExprContext)_localctx).op = match(T__7); setState(359); expr(6); } break; case 7: { _localctx = new BinaryExprContext(new ExprContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expr); setState(360); if (!(precpred(_ctx, 5))) throw new FailedPredicateException(this, "precpred(_ctx, 5)"); setState(361); ((BinaryExprContext)_localctx).op = match(T__16); setState(362); expr(5); } break; case 8: { _localctx = new RecordAccessExprContext(new ExprContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expr); setState(363); if (!(precpred(_ctx, 18))) throw new FailedPredicateException(this, "precpred(_ctx, 18)"); setState(364); match(T__17); setState(365); match(ID); } break; case 9: { _localctx = new RecordUpdateExprContext(new ExprContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expr); setState(366); if (!(precpred(_ctx, 17))) throw new FailedPredicateException(this, "precpred(_ctx, 17)"); setState(367); match(T__54); setState(368); match(ID); setState(369); match(T__23); setState(370); expr(0); setState(371); match(T__25); } break; case 10: { _localctx = new ArrayAccessExprContext(new ExprContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expr); setState(373); if (!(precpred(_ctx, 16))) throw new FailedPredicateException(this, "precpred(_ctx, 16)"); setState(374); match(T__13); setState(375); expr(0); setState(376); match(T__42); } break; case 11: { _localctx = new ArrayUpdateExprContext(new ExprContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_expr); setState(378); if (!(precpred(_ctx, 15))) throw new FailedPredicateException(this, "precpred(_ctx, 15)"); setState(379); match(T__13); setState(380); expr(0); setState(381); match(T__23); setState(382); expr(0); setState(383); match(T__42); } break; } } } setState(389); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,35,_ctx); } } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { unrollRecursionContexts(_parentctx); } return _localctx; } public static class EIDContext extends ParserRuleContext { public EIDContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @Override public int getRuleIndex() { return RULE_eID; } public EIDContext() { } public void copyFrom(EIDContext ctx) { super.copyFrom(ctx); } } public static class BaseEIDContext extends EIDContext { public TerminalNode ID() { return getToken(LustreParser.ID, 0); } public BaseEIDContext(EIDContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitBaseEID(this); else return visitor.visitChildren(this); } } public static class ArrayEIDContext extends EIDContext { public EIDContext eID() { return getRuleContext(EIDContext.class,0); } public TerminalNode INT() { return getToken(LustreParser.INT, 0); } public ArrayEIDContext(EIDContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitArrayEID(this); else return visitor.visitChildren(this); } } public static class RecordEIDContext extends EIDContext { public TerminalNode ID() { return getToken(LustreParser.ID, 0); } public EIDContext eID() { return getRuleContext(EIDContext.class,0); } public RecordEIDContext(EIDContext ctx) { copyFrom(ctx); } @Override public <T> T accept(ParseTreeVisitor<? extends T> visitor) { if ( visitor instanceof LustreVisitor ) return ((LustreVisitor<? extends T>)visitor).visitRecordEID(this); else return visitor.visitChildren(this); } } public final EIDContext eID() throws RecognitionException { return eID(0); } private EIDContext eID(int _p) throws RecognitionException { ParserRuleContext _parentctx = _ctx; int _parentState = getState(); EIDContext _localctx = new EIDContext(_ctx, _parentState); EIDContext _prevctx = _localctx; int _startState = 36; enterRecursionRule(_localctx, 36, RULE_eID, _p); try { int _alt; enterOuterAlt(_localctx, 1); { { _localctx = new BaseEIDContext(_localctx); _ctx = _localctx; _prevctx = _localctx; setState(391); match(ID); } _ctx.stop = _input.LT(-1); setState(402); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,37,_ctx); while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { if ( _parseListeners!=null ) triggerExitRuleEvent(); _prevctx = _localctx; { setState(400); switch ( getInterpreter().adaptivePredict(_input,36,_ctx) ) { case 1: { _localctx = new ArrayEIDContext(new EIDContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_eID); setState(393); if (!(precpred(_ctx, 2))) throw new FailedPredicateException(this, "precpred(_ctx, 2)"); setState(394); match(T__13); setState(395); match(INT); setState(396); match(T__42); } break; case 2: { _localctx = new RecordEIDContext(new EIDContext(_parentctx, _parentState)); pushNewRecursionContext(_localctx, _startState, RULE_eID); setState(397); if (!(precpred(_ctx, 1))) throw new FailedPredicateException(this, "precpred(_ctx, 1)"); setState(398); match(T__17); setState(399); match(ID); } break; } } } setState(404); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,37,_ctx); } } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { unrollRecursionContexts(_parentctx); } return _localctx; } public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) { switch (ruleIndex) { case 8: return type_sempred((TypeContext)_localctx, predIndex); case 17: return expr_sempred((ExprContext)_localctx, predIndex); case 18: return eID_sempred((EIDContext)_localctx, predIndex); } return true; } private boolean eID_sempred(EIDContext _localctx, int predIndex) { switch (predIndex) { case 12: return precpred(_ctx, 2); case 13: return precpred(_ctx, 1); } return true; } private boolean expr_sempred(ExprContext _localctx, int predIndex) { switch (predIndex) { case 1: return precpred(_ctx, 11); case 2: return precpred(_ctx, 10); case 3: return precpred(_ctx, 9); case 4: return precpred(_ctx, 8); case 5: return precpred(_ctx, 7); case 6: return precpred(_ctx, 6); case 7: return precpred(_ctx, 5); case 8: return precpred(_ctx, 18); case 9: return precpred(_ctx, 17); case 10: return precpred(_ctx, 16); case 11: return precpred(_ctx, 15); } return true; } private boolean type_sempred(TypeContext _localctx, int predIndex) { switch (predIndex) { case 0: return precpred(_ctx, 2); } return true; } public static final String _serializedATN = "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\3A\u0198\4\2\t\2\4"+ "\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t"+ "\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ "\4\23\t\23\4\24\t\24\3\2\3\2\3\2\3\2\7\2-\n\2\f\2\16\2\60\13\2\3\2\3\2"+ "\3\3\3\3\3\3\3\3\3\3\3\3\3\4\3\4\3\4\3\4\5\4>\n\4\3\4\3\4\3\4\3\4\3\5"+ "\3\5\3\5\3\5\5\5H\n\5\3\5\3\5\3\5\3\5\5\5N\n\5\3\5\3\5\3\5\3\5\3\5\3\5"+ "\5\5V\n\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\7\5_\n\5\f\5\16\5b\13\5\3\5\3\5"+ "\5\5f\n\5\3\6\3\6\3\6\3\6\5\6l\n\6\3\6\3\6\3\6\3\6\5\6r\n\6\3\6\3\6\3"+ "\6\3\7\3\7\3\7\7\7z\n\7\f\7\16\7}\13\7\3\b\3\b\3\b\7\b\u0082\n\b\f\b\16"+ "\b\u0085\13\b\3\b\3\b\3\b\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t"+ "\7\t\u0095\n\t\f\t\16\t\u0098\13\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\7\t\u00a1"+ "\n\t\f\t\16\t\u00a4\13\t\3\t\5\t\u00a7\n\t\3\n\3\n\3\n\3\n\3\n\3\n\3\n"+ "\3\n\3\n\3\n\3\n\3\n\3\n\3\n\5\n\u00b7\n\n\3\n\3\n\3\n\3\n\7\n\u00bd\n"+ "\n\f\n\16\n\u00c0\13\n\3\13\5\13\u00c3\n\13\3\13\3\13\3\f\3\f\3\f\3\f"+ "\3\r\3\r\3\r\3\r\7\r\u00cf\n\r\f\r\16\r\u00d2\13\r\5\r\u00d4\n\r\3\r\3"+ "\r\3\16\3\16\3\16\3\16\7\16\u00dc\n\16\f\16\16\16\u00df\13\16\5\16\u00e1"+ "\n\16\3\16\3\16\3\17\3\17\5\17\u00e7\n\17\3\20\3\20\3\20\3\20\3\21\3\21"+ "\3\21\5\21\u00f0\n\21\3\21\5\21\u00f3\n\21\3\21\3\21\3\21\3\21\3\22\3"+ "\22\3\22\7\22\u00fc\n\22\f\22\16\22\u00ff\13\22\3\23\3\23\3\23\3\23\3"+ "\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3"+ "\23\3\23\3\23\7\23\u0116\n\23\f\23\16\23\u0119\13\23\5\23\u011b\n\23\3"+ "\23\3\23\3\23\3\23\3\23\3\23\3\23\6\23\u0124\n\23\r\23\16\23\u0125\3\23"+ "\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23"+ "\3\23\3\23\3\23\7\23\u013a\n\23\f\23\16\23\u013d\13\23\3\23\3\23\3\23"+ "\3\23\3\23\3\23\7\23\u0145\n\23\f\23\16\23\u0148\13\23\3\23\3\23\3\23"+ "\3\23\3\23\3\23\7\23\u0150\n\23\f\23\16\23\u0153\13\23\3\23\3\23\5\23"+ "\u0157\n\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23"+ "\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23"+ "\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23"+ "\3\23\3\23\3\23\7\23\u0184\n\23\f\23\16\23\u0187\13\23\3\24\3\24\3\24"+ "\3\24\3\24\3\24\3\24\3\24\3\24\3\24\7\24\u0193\n\24\f\24\16\24\u0196\13"+ "\24\3\24\2\5\22$&\25\2\4\6\b\n\f\16\20\22\24\26\30\32\34\36 \"$&\2\7\4"+ "\2\27\2799\6\2\n\n\33\33\'\'\63\63\4\2\31\3188\7\2\4\4\13\f\22\22$$--"+ "\3\2/\60\u01c9\2.\3\2\2\2\4\63\3\2\2\2\69\3\2\2\2\bC\3\2\2\2\ng\3\2\2"+ "\2\fv\3\2\2\2\16~\3\2\2\2\20\u00a6\3\2\2\2\22\u00b6\3\2\2\2\24\u00c2\3"+ "\2\2\2\26\u00c6\3\2\2\2\30\u00ca\3\2\2\2\32\u00d7\3\2\2\2\34\u00e4\3\2"+ "\2\2\36\u00e8\3\2\2\2 \u00f2\3\2\2\2\"\u00f8\3\2\2\2$\u0156\3\2\2\2&\u0188"+ "\3\2\2\2(-\5\4\3\2)-\5\6\4\2*-\5\b\5\2+-\5\n\6\2,(\3\2\2\2,)\3\2\2\2,"+ "*\3\2\2\2,+\3\2\2\2-\60\3\2\2\2.,\3\2\2\2./\3\2\2\2/\61\3\2\2\2\60.\3"+ "\2\2\2\61\62\7\2\2\3\62\3\3\2\2\2\63\64\7\21\2\2\64\65\7=\2\2\65\66\7"+ "\4\2\2\66\67\5\20\t\2\678\7\36\2\28\5\3\2\2\29:\7\t\2\2:=\7=\2\2;<\7*"+ "\2\2<>\5\22\n\2=;\3\2\2\2=>\3\2\2\2>?\3\2\2\2?@\7\4\2\2@A\5$\23\2AB\7"+ "\36\2\2B\7\3\2\2\2CD\7\20\2\2DE\7=\2\2EG\7\6\2\2FH\5\f\7\2GF\3\2\2\2G"+ "H\3\2\2\2HI\3\2\2\2IJ\7\65\2\2JK\7\24\2\2KM\7\6\2\2LN\5\f\7\2ML\3\2\2"+ "\2MN\3\2\2\2NO\3\2\2\2OP\7\65\2\2PU\7\36\2\2QR\7\b\2\2RS\5\f\7\2ST\7\36"+ "\2\2TV\3\2\2\2UQ\3\2\2\2UV\3\2\2\2VW\3\2\2\2W`\7\23\2\2X_\5 \21\2Y_\5"+ "\26\f\2Z_\5\36\20\2[_\5\34\17\2\\_\5\30\r\2]_\5\32\16\2^X\3\2\2\2^Y\3"+ "\2\2\2^Z\3\2\2\2^[\3\2\2\2^\\\3\2\2\2^]\3\2\2\2_b\3\2\2\2`^\3\2\2\2`a"+ "\3\2\2\2ac\3\2\2\2b`\3\2\2\2ce\7\25\2\2df\7\36\2\2ed\3\2\2\2ef\3\2\2\2"+ "f\t\3\2\2\2gh\7\26\2\2hi\5&\24\2ik\7\6\2\2jl\5\f\7\2kj\3\2\2\2kl\3\2\2"+ "\2lm\3\2\2\2mn\7\65\2\2no\7\24\2\2oq\7\6\2\2pr\5\f\7\2qp\3\2\2\2qr\3\2"+ "\2\2rs\3\2\2\2st\7\65\2\2tu\7\36\2\2u\13\3\2\2\2v{\5\16\b\2wx\7\36\2\2"+ "xz\5\16\b\2yw\3\2\2\2z}\3\2\2\2{y\3\2\2\2{|\3\2\2\2|\r\3\2\2\2}{\3\2\2"+ "\2~\u0083\5&\24\2\177\u0080\7\7\2\2\u0080\u0082\5&\24\2\u0081\177\3\2"+ "\2\2\u0082\u0085\3\2\2\2\u0083\u0081\3\2\2\2\u0083\u0084\3\2\2\2\u0084"+ "\u0086\3\2\2\2\u0085\u0083\3\2\2\2\u0086\u0087\7*\2\2\u0087\u0088\5\22"+ "\n\2\u0088\17\3\2\2\2\u0089\u00a7\5\22\n\2\u008a\u008b\7\32\2\2\u008b"+ "\u008c\7\3\2\2\u008c\u008d\7=\2\2\u008d\u008e\7*\2\2\u008e\u008f\5\22"+ "\n\2\u008f\u0096\3\2\2\2\u0090\u0091\7\36\2\2\u0091\u0092\7=\2\2\u0092"+ "\u0093\7*\2\2\u0093\u0095\5\22\n\2\u0094\u0090\3\2\2\2\u0095\u0098\3\2"+ "\2\2\u0096\u0094\3\2\2\2\u0096\u0097\3\2\2\2\u0097\u0099\3\2\2\2\u0098"+ "\u0096\3\2\2\2\u0099\u009a\7 \2\2\u009a\u00a7\3\2\2\2\u009b\u009c\7#\2"+ "\2\u009c\u009d\7\3\2\2\u009d\u00a2\7=\2\2\u009e\u009f\7\7\2\2\u009f\u00a1"+ "\7=\2\2\u00a0\u009e\3\2\2\2\u00a1\u00a4\3\2\2\2\u00a2\u00a0\3\2\2\2\u00a2"+ "\u00a3\3\2\2\2\u00a3\u00a5\3\2\2\2\u00a4\u00a2\3\2\2\2\u00a5\u00a7\7 "+ "\2\2\u00a6\u0089\3\2\2\2\u00a6\u008a\3\2\2\2\u00a6\u009b\3\2\2\2\u00a7"+ "\21\3\2\2\2\u00a8\u00a9\b\n\1\2\u00a9\u00b7\7\5\2\2\u00aa\u00ab\7\61\2"+ "\2\u00ab\u00ac\7,\2\2\u00ac\u00ad\5\24\13\2\u00ad\u00ae\7\7\2\2\u00ae"+ "\u00af\5\24\13\2\u00af\u00b0\7\17\2\2\u00b0\u00b1\7\34\2\2\u00b1\u00b2"+ "\7\5\2\2\u00b2\u00b7\3\2\2\2\u00b3\u00b7\7.\2\2\u00b4\u00b7\79\2\2\u00b5"+ "\u00b7\7=\2\2\u00b6\u00a8\3\2\2\2\u00b6\u00aa\3\2\2\2\u00b6\u00b3\3\2"+ "\2\2\u00b6\u00b4\3\2\2\2\u00b6\u00b5\3\2\2\2\u00b7\u00be\3\2\2\2\u00b8"+ "\u00b9\f\4\2\2\u00b9\u00ba\7,\2\2\u00ba\u00bb\7<\2\2\u00bb\u00bd\7\17"+ "\2\2\u00bc\u00b8\3\2\2\2\u00bd\u00c0\3\2\2\2\u00be\u00bc\3\2\2\2\u00be"+ "\u00bf\3\2\2\2\u00bf\23\3\2\2\2\u00c0\u00be\3\2\2\2\u00c1\u00c3\78\2\2"+ "\u00c2\u00c1\3\2\2\2\u00c2\u00c3\3\2\2\2\u00c3\u00c4\3\2\2\2\u00c4\u00c5"+ "\7<\2\2\u00c5\25\3\2\2\2\u00c6\u00c7\7\37\2\2\u00c7\u00c8\5&\24\2\u00c8"+ "\u00c9\7\36\2\2\u00c9\27\3\2\2\2\u00ca\u00d3\7\35\2\2\u00cb\u00d0\7=\2"+ "\2\u00cc\u00cd\7\7\2\2\u00cd\u00cf\7=\2\2\u00ce\u00cc\3\2\2\2\u00cf\u00d2"+ "\3\2\2\2\u00d0\u00ce\3\2\2\2\u00d0\u00d1\3\2\2\2\u00d1\u00d4\3\2\2\2\u00d2"+ "\u00d0\3\2\2\2\u00d3\u00cb\3\2\2\2\u00d3\u00d4\3\2\2\2\u00d4\u00d5\3\2"+ "\2\2\u00d5\u00d6\7\36\2\2\u00d6\31\3\2\2\2\u00d7\u00e0\7+\2\2\u00d8\u00dd"+ "\5&\24\2\u00d9\u00da\7\7\2\2\u00da\u00dc\5&\24\2\u00db\u00d9\3\2\2\2\u00dc"+ "\u00df\3\2\2\2\u00dd\u00db\3\2\2\2\u00dd\u00de\3\2\2\2\u00de\u00e1\3\2"+ "\2\2\u00df\u00dd\3\2\2\2\u00e0\u00d8\3\2\2\2\u00e0\u00e1\3\2\2\2\u00e1"+ "\u00e2\3\2\2\2\u00e2\u00e3\7\36\2\2\u00e3\33\3\2\2\2\u00e4\u00e6\7%\2"+ "\2\u00e5\u00e7\7\36\2\2\u00e6\u00e5\3\2\2\2\u00e6\u00e7\3\2\2\2\u00e7"+ "\35\3\2\2\2\u00e8\u00e9\7\16\2\2\u00e9\u00ea\5$\23\2\u00ea\u00eb\7\36"+ "\2\2\u00eb\37\3\2\2\2\u00ec\u00f3\5\"\22\2\u00ed\u00ef\7\6\2\2\u00ee\u00f0"+ "\5\"\22\2\u00ef\u00ee\3\2\2\2\u00ef\u00f0\3\2\2\2\u00f0\u00f1\3\2\2\2"+ "\u00f1\u00f3\7\65\2\2\u00f2\u00ec\3\2\2\2\u00f2\u00ed\3\2\2\2\u00f3\u00f4"+ "\3\2\2\2\u00f4\u00f5\7\4\2\2\u00f5\u00f6\5$\23\2\u00f6\u00f7\7\36\2\2"+ "\u00f7!\3\2\2\2\u00f8\u00fd\5&\24\2\u00f9\u00fa\7\7\2\2\u00fa\u00fc\5"+ "&\24\2\u00fb\u00f9\3\2\2\2\u00fc\u00ff\3\2\2\2\u00fd\u00fb\3\2\2\2\u00fd"+ "\u00fe\3\2\2\2\u00fe#\3\2\2\2\u00ff\u00fd\3\2\2\2\u0100\u0101\b\23\1\2"+ "\u0101\u0102\7\r\2\2\u0102\u0157\5$\23\20\u0103\u0104\7\67\2\2\u0104\u0157"+ "\5$\23\17\u0105\u0106\78\2\2\u0106\u0157\5$\23\16\u0107\u0157\7=\2\2\u0108"+ "\u0157\7<\2\2\u0109\u0157\7:\2\2\u010a\u0157\7;\2\2\u010b\u010c\t\2\2"+ "\2\u010c\u010d\7\6\2\2\u010d\u010e\5$\23\2\u010e\u010f\7\65\2\2\u010f"+ "\u0157\3\2\2\2\u0110\u0111\5&\24\2\u0111\u011a\7\6\2\2\u0112\u0117\5$"+ "\23\2\u0113\u0114\7\7\2\2\u0114\u0116\5$\23\2\u0115\u0113\3\2\2\2\u0116"+ "\u0119\3\2\2\2\u0117\u0115\3\2\2\2\u0117\u0118\3\2\2\2\u0118\u011b\3\2"+ "\2\2\u0119\u0117\3\2\2\2\u011a\u0112\3\2\2\2\u011a\u011b\3\2\2\2\u011b"+ "\u011c\3\2\2\2\u011c\u011d\7\65\2\2\u011d\u0157\3\2\2\2\u011e\u011f\7"+ "&\2\2\u011f\u0120\7\6\2\2\u0120\u0123\5$\23\2\u0121\u0122\7\7\2\2\u0122"+ "\u0124\5$\23\2\u0123\u0121\3\2\2\2\u0124\u0125\3\2\2\2\u0125\u0123\3\2"+ "\2\2\u0125\u0126\3\2\2\2\u0126\u0127\3\2\2\2\u0127\u0128\7\65\2\2\u0128"+ "\u0157\3\2\2\2\u0129\u012a\7!\2\2\u012a\u012b\5$\23\2\u012b\u012c\7\30"+ "\2\2\u012c\u012d\5$\23\2\u012d\u012e\7\64\2\2\u012e\u012f\5$\23\2\u012f"+ "\u0157\3\2\2\2\u0130\u0131\7=\2\2\u0131\u0132\7\3\2\2\u0132\u0133\7=\2"+ "\2\u0133\u0134\7\4\2\2\u0134\u013b\5$\23\2\u0135\u0136\7\36\2\2\u0136"+ "\u0137\7=\2\2\u0137\u0138\7\4\2\2\u0138\u013a\5$\23\2\u0139\u0135\3\2"+ "\2\2\u013a\u013d\3\2\2\2\u013b\u0139\3\2\2\2\u013b\u013c\3\2\2\2\u013c"+ "\u013e\3\2\2\2\u013d\u013b\3\2\2\2\u013e\u013f\7 \2\2\u013f\u0157\3\2"+ "\2\2\u0140\u0141\7,\2\2\u0141\u0146\5$\23\2\u0142\u0143\7\7\2\2\u0143"+ "\u0145\5$\23\2\u0144\u0142\3\2\2\2\u0145\u0148\3\2\2\2\u0146\u0144\3\2"+ "\2\2\u0146\u0147\3\2\2\2\u0147\u0149\3\2\2\2\u0148\u0146\3\2\2\2\u0149"+ "\u014a\7\17\2\2\u014a\u0157\3\2\2\2\u014b\u014c\7\6\2\2\u014c\u0151\5"+ "$\23\2\u014d\u014e\7\7\2\2\u014e\u0150\5$\23\2\u014f\u014d\3\2\2\2\u0150"+ "\u0153\3\2\2\2\u0151\u014f\3\2\2\2\u0151\u0152\3\2\2\2\u0152\u0154\3\2"+ "\2\2\u0153\u0151\3\2\2\2\u0154\u0155\7\65\2\2\u0155\u0157\3\2\2\2\u0156"+ "\u0100\3\2\2\2\u0156\u0103\3\2\2\2\u0156\u0105\3\2\2\2\u0156\u0107\3\2"+ "\2\2\u0156\u0108\3\2\2\2\u0156\u0109\3\2\2\2\u0156\u010a\3\2\2\2\u0156"+ "\u010b\3\2\2\2\u0156\u0110\3\2\2\2\u0156\u011e\3\2\2\2\u0156\u0129\3\2"+ "\2\2\u0156\u0130\3\2\2\2\u0156\u0140\3\2\2\2\u0156\u014b\3\2\2\2\u0157"+ "\u0185\3\2\2\2\u0158\u0159\f\r\2\2\u0159\u015a\t\3\2\2\u015a\u0184\5$"+ "\23\16\u015b\u015c\f\f\2\2\u015c\u015d\t\4\2\2\u015d\u0184\5$\23\r\u015e"+ "\u015f\f\13\2\2\u015f\u0160\t\5\2\2\u0160\u0184\5$\23\f\u0161\u0162\f"+ "\n\2\2\u0162\u0163\7\66\2\2\u0163\u0184\5$\23\13\u0164\u0165\f\t\2\2\u0165"+ "\u0166\t\6\2\2\u0166\u0184\5$\23\n\u0167\u0168\f\b\2\2\u0168\u0169\7\62"+ "\2\2\u0169\u0184\5$\23\b\u016a\u016b\f\7\2\2\u016b\u016c\7)\2\2\u016c"+ "\u0184\5$\23\7\u016d\u016e\f\24\2\2\u016e\u016f\7(\2\2\u016f\u0184\7="+ "\2\2\u0170\u0171\f\23\2\2\u0171\u0172\7\3\2\2\u0172\u0173\7=\2\2\u0173"+ "\u0174\7\"\2\2\u0174\u0175\5$\23\2\u0175\u0176\7 \2\2\u0176\u0184\3\2"+ "\2\2\u0177\u0178\f\22\2\2\u0178\u0179\7,\2\2\u0179\u017a\5$\23\2\u017a"+ "\u017b\7\17\2\2\u017b\u0184\3\2\2\2\u017c\u017d\f\21\2\2\u017d\u017e\7"+ ",\2\2\u017e\u017f\5$\23\2\u017f\u0180\7\"\2\2\u0180\u0181\5$\23\2\u0181"+ "\u0182\7\17\2\2\u0182\u0184\3\2\2\2\u0183\u0158\3\2\2\2\u0183\u015b\3"+ "\2\2\2\u0183\u015e\3\2\2\2\u0183\u0161\3\2\2\2\u0183\u0164\3\2\2\2\u0183"+ "\u0167\3\2\2\2\u0183\u016a\3\2\2\2\u0183\u016d\3\2\2\2\u0183\u0170\3\2"+ "\2\2\u0183\u0177\3\2\2\2\u0183\u017c\3\2\2\2\u0184\u0187\3\2\2\2\u0185"+ "\u0183\3\2\2\2\u0185\u0186\3\2\2\2\u0186%\3\2\2\2\u0187\u0185\3\2\2\2"+ "\u0188\u0189\b\24\1\2\u0189\u018a\7=\2\2\u018a\u0194\3\2\2\2\u018b\u018c"+ "\f\4\2\2\u018c\u018d\7,\2\2\u018d\u018e\7<\2\2\u018e\u0193\7\17\2\2\u018f"+ "\u0190\f\3\2\2\u0190\u0191\7(\2\2\u0191\u0193\7=\2\2\u0192\u018b\3\2\2"+ "\2\u0192\u018f\3\2\2\2\u0193\u0196\3\2\2\2\u0194\u0192\3\2\2\2\u0194\u0195"+ "\3\2\2\2\u0195\'\3\2\2\2\u0196\u0194\3\2\2\2(,.=GMU^`ekq{\u0083\u0096"+ "\u00a2\u00a6\u00b6\u00be\u00c2\u00d0\u00d3\u00dd\u00e0\u00e6\u00ef\u00f2"+ "\u00fd\u0117\u011a\u0125\u013b\u0146\u0151\u0156\u0183\u0185\u0192\u0194"; public static final ATN _ATN = new ATNDeserializer().deserialize(_serializedATN.toCharArray()); static { _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); } } }
75,863
31.955691
255
java
jkind
jkind-master/jkind-common/src/jkind/lustre/parsing/LustreLexer.java
// Generated from Lustre.g4 by ANTLR 4.4 package jkind.lustre.parsing; import org.antlr.v4.runtime.Lexer; import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.Token; import org.antlr.v4.runtime.TokenStream; import org.antlr.v4.runtime.*; import org.antlr.v4.runtime.atn.*; import org.antlr.v4.runtime.dfa.DFA; import org.antlr.v4.runtime.misc.*; @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) public class LustreLexer extends Lexer { static { RuntimeMetaData.checkVersion("4.4", RuntimeMetaData.VERSION); } protected static final DFA[] _decisionToDFA; protected static final PredictionContextCache _sharedContextCache = new PredictionContextCache(); public static final int T__54=1, T__53=2, T__52=3, T__51=4, T__50=5, T__49=6, T__48=7, T__47=8, T__46=9, T__45=10, T__44=11, T__43=12, T__42=13, T__41=14, T__40=15, T__39=16, T__38=17, T__37=18, T__36=19, T__35=20, T__34=21, T__33=22, T__32=23, T__31=24, T__30=25, T__29=26, T__28=27, T__27=28, T__26=29, T__25=30, T__24=31, T__23=32, T__22=33, T__21=34, T__20=35, T__19=36, T__18=37, T__17=38, T__16=39, T__15=40, T__14=41, T__13=42, T__12=43, T__11=44, T__10=45, T__9=46, T__8=47, T__7=48, T__6=49, T__5=50, T__4=51, T__3=52, T__2=53, T__1=54, T__0=55, REAL=56, BOOL=57, INT=58, ID=59, WS=60, SL_COMMENT=61, ML_COMMENT=62, ERROR=63; public static String[] modeNames = { "DEFAULT_MODE" }; public static final String[] tokenNames = { "'\\u0000'", "'\\u0001'", "'\\u0002'", "'\\u0003'", "'\\u0004'", "'\\u0005'", "'\\u0006'", "'\\u0007'", "'\b'", "'\t'", "'\n'", "'\\u000B'", "'\f'", "'\r'", "'\\u000E'", "'\\u000F'", "'\\u0010'", "'\\u0011'", "'\\u0012'", "'\\u0013'", "'\\u0014'", "'\\u0015'", "'\\u0016'", "'\\u0017'", "'\\u0018'", "'\\u0019'", "'\\u001A'", "'\\u001B'", "'\\u001C'", "'\\u001D'", "'\\u001E'", "'\\u001F'", "' '", "'!'", "'\"'", "'#'", "'$'", "'%'", "'&'", "'''", "'('", "')'", "'*'", "'+'", "','", "'-'", "'.'", "'/'", "'0'", "'1'", "'2'", "'3'", "'4'", "'5'", "'6'", "'7'", "'8'", "'9'", "':'", "';'", "'<'", "'='", "'>'", "'?'" }; public static final String[] ruleNames = { "T__54", "T__53", "T__52", "T__51", "T__50", "T__49", "T__48", "T__47", "T__46", "T__45", "T__44", "T__43", "T__42", "T__41", "T__40", "T__39", "T__38", "T__37", "T__36", "T__35", "T__34", "T__33", "T__32", "T__31", "T__30", "T__29", "T__28", "T__27", "T__26", "T__25", "T__24", "T__23", "T__22", "T__21", "T__20", "T__19", "T__18", "T__17", "T__16", "T__15", "T__14", "T__13", "T__12", "T__11", "T__10", "T__9", "T__8", "T__7", "T__6", "T__5", "T__4", "T__3", "T__2", "T__1", "T__0", "REAL", "BOOL", "INT", "ID", "WS", "SL_COMMENT", "ML_COMMENT", "ERROR" }; public LustreLexer(CharStream input) { super(input); _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); } @Override public String getGrammarFileName() { return "Lustre.g4"; } @Override public String[] getTokenNames() { return tokenNames; } @Override public String[] getRuleNames() { return ruleNames; } @Override public String getSerializedATN() { return _serializedATN; } @Override public String[] getModeNames() { return modeNames; } @Override public ATN getATN() { return _ATN; } public static final String _serializedATN = "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\2A\u01b5\b\1\4\2\t"+ "\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+ "\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+ "\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!"+ "\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4"+ ",\t,\4-\t-\4.\t.\4/\t/\4\60\t\60\4\61\t\61\4\62\t\62\4\63\t\63\4\64\t"+ "\64\4\65\t\65\4\66\t\66\4\67\t\67\48\t8\49\t9\4:\t:\4;\t;\4<\t<\4=\t="+ "\4>\t>\4?\t?\4@\t@\3\2\3\2\3\3\3\3\3\4\3\4\3\4\3\4\3\5\3\5\3\6\3\6\3\7"+ "\3\7\3\7\3\7\3\b\3\b\3\b\3\b\3\b\3\b\3\t\3\t\3\t\3\t\3\n\3\n\3\n\3\13"+ "\3\13\3\f\3\f\3\f\3\f\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\16\3\16\3\17\3\17"+ "\3\17\3\17\3\17\3\20\3\20\3\20\3\20\3\20\3\21\3\21\3\21\3\22\3\22\3\22"+ "\3\22\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\24\3\24\3\24\3\24\3\25"+ "\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\26\3\26\3\26\3\26\3\26\3\26"+ "\3\27\3\27\3\27\3\27\3\27\3\30\3\30\3\31\3\31\3\31\3\31\3\31\3\31\3\31"+ "\3\32\3\32\3\33\3\33\3\33\3\34\3\34\3\34\3\34\3\34\3\34\3\34\3\34\3\34"+ "\3\34\3\34\3\34\3\34\3\34\3\35\3\35\3\36\3\36\3\36\3\36\3\36\3\36\3\36"+ "\3\36\3\36\3\36\3\36\3\36\3\37\3\37\3 \3 \3 \3!\3!\3!\3\"\3\"\3\"\3\""+ "\3\"\3#\3#\3#\3$\3$\3$\3$\3$\3$\3$\3$\3%\3%\3%\3%\3%\3%\3%\3%\3&\3&\3"+ "\'\3\'\3(\3(\3(\3)\3)\3*\3*\3*\3*\3*\3*\3*\3+\3+\3,\3,\3-\3-\3-\3-\3-"+ "\3.\3.\3.\3.\3/\3/\3/\3\60\3\60\3\60\3\60\3\60\3\60\3\60\3\60\3\60\3\61"+ "\3\61\3\61\3\62\3\62\3\62\3\62\3\63\3\63\3\63\3\63\3\63\3\64\3\64\3\65"+ "\3\65\3\65\3\65\3\66\3\66\3\66\3\66\3\67\3\67\38\38\38\38\38\39\39\39"+ "\39\3:\3:\3:\3:\3:\3:\3:\3:\3:\5:\u017c\n:\3;\6;\u017f\n;\r;\16;\u0180"+ "\3<\3<\7<\u0185\n<\f<\16<\u0188\13<\3=\6=\u018b\n=\r=\16=\u018c\3=\3="+ "\3>\3>\3>\3>\3>\7>\u0196\n>\f>\16>\u0199\13>\3>\5>\u019c\n>\3>\5>\u019f"+ "\n>\3>\5>\u01a2\n>\3>\3>\3?\3?\3?\3?\7?\u01aa\n?\f?\16?\u01ad\13?\3?\3"+ "?\3?\3?\3?\3@\3@\3\u01ab\2A\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25"+ "\f\27\r\31\16\33\17\35\20\37\21!\22#\23%\24\'\25)\26+\27-\30/\31\61\32"+ "\63\33\65\34\67\359\36;\37= ?!A\"C#E$G%I&K\'M(O)Q*S+U,W-Y.[/]\60_\61a"+ "\62c\63e\64g\65i\66k\67m8o9q:s;u<w=y>{?}@\177A\3\2\b\3\2\62;\7\2##C\\"+ "aac|\u0080\u0080\b\2##\62;C\\aac|\u0080\u0080\5\2\13\f\16\17\"\"\5\2\f"+ "\f\17\17\'\'\4\2\f\f\17\17\u01bd\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2"+ "\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2"+ "\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2"+ "\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2"+ "\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2"+ "\2\2\67\3\2\2\2\29\3\2\2\2\2;\3\2\2\2\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2"+ "\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2\2\2I\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O"+ "\3\2\2\2\2Q\3\2\2\2\2S\3\2\2\2\2U\3\2\2\2\2W\3\2\2\2\2Y\3\2\2\2\2[\3\2"+ "\2\2\2]\3\2\2\2\2_\3\2\2\2\2a\3\2\2\2\2c\3\2\2\2\2e\3\2\2\2\2g\3\2\2\2"+ "\2i\3\2\2\2\2k\3\2\2\2\2m\3\2\2\2\2o\3\2\2\2\2q\3\2\2\2\2s\3\2\2\2\2u"+ "\3\2\2\2\2w\3\2\2\2\2y\3\2\2\2\2{\3\2\2\2\2}\3\2\2\2\2\177\3\2\2\2\3\u0081"+ "\3\2\2\2\5\u0083\3\2\2\2\7\u0085\3\2\2\2\t\u0089\3\2\2\2\13\u008b\3\2"+ "\2\2\r\u008d\3\2\2\2\17\u0091\3\2\2\2\21\u0097\3\2\2\2\23\u009b\3\2\2"+ "\2\25\u009e\3\2\2\2\27\u00a0\3\2\2\2\31\u00a4\3\2\2\2\33\u00ab\3\2\2\2"+ "\35\u00ad\3\2\2\2\37\u00b2\3\2\2\2!\u00b7\3\2\2\2#\u00ba\3\2\2\2%\u00be"+ "\3\2\2\2\'\u00c6\3\2\2\2)\u00ca\3\2\2\2+\u00d3\3\2\2\2-\u00d9\3\2\2\2"+ "/\u00de\3\2\2\2\61\u00e0\3\2\2\2\63\u00e7\3\2\2\2\65\u00e9\3\2\2\2\67"+ "\u00ec\3\2\2\29\u00fa\3\2\2\2;\u00fc\3\2\2\2=\u0108\3\2\2\2?\u010a\3\2"+ "\2\2A\u010d\3\2\2\2C\u0110\3\2\2\2E\u0115\3\2\2\2G\u0118\3\2\2\2I\u0120"+ "\3\2\2\2K\u0128\3\2\2\2M\u012a\3\2\2\2O\u012c\3\2\2\2Q\u012f\3\2\2\2S"+ "\u0131\3\2\2\2U\u0138\3\2\2\2W\u013a\3\2\2\2Y\u013c\3\2\2\2[\u0141\3\2"+ "\2\2]\u0145\3\2\2\2_\u0148\3\2\2\2a\u0151\3\2\2\2c\u0154\3\2\2\2e\u0158"+ "\3\2\2\2g\u015d\3\2\2\2i\u015f\3\2\2\2k\u0163\3\2\2\2m\u0167\3\2\2\2o"+ "\u0169\3\2\2\2q\u016e\3\2\2\2s\u017b\3\2\2\2u\u017e\3\2\2\2w\u0182\3\2"+ "\2\2y\u018a\3\2\2\2{\u0190\3\2\2\2}\u01a5\3\2\2\2\177\u01b3\3\2\2\2\u0081"+ "\u0082\7}\2\2\u0082\4\3\2\2\2\u0083\u0084\7?\2\2\u0084\6\3\2\2\2\u0085"+ "\u0086\7k\2\2\u0086\u0087\7p\2\2\u0087\u0088\7v\2\2\u0088\b\3\2\2\2\u0089"+ "\u008a\7*\2\2\u008a\n\3\2\2\2\u008b\u008c\7.\2\2\u008c\f\3\2\2\2\u008d"+ "\u008e\7x\2\2\u008e\u008f\7c\2\2\u008f\u0090\7t\2\2\u0090\16\3\2\2\2\u0091"+ "\u0092\7e\2\2\u0092\u0093\7q\2\2\u0093\u0094\7p\2\2\u0094\u0095\7u\2\2"+ "\u0095\u0096\7v\2\2\u0096\20\3\2\2\2\u0097\u0098\7o\2\2\u0098\u0099\7"+ "q\2\2\u0099\u009a\7f\2\2\u009a\22\3\2\2\2\u009b\u009c\7@\2\2\u009c\u009d"+ "\7?\2\2\u009d\24\3\2\2\2\u009e\u009f\7>\2\2\u009f\26\3\2\2\2\u00a0\u00a1"+ "\7r\2\2\u00a1\u00a2\7t\2\2\u00a2\u00a3\7g\2\2\u00a3\30\3\2\2\2\u00a4\u00a5"+ "\7c\2\2\u00a5\u00a6\7u\2\2\u00a6\u00a7\7u\2\2\u00a7\u00a8\7g\2\2\u00a8"+ "\u00a9\7t\2\2\u00a9\u00aa\7v\2\2\u00aa\32\3\2\2\2\u00ab\u00ac\7_\2\2\u00ac"+ "\34\3\2\2\2\u00ad\u00ae\7p\2\2\u00ae\u00af\7q\2\2\u00af\u00b0\7f\2\2\u00b0"+ "\u00b1\7g\2\2\u00b1\36\3\2\2\2\u00b2\u00b3\7v\2\2\u00b3\u00b4\7{\2\2\u00b4"+ "\u00b5\7r\2\2\u00b5\u00b6\7g\2\2\u00b6 \3\2\2\2\u00b7\u00b8\7>\2\2\u00b8"+ "\u00b9\7@\2\2\u00b9\"\3\2\2\2\u00ba\u00bb\7n\2\2\u00bb\u00bc\7g\2\2\u00bc"+ "\u00bd\7v\2\2\u00bd$\3\2\2\2\u00be\u00bf\7t\2\2\u00bf\u00c0\7g\2\2\u00c0"+ "\u00c1\7v\2\2\u00c1\u00c2\7w\2\2\u00c2\u00c3\7t\2\2\u00c3\u00c4\7p\2\2"+ "\u00c4\u00c5\7u\2\2\u00c5&\3\2\2\2\u00c6\u00c7\7v\2\2\u00c7\u00c8\7g\2"+ "\2\u00c8\u00c9\7n\2\2\u00c9(\3\2\2\2\u00ca\u00cb\7h\2\2\u00cb\u00cc\7"+ "w\2\2\u00cc\u00cd\7p\2\2\u00cd\u00ce\7e\2\2\u00ce\u00cf\7v\2\2\u00cf\u00d0"+ "\7k\2\2\u00d0\u00d1\7q\2\2\u00d1\u00d2\7p\2\2\u00d2*\3\2\2\2\u00d3\u00d4"+ "\7h\2\2\u00d4\u00d5\7n\2\2\u00d5\u00d6\7q\2\2\u00d6\u00d7\7q\2\2\u00d7"+ "\u00d8\7t\2\2\u00d8,\3\2\2\2\u00d9\u00da\7v\2\2\u00da\u00db\7j\2\2\u00db"+ "\u00dc\7g\2\2\u00dc\u00dd\7p\2\2\u00dd.\3\2\2\2\u00de\u00df\7-\2\2\u00df"+ "\60\3\2\2\2\u00e0\u00e1\7u\2\2\u00e1\u00e2\7v\2\2\u00e2\u00e3\7t\2\2\u00e3"+ "\u00e4\7w\2\2\u00e4\u00e5\7e\2\2\u00e5\u00e6\7v\2\2\u00e6\62\3\2\2\2\u00e7"+ "\u00e8\7\61\2\2\u00e8\64\3\2\2\2\u00e9\u00ea\7q\2\2\u00ea\u00eb\7h\2\2"+ "\u00eb\66\3\2\2\2\u00ec\u00ed\7/\2\2\u00ed\u00ee\7/\2\2\u00ee\u00ef\7"+ "\'\2\2\u00ef\u00f0\7T\2\2\u00f0\u00f1\7G\2\2\u00f1\u00f2\7C\2\2\u00f2"+ "\u00f3\7N\2\2\u00f3\u00f4\7K\2\2\u00f4\u00f5\7\\\2\2\u00f5\u00f6\7C\2"+ "\2\u00f6\u00f7\7D\2\2\u00f7\u00f8\7N\2\2\u00f8\u00f9\7G\2\2\u00f98\3\2"+ "\2\2\u00fa\u00fb\7=\2\2\u00fb:\3\2\2\2\u00fc\u00fd\7/\2\2\u00fd\u00fe"+ "\7/\2\2\u00fe\u00ff\7\'\2\2\u00ff\u0100\7R\2\2\u0100\u0101\7T\2\2\u0101"+ "\u0102\7Q\2\2\u0102\u0103\7R\2\2\u0103\u0104\7G\2\2\u0104\u0105\7T\2\2"+ "\u0105\u0106\7V\2\2\u0106\u0107\7[\2\2\u0107<\3\2\2\2\u0108\u0109\7\177"+ "\2\2\u0109>\3\2\2\2\u010a\u010b\7k\2\2\u010b\u010c\7h\2\2\u010c@\3\2\2"+ "\2\u010d\u010e\7<\2\2\u010e\u010f\7?\2\2\u010fB\3\2\2\2\u0110\u0111\7"+ "g\2\2\u0111\u0112\7p\2\2\u0112\u0113\7w\2\2\u0113\u0114\7o\2\2\u0114D"+ "\3\2\2\2\u0115\u0116\7>\2\2\u0116\u0117\7?\2\2\u0117F\3\2\2\2\u0118\u0119"+ "\7/\2\2\u0119\u011a\7/\2\2\u011a\u011b\7\'\2\2\u011b\u011c\7O\2\2\u011c"+ "\u011d\7C\2\2\u011d\u011e\7K\2\2\u011e\u011f\7P\2\2\u011fH\3\2\2\2\u0120"+ "\u0121\7e\2\2\u0121\u0122\7q\2\2\u0122\u0123\7p\2\2\u0123\u0124\7f\2\2"+ "\u0124\u0125\7c\2\2\u0125\u0126\7e\2\2\u0126\u0127\7v\2\2\u0127J\3\2\2"+ "\2\u0128\u0129\7,\2\2\u0129L\3\2\2\2\u012a\u012b\7\60\2\2\u012bN\3\2\2"+ "\2\u012c\u012d\7/\2\2\u012d\u012e\7@\2\2\u012eP\3\2\2\2\u012f\u0130\7"+ "<\2\2\u0130R\3\2\2\2\u0131\u0132\7/\2\2\u0132\u0133\7/\2\2\u0133\u0134"+ "\7\'\2\2\u0134\u0135\7K\2\2\u0135\u0136\7X\2\2\u0136\u0137\7E\2\2\u0137"+ "T\3\2\2\2\u0138\u0139\7]\2\2\u0139V\3\2\2\2\u013a\u013b\7@\2\2\u013bX"+ "\3\2\2\2\u013c\u013d\7d\2\2\u013d\u013e\7q\2\2\u013e\u013f\7q\2\2\u013f"+ "\u0140\7n\2\2\u0140Z\3\2\2\2\u0141\u0142\7z\2\2\u0142\u0143\7q\2\2\u0143"+ "\u0144\7t\2\2\u0144\\\3\2\2\2\u0145\u0146\7q\2\2\u0146\u0147\7t\2\2\u0147"+ "^\3\2\2\2\u0148\u0149\7u\2\2\u0149\u014a\7w\2\2\u014a\u014b\7d\2\2\u014b"+ "\u014c\7t\2\2\u014c\u014d\7c\2\2\u014d\u014e\7p\2\2\u014e\u014f\7i\2\2"+ "\u014f\u0150\7g\2\2\u0150`\3\2\2\2\u0151\u0152\7?\2\2\u0152\u0153\7@\2"+ "\2\u0153b\3\2\2\2\u0154\u0155\7f\2\2\u0155\u0156\7k\2\2\u0156\u0157\7"+ "x\2\2\u0157d\3\2\2\2\u0158\u0159\7g\2\2\u0159\u015a\7n\2\2\u015a\u015b"+ "\7u\2\2\u015b\u015c\7g\2\2\u015cf\3\2\2\2\u015d\u015e\7+\2\2\u015eh\3"+ "\2\2\2\u015f\u0160\7c\2\2\u0160\u0161\7p\2\2\u0161\u0162\7f\2\2\u0162"+ "j\3\2\2\2\u0163\u0164\7p\2\2\u0164\u0165\7q\2\2\u0165\u0166\7v\2\2\u0166"+ "l\3\2\2\2\u0167\u0168\7/\2\2\u0168n\3\2\2\2\u0169\u016a\7t\2\2\u016a\u016b"+ "\7g\2\2\u016b\u016c\7c\2\2\u016c\u016d\7n\2\2\u016dp\3\2\2\2\u016e\u016f"+ "\5u;\2\u016f\u0170\7\60\2\2\u0170\u0171\5u;\2\u0171r\3\2\2\2\u0172\u0173"+ "\7v\2\2\u0173\u0174\7t\2\2\u0174\u0175\7w\2\2\u0175\u017c\7g\2\2\u0176"+ "\u0177\7h\2\2\u0177\u0178\7c\2\2\u0178\u0179\7n\2\2\u0179\u017a\7u\2\2"+ "\u017a\u017c\7g\2\2\u017b\u0172\3\2\2\2\u017b\u0176\3\2\2\2\u017ct\3\2"+ "\2\2\u017d\u017f\t\2\2\2\u017e\u017d\3\2\2\2\u017f\u0180\3\2\2\2\u0180"+ "\u017e\3\2\2\2\u0180\u0181\3\2\2\2\u0181v\3\2\2\2\u0182\u0186\t\3\2\2"+ "\u0183\u0185\t\4\2\2\u0184\u0183\3\2\2\2\u0185\u0188\3\2\2\2\u0186\u0184"+ "\3\2\2\2\u0186\u0187\3\2\2\2\u0187x\3\2\2\2\u0188\u0186\3\2\2\2\u0189"+ "\u018b\t\5\2\2\u018a\u0189\3\2\2\2\u018b\u018c\3\2\2\2\u018c\u018a\3\2"+ "\2\2\u018c\u018d\3\2\2\2\u018d\u018e\3\2\2\2\u018e\u018f\b=\2\2\u018f"+ "z\3\2\2\2\u0190\u0191\7/\2\2\u0191\u0192\7/\2\2\u0192\u019b\3\2\2\2\u0193"+ "\u0197\n\6\2\2\u0194\u0196\n\7\2\2\u0195\u0194\3\2\2\2\u0196\u0199\3\2"+ "\2\2\u0197\u0195\3\2\2\2\u0197\u0198\3\2\2\2\u0198\u019c\3\2\2\2\u0199"+ "\u0197\3\2\2\2\u019a\u019c\3\2\2\2\u019b\u0193\3\2\2\2\u019b\u019a\3\2"+ "\2\2\u019c\u01a1\3\2\2\2\u019d\u019f\7\17\2\2\u019e\u019d\3\2\2\2\u019e"+ "\u019f\3\2\2\2\u019f\u01a0\3\2\2\2\u01a0\u01a2\7\f\2\2\u01a1\u019e\3\2"+ "\2\2\u01a1\u01a2\3\2\2\2\u01a2\u01a3\3\2\2\2\u01a3\u01a4\b>\2\2\u01a4"+ "|\3\2\2\2\u01a5\u01a6\7*\2\2\u01a6\u01a7\7,\2\2\u01a7\u01ab\3\2\2\2\u01a8"+ "\u01aa\13\2\2\2\u01a9\u01a8\3\2\2\2\u01aa\u01ad\3\2\2\2\u01ab\u01ac\3"+ "\2\2\2\u01ab\u01a9\3\2\2\2\u01ac\u01ae\3\2\2\2\u01ad\u01ab\3\2\2\2\u01ae"+ "\u01af\7,\2\2\u01af\u01b0\7+\2\2\u01b0\u01b1\3\2\2\2\u01b1\u01b2\b?\2"+ "\2\u01b2~\3\2\2\2\u01b3\u01b4\13\2\2\2\u01b4\u0080\3\2\2\2\f\2\u017b\u0180"+ "\u0186\u018c\u0197\u019b\u019e\u01a1\u01ab\3\b\2\2"; public static final ATN _ATN = new ATNDeserializer().deserialize(_serializedATN.toCharArray()); static { _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); } } }
14,372
61.764192
84
java
jkind
jkind-master/jkind-common/src/jkind/lustre/parsing/LustreParseException.java
package jkind.lustre.parsing; import jkind.JKindException; import jkind.lustre.Location; public class LustreParseException extends JKindException { private static final long serialVersionUID = 1L; private final Location loc; public LustreParseException(Location loc, String text) { super(text); this.loc = loc; } public Location getLocation() { return loc; } }
378
17.95
58
java
jkind
jkind-master/jkind-common/src/jkind/lustre/parsing/LustreVisitor.java
// Generated from Lustre.g4 by ANTLR 4.4 package jkind.lustre.parsing; import org.antlr.v4.runtime.misc.NotNull; import org.antlr.v4.runtime.tree.ParseTreeVisitor; /** * This interface defines a complete generic visitor for a parse tree produced * by {@link LustreParser}. * * @param <T> The return type of the visit operation. Use {@link Void} for * operations with no return type. */ public interface LustreVisitor<T> extends ParseTreeVisitor<T> { /** * Visit a parse tree produced by {@link LustreParser#constant}. * @param ctx the parse tree * @return the visitor result */ T visitConstant(@NotNull LustreParser.ConstantContext ctx); /** * Visit a parse tree produced by the {@code realType} * labeled alternative in {@link LustreParser#type}. * @param ctx the parse tree * @return the visitor result */ T visitRealType(@NotNull LustreParser.RealTypeContext ctx); /** * Visit a parse tree produced by the {@code baseEID} * labeled alternative in {@link LustreParser#eID}. * @param ctx the parse tree * @return the visitor result */ T visitBaseEID(@NotNull LustreParser.BaseEIDContext ctx); /** * Visit a parse tree produced by the {@code castExpr} * labeled alternative in {@link LustreParser#expr}. * @param ctx the parse tree * @return the visitor result */ T visitCastExpr(@NotNull LustreParser.CastExprContext ctx); /** * Visit a parse tree produced by the {@code realExpr} * labeled alternative in {@link LustreParser#expr}. * @param ctx the parse tree * @return the visitor result */ T visitRealExpr(@NotNull LustreParser.RealExprContext ctx); /** * Visit a parse tree produced by the {@code enumType} * labeled alternative in {@link LustreParser#topLevelType}. * @param ctx the parse tree * @return the visitor result */ T visitEnumType(@NotNull LustreParser.EnumTypeContext ctx); /** * Visit a parse tree produced by the {@code ifThenElseExpr} * labeled alternative in {@link LustreParser#expr}. * @param ctx the parse tree * @return the visitor result */ T visitIfThenElseExpr(@NotNull LustreParser.IfThenElseExprContext ctx); /** * Visit a parse tree produced by the {@code arrayEID} * labeled alternative in {@link LustreParser#eID}. * @param ctx the parse tree * @return the visitor result */ T visitArrayEID(@NotNull LustreParser.ArrayEIDContext ctx); /** * Visit a parse tree produced by {@link LustreParser#main}. * @param ctx the parse tree * @return the visitor result */ T visitMain(@NotNull LustreParser.MainContext ctx); /** * Visit a parse tree produced by the {@code preExpr} * labeled alternative in {@link LustreParser#expr}. * @param ctx the parse tree * @return the visitor result */ T visitPreExpr(@NotNull LustreParser.PreExprContext ctx); /** * Visit a parse tree produced by {@link LustreParser#program}. * @param ctx the parse tree * @return the visitor result */ T visitProgram(@NotNull LustreParser.ProgramContext ctx); /** * Visit a parse tree produced by {@link LustreParser#varDeclList}. * @param ctx the parse tree * @return the visitor result */ T visitVarDeclList(@NotNull LustreParser.VarDeclListContext ctx); /** * Visit a parse tree produced by the {@code boolType} * labeled alternative in {@link LustreParser#type}. * @param ctx the parse tree * @return the visitor result */ T visitBoolType(@NotNull LustreParser.BoolTypeContext ctx); /** * Visit a parse tree produced by the {@code negateExpr} * labeled alternative in {@link LustreParser#expr}. * @param ctx the parse tree * @return the visitor result */ T visitNegateExpr(@NotNull LustreParser.NegateExprContext ctx); /** * Visit a parse tree produced by the {@code condactExpr} * labeled alternative in {@link LustreParser#expr}. * @param ctx the parse tree * @return the visitor result */ T visitCondactExpr(@NotNull LustreParser.CondactExprContext ctx); /** * Visit a parse tree produced by the {@code arrayAccessExpr} * labeled alternative in {@link LustreParser#expr}. * @param ctx the parse tree * @return the visitor result */ T visitArrayAccessExpr(@NotNull LustreParser.ArrayAccessExprContext ctx); /** * Visit a parse tree produced by {@link LustreParser#function}. * @param ctx the parse tree * @return the visitor result */ T visitFunction(@NotNull LustreParser.FunctionContext ctx); /** * Visit a parse tree produced by {@link LustreParser#ivc}. * @param ctx the parse tree * @return the visitor result */ T visitIvc(@NotNull LustreParser.IvcContext ctx); /** * Visit a parse tree produced by {@link LustreParser#property}. * @param ctx the parse tree * @return the visitor result */ T visitProperty(@NotNull LustreParser.PropertyContext ctx); /** * Visit a parse tree produced by the {@code arrayUpdateExpr} * labeled alternative in {@link LustreParser#expr}. * @param ctx the parse tree * @return the visitor result */ T visitArrayUpdateExpr(@NotNull LustreParser.ArrayUpdateExprContext ctx); /** * Visit a parse tree produced by the {@code recordEID} * labeled alternative in {@link LustreParser#eID}. * @param ctx the parse tree * @return the visitor result */ T visitRecordEID(@NotNull LustreParser.RecordEIDContext ctx); /** * Visit a parse tree produced by {@link LustreParser#assertion}. * @param ctx the parse tree * @return the visitor result */ T visitAssertion(@NotNull LustreParser.AssertionContext ctx); /** * Visit a parse tree produced by the {@code callExpr} * labeled alternative in {@link LustreParser#expr}. * @param ctx the parse tree * @return the visitor result */ T visitCallExpr(@NotNull LustreParser.CallExprContext ctx); /** * Visit a parse tree produced by the {@code recordExpr} * labeled alternative in {@link LustreParser#expr}. * @param ctx the parse tree * @return the visitor result */ T visitRecordExpr(@NotNull LustreParser.RecordExprContext ctx); /** * Visit a parse tree produced by the {@code arrayType} * labeled alternative in {@link LustreParser#type}. * @param ctx the parse tree * @return the visitor result */ T visitArrayType(@NotNull LustreParser.ArrayTypeContext ctx); /** * Visit a parse tree produced by the {@code intExpr} * labeled alternative in {@link LustreParser#expr}. * @param ctx the parse tree * @return the visitor result */ T visitIntExpr(@NotNull LustreParser.IntExprContext ctx); /** * Visit a parse tree produced by the {@code arrayExpr} * labeled alternative in {@link LustreParser#expr}. * @param ctx the parse tree * @return the visitor result */ T visitArrayExpr(@NotNull LustreParser.ArrayExprContext ctx); /** * Visit a parse tree produced by the {@code recordType} * labeled alternative in {@link LustreParser#topLevelType}. * @param ctx the parse tree * @return the visitor result */ T visitRecordType(@NotNull LustreParser.RecordTypeContext ctx); /** * Visit a parse tree produced by the {@code intType} * labeled alternative in {@link LustreParser#type}. * @param ctx the parse tree * @return the visitor result */ T visitIntType(@NotNull LustreParser.IntTypeContext ctx); /** * Visit a parse tree produced by {@link LustreParser#bound}. * @param ctx the parse tree * @return the visitor result */ T visitBound(@NotNull LustreParser.BoundContext ctx); /** * Visit a parse tree produced by {@link LustreParser#equation}. * @param ctx the parse tree * @return the visitor result */ T visitEquation(@NotNull LustreParser.EquationContext ctx); /** * Visit a parse tree produced by the {@code binaryExpr} * labeled alternative in {@link LustreParser#expr}. * @param ctx the parse tree * @return the visitor result */ T visitBinaryExpr(@NotNull LustreParser.BinaryExprContext ctx); /** * Visit a parse tree produced by the {@code plainType} * labeled alternative in {@link LustreParser#topLevelType}. * @param ctx the parse tree * @return the visitor result */ T visitPlainType(@NotNull LustreParser.PlainTypeContext ctx); /** * Visit a parse tree produced by {@link LustreParser#typedef}. * @param ctx the parse tree * @return the visitor result */ T visitTypedef(@NotNull LustreParser.TypedefContext ctx); /** * Visit a parse tree produced by the {@code recordAccessExpr} * labeled alternative in {@link LustreParser#expr}. * @param ctx the parse tree * @return the visitor result */ T visitRecordAccessExpr(@NotNull LustreParser.RecordAccessExprContext ctx); /** * Visit a parse tree produced by {@link LustreParser#node}. * @param ctx the parse tree * @return the visitor result */ T visitNode(@NotNull LustreParser.NodeContext ctx); /** * Visit a parse tree produced by {@link LustreParser#realizabilityInputs}. * @param ctx the parse tree * @return the visitor result */ T visitRealizabilityInputs(@NotNull LustreParser.RealizabilityInputsContext ctx); /** * Visit a parse tree produced by the {@code notExpr} * labeled alternative in {@link LustreParser#expr}. * @param ctx the parse tree * @return the visitor result */ T visitNotExpr(@NotNull LustreParser.NotExprContext ctx); /** * Visit a parse tree produced by the {@code subrangeType} * labeled alternative in {@link LustreParser#type}. * @param ctx the parse tree * @return the visitor result */ T visitSubrangeType(@NotNull LustreParser.SubrangeTypeContext ctx); /** * Visit a parse tree produced by {@link LustreParser#lhs}. * @param ctx the parse tree * @return the visitor result */ T visitLhs(@NotNull LustreParser.LhsContext ctx); /** * Visit a parse tree produced by {@link LustreParser#varDeclGroup}. * @param ctx the parse tree * @return the visitor result */ T visitVarDeclGroup(@NotNull LustreParser.VarDeclGroupContext ctx); /** * Visit a parse tree produced by the {@code userType} * labeled alternative in {@link LustreParser#type}. * @param ctx the parse tree * @return the visitor result */ T visitUserType(@NotNull LustreParser.UserTypeContext ctx); /** * Visit a parse tree produced by the {@code boolExpr} * labeled alternative in {@link LustreParser#expr}. * @param ctx the parse tree * @return the visitor result */ T visitBoolExpr(@NotNull LustreParser.BoolExprContext ctx); /** * Visit a parse tree produced by the {@code tupleExpr} * labeled alternative in {@link LustreParser#expr}. * @param ctx the parse tree * @return the visitor result */ T visitTupleExpr(@NotNull LustreParser.TupleExprContext ctx); /** * Visit a parse tree produced by the {@code recordUpdateExpr} * labeled alternative in {@link LustreParser#expr}. * @param ctx the parse tree * @return the visitor result */ T visitRecordUpdateExpr(@NotNull LustreParser.RecordUpdateExprContext ctx); /** * Visit a parse tree produced by the {@code idExpr} * labeled alternative in {@link LustreParser#expr}. * @param ctx the parse tree * @return the visitor result */ T visitIdExpr(@NotNull LustreParser.IdExprContext ctx); }
11,086
33.538941
82
java
jkind
jkind-master/jkind-common/src/jkind/lustre/parsing/FullSubstitutionVisitor.java
package jkind.lustre.parsing; import java.util.ArrayList; import java.util.List; import java.util.Map; import jkind.JKindException; import jkind.lustre.Constant; import jkind.lustre.Equation; import jkind.lustre.Expr; import jkind.lustre.IdExpr; import jkind.lustre.VarDecl; import jkind.lustre.visitors.AstMapVisitor; /** * Replace ids with expressions based on a map. This substitution is not * recursive: the newly substituted expression will not be analyzed for * additional substitutions. This substitution differs from SubstitutionVisitor * in that it works on non-expression ids such as on the left-hand side of an * equation. */ public class FullSubstitutionVisitor extends AstMapVisitor { private final Map<String, ? extends Expr> map; public FullSubstitutionVisitor(Map<String, ? extends Expr> map) { this.map = map; } private String visit(String id) { if (map.containsKey(id)) { Expr e = map.get(id); if (e instanceof IdExpr) { IdExpr ide = (IdExpr) e; return ide.id; } else { throw new JKindException("Unable to replace '" + id + "' with non-id '" + e + "'"); } } else { return id; } } @Override public Expr visit(IdExpr e) { if (map.containsKey(e.id)) { return map.get(e.id); } else { return e; } } @Override public Constant visit(Constant e) { return new Constant(e.location, visit(e.id), e.type, e.expr.accept(this)); } @Override public Equation visit(Equation e) { List<IdExpr> lhs = new ArrayList<>(); for (IdExpr ide : e.lhs) { lhs.add(new IdExpr(visit(ide.id))); } return new Equation(e.location, lhs, e.expr.accept(this)); } @Override protected String visitProperty(String e) { return visit(e); } @Override protected String visitIvc(String e) { return visit(e); } @Override protected String visitRealizabilityInput(String e) { return visit(e); } @Override public VarDecl visit(VarDecl e) { return new VarDecl(e.location, visit(e.id), e.type); } }
1,979
22.023256
87
java
jkind
jkind-master/jkind-common/src/jkind/lustre/parsing/LustreToAstVisitor.java
package jkind.lustre.parsing; import static java.util.stream.Collectors.toList; import java.math.BigDecimal; import java.math.BigInteger; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import org.antlr.v4.runtime.ParserRuleContext; import org.antlr.v4.runtime.Token; import org.antlr.v4.runtime.tree.TerminalNode; import jkind.lustre.ArrayAccessExpr; import jkind.lustre.ArrayExpr; import jkind.lustre.ArrayType; import jkind.lustre.ArrayUpdateExpr; import jkind.lustre.BinaryExpr; import jkind.lustre.BinaryOp; import jkind.lustre.BoolExpr; import jkind.lustre.CastExpr; import jkind.lustre.CondactExpr; import jkind.lustre.Constant; import jkind.lustre.Contract; import jkind.lustre.EnumType; import jkind.lustre.Equation; import jkind.lustre.Expr; import jkind.lustre.Function; import jkind.lustre.FunctionCallExpr; import jkind.lustre.IdExpr; import jkind.lustre.IfThenElseExpr; import jkind.lustre.IntExpr; import jkind.lustre.Location; import jkind.lustre.NamedType; import jkind.lustre.Node; import jkind.lustre.NodeCallExpr; import jkind.lustre.Program; import jkind.lustre.RealExpr; import jkind.lustre.RecordAccessExpr; import jkind.lustre.RecordExpr; import jkind.lustre.RecordType; import jkind.lustre.RecordUpdateExpr; import jkind.lustre.SubrangeIntType; import jkind.lustre.TupleExpr; import jkind.lustre.Type; import jkind.lustre.TypeDef; import jkind.lustre.UnaryExpr; import jkind.lustre.UnaryOp; import jkind.lustre.VarDecl; import jkind.lustre.parsing.LustreParser.ArrayAccessExprContext; import jkind.lustre.parsing.LustreParser.ArrayEIDContext; import jkind.lustre.parsing.LustreParser.ArrayExprContext; import jkind.lustre.parsing.LustreParser.ArrayTypeContext; import jkind.lustre.parsing.LustreParser.ArrayUpdateExprContext; import jkind.lustre.parsing.LustreParser.AssertionContext; import jkind.lustre.parsing.LustreParser.BaseEIDContext; import jkind.lustre.parsing.LustreParser.BinaryExprContext; import jkind.lustre.parsing.LustreParser.BoolExprContext; import jkind.lustre.parsing.LustreParser.BoolTypeContext; import jkind.lustre.parsing.LustreParser.CallExprContext; import jkind.lustre.parsing.LustreParser.CastExprContext; import jkind.lustre.parsing.LustreParser.CondactExprContext; import jkind.lustre.parsing.LustreParser.ConstantContext; import jkind.lustre.parsing.LustreParser.EIDContext; import jkind.lustre.parsing.LustreParser.EnumTypeContext; import jkind.lustre.parsing.LustreParser.EquationContext; import jkind.lustre.parsing.LustreParser.ExprContext; import jkind.lustre.parsing.LustreParser.FunctionContext; import jkind.lustre.parsing.LustreParser.IdExprContext; import jkind.lustre.parsing.LustreParser.IfThenElseExprContext; import jkind.lustre.parsing.LustreParser.IntExprContext; import jkind.lustre.parsing.LustreParser.IntTypeContext; import jkind.lustre.parsing.LustreParser.IvcContext; import jkind.lustre.parsing.LustreParser.LhsContext; import jkind.lustre.parsing.LustreParser.NegateExprContext; import jkind.lustre.parsing.LustreParser.NodeContext; import jkind.lustre.parsing.LustreParser.NotExprContext; import jkind.lustre.parsing.LustreParser.PlainTypeContext; import jkind.lustre.parsing.LustreParser.PreExprContext; import jkind.lustre.parsing.LustreParser.ProgramContext; import jkind.lustre.parsing.LustreParser.PropertyContext; import jkind.lustre.parsing.LustreParser.RealExprContext; import jkind.lustre.parsing.LustreParser.RealTypeContext; import jkind.lustre.parsing.LustreParser.RealizabilityInputsContext; import jkind.lustre.parsing.LustreParser.RecordAccessExprContext; import jkind.lustre.parsing.LustreParser.RecordEIDContext; import jkind.lustre.parsing.LustreParser.RecordExprContext; import jkind.lustre.parsing.LustreParser.RecordTypeContext; import jkind.lustre.parsing.LustreParser.RecordUpdateExprContext; import jkind.lustre.parsing.LustreParser.SubrangeTypeContext; import jkind.lustre.parsing.LustreParser.TopLevelTypeContext; import jkind.lustre.parsing.LustreParser.TupleExprContext; import jkind.lustre.parsing.LustreParser.TypeContext; import jkind.lustre.parsing.LustreParser.TypedefContext; import jkind.lustre.parsing.LustreParser.UserTypeContext; import jkind.lustre.parsing.LustreParser.VarDeclGroupContext; import jkind.lustre.parsing.LustreParser.VarDeclListContext; public class LustreToAstVisitor extends LustreBaseVisitor<Object> { private String main; private Set<String> functionNames = new HashSet<>(); public Program program(ProgramContext ctx) { List<TypeDef> types = types(ctx.typedef()); List<Constant> constants = constants(ctx.constant()); List<Function> functions = functions(ctx.function()); List<Node> nodes = nodes(ctx.node()); return new Program(loc(ctx), types, constants, functions, nodes, main); } private List<TypeDef> types(List<TypedefContext> ctxs) { List<TypeDef> types = new ArrayList<>(); for (TypedefContext ctx : ctxs) { String id = ctx.ID().getText(); Type type = topLevelType(id, ctx.topLevelType()); types.add(new TypeDef(loc(ctx), id, type)); } return types; } private List<Constant> constants(List<ConstantContext> ctxs) { List<Constant> constants = new ArrayList<>(); for (ConstantContext ctx : ctxs) { String id = ctx.ID().getText(); Type type = ctx.type() == null ? null : type(ctx.type()); Expr expr = expr(ctx.expr()); constants.add(new Constant(loc(ctx), id, type, expr)); } return constants; } private List<Function> functions(List<FunctionContext> ctxs) { return ctxs.stream().map(this::function).collect(toList()); } private List<Node> nodes(List<NodeContext> ctxs) { return ctxs.stream().map(this::node).collect(toList()); } public Function function(FunctionContext ctx) { String id = eid(ctx.eID()); List<VarDecl> inputs = varDecls(ctx.input); List<VarDecl> outputs = varDecls(ctx.output); functionNames.add(id); return new Function(loc(ctx), id, inputs, outputs); } public Node node(NodeContext ctx) { String id = ctx.ID().getText(); List<VarDecl> inputs = varDecls(ctx.input); List<VarDecl> outputs = varDecls(ctx.output); List<VarDecl> locals = varDecls(ctx.local); List<Equation> equations = equations(ctx.equation()); List<String> properties = properties(ctx.property()); List<Expr> assertions = assertions(ctx.assertion()); List<String> ivc = ivc(ctx.ivc()); List<String> realizabilityInputs = realizabilityInputs(ctx.realizabilityInputs()); Contract contract = null; if (!ctx.main().isEmpty()) { if (main == null) { main = id; } else { fatal(ctx.main(0), "node '" + main + "' already declared as --%MAIN"); } } return new Node(loc(ctx), id, inputs, outputs, locals, equations, properties, assertions, realizabilityInputs, contract, ivc); } private List<VarDecl> varDecls(VarDeclListContext listCtx) { List<VarDecl> decls = new ArrayList<>(); if (listCtx == null) { return decls; } for (VarDeclGroupContext groupCtx : listCtx.varDeclGroup()) { Type type = type(groupCtx.type()); for (EIDContext id : groupCtx.eID()) { decls.add(new VarDecl(loc(id), eid(id), type)); } } return decls; } private List<Equation> equations(List<EquationContext> ctxs) { List<Equation> equations = new ArrayList<>(); for (EquationContext ctx : ctxs) { equations.add(equation(ctx)); } return equations; } public Equation equation(EquationContext ctx) { List<IdExpr> lhs = lhs(ctx.lhs()); Expr expr = expr(ctx.expr()); return new Equation(loc(ctx), lhs, expr); } private List<IdExpr> lhs(LhsContext ctx) { List<IdExpr> lhs = new ArrayList<>(); if (ctx != null) { for (EIDContext id : ctx.eID()) { lhs.add(new IdExpr(loc(id), eid(id))); } } return lhs; } private String eid(EIDContext id) { return (String) visit(id); } private List<String> properties(List<PropertyContext> ctxs) { List<String> props = new ArrayList<>(); for (PropertyContext ctx : ctxs) { props.add(eid(ctx.eID())); } return props; } private List<Expr> assertions(List<AssertionContext> ctxs) { List<Expr> assertions = new ArrayList<>(); for (AssertionContext ctx : ctxs) { assertions.add(expr(ctx.expr())); } return assertions; } private List<String> realizabilityInputs(List<RealizabilityInputsContext> ctxs) { if (ctxs.size() > 1) { fatal(ctxs.get(1), "at most one realizability statement allowed"); } for (RealizabilityInputsContext ctx : ctxs) { List<String> ids = new ArrayList<>(); for (TerminalNode ictx : ctx.ID()) { ids.add(ictx.getText()); } return ids; } return null; } private List<String> ivc(List<IvcContext> ctxs) { if (ctxs.size() > 1) { fatal(ctxs.get(1), "at most one ivc statement allowed per node"); } for (IvcContext ctx : ctxs) { List<String> ids = new ArrayList<>(); for (EIDContext ictx : ctx.eID()) { ids.add(eid(ictx)); } return ids; } return null; } private Type topLevelType(String id, TopLevelTypeContext ctx) { if (ctx instanceof PlainTypeContext) { PlainTypeContext pctx = (PlainTypeContext) ctx; return type(pctx.type()); } else if (ctx instanceof RecordTypeContext) { RecordTypeContext rctx = (RecordTypeContext) ctx; Map<String, Type> fields = new HashMap<>(); for (int i = 0; i < rctx.ID().size(); i++) { String field = rctx.ID(i).getText(); if (fields.containsKey(field)) { fatal(ctx, "field declared multiple times: " + field); } fields.put(field, type(rctx.type(i))); } return new RecordType(loc(ctx), id, fields); } else if (ctx instanceof EnumTypeContext) { EnumTypeContext ectx = (EnumTypeContext) ctx; List<String> values = new ArrayList<>(); for (TerminalNode node : ectx.ID()) { values.add(node.getText()); } return new EnumType(loc(ctx), id, values); } else { throw new IllegalArgumentException(ctx.getClass().getSimpleName()); } } private Type type(TypeContext ctx) { return (Type) ctx.accept(this); } @Override public Type visitIntType(IntTypeContext ctx) { return NamedType.INT; } @Override public Type visitSubrangeType(SubrangeTypeContext ctx) { BigInteger low = new BigInteger(ctx.bound(0).getText()); BigInteger high = new BigInteger(ctx.bound(1).getText()); return new SubrangeIntType(loc(ctx), low, high); } @Override public Type visitBoolType(BoolTypeContext ctx) { return NamedType.BOOL; } @Override public Type visitRealType(RealTypeContext ctx) { return NamedType.REAL; } @Override public Type visitArrayType(ArrayTypeContext ctx) { try { int index = Integer.parseInt(ctx.INT().getText()); if (index == 0) { fatal(ctx, "array size must be non-zero"); } return new ArrayType(loc(ctx), type(ctx.type()), index); } catch (NumberFormatException nfe) { fatal(ctx, "array size too large: " + ctx.INT().getText()); return null; } } @Override public Type visitUserType(UserTypeContext ctx) { return new NamedType(loc(ctx), ctx.ID().getText()); } public Expr expr(ExprContext ctx) { return (Expr) ctx.accept(this); } @Override public Expr visitIdExpr(IdExprContext ctx) { return new IdExpr(loc(ctx), ctx.ID().getText()); } @Override public Expr visitIntExpr(IntExprContext ctx) { return new IntExpr(loc(ctx), new BigInteger(ctx.INT().getText())); } @Override public Expr visitRealExpr(RealExprContext ctx) { return new RealExpr(loc(ctx), new BigDecimal(ctx.REAL().getText())); } @Override public Expr visitBoolExpr(BoolExprContext ctx) { return new BoolExpr(loc(ctx), ctx.BOOL().getText().equals("true")); } @Override public Expr visitCastExpr(CastExprContext ctx) { return new CastExpr(loc(ctx), getCastType(ctx.op.getText()), expr(ctx.expr())); } private Type getCastType(String cast) { switch (cast) { case "real": return NamedType.REAL; case "floor": return NamedType.INT; default: throw new IllegalArgumentException("Unknown cast: " + cast); } } @Override public Expr visitCallExpr(CallExprContext ctx) { String name = eid(ctx.eID()); List<Expr> args = new ArrayList<>(); for (ExprContext arg : ctx.expr()) { args.add(expr(arg)); } if (functionNames.contains(name)) { return new FunctionCallExpr(loc(ctx), name, args); } else { return new NodeCallExpr(loc(ctx), name, args); } } @Override public Expr visitCondactExpr(CondactExprContext ctx) { Expr clock = expr(ctx.expr(0)); if (ctx.expr(1) instanceof CallExprContext) { CallExprContext callCtx = (CallExprContext) ctx.expr(1); Expr call = visitCallExpr(callCtx); if (call instanceof NodeCallExpr) { NodeCallExpr nodeCall = (NodeCallExpr) call; List<Expr> args = new ArrayList<>(); for (int i = 2; i < ctx.expr().size(); i++) { args.add(expr(ctx.expr(i))); } return new CondactExpr(loc(ctx), clock, nodeCall, args); } } fatal(ctx, "second argument to condact must be a node call"); return null; } @Override public Expr visitRecordAccessExpr(RecordAccessExprContext ctx) { return new RecordAccessExpr(loc(ctx), expr(ctx.expr()), ctx.ID().getText()); } @Override public Expr visitRecordUpdateExpr(RecordUpdateExprContext ctx) { return new RecordUpdateExpr(loc(ctx), expr(ctx.expr(0)), ctx.ID().getText(), expr(ctx.expr(1))); } @Override public Expr visitArrayAccessExpr(ArrayAccessExprContext ctx) { return new ArrayAccessExpr(loc(ctx), expr(ctx.expr(0)), expr(ctx.expr(1))); } @Override public Expr visitArrayUpdateExpr(ArrayUpdateExprContext ctx) { return new ArrayUpdateExpr(loc(ctx), expr(ctx.expr(0)), expr(ctx.expr(1)), expr(ctx.expr(2))); } @Override public Expr visitPreExpr(PreExprContext ctx) { return new UnaryExpr(loc(ctx), UnaryOp.PRE, expr(ctx.expr())); } @Override public Expr visitNotExpr(NotExprContext ctx) { return new UnaryExpr(loc(ctx), UnaryOp.NOT, expr(ctx.expr())); } @Override public Expr visitNegateExpr(NegateExprContext ctx) { return new UnaryExpr(loc(ctx), UnaryOp.NEGATIVE, expr(ctx.expr())); } @Override public Expr visitBinaryExpr(BinaryExprContext ctx) { String op = ctx.op.getText(); Expr left = expr(ctx.expr(0)); Expr right = expr(ctx.expr(1)); return new BinaryExpr(loc(ctx), left, BinaryOp.fromString(op), right); } @Override public Expr visitIfThenElseExpr(IfThenElseExprContext ctx) { return new IfThenElseExpr(loc(ctx), expr(ctx.expr(0)), expr(ctx.expr(1)), expr(ctx.expr(2))); } @Override public Expr visitRecordExpr(RecordExprContext ctx) { Map<String, Expr> fields = new HashMap<>(); for (int i = 0; i < ctx.expr().size(); i++) { String field = ctx.ID(i + 1).getText(); if (fields.containsKey(field)) { fatal(ctx, "field assigned multiple times: " + field); } fields.put(field, expr(ctx.expr(i))); } return new RecordExpr(loc(ctx), ctx.ID(0).getText(), fields); } @Override public Expr visitArrayExpr(ArrayExprContext ctx) { List<Expr> elements = new ArrayList<>(); for (int i = 0; i < ctx.expr().size(); i++) { elements.add(expr(ctx.expr(i))); } return new ArrayExpr(loc(ctx), elements); } @Override public Expr visitTupleExpr(TupleExprContext ctx) { // Treat singleton tuples as simply parentheses. This increases parsing // performance by not having to decide between parenExpr and tupleExpr. if (ctx.expr().size() == 1) { return expr(ctx.expr(0)); } List<Expr> elements = new ArrayList<>(); for (int i = 0; i < ctx.expr().size(); i++) { elements.add(expr(ctx.expr(i))); } return new TupleExpr(loc(ctx), elements); } @Override public String visitBaseEID(BaseEIDContext ctx) { return ctx.ID().getText(); } @Override public String visitArrayEID(ArrayEIDContext ctx) { return visit(ctx.eID()) + "[" + ctx.INT().getText() + "]"; } @Override public String visitRecordEID(RecordEIDContext ctx) { return visit(ctx.eID()) + "." + ctx.ID().getText(); } protected Location loc(ParserRuleContext ctx) { Token token = ctx.getStart(); if (ctx instanceof BinaryExprContext) { BinaryExprContext binExpr = (BinaryExprContext) ctx; token = binExpr.op; } return new Location(token.getLine(), token.getCharPositionInLine()); } private void fatal(ParserRuleContext ctx, String text) { throw new LustreParseException(loc(ctx), text); } }
16,334
30.114286
112
java
jkind
jkind-master/jkind-common/src/jkind/lustre/parsing/LustreBaseVisitor.java
// Generated from Lustre.g4 by ANTLR 4.4 package jkind.lustre.parsing; import org.antlr.v4.runtime.misc.NotNull; import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; /** * This class provides an empty implementation of {@link LustreVisitor}, * which can be extended to create a visitor which only needs to handle a subset * of the available methods. * * @param <T> The return type of the visit operation. Use {@link Void} for * operations with no return type. */ public class LustreBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements LustreVisitor<T> { /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitConstant(@NotNull LustreParser.ConstantContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitRealType(@NotNull LustreParser.RealTypeContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitBaseEID(@NotNull LustreParser.BaseEIDContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitCastExpr(@NotNull LustreParser.CastExprContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitRealExpr(@NotNull LustreParser.RealExprContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitEnumType(@NotNull LustreParser.EnumTypeContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitIfThenElseExpr(@NotNull LustreParser.IfThenElseExprContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitArrayEID(@NotNull LustreParser.ArrayEIDContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitMain(@NotNull LustreParser.MainContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitPreExpr(@NotNull LustreParser.PreExprContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitProgram(@NotNull LustreParser.ProgramContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitVarDeclList(@NotNull LustreParser.VarDeclListContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitBoolType(@NotNull LustreParser.BoolTypeContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitNegateExpr(@NotNull LustreParser.NegateExprContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitCondactExpr(@NotNull LustreParser.CondactExprContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitArrayAccessExpr(@NotNull LustreParser.ArrayAccessExprContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitFunction(@NotNull LustreParser.FunctionContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitIvc(@NotNull LustreParser.IvcContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitProperty(@NotNull LustreParser.PropertyContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitArrayUpdateExpr(@NotNull LustreParser.ArrayUpdateExprContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitRecordEID(@NotNull LustreParser.RecordEIDContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitAssertion(@NotNull LustreParser.AssertionContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitCallExpr(@NotNull LustreParser.CallExprContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitRecordExpr(@NotNull LustreParser.RecordExprContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitArrayType(@NotNull LustreParser.ArrayTypeContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitIntExpr(@NotNull LustreParser.IntExprContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitArrayExpr(@NotNull LustreParser.ArrayExprContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitRecordType(@NotNull LustreParser.RecordTypeContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitIntType(@NotNull LustreParser.IntTypeContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitBound(@NotNull LustreParser.BoundContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitEquation(@NotNull LustreParser.EquationContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitBinaryExpr(@NotNull LustreParser.BinaryExprContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitPlainType(@NotNull LustreParser.PlainTypeContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitTypedef(@NotNull LustreParser.TypedefContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitRecordAccessExpr(@NotNull LustreParser.RecordAccessExprContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitNode(@NotNull LustreParser.NodeContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitRealizabilityInputs(@NotNull LustreParser.RealizabilityInputsContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitNotExpr(@NotNull LustreParser.NotExprContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitSubrangeType(@NotNull LustreParser.SubrangeTypeContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitLhs(@NotNull LustreParser.LhsContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitVarDeclGroup(@NotNull LustreParser.VarDeclGroupContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitUserType(@NotNull LustreParser.UserTypeContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitBoolExpr(@NotNull LustreParser.BoolExprContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitTupleExpr(@NotNull LustreParser.TupleExprContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitRecordUpdateExpr(@NotNull LustreParser.RecordUpdateExprContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitIdExpr(@NotNull LustreParser.IdExprContext ctx) { return visitChildren(ctx); } }
12,214
35.246291
129
java
jkind
jkind-master/jkind-common/src/jkind/lustre/parsing/LustreParseUtil.java
package jkind.lustre.parsing; import java.util.HashMap; import java.util.Map; import jkind.JKindException; import jkind.lustre.Equation; import jkind.lustre.Expr; import jkind.lustre.IdExpr; import jkind.lustre.Location; import jkind.lustre.Node; import jkind.lustre.Program; import jkind.lustre.VarDecl; import jkind.translation.SubstitutionVisitor; import jkind.util.Util; import org.antlr.v4.runtime.ANTLRInputStream; import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.CommonTokenStream; public class LustreParseUtil { public static Expr expr(String input) { try { LustreParser parser = getParser(input); return new LustreToAstVisitor().expr(parser.expr()); } catch (LustreParseException e) { throw new JKindException(formatErrorMessage(input, e)); } } public static Expr expr(String input, Map<String, ? extends Expr> map) { return expr(input).accept(new SubstitutionVisitor(map)); } public static Expr expr(String input, Mapping... mappings) { return expr(input, map(mappings)); } public static Equation equation(String input) { try { LustreParser parser = getParser(input); return new LustreToAstVisitor().equation(parser.equation()); } catch (LustreParseException e) { throw new JKindException(formatErrorMessage(input, e)); } } public static Equation equation(String input, Map<String, ? extends Expr> map) { return new FullSubstitutionVisitor(map).visit(equation(input)); } public static Equation equation(String input, Mapping... mappings) { return equation(input, map(mappings)); } public static Node node(String input) { try { LustreParser parser = getParser(input); return new LustreToAstVisitor().node(parser.node()); } catch (LustreParseException e) { throw new JKindException(formatErrorMessage(input, e)); } } public static Node node(String input, Map<String, ? extends Expr> map) { return new FullSubstitutionVisitor(map).visit(node(input)); } public static Node node(String input, Mapping... mappings) { return node(input, map(mappings)); } public static Program program(String input) { try { LustreParser parser = getParser(input); return new LustreToAstVisitor().program(parser.program()); } catch (LustreParseException e) { throw new JKindException(formatErrorMessage(input, e)); } } public static Program program(String input, Map<String, ? extends Expr> map) { return new FullSubstitutionVisitor(map).visit(program(input)); } public static Program program(String input, Mapping... mappings) { return program(input, map(mappings)); } private static LustreParser getParser(String input) { CharStream stream = new ANTLRInputStream(input); LustreLexer lexer = new LustreLexer(stream); CommonTokenStream tokens = new CommonTokenStream(lexer); LustreParser parser = new LustreParser(tokens); parser.removeErrorListeners(); parser.addErrorListener(new LustreParseExceptionErrorListener()); return parser; } private static String formatErrorMessage(String input, LustreParseException e) { String message = "LustreParseUtil internal parsing error"; message += System.lineSeparator() + e.getMessage(); String[] lines = input.split("\\r?\\n"); Location loc = e.getLocation(); if (1 <= loc.line && loc.line <= lines.length) { String line = lines[loc.line - 1]; message += System.lineSeparator() + line; message += System.lineSeparator() + Util.spaces(loc.charPositionInLine) + "^"; } return message; } public static class Mapping { private final String key; private final Expr value; public Mapping(String key, Expr value) { this.key = key; this.value = value; } } public static Mapping to(String key, Expr value) { return new Mapping(key, value); } public static Mapping to(String key, VarDecl varDecl) { return new Mapping(key, new IdExpr(varDecl.id)); } public static Mapping to(String key, String id) { return new Mapping(key, new IdExpr(id)); } public static Map<String, Expr> map(Mapping... mappings) { Map<String, Expr> map = new HashMap<>(); for (Mapping mapping : mappings) { map.put(mapping.key, mapping.value); } return map; } }
4,174
28.195804
81
java
jkind
jkind-master/jkind-common/src/jkind/lustre/values/TupleValue.java
package jkind.lustre.values; import java.util.Collections; import java.util.List; import java.util.StringJoiner; import jkind.lustre.BinaryOp; import jkind.lustre.UnaryOp; /** * A tuple signal value (only used during static analysis) */ public class TupleValue extends Value { public final List<Value> elements; public TupleValue(List<Value> elements) { this.elements = Collections.unmodifiableList(elements); } @Override public Value applyBinaryOp(BinaryOp op, Value right) { if (right instanceof UnknownValue) { return UnknownValue.UNKNOWN; } if (!(right instanceof TupleValue)) { return null; } TupleValue other = (TupleValue) right; switch (op) { case EQUAL: return BooleanValue.fromBoolean(equals(other)); case NOTEQUAL: return BooleanValue.fromBoolean(!equals(other)); default: return null; } } @Override public Value applyUnaryOp(UnaryOp op) { return null; } @Override public String toString() { StringJoiner text = new StringJoiner(", ", "(", ")"); elements.forEach(v -> text.add(v.toString())); return text.toString(); } @Override public int hashCode() { return elements.hashCode(); } @Override public boolean equals(Object obj) { if (obj instanceof TupleValue) { TupleValue other = (TupleValue) obj; return elements.equals(other.elements); } return false; } }
1,364
18.225352
58
java
jkind
jkind-master/jkind-common/src/jkind/lustre/values/BooleanValue.java
package jkind.lustre.values; import jkind.lustre.BinaryOp; import jkind.lustre.UnaryOp; /** * A boolean signal value */ public class BooleanValue extends Value { public final boolean value; private BooleanValue(boolean value) { this.value = value; } public static final BooleanValue TRUE = new BooleanValue(true); public static final BooleanValue FALSE = new BooleanValue(false); public static BooleanValue fromBoolean(boolean value) { return value ? TRUE : FALSE; } @Override public Value applyBinaryOp(BinaryOp op, Value right) { if (right instanceof UnknownValue) { switch (op) { case OR: return value ? TRUE : UnknownValue.UNKNOWN; case AND: return !value ? FALSE : UnknownValue.UNKNOWN; case IMPLIES: return !value ? TRUE : UnknownValue.UNKNOWN; default: return UnknownValue.UNKNOWN; } } if (!(right instanceof BooleanValue)) { return null; } boolean other = ((BooleanValue) right).value; switch (op) { case EQUAL: return fromBoolean(value == other); case NOTEQUAL: return fromBoolean(value != other); case OR: return fromBoolean(value || other); case AND: return fromBoolean(value && other); case XOR: return fromBoolean(value != other); case IMPLIES: return fromBoolean(!value || other); default: return null; } } @Override public Value applyUnaryOp(UnaryOp op) { switch (op) { case NOT: return fromBoolean(!value); default: return null; } } @Override public String toString() { return Boolean.toString(value); } @Override public int hashCode() { return Boolean.valueOf(value).hashCode(); } @Override public boolean equals(Object obj) { if (obj instanceof BooleanValue) { BooleanValue other = (BooleanValue) obj; return (value == other.value); } return false; } }
1,831
18.489362
66
java
jkind
jkind-master/jkind-common/src/jkind/lustre/values/RecordValue.java
package jkind.lustre.values; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.SortedMap; import java.util.StringJoiner; import java.util.TreeMap; import jkind.lustre.BinaryOp; import jkind.lustre.UnaryOp; /** * A record signal value (only used during static analysis) */ public class RecordValue extends Value { public final SortedMap<String, Value> fields; public RecordValue(Map<String, Value> fields) { this.fields = Collections.unmodifiableSortedMap(new TreeMap<>(fields)); } public Value update(String field, Value value) { Map<String, Value> copy = new HashMap<>(fields); copy.put(field, value); return new RecordValue(copy); } @Override public Value applyBinaryOp(BinaryOp op, Value right) { if (right instanceof UnknownValue) { return UnknownValue.UNKNOWN; } if (!(right instanceof RecordValue)) { return null; } RecordValue other = (RecordValue) right; switch (op) { case EQUAL: return BooleanValue.fromBoolean(equals(other)); case NOTEQUAL: return BooleanValue.fromBoolean(!equals(other)); default: return null; } } @Override public Value applyUnaryOp(UnaryOp op) { return null; } @Override public String toString() { StringJoiner text = new StringJoiner("; ", "{", "}"); fields.forEach((field, value) -> text.add(field + " = " + value)); return text.toString(); } @Override public int hashCode() { return fields.hashCode(); } @Override public boolean equals(Object obj) { if (obj instanceof RecordValue) { RecordValue other = (RecordValue) obj; return fields.equals(other.fields); } return false; } }
1,661
19.775
73
java
jkind
jkind-master/jkind-common/src/jkind/lustre/values/RealValue.java
package jkind.lustre.values; import jkind.lustre.BinaryOp; import jkind.lustre.UnaryOp; import jkind.util.BigFraction; /** * A real signal value */ public class RealValue extends Value implements Comparable<RealValue> { public final BigFraction value; public RealValue(BigFraction value) { this.value = value; } @Override public Value applyBinaryOp(BinaryOp op, Value right) { if (right instanceof UnknownValue) { return UnknownValue.UNKNOWN; } if (!(right instanceof RealValue)) { return null; } RealValue other = (RealValue) right; switch (op) { case PLUS: return new RealValue(value.add(other.value)); case MINUS: return new RealValue(value.subtract(other.value)); case MULTIPLY: return new RealValue(value.multiply(other.value)); case DIVIDE: return new RealValue(value.divide(other.value)); case EQUAL: return BooleanValue.fromBoolean(compareTo(other) == 0); case NOTEQUAL: return BooleanValue.fromBoolean(compareTo(other) != 0); case GREATER: return BooleanValue.fromBoolean(compareTo(other) > 0); case LESS: return BooleanValue.fromBoolean(compareTo(other) < 0); case GREATEREQUAL: return BooleanValue.fromBoolean(compareTo(other) >= 0); case LESSEQUAL: return BooleanValue.fromBoolean(compareTo(other) <= 0); default: return null; } } @Override public int compareTo(RealValue other) { return value.compareTo(other.value); } @Override public Value applyUnaryOp(UnaryOp op) { switch (op) { case NEGATIVE: return new RealValue(value.negate()); default: return null; } } @Override public String toString() { return value.toString(); } @Override public int hashCode() { return value.hashCode(); } @Override public boolean equals(Object obj) { if (obj instanceof RealValue) { RealValue other = (RealValue) obj; return value.equals(other.value); } return false; } }
1,911
20.483146
71
java
jkind
jkind-master/jkind-common/src/jkind/lustre/values/Value.java
package jkind.lustre.values; import jkind.lustre.BinaryOp; import jkind.lustre.UnaryOp; /** * A signal value * @see BooleanValue * @see IntegerValue * @see RealValue */ public abstract class Value { public abstract Value applyBinaryOp(BinaryOp op, Value right); public abstract Value applyUnaryOp(UnaryOp op); }
322
18
63
java
jkind
jkind-master/jkind-common/src/jkind/lustre/values/IntegerValue.java
package jkind.lustre.values; import java.math.BigInteger; import jkind.lustre.BinaryOp; import jkind.lustre.UnaryOp; import jkind.util.Util; /** * An integer signal value */ public class IntegerValue extends Value { public final BigInteger value; public IntegerValue(BigInteger value) { if (value == null) { throw new IllegalArgumentException("Cannot create null integer value"); } this.value = value; } @Override public Value applyBinaryOp(BinaryOp op, Value right) { if (right instanceof UnknownValue) { return UnknownValue.UNKNOWN; } if (!(right instanceof IntegerValue)) { return null; } BigInteger other = ((IntegerValue) right).value; switch (op) { case PLUS: return new IntegerValue(value.add(other)); case MINUS: return new IntegerValue(value.subtract(other)); case MULTIPLY: return new IntegerValue(value.multiply(other)); case INT_DIVIDE: return new IntegerValue(Util.smtDivide(value, other)); case MODULUS: return new IntegerValue(value.mod(other)); case EQUAL: return BooleanValue.fromBoolean(value.compareTo(other) == 0); case NOTEQUAL: return BooleanValue.fromBoolean(value.compareTo(other) != 0); case GREATER: return BooleanValue.fromBoolean(value.compareTo(other) > 0); case LESS: return BooleanValue.fromBoolean(value.compareTo(other) < 0); case GREATEREQUAL: return BooleanValue.fromBoolean(value.compareTo(other) >= 0); case LESSEQUAL: return BooleanValue.fromBoolean(value.compareTo(other) <= 0); default: return null; } } @Override public Value applyUnaryOp(UnaryOp op) { switch (op) { case NEGATIVE: return new IntegerValue(value.negate()); default: return null; } } @Override public String toString() { return value.toString(); } @Override public int hashCode() { return value.hashCode(); } @Override public boolean equals(Object obj) { if (obj instanceof IntegerValue) { IntegerValue other = (IntegerValue) obj; return value.equals(other.value); } return false; } }
2,042
21.450549
74
java
jkind
jkind-master/jkind-common/src/jkind/lustre/values/ArrayValue.java
package jkind.lustre.values; import java.math.BigInteger; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.StringJoiner; import jkind.lustre.BinaryOp; import jkind.lustre.UnaryOp; /** * An array signal value (only used during static analysis) */ public class ArrayValue extends Value { public final List<Value> elements; public ArrayValue(List<Value> elements) { this.elements = Collections.unmodifiableList(elements); } public ArrayValue update(BigInteger index, Value value) { if (validIndex(index)) { List<Value> copy = new ArrayList<>(elements); copy.set(index.intValue(), value); return new ArrayValue(copy); } else { return this; } } public Value get(BigInteger index) { if (validIndex(index)) { return elements.get(index.intValue()); } return null; } private boolean validIndex(BigInteger index) { return BigInteger.ZERO.compareTo(index) <= 0 && index.compareTo(BigInteger.valueOf(elements.size())) < 0; } @Override public Value applyBinaryOp(BinaryOp op, Value right) { if (right instanceof UnknownValue) { return UnknownValue.UNKNOWN; } if (!(right instanceof ArrayValue)) { return null; } ArrayValue other = (ArrayValue) right; switch (op) { case EQUAL: return BooleanValue.fromBoolean(equals(other)); case NOTEQUAL: return BooleanValue.fromBoolean(!equals(other)); default: return null; } } @Override public Value applyUnaryOp(UnaryOp op) { return null; } @Override public String toString() { StringJoiner text = new StringJoiner(", ", "[", "]"); elements.forEach(v -> text.add(v.toString())); return text.toString(); } @Override public int hashCode() { return elements.hashCode(); } @Override public boolean equals(Object obj) { if (obj instanceof ArrayValue) { ArrayValue other = (ArrayValue) obj; return elements.equals(other.elements); } return false; } }
1,952
19.776596
107
java
jkind
jkind-master/jkind-common/src/jkind/lustre/values/UnknownValue.java
package jkind.lustre.values; import jkind.lustre.BinaryOp; import jkind.lustre.UnaryOp; public class UnknownValue extends Value { public static final Value UNKNOWN = new UnknownValue(); @Override public Value applyBinaryOp(BinaryOp op, Value right) { switch (op) { case PLUS: case MINUS: case MULTIPLY: case DIVIDE: case INT_DIVIDE: case MODULUS: case EQUAL: case NOTEQUAL: case GREATER: case LESS: case GREATEREQUAL: case LESSEQUAL: case XOR: case IMPLIES: return UNKNOWN; case OR: if (right instanceof BooleanValue) { BooleanValue v = (BooleanValue) right; if (v.value) { return BooleanValue.TRUE; } } return UNKNOWN; case AND: if (right instanceof BooleanValue) { BooleanValue v = (BooleanValue) right; if (!v.value) { return BooleanValue.FALSE; } } return UNKNOWN; case ARROW: default: return null; } } @Override public Value applyUnaryOp(UnaryOp op) { switch (op) { case NEGATIVE: case NOT: return UNKNOWN; default: return null; } } @Override public String toString() { return "?"; } }
1,128
14.901408
56
java
jkind
jkind-master/jkind-common/src/jkind/lustre/values/EnumValue.java
package jkind.lustre.values; import jkind.lustre.BinaryOp; import jkind.lustre.UnaryOp; import jkind.util.StringNaturalOrdering; /** * An enumerated value (only used during counter-example output) */ public class EnumValue extends Value implements Comparable<EnumValue> { public final String value; public EnumValue(String value) { this.value = value; } @Override public Value applyBinaryOp(BinaryOp op, Value right) { if (right instanceof UnknownValue) { return UnknownValue.UNKNOWN; } if (!(right instanceof EnumValue)) { return null; } EnumValue other = (EnumValue) right; switch (op) { case EQUAL: return BooleanValue.fromBoolean(equals(other)); case NOTEQUAL: return BooleanValue.fromBoolean(!equals(other)); default: return null; } } @Override public Value applyUnaryOp(UnaryOp op) { return null; } @Override public String toString() { return value; } @Override public int hashCode() { return value.hashCode(); } @Override public boolean equals(Object obj) { if (obj instanceof EnumValue) { EnumValue other = (EnumValue) obj; return value.equals(other.value); } return false; } @Override public int compareTo(EnumValue other) { return new StringNaturalOrdering().compare(value, other.value); } }
1,297
17.28169
71
java
jkind
jkind-master/jkind-common/src/jkind/lustre/visitors/Kind2ArraysPrettyPrintVisitor.java
package jkind.lustre.visitors; import jkind.lustre.ArrayType; import jkind.lustre.Type; import jkind.lustre.VarDecl; public class Kind2ArraysPrettyPrintVisitor extends PrettyPrintVisitor { @Override public Void visit(VarDecl varDecl) { Type type = varDecl.type; if (type instanceof ArrayType) { StringBuilder sb = new StringBuilder(""); while (type instanceof ArrayType) { ArrayType arrayType = (ArrayType) type; StringBuilder thisStr = new StringBuilder("^" + arrayType.size); thisStr.append(sb); sb = thisStr; type = arrayType.base; } write(varDecl.id); write(" : "); write(type); write(sb); return null; } else { return super.visit(varDecl); } } }
712
22
71
java
jkind
jkind-master/jkind-common/src/jkind/lustre/visitors/Evaluator.java
package jkind.lustre.visitors; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import jkind.lustre.ArrayAccessExpr; import jkind.lustre.ArrayExpr; import jkind.lustre.ArrayUpdateExpr; import jkind.lustre.BinaryExpr; import jkind.lustre.BoolExpr; import jkind.lustre.CastExpr; import jkind.lustre.CondactExpr; import jkind.lustre.Expr; import jkind.lustre.FunctionCallExpr; import jkind.lustre.IfThenElseExpr; import jkind.lustre.IntExpr; import jkind.lustre.NodeCallExpr; import jkind.lustre.RealExpr; import jkind.lustre.RecordAccessExpr; import jkind.lustre.RecordExpr; import jkind.lustre.RecordUpdateExpr; import jkind.lustre.TupleExpr; import jkind.lustre.UnaryExpr; import jkind.lustre.values.ArrayValue; import jkind.lustre.values.BooleanValue; import jkind.lustre.values.IntegerValue; import jkind.lustre.values.RealValue; import jkind.lustre.values.RecordValue; import jkind.lustre.values.TupleValue; import jkind.lustre.values.Value; import jkind.util.BigFraction; import jkind.util.Util; public abstract class Evaluator implements ExprVisitor<Value> { public Value eval(Expr e) { return e.accept(this); } public IntegerValue evalInt(Expr e) { return (IntegerValue) eval(e); } @Override public Value visit(ArrayAccessExpr e) { ArrayValue array = (ArrayValue) eval(e.array); IntegerValue index = (IntegerValue) eval(e.index); if (array == null || index == null) { return null; } return array.get(index.value); } @Override public Value visit(ArrayExpr e) { List<Value> elements = visitExprs(e.elements); if (elements == null) { return null; } return new ArrayValue(elements); } @Override public Value visit(ArrayUpdateExpr e) { ArrayValue array = (ArrayValue) eval(e.array); IntegerValue index = (IntegerValue) eval(e.index); Value value = eval(e.value); if (array == null || index == null || value == null) { return null; } return array.update(index.value, value); } @Override public Value visit(BinaryExpr e) { Value left = eval(e.left); Value right = eval(e.right); if (left == null || right == null) { return null; } return left.applyBinaryOp(e.op, right); } @Override public Value visit(BoolExpr e) { return BooleanValue.fromBoolean(e.value); } @Override public Value visit(CastExpr e) { Value value = eval(e.expr); if (value == null) { return null; } return Util.cast(e.type, value); } @Override public Value visit(CondactExpr e) { return null; } @Override public Value visit(FunctionCallExpr e) { return null; } @Override public Value visit(IfThenElseExpr e) { BooleanValue cond = (BooleanValue) eval(e.cond); if (cond == null) { return null; } if (cond.value) { return eval(e.thenExpr); } else { return eval(e.elseExpr); } } @Override public Value visit(IntExpr e) { return new IntegerValue(e.value); } @Override public Value visit(NodeCallExpr e) { return null; } @Override public Value visit(RealExpr e) { return new RealValue(BigFraction.valueOf(e.value)); } @Override public Value visit(RecordAccessExpr e) { RecordValue record = (RecordValue) eval(e.record); if (record == null) { return null; } return record.fields.get(e.field); } @Override public Value visit(RecordExpr e) { Map<String, Value> fields = new HashMap<>(); for (Entry<String, Expr> entry : e.fields.entrySet()) { Value value = eval(entry.getValue()); if (value == null) { return null; } fields.put(entry.getKey(), value); } return new RecordValue(fields); } @Override public Value visit(RecordUpdateExpr e) { RecordValue record = (RecordValue) eval(e.record); Value value = eval(e.value); if (record == null || value == null) { return null; } return record.update(e.field, value); } @Override public Value visit(TupleExpr e) { List<Value> elements = visitExprs(e.elements); if (elements == null) { return null; } return new TupleValue(elements); } @Override public Value visit(UnaryExpr e) { Value value = eval(e.expr); if (value == null) { return null; } return value.applyUnaryOp(e.op); } protected List<Value> visitExprs(List<Expr> es) { List<Value> values = new ArrayList<>(); for (Expr e : es) { Value value = eval(e); if (value == null) { return null; } values.add(value); } return values; } }
4,440
21.094527
63
java
jkind
jkind-master/jkind-common/src/jkind/lustre/visitors/ExprVisitor.java
package jkind.lustre.visitors; import jkind.lustre.ArrayAccessExpr; import jkind.lustre.ArrayExpr; import jkind.lustre.ArrayUpdateExpr; import jkind.lustre.BinaryExpr; import jkind.lustre.BoolExpr; import jkind.lustre.CastExpr; import jkind.lustre.CondactExpr; import jkind.lustre.FunctionCallExpr; import jkind.lustre.IdExpr; import jkind.lustre.IfThenElseExpr; import jkind.lustre.IntExpr; import jkind.lustre.NodeCallExpr; import jkind.lustre.RealExpr; import jkind.lustre.RecordAccessExpr; import jkind.lustre.RecordExpr; import jkind.lustre.RecordUpdateExpr; import jkind.lustre.TupleExpr; import jkind.lustre.UnaryExpr; public interface ExprVisitor<T> { public T visit(ArrayAccessExpr e); public T visit(ArrayExpr e); public T visit(ArrayUpdateExpr e); public T visit(BinaryExpr e); public T visit(BoolExpr e); public T visit(CastExpr e); public T visit(CondactExpr e); public T visit(FunctionCallExpr e); public T visit(IdExpr e); public T visit(IfThenElseExpr e); public T visit(IntExpr e); public T visit(NodeCallExpr e); public T visit(RealExpr e); public T visit(RecordAccessExpr e); public T visit(RecordExpr e); public T visit(RecordUpdateExpr e); public T visit(TupleExpr e); public T visit(UnaryExpr e); }
1,258
20.338983
37
java
jkind
jkind-master/jkind-common/src/jkind/lustre/visitors/ExprConjunctiveVisitor.java
package jkind.lustre.visitors; import java.util.Collection; import jkind.lustre.ArrayAccessExpr; import jkind.lustre.ArrayExpr; import jkind.lustre.ArrayUpdateExpr; import jkind.lustre.BinaryExpr; import jkind.lustre.BoolExpr; import jkind.lustre.CastExpr; import jkind.lustre.CondactExpr; import jkind.lustre.Expr; import jkind.lustre.FunctionCallExpr; import jkind.lustre.IdExpr; import jkind.lustre.IfThenElseExpr; import jkind.lustre.IntExpr; import jkind.lustre.NodeCallExpr; import jkind.lustre.RealExpr; import jkind.lustre.RecordAccessExpr; import jkind.lustre.RecordExpr; import jkind.lustre.RecordUpdateExpr; import jkind.lustre.TupleExpr; import jkind.lustre.UnaryExpr; public class ExprConjunctiveVisitor implements ExprVisitor<Boolean> { @Override public Boolean visit(ArrayAccessExpr e) { return e.array.accept(this) && e.index.accept(this); } @Override public Boolean visit(ArrayExpr e) { return visitExprs(e.elements); } @Override public Boolean visit(ArrayUpdateExpr e) { return e.array.accept(this) && e.index.accept(this) && e.value.accept(this); } @Override public Boolean visit(BinaryExpr e) { return e.left.accept(this) && e.right.accept(this); } @Override public Boolean visit(BoolExpr e) { return true; } @Override public Boolean visit(CastExpr e) { return e.expr.accept(this); } @Override public Boolean visit(CondactExpr e) { return e.clock.accept(this) && e.call.accept(this) && visitExprs(e.args); } @Override public Boolean visit(FunctionCallExpr e) { return visitExprs(e.args); } @Override public Boolean visit(IdExpr e) { return true; } @Override public Boolean visit(IfThenElseExpr e) { return e.cond.accept(this) && e.thenExpr.accept(this) && e.elseExpr.accept(this); } @Override public Boolean visit(IntExpr e) { return true; } @Override public Boolean visit(NodeCallExpr e) { return visitExprs(e.args); } @Override public Boolean visit(RealExpr e) { return true; } @Override public Boolean visit(RecordAccessExpr e) { return e.record.accept(this); } @Override public Boolean visit(RecordExpr e) { return visitExprs(e.fields.values()); } @Override public Boolean visit(RecordUpdateExpr e) { return e.record.accept(this) && e.value.accept(this); } @Override public Boolean visit(TupleExpr e) { return visitExprs(e.elements); } @Override public Boolean visit(UnaryExpr e) { return e.expr.accept(this); } private Boolean visitExprs(Collection<Expr> list) { for (Expr e : list) { if (!e.accept(this)) { return false; } } return true; } }
2,597
19.784
83
java
jkind
jkind-master/jkind-common/src/jkind/lustre/visitors/TypeAwareAstMapVisitor.java
package jkind.lustre.visitors; import jkind.lustre.Expr; import jkind.lustre.Node; import jkind.lustre.Program; import jkind.lustre.Type; public class TypeAwareAstMapVisitor extends AstMapVisitor { protected TypeReconstructor typeReconstructor; protected Type getType(Expr e) { return e.accept(typeReconstructor); } @Override public Program visit(Program e) { typeReconstructor = new TypeReconstructor(e); return super.visit(e); } @Override public Node visit(Node e) { typeReconstructor.setNodeContext(e); return super.visit(e); } }
557
19.666667
59
java
jkind
jkind-master/jkind-common/src/jkind/lustre/visitors/PrettyPrintVisitor.java
package jkind.lustre.visitors; import static java.util.stream.Collectors.joining; import java.util.Iterator; import java.util.List; import java.util.Map.Entry; import jkind.lustre.ArrayAccessExpr; import jkind.lustre.ArrayExpr; import jkind.lustre.ArrayUpdateExpr; import jkind.lustre.BinaryExpr; import jkind.lustre.BoolExpr; import jkind.lustre.CastExpr; import jkind.lustre.CondactExpr; import jkind.lustre.Constant; import jkind.lustre.Contract; import jkind.lustre.EnumType; import jkind.lustre.Equation; import jkind.lustre.Expr; import jkind.lustre.Function; import jkind.lustre.FunctionCallExpr; import jkind.lustre.IdExpr; import jkind.lustre.IfThenElseExpr; import jkind.lustre.IntExpr; import jkind.lustre.NamedType; import jkind.lustre.Node; import jkind.lustre.NodeCallExpr; import jkind.lustre.Program; import jkind.lustre.RealExpr; import jkind.lustre.RecordAccessExpr; import jkind.lustre.RecordExpr; import jkind.lustre.RecordType; import jkind.lustre.RecordUpdateExpr; import jkind.lustre.TupleExpr; import jkind.lustre.Type; import jkind.lustre.TypeDef; import jkind.lustre.UnaryExpr; import jkind.lustre.UnaryOp; import jkind.lustre.VarDecl; public class PrettyPrintVisitor implements AstVisitor<Void, Void> { private StringBuilder sb = new StringBuilder(); private String main; @Override public String toString() { return sb.toString(); } protected void write(Object o) { sb.append(o); } private static final String seperator = System.getProperty("line.separator"); private void newline() { write(seperator); } @Override public Void visit(Program program) { main = program.main; if (!program.types.isEmpty()) { for (TypeDef typeDef : program.types) { typeDef.accept(this); newline(); } newline(); } if (!program.constants.isEmpty()) { for (Constant constant : program.constants) { constant.accept(this); newline(); } newline(); } if (!program.functions.isEmpty()) { for (Function function : program.functions) { function.accept(this); newline(); } newline(); } Iterator<Node> iterator = program.nodes.iterator(); while (iterator.hasNext()) { iterator.next().accept(this); newline(); if (iterator.hasNext()) { newline(); } } return null; } @Override public Void visit(TypeDef typeDef) { write("type "); write(typeDef.id); write(" = "); writeType(typeDef.type); write(";"); return null; } private void writeType(Type type) { if (type instanceof RecordType) { RecordType recordType = (RecordType) type; write("struct {"); Iterator<Entry<String, Type>> iterator = recordType.fields.entrySet().iterator(); while (iterator.hasNext()) { Entry<String, Type> entry = iterator.next(); write(entry.getKey()); write(" : "); write(entry.getValue()); if (iterator.hasNext()) { write("; "); } } write("}"); } else if (type instanceof EnumType) { EnumType enumType = (EnumType) type; write("enum {"); Iterator<String> iterator = enumType.values.iterator(); while (iterator.hasNext()) { write(iterator.next()); if (iterator.hasNext()) { write(", "); } } write("}"); } else { write(type); } } @Override public Void visit(Constant constant) { write("const "); write(constant.id); write(" = "); expr(constant.expr); write(";"); return null; } @Override public Void visit(Function function) { write("function "); write(function.id); write("("); newline(); varDecls(function.inputs); newline(); write(") returns ("); newline(); varDecls(function.outputs); newline(); write(");"); newline(); return null; } @Override public Void visit(Node node) { write("node "); write(node.id); write("("); newline(); varDecls(node.inputs); newline(); write(") returns ("); newline(); varDecls(node.outputs); newline(); write(");"); newline(); if (node.contract != null) { node.contract.accept(this); } if (!node.locals.isEmpty()) { write("var"); newline(); varDecls(node.locals); write(";"); newline(); } write("let"); newline(); if (node.id.equals(main)) { write(" --%MAIN;"); newline(); } for (Equation equation : node.equations) { write(" "); equation.accept(this); newline(); newline(); } for (Expr assertion : node.assertions) { assertion(assertion); newline(); } if (!node.properties.isEmpty()) { for (String property : node.properties) { property(property); } newline(); } if (node.realizabilityInputs != null) { write(" --%REALIZABLE "); write(node.realizabilityInputs.stream().collect(joining(", "))); write(";"); newline(); newline(); } if (!node.ivc.isEmpty()) { write(" --%IVC "); write(node.ivc.stream().collect(joining(", "))); write(";"); newline(); newline(); } write("tel;"); return null; } private void varDecls(List<VarDecl> varDecls) { Iterator<VarDecl> iterator = varDecls.iterator(); while (iterator.hasNext()) { write(" "); iterator.next().accept(this); if (iterator.hasNext()) { write(";"); newline(); } } } @Override public Void visit(VarDecl varDecl) { write(varDecl.id); write(" : "); write(varDecl.type); return null; } @Override public Void visit(Equation equation) { if (equation.lhs.isEmpty()) { write("()"); } else { Iterator<IdExpr> iterator = equation.lhs.iterator(); while (iterator.hasNext()) { write(iterator.next().id); if (iterator.hasNext()) { write(", "); } } } write(" = "); expr(equation.expr); write(";"); return null; } private void assertion(Expr assertion) { write(" assert "); expr(assertion); write(";"); newline(); } protected void property(String s) { write(" --%PROPERTY "); write(s); write(";"); newline(); } public void expr(Expr e) { e.accept(this); } @Override public Void visit(ArrayAccessExpr e) { expr(e.array); write("["); expr(e.index); write("]"); return null; } @Override public Void visit(ArrayExpr e) { Iterator<Expr> iterator = e.elements.iterator(); write("["); expr(iterator.next()); while (iterator.hasNext()) { write(", "); expr(iterator.next()); } write("]"); return null; } @Override public Void visit(ArrayUpdateExpr e) { expr(e.array); write("["); expr(e.index); write(" := "); expr(e.value); write("]"); return null; } @Override public Void visit(BinaryExpr e) { write("("); expr(e.left); write(" "); write(e.op); write(" "); expr(e.right); write(")"); return null; } @Override public Void visit(BoolExpr e) { write(Boolean.toString(e.value)); return null; } @Override public Void visit(CastExpr e) { write(getCastFunction(e.type)); write("("); expr(e.expr); write(")"); return null; } private String getCastFunction(Type type) { if (type == NamedType.REAL) { return "real"; } else if (type == NamedType.INT) { return "floor"; } else { throw new IllegalArgumentException("Unable to cast to type: " + type); } } @Override public Void visit(CondactExpr e) { write("condact("); expr(e.clock); write(", "); expr(e.call); for (Expr arg : e.args) { write(", "); expr(arg); } write(")"); return null; } @Override public Void visit(FunctionCallExpr e) { write(e.function); write("("); Iterator<Expr> iterator = e.args.iterator(); while (iterator.hasNext()) { expr(iterator.next()); if (iterator.hasNext()) { write(", "); } } write(")"); return null; } @Override public Void visit(IdExpr e) { write(e.id); return null; } @Override public Void visit(IfThenElseExpr e) { write("(if "); expr(e.cond); write(" then "); expr(e.thenExpr); write(" else "); expr(e.elseExpr); write(")"); return null; } @Override public Void visit(IntExpr e) { write(e.value); return null; } @Override public Void visit(NodeCallExpr e) { write(e.node); write("("); Iterator<Expr> iterator = e.args.iterator(); while (iterator.hasNext()) { expr(iterator.next()); if (iterator.hasNext()) { write(", "); } } write(")"); return null; } @Override public Void visit(RealExpr e) { String str = e.value.toPlainString(); write(str); if (!str.contains(".")) { write(".0"); } return null; } @Override public Void visit(RecordAccessExpr e) { expr(e.record); write("."); write(e.field); return null; } @Override public Void visit(RecordExpr e) { write(e.id); write(" {"); Iterator<Entry<String, Expr>> iterator = e.fields.entrySet().iterator(); while (iterator.hasNext()) { Entry<String, Expr> entry = iterator.next(); write(entry.getKey()); write(" = "); expr(entry.getValue()); if (iterator.hasNext()) { write("; "); } } write("}"); return null; } @Override public Void visit(RecordUpdateExpr e) { expr(e.record); write("{"); write(e.field); write(" := "); expr(e.value); write("}"); return null; } @Override public Void visit(TupleExpr e) { if (e.elements.isEmpty()) { write("()"); return null; } Iterator<Expr> iterator = e.elements.iterator(); write("("); expr(iterator.next()); while (iterator.hasNext()) { write(", "); expr(iterator.next()); } write(")"); return null; } @Override public Void visit(UnaryExpr e) { write("("); write(e.op); if (e.op != UnaryOp.NEGATIVE) { write(" "); } expr(e.expr); write(")"); return null; } @Override public Void visit(Contract contract) { newline(); write("(*@contract"); newline(); for (Expr expr : contract.requires) { write("assume "); expr(expr); write(";"); newline(); } for (Expr expr : contract.ensures) { write("guarantee "); expr(expr); write(";"); newline(); } write("*)"); newline(); return null; } }
9,965
17.558659
84
java
jkind
jkind-master/jkind-common/src/jkind/lustre/visitors/TypeReconstructor.java
package jkind.lustre.visitors; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import jkind.lustre.ArrayAccessExpr; import jkind.lustre.ArrayExpr; import jkind.lustre.ArrayType; import jkind.lustre.ArrayUpdateExpr; import jkind.lustre.BinaryExpr; import jkind.lustre.BoolExpr; import jkind.lustre.CastExpr; import jkind.lustre.CondactExpr; import jkind.lustre.Constant; import jkind.lustre.EnumType; import jkind.lustre.Expr; import jkind.lustre.Function; import jkind.lustre.FunctionCallExpr; import jkind.lustre.IdExpr; import jkind.lustre.IfThenElseExpr; import jkind.lustre.IntExpr; import jkind.lustre.NamedType; import jkind.lustre.Node; import jkind.lustre.NodeCallExpr; import jkind.lustre.Program; import jkind.lustre.RealExpr; import jkind.lustre.RecordAccessExpr; import jkind.lustre.RecordExpr; import jkind.lustre.RecordType; import jkind.lustre.RecordUpdateExpr; import jkind.lustre.SubrangeIntType; import jkind.lustre.TupleExpr; import jkind.lustre.TupleType; import jkind.lustre.Type; import jkind.lustre.TypeDef; import jkind.lustre.UnaryExpr; import jkind.lustre.VarDecl; import jkind.util.Util; /** * Assuming everything is well-typed, this class can be used to quickly * reconstruct the type of an expression (often useful during translations). * This class treats subrange and enumeration types as integer types. */ public class TypeReconstructor implements ExprVisitor<Type> { private final Map<String, Type> typeTable = new HashMap<>(); private final Map<String, Type> constantTable = new HashMap<>(); private final Map<String, Expr> constantDefinitionTable = new HashMap<>(); private final Map<String, EnumType> enumValueTable = new HashMap<>(); private final Map<String, Type> variableTable = new HashMap<>(); private final Map<String, Node> nodeTable = new HashMap<>(); private final Map<String, Function> functionTable = new HashMap<>(); private final boolean enumsAsInts; public TypeReconstructor(Program program) { this(program, true); } public TypeReconstructor(Program program, boolean enumsAsInts) { this.enumsAsInts = enumsAsInts; populateTypeTable(program.types); populateEnumValueTable(program.types); populateConstantTable(program.constants); functionTable.putAll(Util.getFunctionTable(program.functions)); nodeTable.putAll(Util.getNodeTable(program.nodes)); } private void populateTypeTable(List<TypeDef> typeDefs) { typeTable.putAll(Util.createResolvedTypeTable(typeDefs)); } private void populateEnumValueTable(List<TypeDef> typeDefs) { for (EnumType et : Util.getEnumTypes(typeDefs)) { for (String id : et.values) { enumValueTable.put(id, et); } } } private void populateConstantTable(List<Constant> constants) { for (Constant c : constants) { constantDefinitionTable.put(c.id, c.expr); } for (Constant c : constants) { if (c.type == null) { constantTable.put(c.id, c.expr.accept(this)); } else { constantTable.put(c.id, resolveType(c.type)); } } } public void setNodeContext(Node node) { variableTable.clear(); Util.getVarDecls(node).forEach(this::addVariable); } public void addVariable(VarDecl varDecl) { variableTable.put(varDecl.id, resolveType(varDecl.type)); } @Override public Type visit(ArrayAccessExpr e) { ArrayType array = (ArrayType) e.array.accept(this); return array.base; } @Override public Type visit(ArrayExpr e) { return new ArrayType(e.elements.get(0).accept(this), e.elements.size()); } @Override public Type visit(ArrayUpdateExpr e) { return e.array.accept(this); } @Override public Type visit(BinaryExpr e) { switch (e.op) { case PLUS: case MINUS: case MULTIPLY: return e.left.accept(this); case DIVIDE: return NamedType.REAL; case INT_DIVIDE: case MODULUS: return NamedType.INT; case EQUAL: case NOTEQUAL: case GREATER: case LESS: case GREATEREQUAL: case LESSEQUAL: case OR: case AND: case XOR: case IMPLIES: return NamedType.BOOL; case ARROW: return e.left.accept(this); default: throw new IllegalArgumentException(); } } @Override public Type visit(BoolExpr e) { return NamedType.BOOL; } @Override public Type visit(CastExpr e) { return e.type; } @Override public Type visit(CondactExpr e) { return e.call.accept(this); } @Override public Type visit(IdExpr e) { if (variableTable.containsKey(e.id)) { return variableTable.get(e.id); } else if (constantTable.containsKey(e.id)) { return constantTable.get(e.id); } else if (constantDefinitionTable.containsKey(e.id)) { return constantDefinitionTable.get(e.id).accept(this); } else if (enumValueTable.containsKey(e.id)) { return enumsAsInts ? NamedType.INT : enumValueTable.get(e.id); } else { throw new IllegalArgumentException("Unknown variable: " + e.id); } } @Override public Type visit(IfThenElseExpr e) { return e.thenExpr.accept(this); } @Override public Type visit(IntExpr e) { return NamedType.INT; } @Override public Type visit(NodeCallExpr e) { Node node = nodeTable.get(e.node); return visitCallOutputs(node.outputs); } @Override public Type visit(FunctionCallExpr e) { Function function = functionTable.get(e.function); return visitCallOutputs(function.outputs); } private Type visitCallOutputs(List<VarDecl> outputDecls) { List<Type> outputs = new ArrayList<>(); for (VarDecl output : outputDecls) { outputs.add(resolveType(output.type)); } return TupleType.compress(outputs); } @Override public Type visit(RealExpr e) { return NamedType.REAL; } @Override public Type visit(RecordAccessExpr e) { RecordType record = (RecordType) e.record.accept(this); return record.fields.get(e.field); } @Override public Type visit(RecordExpr e) { if (typeTable.containsKey(e.id)) { return typeTable.get(e.id); } else { // If user types have already been inlined, we reconstruct the type Map<String, Type> fields = new HashMap<>(); for (String field : e.fields.keySet()) { fields.put(field, e.fields.get(field).accept(this)); } return new RecordType(e.id, fields); } } @Override public Type visit(RecordUpdateExpr e) { return e.record.accept(this); } @Override public Type visit(TupleExpr e) { List<Type> types = new ArrayList<>(); for (Expr expr : e.elements) { types.add(expr.accept(this)); } return new TupleType(types); } @Override public Type visit(UnaryExpr e) { switch (e.op) { case PRE: case NEGATIVE: return e.expr.accept(this); case NOT: return NamedType.BOOL; default: throw new IllegalArgumentException(); } } private Type resolveType(Type type) { return type.accept(new TypeMapVisitor() { @Override public Type visit(SubrangeIntType e) { return NamedType.INT; } @Override public Type visit(EnumType e) { return enumsAsInts ? NamedType.INT : e; } @Override public Type visit(NamedType e) { if (e.isBuiltin()) { return e; } else { return typeTable.get(e.name); } } }); } }
7,087
23.191126
76
java
jkind
jkind-master/jkind-common/src/jkind/lustre/visitors/AstIterVisitor.java
package jkind.lustre.visitors; import java.util.List; import jkind.lustre.Constant; import jkind.lustre.Contract; import jkind.lustre.Equation; import jkind.lustre.Expr; import jkind.lustre.Function; import jkind.lustre.Node; import jkind.lustre.Program; import jkind.lustre.TypeDef; import jkind.lustre.VarDecl; public class AstIterVisitor extends ExprIterVisitor implements AstVisitor<Void, Void> { @Override public Void visit(Constant e) { e.expr.accept(this); return null; } @Override public Void visit(Equation e) { e.expr.accept(this); return null; } @Override public Void visit(Function e) { visitVarDecls(e.inputs); visitVarDecls(e.outputs); return null; } @Override public Void visit(Node e) { visitVarDecls(e.inputs); visitVarDecls(e.outputs); visitVarDecls(e.locals); visitEquations(e.equations); visitAssertions(e.assertions); return null; } protected void visitVarDecls(List<VarDecl> es) { for (VarDecl e : es) { visit(e); } } protected void visitEquations(List<Equation> es) { for (Equation e : es) { visit(e); } } protected void visitAssertions(List<Expr> es) { visitExprs(es); } @Override public Void visit(Program e) { visitTypeDefs(e.types); visitConstants(e.constants); visitFunctions(e.functions); visitNodes(e.nodes); return null; } protected void visitTypeDefs(List<TypeDef> es) { for (TypeDef e : es) { visit(e); } } protected void visitConstants(List<Constant> es) { for (Constant e : es) { visit(e); } } protected void visitFunctions(List<Function> es) { for (Function e : es) { visit(e); } } protected void visitNodes(List<Node> es) { for (Node e : es) { visit(e); } } @Override public Void visit(TypeDef e) { return null; } @Override public Void visit(VarDecl e) { return null; } @Override public Void visit(Contract contract) { visitExprs(contract.requires); visitExprs(contract.ensures); return null; } }
1,979
16.837838
87
java
jkind
jkind-master/jkind-common/src/jkind/lustre/visitors/AstVisitor.java
package jkind.lustre.visitors; import jkind.lustre.Constant; import jkind.lustre.Contract; import jkind.lustre.Equation; import jkind.lustre.Function; import jkind.lustre.Node; import jkind.lustre.Program; import jkind.lustre.TypeDef; import jkind.lustre.VarDecl; public interface AstVisitor<T, S extends T> extends ExprVisitor<S> { public T visit(Constant constant); public T visit(Equation equation); public T visit(Function function); public T visit(Node node); public T visit(Program program); public T visit(TypeDef typeDef); public T visit(VarDecl varDecl); public T visit(Contract contract); }
618
20.344828
68
java
jkind
jkind-master/jkind-common/src/jkind/lustre/visitors/ExprIterVisitor.java
package jkind.lustre.visitors; import java.util.Collection; import jkind.lustre.ArrayAccessExpr; import jkind.lustre.ArrayExpr; import jkind.lustre.ArrayUpdateExpr; import jkind.lustre.BinaryExpr; import jkind.lustre.BoolExpr; import jkind.lustre.CastExpr; import jkind.lustre.CondactExpr; import jkind.lustre.Expr; import jkind.lustre.FunctionCallExpr; import jkind.lustre.IdExpr; import jkind.lustre.IfThenElseExpr; import jkind.lustre.IntExpr; import jkind.lustre.NodeCallExpr; import jkind.lustre.RealExpr; import jkind.lustre.RecordAccessExpr; import jkind.lustre.RecordExpr; import jkind.lustre.RecordUpdateExpr; import jkind.lustre.TupleExpr; import jkind.lustre.UnaryExpr; public class ExprIterVisitor implements ExprVisitor<Void> { @Override public Void visit(ArrayAccessExpr e) { e.array.accept(this); e.index.accept(this); return null; } @Override public Void visit(ArrayExpr e) { visitExprs(e.elements); return null; } @Override public Void visit(ArrayUpdateExpr e) { e.array.accept(this); e.index.accept(this); e.value.accept(this); return null; } @Override public Void visit(BinaryExpr e) { e.left.accept(this); e.right.accept(this); return null; } @Override public Void visit(BoolExpr e) { return null; } @Override public Void visit(CastExpr e) { e.expr.accept(this); return null; } @Override public Void visit(CondactExpr e) { e.clock.accept(this); e.call.accept(this); visitExprs(e.args); return null; } @Override public Void visit(FunctionCallExpr e) { visitExprs(e.args); return null; } @Override public Void visit(IdExpr e) { return null; } @Override public Void visit(IfThenElseExpr e) { e.cond.accept(this); e.thenExpr.accept(this); e.elseExpr.accept(this); return null; } @Override public Void visit(IntExpr e) { return null; } @Override public Void visit(NodeCallExpr e) { visitExprs(e.args); return null; } @Override public Void visit(RealExpr e) { return null; } @Override public Void visit(RecordAccessExpr e) { e.record.accept(this); return null; } @Override public Void visit(RecordExpr e) { visitExprs(e.fields.values()); return null; } @Override public Void visit(RecordUpdateExpr e) { e.record.accept(this); e.value.accept(this); return null; } @Override public Void visit(TupleExpr e) { visitExprs(e.elements); return null; } @Override public Void visit(UnaryExpr e) { e.expr.accept(this); return null; } protected Void visitExprs(Collection<Expr> list) { for (Expr e : list) { e.accept(this); } return null; } }
2,614
16.910959
59
java
jkind
jkind-master/jkind-common/src/jkind/lustre/visitors/TypeMapVisitor.java
package jkind.lustre.visitors; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import jkind.lustre.ArrayType; import jkind.lustre.EnumType; import jkind.lustre.NamedType; import jkind.lustre.RecordType; import jkind.lustre.SubrangeIntType; import jkind.lustre.TupleType; import jkind.lustre.Type; public class TypeMapVisitor implements TypeVisitor<Type> { @Override public Type visit(ArrayType e) { return new ArrayType(e.location, e.base.accept(this), e.size); } @Override public Type visit(NamedType e) { return e; } @Override public Type visit(EnumType e) { return e; } @Override public Type visit(RecordType e) { Map<String, Type> fields = new HashMap<>(); for (Entry<String, Type> entry : e.fields.entrySet()) { fields.put(entry.getKey(), entry.getValue().accept(this)); } return new RecordType(e.location, e.id, fields); } @Override public Type visit(TupleType e) { List<Type> types = new ArrayList<>(); for (Type t : e.types) { types.add(t.accept(this)); } return new TupleType(types); } @Override public Type visit(SubrangeIntType e) { return e; } }
1,193
20.321429
64
java
jkind
jkind-master/jkind-common/src/jkind/lustre/visitors/AstMapVisitor.java
package jkind.lustre.visitors; import java.util.List; import jkind.lustre.Ast; import jkind.lustre.Constant; import jkind.lustre.Contract; import jkind.lustre.Equation; import jkind.lustre.Expr; import jkind.lustre.Function; import jkind.lustre.Node; import jkind.lustre.Program; import jkind.lustre.TypeDef; import jkind.lustre.VarDecl; public class AstMapVisitor extends ExprMapVisitor implements AstVisitor<Ast, Expr> { @Override public Constant visit(Constant e) { return new Constant(e.location, e.id, e.type, e.expr.accept(this)); } @Override public Equation visit(Equation e) { // Do not traverse e.lhs since they do not really act like Exprs return new Equation(e.location, e.lhs, e.expr.accept(this)); } @Override public Function visit(Function e) { List<VarDecl> inputs = visitVarDecls(e.inputs); List<VarDecl> outputs = visitVarDecls(e.outputs); return new Function(e.location, e.id, inputs, outputs); } @Override public Node visit(Node e) { List<VarDecl> inputs = visitVarDecls(e.inputs); List<VarDecl> outputs = visitVarDecls(e.outputs); List<VarDecl> locals = visitVarDecls(e.locals); List<Equation> equations = visitEquations(e.equations); List<Expr> assertions = visitAssertions(e.assertions); List<String> properties = visitProperties(e.properties); List<String> ivc = visitIvc(e.ivc); List<String> realizabilityInputs = visitRealizabilityInputs(e.realizabilityInputs); Contract contract = visit(e.contract); return new Node(e.location, e.id, inputs, outputs, locals, equations, properties, assertions, realizabilityInputs, contract, ivc); } protected List<VarDecl> visitVarDecls(List<VarDecl> es) { return map(this::visit, es); } protected List<Equation> visitEquations(List<Equation> es) { return map(this::visit, es); } protected List<Expr> visitAssertions(List<Expr> es) { return visitExprs(es); } protected List<String> visitProperties(List<String> es) { return map(this::visitProperty, es); } protected String visitProperty(String e) { return e; } protected List<String> visitIvc(List<String> es) { return map(this::visitIvc, es); } protected String visitIvc(String e) { return e; } protected List<String> visitRealizabilityInputs(List<String> es) { if (es == null) { return null; } return map(this::visitRealizabilityInput, es); } protected String visitRealizabilityInput(String e) { return e; } @Override public Program visit(Program e) { List<TypeDef> types = visitTypeDefs(e.types); List<Constant> constants = visitConstants(e.constants); List<Function> functions = visitFunctions(e.functions); List<Node> nodes = visitNodes(e.nodes); return new Program(e.location, types, constants, functions, nodes, e.main); } protected List<TypeDef> visitTypeDefs(List<TypeDef> es) { return map(this::visit, es); } protected List<Constant> visitConstants(List<Constant> es) { return map(this::visit, es); } protected List<Node> visitNodes(List<Node> es) { return map(this::visit, es); } protected List<Function> visitFunctions(List<Function> es) { return map(this::visit, es); } @Override public TypeDef visit(TypeDef e) { return e; } @Override public VarDecl visit(VarDecl e) { return e; } @Override public Contract visit(Contract contract) { if (contract == null) { return null; } return new Contract(visitExprs(contract.requires), visitExprs(contract.ensures)); } }
3,448
25.128788
95
java
jkind
jkind-master/jkind-common/src/jkind/lustre/visitors/TypeIterVisitor.java
package jkind.lustre.visitors; import jkind.lustre.ArrayType; import jkind.lustre.EnumType; import jkind.lustre.NamedType; import jkind.lustre.Node; import jkind.lustre.Program; import jkind.lustre.RecordType; import jkind.lustre.SubrangeIntType; import jkind.lustre.TupleType; import jkind.lustre.Type; import jkind.lustre.TypeDef; import jkind.lustre.VarDecl; import jkind.util.Util; public class TypeIterVisitor implements TypeVisitor<Void> { @Override public Void visit(ArrayType e) { e.base.accept(this); return null; } @Override public Void visit(EnumType e) { return null; } @Override public Void visit(NamedType e) { return null; } @Override public Void visit(RecordType e) { for (Type type : e.fields.values()) { type.accept(this); } return null; } @Override public Void visit(TupleType e) { for (Type t : e.types) { t.accept(this); } return null; } @Override public Void visit(SubrangeIntType e) { return null; } public void visitProgram(Program program) { for (TypeDef def : program.types) { def.type.accept(this); } for (Node node : program.nodes) { for (VarDecl decl : Util.getVarDecls(node)) { decl.type.accept(this); } } } }
1,218
17.469697
59
java
jkind
jkind-master/jkind-common/src/jkind/lustre/visitors/TypeVisitor.java
package jkind.lustre.visitors; import jkind.lustre.ArrayType; import jkind.lustre.EnumType; import jkind.lustre.NamedType; import jkind.lustre.RecordType; import jkind.lustre.SubrangeIntType; import jkind.lustre.TupleType; public interface TypeVisitor<T> { public T visit(ArrayType e); public T visit(EnumType e); public T visit(NamedType e); public T visit(RecordType e); public T visit(TupleType e); public T visit(SubrangeIntType e); }
452
18.695652
36
java
jkind
jkind-master/jkind-common/src/jkind/lustre/visitors/ExprMapVisitor.java
package jkind.lustre.visitors; import static java.util.stream.Collectors.toList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.function.Function; import jkind.lustre.ArrayAccessExpr; import jkind.lustre.ArrayExpr; import jkind.lustre.ArrayUpdateExpr; import jkind.lustre.BinaryExpr; import jkind.lustre.BoolExpr; import jkind.lustre.CastExpr; import jkind.lustre.CondactExpr; import jkind.lustre.Expr; import jkind.lustre.FunctionCallExpr; import jkind.lustre.IdExpr; import jkind.lustre.IfThenElseExpr; import jkind.lustre.IntExpr; import jkind.lustre.NodeCallExpr; import jkind.lustre.RealExpr; import jkind.lustre.RecordAccessExpr; import jkind.lustre.RecordExpr; import jkind.lustre.RecordUpdateExpr; import jkind.lustre.TupleExpr; import jkind.lustre.UnaryExpr; public class ExprMapVisitor implements ExprVisitor<Expr> { @Override public Expr visit(ArrayAccessExpr e) { return new ArrayAccessExpr(e.location, e.array.accept(this), e.index.accept(this)); } @Override public Expr visit(ArrayExpr e) { return new ArrayExpr(e.location, visitExprs(e.elements)); } @Override public Expr visit(ArrayUpdateExpr e) { return new ArrayUpdateExpr(e.location, e.array.accept(this), e.index.accept(this), e.value.accept(this)); } @Override public Expr visit(BinaryExpr e) { Expr left = e.left.accept(this); Expr right = e.right.accept(this); if (e.left == left && e.right == right) { return e; } return new BinaryExpr(e.location, left, e.op, right); } @Override public Expr visit(BoolExpr e) { return e; } @Override public Expr visit(CastExpr e) { return new CastExpr(e.location, e.type, e.expr.accept(this)); } @Override public Expr visit(CondactExpr e) { return new CondactExpr(e.location, e.clock.accept(this), (NodeCallExpr) e.call.accept(this), visitExprs(e.args)); } @Override public Expr visit(FunctionCallExpr e) { return new FunctionCallExpr(e.location, e.function, visitExprs(e.args)); } @Override public Expr visit(IdExpr e) { return e; } @Override public Expr visit(IfThenElseExpr e) { Expr cond = e.cond.accept(this); Expr thenExpr = e.thenExpr.accept(this); Expr elseExpr = e.elseExpr.accept(this); if (e.cond == cond && e.thenExpr == thenExpr && e.elseExpr == elseExpr) { return e; } return new IfThenElseExpr(e.location, cond, thenExpr, elseExpr); } @Override public Expr visit(IntExpr e) { return e; } @Override public Expr visit(NodeCallExpr e) { return new NodeCallExpr(e.location, e.node, visitExprs(e.args)); } @Override public Expr visit(RealExpr e) { return e; } @Override public Expr visit(RecordAccessExpr e) { return new RecordAccessExpr(e.location, e.record.accept(this), e.field); } @Override public Expr visit(RecordExpr e) { Map<String, Expr> fields = new HashMap<>(); for (Entry<String, Expr> entry : e.fields.entrySet()) { fields.put(entry.getKey(), entry.getValue().accept(this)); } return new RecordExpr(e.location, e.id, fields); } @Override public Expr visit(RecordUpdateExpr e) { return new RecordUpdateExpr(e.location, e.record.accept(this), e.field, e.value.accept(this)); } @Override public Expr visit(TupleExpr e) { return new TupleExpr(e.location, visitExprs(e.elements)); } @Override public Expr visit(UnaryExpr e) { Expr expr = e.expr.accept(this); if (e.expr == expr) { return e; } return new UnaryExpr(e.location, e.op, expr); } protected List<Expr> visitExprs(List<? extends Expr> es) { return map(e -> e.accept(this), es); } protected <A, B> List<B> map(Function<? super A, ? extends B> f, List<A> xs) { return xs.stream().map(f).collect(toList()); } }
3,729
23.866667
107
java
jkind
jkind-master/jkind-common/src/jkind/lustre/visitors/ExprDisjunctiveVisitor.java
package jkind.lustre.visitors; import java.util.Collection; import jkind.lustre.ArrayAccessExpr; import jkind.lustre.ArrayExpr; import jkind.lustre.ArrayUpdateExpr; import jkind.lustre.BinaryExpr; import jkind.lustre.BoolExpr; import jkind.lustre.CastExpr; import jkind.lustre.CondactExpr; import jkind.lustre.Expr; import jkind.lustre.FunctionCallExpr; import jkind.lustre.IdExpr; import jkind.lustre.IfThenElseExpr; import jkind.lustre.IntExpr; import jkind.lustre.NodeCallExpr; import jkind.lustre.RealExpr; import jkind.lustre.RecordAccessExpr; import jkind.lustre.RecordExpr; import jkind.lustre.RecordUpdateExpr; import jkind.lustre.TupleExpr; import jkind.lustre.UnaryExpr; public class ExprDisjunctiveVisitor implements ExprVisitor<Boolean> { @Override public Boolean visit(ArrayAccessExpr e) { return e.array.accept(this) || e.index.accept(this); } @Override public Boolean visit(ArrayExpr e) { return visitExprs(e.elements); } @Override public Boolean visit(ArrayUpdateExpr e) { return e.array.accept(this) || e.index.accept(this) || e.value.accept(this); } @Override public Boolean visit(BinaryExpr e) { return e.left.accept(this) || e.right.accept(this); } @Override public Boolean visit(BoolExpr e) { return false; } @Override public Boolean visit(CastExpr e) { return e.expr.accept(this); } @Override public Boolean visit(CondactExpr e) { return e.clock.accept(this) || e.call.accept(this) || visitExprs(e.args); } @Override public Boolean visit(FunctionCallExpr e) { return visitExprs(e.args); } @Override public Boolean visit(IdExpr e) { return false; } @Override public Boolean visit(IfThenElseExpr e) { return e.cond.accept(this) || e.thenExpr.accept(this) || e.elseExpr.accept(this); } @Override public Boolean visit(IntExpr e) { return false; } @Override public Boolean visit(NodeCallExpr e) { return visitExprs(e.args); } @Override public Boolean visit(RealExpr e) { return false; } @Override public Boolean visit(RecordAccessExpr e) { return e.record.accept(this); } @Override public Boolean visit(RecordExpr e) { return visitExprs(e.fields.values()); } @Override public Boolean visit(RecordUpdateExpr e) { return e.record.accept(this) || e.value.accept(this); } @Override public Boolean visit(TupleExpr e) { return visitExprs(e.elements); } @Override public Boolean visit(UnaryExpr e) { return e.expr.accept(this); } protected Boolean visitExprs(Collection<Expr> list) { for (Expr e : list) { if (e.accept(this)) { return true; } } return false; } }
2,602
19.824
83
java
jkind
jkind-master/jkind-common/src/jkind/lustre/builders/ProgramBuilder.java
package jkind.lustre.builders; import java.util.ArrayList; import java.util.Collection; import java.util.List; import jkind.lustre.Constant; import jkind.lustre.Function; import jkind.lustre.Location; import jkind.lustre.Node; import jkind.lustre.Program; import jkind.lustre.TypeDef; public class ProgramBuilder { private List<TypeDef> types = new ArrayList<>(); private List<Constant> constants = new ArrayList<>(); private List<Node> nodes = new ArrayList<>(); private List<Function> functions = new ArrayList<>(); private String main; public ProgramBuilder() { } public ProgramBuilder(Program program) { this.types = new ArrayList<>(program.types); this.constants = new ArrayList<>(program.constants); this.nodes = new ArrayList<>(program.nodes); this.functions = new ArrayList<>(program.functions); this.main = program.main; } public ProgramBuilder addType(TypeDef type) { this.types.add(type); return this; } public ProgramBuilder addTypes(Collection<TypeDef> types) { this.types.addAll(types); return this; } public ProgramBuilder clearTypes() { this.types.clear(); return this; } public ProgramBuilder addConstant(Constant constant) { this.constants.add(constant); return this; } public ProgramBuilder addConstants(Collection<Constant> constants) { this.constants.addAll(constants); return this; } public ProgramBuilder clearConstants() { this.constants.clear(); return this; } public ProgramBuilder addNode(Node node) { this.nodes.add(node); return this; } public ProgramBuilder addNodes(Collection<Node> nodes) { this.nodes.addAll(nodes); return this; } public ProgramBuilder clearNodes() { this.nodes.clear(); return this; } public ProgramBuilder addFunction(Function function) { this.functions.add(function); return this; } public ProgramBuilder addFunctions(Collection<Function> functions) { this.functions.addAll(functions); return this; } public ProgramBuilder clearFunctions() { this.functions.clear(); return this; } public ProgramBuilder setMain(String main) { this.main = main; return this; } public Program build() { return new Program(Location.NULL, types, constants, functions, nodes, main); } }
2,237
21.38
78
java
jkind
jkind-master/jkind-common/src/jkind/lustre/builders/EquationBuilder.java
package jkind.lustre.builders; import java.util.ArrayList; import java.util.List; import jkind.JKindException; import jkind.lustre.Equation; import jkind.lustre.Expr; import jkind.lustre.IdExpr; import jkind.lustre.Location; import jkind.lustre.VarDecl; public class EquationBuilder { private List<IdExpr> lhs = new ArrayList<>(); private Expr expr; public EquationBuilder() { } public EquationBuilder(Equation eq) { lhs.addAll(eq.lhs); expr = eq.expr; } public EquationBuilder addLhs(IdExpr ide) { this.lhs.add(ide); return this; } public EquationBuilder addLhs(String id) { this.lhs.add(new IdExpr(id)); return this; } public EquationBuilder addLhs(VarDecl varDecl) { this.lhs.add(new IdExpr(varDecl.id)); return this; } public EquationBuilder clearLhs() { this.lhs.clear(); return this; } public EquationBuilder setExpr(Expr expr) { this.expr = expr; return this; } public Equation build() { if (lhs.isEmpty()) { throw new JKindException("left-hand side is empty"); } if (expr == null) { throw new JKindException("right-hand side is empty"); } return new Equation(Location.NULL, lhs, expr); } }
1,166
18.779661
56
java
jkind
jkind-master/jkind-common/src/jkind/lustre/builders/NodeBuilder.java
package jkind.lustre.builders; import java.util.ArrayList; import java.util.Collection; import java.util.List; import jkind.lustre.Contract; import jkind.lustre.Equation; import jkind.lustre.Expr; import jkind.lustre.IdExpr; import jkind.lustre.Location; import jkind.lustre.Node; import jkind.lustre.Type; import jkind.lustre.VarDecl; import jkind.util.Util; public class NodeBuilder { private String id; private List<VarDecl> inputs = new ArrayList<>(); private List<VarDecl> outputs = new ArrayList<>(); private List<VarDecl> locals = new ArrayList<>(); private List<Equation> equations = new ArrayList<>(); private List<String> properties = new ArrayList<>(); private List<Expr> assertions = new ArrayList<>(); private List<String> ivc = new ArrayList<>(); private List<String> realizabilityInputs = null; private Contract contract = null; public NodeBuilder(String id) { this.id = id; } public NodeBuilder(Node node) { this.id = node.id; this.inputs = new ArrayList<>(node.inputs); this.outputs = new ArrayList<>(node.outputs); this.locals = new ArrayList<>(node.locals); this.equations = new ArrayList<>(node.equations); this.properties = new ArrayList<>(node.properties); this.assertions = new ArrayList<>(node.assertions); this.ivc = new ArrayList<>(node.ivc); this.realizabilityInputs = Util.copyNullable(node.realizabilityInputs); this.contract = node.contract; } public NodeBuilder setId(String id) { this.id = id; return this; } public NodeBuilder addInput(VarDecl input) { this.inputs.add(input); return this; } public NodeBuilder addInputs(Collection<VarDecl> inputs) { this.inputs.addAll(inputs); return this; } public IdExpr createInput(String name, Type type) { this.inputs.add(new VarDecl(name, type)); return new IdExpr(name); } public NodeBuilder clearInputs() { this.inputs.clear(); return this; } public NodeBuilder addOutput(VarDecl output) { this.outputs.add(output); return this; } public NodeBuilder addOutputs(Collection<VarDecl> outputs) { this.outputs.addAll(outputs); return this; } public IdExpr createOutput(String name, Type type) { this.outputs.add(new VarDecl(name, type)); return new IdExpr(name); } public NodeBuilder clearOutputs() { this.outputs.clear(); return this; } public NodeBuilder addLocal(VarDecl local) { this.locals.add(local); return this; } public NodeBuilder addLocals(Collection<VarDecl> locals) { this.locals.addAll(locals); return this; } public IdExpr createLocal(String name, Type type) { this.locals.add(new VarDecl(name, type)); return new IdExpr(name); } public NodeBuilder clearLocals() { this.locals.clear(); return this; } public NodeBuilder addEquation(Equation equation) { this.equations.add(equation); return this; } public NodeBuilder addEquation(IdExpr var, Expr expr) { this.equations.add(new Equation(var, expr)); return this; } public NodeBuilder addEquations(Collection<Equation> equations) { this.equations.addAll(equations); return this; } public NodeBuilder clearEquations() { this.equations.clear(); return this; } public NodeBuilder addProperty(String property) { this.properties.add(property); return this; } public NodeBuilder addProperty(IdExpr property) { this.properties.add(property.id); return this; } public NodeBuilder addProperties(Collection<String> properties) { this.properties.addAll(properties); return this; } public NodeBuilder clearProperties() { this.properties.clear(); return this; } public NodeBuilder addAssertion(Expr assertion) { this.assertions.add(assertion); return this; } public NodeBuilder addAssertions(Collection<Expr> assertions) { this.assertions.addAll(assertions); return this; } public NodeBuilder clearAssertions() { this.assertions.clear(); return this; } public NodeBuilder addIvc(String e) { this.ivc.add(e); return this; } public NodeBuilder addIvcs(List<String> ivc) { this.ivc.addAll(ivc); return this; } public NodeBuilder clearIvc() { this.ivc.clear(); return this; } public NodeBuilder setRealizabilityInputs(List<String> realizabilityInputs) { this.realizabilityInputs = Util.copyNullable(realizabilityInputs); return this; } public NodeBuilder setContract(Contract contract) { this.contract = contract; return this; } public Node build() { return new Node(Location.NULL, id, inputs, outputs, locals, equations, properties, assertions, realizabilityInputs, contract, ivc); } }
4,556
22.369231
96
java
jkind
jkind-master/jkind-common/src/jkind/results/Property.java
package jkind.results; /** * Abstract class of property result from JKind */ public abstract class Property { private final String name; private final double runtime; public Property(String name, double runtime) { this.name = name; this.runtime = runtime; } /** * Get the name of the property */ public String getName() { return name; } /** * Runtime of the property measured in seconds */ public double getRuntime() { return runtime; } /** * Discard details such as counterexamples and IVCs to save space */ public abstract void discardDetails(); }
589
16.352941
66
java
jkind
jkind-master/jkind-common/src/jkind/results/InconsistentProperty.java
package jkind.results; /** * An inconsistent property */ public final class InconsistentProperty extends Property { private final String source; private final int k; public InconsistentProperty(String name, String source, int k, double runtime) { super(name, runtime); this.source = source; this.k = k; } /** * Name of the engine used to prove the property inconsistent */ public String getSource() { return source; } /** * Number of steps until the property is inconsistent */ public int getK() { return k; } @Override public void discardDetails() { } }
593
16.470588
81
java
jkind
jkind-master/jkind-common/src/jkind/results/FunctionTableRow.java
package jkind.results; import java.util.List; import jkind.lustre.values.BooleanValue; import jkind.lustre.values.EnumValue; import jkind.lustre.values.IntegerValue; import jkind.lustre.values.RealValue; import jkind.lustre.values.Value; import jkind.util.Util; public class FunctionTableRow implements Comparable<FunctionTableRow> { private final List<Value> inputs; private final Value output; public FunctionTableRow(List<Value> inputs, Value output) { this.inputs = Util.safeList(inputs); this.output = output; } public List<Value> getInputs() { return inputs; } public Value getOutput() { return output; } @Override public int hashCode() { return inputs.hashCode(); } @Override public boolean equals(Object o) { if (o instanceof FunctionTableRow) { FunctionTableRow row = (FunctionTableRow) o; return row.inputs.equals(inputs); } return false; } @Override public int compareTo(FunctionTableRow other) { for (int i = 0; i < inputs.size(); i++) { Value x = inputs.get(i); Value y = other.inputs.get(i); int r = compareValues(x, y); if (r != 0) { return r; } } return 0; } private int compareValues(Value x, Value y) { if (x instanceof BooleanValue && y instanceof BooleanValue) { BooleanValue xbv = (BooleanValue) x; BooleanValue ybv = (BooleanValue) y; return Boolean.compare(xbv.value, ybv.value); } else if (x instanceof IntegerValue && y instanceof IntegerValue) { IntegerValue xiv = (IntegerValue) x; IntegerValue yiv = (IntegerValue) y; return xiv.value.compareTo(yiv.value); } else if (x instanceof RealValue && y instanceof RealValue) { RealValue xrv = (RealValue) x; RealValue yrv = (RealValue) y; return xrv.value.compareTo(yrv.value); } else if (x instanceof EnumValue && y instanceof EnumValue) { EnumValue xev = (EnumValue) x; EnumValue yev = (EnumValue) y; return xev.compareTo(yev); } else { throw new IllegalArgumentException(); } } }
1,982
24.101266
71
java
jkind
jkind-master/jkind-common/src/jkind/results/Counterexample.java
package jkind.results; import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.SortedSet; import java.util.TreeSet; import jkind.excel.ExcelCounterexampleFormatter; import jkind.lustre.values.BooleanValue; import jkind.lustre.values.EnumValue; import jkind.lustre.values.IntegerValue; import jkind.lustre.values.RealValue; import jkind.lustre.values.Value; import jkind.results.layout.Layout; import jkind.results.layout.SingletonLayout; import jkind.util.CounterexampleFormatter; import jkind.util.Util; /** * A JKind counterexample */ public final class Counterexample { private final int length; private final Map<String, Signal<Value>> signals = new HashMap<>(); private final SortedSet<FunctionTable> functionTables = new TreeSet<>(); public Counterexample(int length) { this.length = length; } /** * Length of the counterexample */ public int getLength() { return length; } public void addSignal(Signal<Value> signal) { signals.put(signal.getName(), signal); } public void addFunctionTable(FunctionTable functionTable) { this.functionTables.add(functionTable); } public List<FunctionTable> getFunctionTables() { return Util.safeList(functionTables); } /** * All signals in the counterexample */ public List<Signal<Value>> getSignals() { List<Signal<Value>> result = new ArrayList<>(signals.values()); Collections.sort(result, new SignalNaturalOrdering()); return result; } /** * All signals in the counterexample belonging to the given category in the * given layout */ public List<Signal<Value>> getCategorySignals(Layout layout, String category) { List<Signal<Value>> result = new ArrayList<>(); for (Signal<Value> signal : getSignals()) { if (category.equals(layout.getCategory(signal.getName()))) { result.add(signal); } } return result; } /** * Get a specific signal from the counterexample * * @param name * Name of the signal to retrieve * @return Signal with the specified name, or <code>null</code> if it cannot * be found */ public Signal<Value> getSignal(String name) { return signals.get(name); } public Signal<Value> getOrCreateSignal(String name) { if (!signals.containsKey(name)) { signals.put(name, new Signal<>(name)); } return signals.get(name); } /** * Get a specific step of the counterexample * * @param step * Step to retrieve * @return Map from signal names to their values on the specified step */ public Map<String, Value> getStep(int step) { Map<String, Value> result = new HashMap<>(); for (Signal<Value> signal : signals.values()) { Value value = signal.getValue(step); if (value != null) { result.put(signal.getName(), value); } } return result; } /** * Get a specific integer signal from the counterexample * * @param name * Name of the signal to retrieve * @return Integer signal with the specified name, or <code>null</code> if * it cannot be found */ public Signal<IntegerValue> getIntegerSignal(String name) { return getTypedSignal(name, IntegerValue.class); } /** * Get a specific boolean signal from the counterexample * * @param name * Name of the signal to retrieve * @return Boolean signal with the specified name, or <code>null</code> if * it cannot be found */ public Signal<BooleanValue> getBooleanSignal(String name) { return getTypedSignal(name, BooleanValue.class); } /** * Get a specific enumerated value signal from the counterexample * * @param name * Name of the signal to retrieve * @return Enumerated value signal with the specified name, or * <code>null</code> if it cannot be found */ public Signal<EnumValue> getEnumSignal(String name) { return getTypedSignal(name, EnumValue.class); } /** * Get a specific real signal from the counterexample * * @param name * Name of the signal to retrieve * @return Real signal with the specified name, or <code>null</code> if it * cannot be found */ public Signal<RealValue> getRealSignal(String name) { return getTypedSignal(name, RealValue.class); } private <T extends Value> Signal<T> getTypedSignal(String name, Class<T> klass) { Signal<Value> signal = getSignal(name); if (signal == null) { return null; } return signal.cast(klass); } /** * Convert counterexample to an Excel spreadsheet * * Using this requires the jxl.jar file in your classpath * * @param file * File to write Excel spreadsheet to * @param layout * Layout information for signals in counterexample * @see Layout * @throws jkind.JKindException */ public void toExcel(File file, Layout layout) { try (ExcelCounterexampleFormatter formatter = new ExcelCounterexampleFormatter(file, layout)) { formatter.writeCounterexample("Counterexample", this, Collections.emptyList()); } } /** * Convert counterexample to an Excel spreadsheet using default layout * * Using this requires the jxl.jar file in your classpath * * @param file * File to write Excel spreadsheet to * @throws jkind.JKindException */ public void toExcel(File file) { toExcel(file, new SingletonLayout("Signals")); } @Override public String toString() { return toString(new SingletonLayout()); } public String toString(Layout layout) { return new CounterexampleFormatter(this, layout).toString(); } }
5,600
25.671429
97
java
jkind
jkind-master/jkind-common/src/jkind/results/Signal.java
package jkind.results; import java.util.Collections; import java.util.HashMap; import java.util.Map; import jkind.JKindException; import jkind.lustre.values.Value; /** * A signal is a trace of values for a specific variable * * @param <T> * Type of value contained in the signal */ public final class Signal<T extends Value> implements Comparable<Signal<T>> { private final String name; private final Map<Integer, T> values = new HashMap<>(); public Signal(String name) { this.name = name; } /** * Name of the signal */ public String getName() { return name; } public void putValue(int step, T value) { values.put(step, value); } /** * Get the value of the signal on a specific step * * @param step * Step to query the value at * @return Value at the specified step or <code>null</code> if the signal * does not have a value on that step */ public T getValue(int step) { return values.get(step); } /** * Get a time step indexed map containing all values for the signal */ public Map<Integer, T> getValues() { return Collections.unmodifiableMap(values); } /** * Downcast the signal to a specific signal type */ public <S extends T> Signal<S> cast(Class<S> klass) { Signal<S> castSignal = new Signal<>(name); for (Integer step : values.keySet()) { Value value = values.get(step); if (klass.isInstance(value)) { castSignal.putValue(step, klass.cast(value)); } else { throw new JKindException( "Cannot cast " + value.getClass().getSimpleName() + " to " + klass.getSimpleName()); } } return castSignal; } public Signal<T> rename(String newName) { Signal<T> copy = new Signal<>(newName); copy.values.putAll(values); return copy; } @Override public int compareTo(Signal<T> other) { return name.compareTo(other.name); } }
1,863
21.731707
90
java
jkind
jkind-master/jkind-common/src/jkind/results/ValidProperty.java
package jkind.results; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Set; import jkind.util.Util; /** * A valid property */ public final class ValidProperty extends Property { private final String source; private final int k; private List<String> invariants; private Set<String> ivc; private final Set<List<String>> ivcSets; private final Set<List<String>> invarantSets; private final boolean mivcTimedOut; public ValidProperty(String name, String source, int k, double runtime, List<String> invariants, Collection<String> ivc, Set<List<String>> invariantSets, Set<List<String>> ivcSets, boolean mivcTimedOut) { super(name, runtime); this.source = source; this.k = k; this.invariants = Util.safeList(invariants); this.ivc = Util.safeStringSortedSet(ivc); this.invarantSets = Util.safeStringSortedSets(invariantSets); this.ivcSets = Util.safeStringSortedSets(ivcSets); this.mivcTimedOut = mivcTimedOut; } /** * Name of the engine used to prove the property (k-induction, pdr, ...) */ public String getSource() { return source; } /** * k value (from k-induction) used to prove the property */ public int getK() { return k; } /** * whether timeout occurred during MIVC analysis */ public boolean getMivcTimedOut() { return mivcTimedOut; } /** * Invariants used to prove property, only available if * JKindApi.setIvcReduction() */ public List<String> getInvariants() { return invariants; } /** * Inductive validity core, only available if JKindApi.setIvcReduction() */ public Set<String> getIvc() { return ivc; } /** * Invariants used to prove property, only available if * JKindApi.setIvcReduction() */ public Set<List<String>> getInvariantSets() { return invarantSets; } /** * Inductive validity core, only available if JKindApi.setIvcReduction() */ public Set<List<String>> getIvcSets() { return ivcSets; } @Override public void discardDetails() { invariants = Collections.emptyList(); ivc = Collections.emptySet(); } }
2,089
21.717391
110
java
jkind
jkind-master/jkind-common/src/jkind/results/InvalidProperty.java
package jkind.results; import java.util.Collections; import java.util.List; import jkind.util.Util; /** * An invalid property */ public final class InvalidProperty extends Property { private final String source; private Counterexample cex; private List<String> conflicts; private String report; public InvalidProperty(String name, String source, Counterexample cex, List<String> conflicts, double runtime, String report) { super(name, runtime); this.source = source; this.conflicts = Util.safeList(conflicts); this.cex = cex; this.report = report; } public InvalidProperty(String name, String source, Counterexample cex, List<String> conflicts, double runtime) { this(name, source, cex, conflicts, runtime, "Empty report"); } /** * Name of the engine used to find the counterexample (bmc, pdr, ...) */ public String getSource() { return source; } /** * Counterexample for the property */ public Counterexample getCounterexample() { return cex; } /** * Conflicts (used in realizability analysis) */ public List<String> getConflicts() { return conflicts; } /** * Report (used only by Sally) */ public String getReport() { return report; } @Override public void discardDetails() { cex = null; conflicts = Collections.emptyList(); } }
1,309
19.46875
128
java
jkind
jkind-master/jkind-common/src/jkind/results/SignalNaturalOrdering.java
package jkind.results; import java.util.Comparator; import jkind.util.StringNaturalOrdering; public class SignalNaturalOrdering implements Comparator<Signal<?>> { @Override public int compare(Signal<?> a, Signal<?> b) { return new StringNaturalOrdering().compare(a.getName(), b.getName()); } }
302
22.307692
71
java
jkind
jkind-master/jkind-common/src/jkind/results/UnknownProperty.java
package jkind.results; /** * An unknown property */ public final class UnknownProperty extends Property { private final int trueFor; private Counterexample cex; public UnknownProperty(String name, int trueFor, Counterexample cex, double runtime) { super(name, runtime); this.trueFor = trueFor; this.cex = cex; } /** * How many steps the property was true for in the base step */ public int getTrueFor() { return trueFor; } /** * Inductive counterexample for the property, only available if * JKindApi.setInductiveCounterexamples() */ public Counterexample getInductiveCounterexample() { return cex; } @Override public void discardDetails() { cex = null; } }
700
18.472222
87
java
jkind
jkind-master/jkind-common/src/jkind/results/FunctionTable.java
package jkind.results; import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; import jkind.lustre.VarDecl; import jkind.lustre.values.Value; import jkind.util.StringNaturalOrdering; import jkind.util.Util; public class FunctionTable implements Comparable<FunctionTable> { private final String name; private final List<VarDecl> inputs; private final VarDecl output; /** * FunctionTableRows are hashed only based on inputs, so this map allows * lookup to be efficient. */ private final SortedMap<FunctionTableRow, FunctionTableRow> rows = new TreeMap<>(); public FunctionTable(String name, List<VarDecl> inputs, VarDecl output) { this.name = name; this.inputs = inputs; this.output = output; } public String getName() { return name; } public List<VarDecl> getInputs() { return inputs; } public VarDecl getOutput() { return output; } public void addRow(List<Value> inputValues, Value outputValue) { FunctionTableRow row = new FunctionTableRow(typeCorrectInputs(inputValues), Util.promoteIfNeeded(outputValue, output.type)); rows.put(row, row); } private List<Value> typeCorrectInputs(List<Value> inputValues) { List<Value> result = new ArrayList<>(); for (int i = 0; i < inputValues.size(); i++) { result.add(Util.promoteIfNeeded(inputValues.get(i), inputs.get(i).type)); } return result; } public Set<FunctionTableRow> getRows() { return rows.keySet(); } public Value lookup(List<Value> inputValues) { if (inputs.size() != inputValues.size()) { throw new IllegalArgumentException(); } FunctionTableRow fakeRow = new FunctionTableRow(typeCorrectInputs(inputValues), null); FunctionTableRow realRow = rows.get(fakeRow); if (realRow != null) { return realRow.getOutput(); } else { return null; } } @Override public int compareTo(FunctionTable other) { return new StringNaturalOrdering().compare(name, other.name); } }
1,987
23.85
88
java
jkind
jkind-master/jkind-common/src/jkind/results/layout/NodeLayout.java
package jkind.results.layout; import static java.util.stream.Collectors.toSet; import java.util.Arrays; import java.util.List; import java.util.Set; import jkind.lustre.Node; import jkind.lustre.Program; import jkind.util.Util; /** * A layout for the inputs, outputs, and locals of a Lustre node */ public class NodeLayout implements Layout { private static final String INPUTS = "Inputs"; private static final String OUTPUTS = "Outputs"; private static final String LOCALS = "Locals"; private static final String INLINED = "Inlined"; private static final String[] CATEGORIES = { INPUTS, OUTPUTS, LOCALS, INLINED }; private final Set<String> inputs; private final Set<String> outputs; private final Set<String> locals; public NodeLayout(Node node) { if (node == null) { throw new IllegalArgumentException("Unable to create layout for null node"); } this.inputs = getPrefix(Util.getIds(node.inputs)); this.outputs = getPrefix(Util.getIds(node.outputs)); this.locals = getPrefix(Util.getIds(node.locals)); } public NodeLayout(Program program) { this(program.getMainNode()); } @Override public List<String> getCategories() { return Arrays.asList(CATEGORIES); } @Override public String getCategory(String signal) { String prefix = getPrefix(signal); if (prefix.contains("~")) { return INLINED; } else if (inputs.contains(prefix)) { return INPUTS; } else if (outputs.contains(prefix)) { return OUTPUTS; } else if (locals.contains(prefix)) { return LOCALS; } else { return null; } } private String getPrefix(String signal) { return signal.split("\\.|\\[")[0]; } private Set<String> getPrefix(List<String> signals) { return signals.stream().map(this::getPrefix).collect(toSet()); } }
1,763
24.2
81
java
jkind
jkind-master/jkind-common/src/jkind/results/layout/SingletonLayout.java
package jkind.results.layout; import java.util.Collections; import java.util.List; /** * A layout which assigns everything to one single category */ public class SingletonLayout implements Layout { private final String name; /** * @param name * Name of the single category */ public SingletonLayout(String name) { this.name = name; } public SingletonLayout() { this("Signals"); } @Override public List<String> getCategories() { return Collections.singletonList(name); } @Override public String getCategory(String signal) { return name; } }
585
16.235294
59
java
jkind
jkind-master/jkind-common/src/jkind/results/layout/Layout.java
package jkind.results.layout; import java.util.List; /** * Layout information for signals in counterexamples * * @see NodeLayout * @see SingletonLayout */ public interface Layout { /** * Return the list of categories to use, in the order desired * * For example, this might return ["Inputs", "Outputs", "Locals"] */ public List<String> getCategories(); /** * Get the category for a specific signal * * @param signal * Name of the signal * @return The category to which the signal belongs, or <code>null</code> if * the signal should be ignored */ public String getCategory(String signal); }
647
21.344828
77
java
jkind
jkind-master/jkind-common/src/jkind/results/layout/RealizabilityNodeLayout.java
package jkind.results.layout; import static java.util.stream.Collectors.toSet; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Set; import jkind.lustre.Node; import jkind.lustre.Program; import jkind.util.Util; /** * A layout for the actual inputs, outputs, and locals of a Lustre node used for * realizability checking */ public class RealizabilityNodeLayout implements Layout { private static final String REALIZABILITY_INPUTS = "Realizability Inputs"; private static final String REALIZABILITY_OUTPUTS = "Realizability Outputs"; private static final String NODE_OUTPUTS = "Node Outputs"; private static final String NODE_LOCALS = "Node Locals"; private static final String NODE_INLINED = "Node Inlined"; private static final String[] CATEGORIES = { REALIZABILITY_INPUTS, REALIZABILITY_OUTPUTS, NODE_OUTPUTS, NODE_LOCALS, NODE_INLINED }; private final Set<String> realizabilityInputs; private final Set<String> realizabilityOutputs; private final Set<String> nodeOutputs; private final Set<String> nodeLocals; public RealizabilityNodeLayout(Node node) { if (node == null) { throw new IllegalArgumentException("Unable to create layout for null node"); } if (node.realizabilityInputs == null) { throw new IllegalArgumentException( "Unable to create realizability-based layout for node without realizability query"); } this.realizabilityInputs = getPrefix(node.realizabilityInputs); this.realizabilityOutputs = getPrefix(getRealizabilityOutputs(node)); this.nodeOutputs = getPrefix(Util.getIds(node.outputs)); this.nodeLocals = getPrefix(Util.getIds(node.locals)); } private static List<String> getRealizabilityOutputs(Node node) { List<String> realizabilityOutputs = new ArrayList<>(Util.getIds(node.inputs)); realizabilityOutputs.removeAll(node.realizabilityInputs); return realizabilityOutputs; } public RealizabilityNodeLayout(Program program) { this(program.getMainNode()); } @Override public List<String> getCategories() { return Arrays.asList(CATEGORIES); } @Override public String getCategory(String signal) { String prefix = getPrefix(signal); if (prefix.contains("~")) { return NODE_INLINED; } else if (realizabilityInputs.contains(prefix)) { return REALIZABILITY_INPUTS; } else if (realizabilityOutputs.contains(prefix)) { return REALIZABILITY_OUTPUTS; } else if (nodeOutputs.contains(prefix)) { return NODE_OUTPUTS; } else if (nodeLocals.contains(prefix)) { return NODE_LOCALS; } else { return null; } } private String getPrefix(String signal) { return signal.split("\\.|\\[")[0]; } private Set<String> getPrefix(List<String> signals) { return signals.stream().map(this::getPrefix).collect(toSet()); } }
2,781
30.258427
117
java
jkind
jkind-master/jkind-common/src/jkind/excel/ExcelUtil.java
package jkind.excel; import jkind.JKindException; import jxl.format.Border; import jxl.format.BorderLineStyle; import jxl.format.CellFormat; import jxl.CellView; import jxl.format.Colour; import jxl.write.WritableCellFormat; import jxl.write.WritableFont; import jxl.write.WritableSheet; import jxl.write.WriteException; public class ExcelUtil { public static CellFormat getBoldFormat() { WritableCellFormat boldFormat = new WritableCellFormat(); WritableFont font = new WritableFont(boldFormat.getFont()); try { font.setBoldStyle(WritableFont.BOLD); } catch (WriteException e) { throw new JKindException("Error creating bold font for Excel", e); } boldFormat.setFont(font); return boldFormat; } public static CellFormat getFadedFormat() { WritableCellFormat fadedFormat = new WritableCellFormat(); WritableFont font = new WritableFont(fadedFormat.getFont()); try { font.setColour(Colour.GREY_25_PERCENT); } catch (WriteException e) { throw new JKindException("Error creating grey font for Excel", e); } fadedFormat.setFont(font); return fadedFormat; } public static CellFormat getHighlightFormat() { WritableCellFormat highlightFormat = new WritableCellFormat(); try { highlightFormat.setBackground(Colour.ROSE); } catch (WriteException e) { throw new JKindException("Error creating highlighting for Excel", e); } return highlightFormat; } public static CellFormat addBottomBorder(CellFormat cf) { WritableCellFormat format = new WritableCellFormat(cf); try { format.setBorder(Border.BOTTOM, BorderLineStyle.THIN); } catch (WriteException e) { throw new JKindException("Error creating border format for Excel", e); } return format; } public static CellFormat addLeftBorder(CellFormat cf) { WritableCellFormat format = new WritableCellFormat(cf); try { format.setBorder(Border.LEFT, BorderLineStyle.THIN); } catch (WriteException e) { throw new JKindException("Error creating border format for Excel", e); } return format; } public static void autosize(WritableSheet sheet, int max) { for (int col = 0; col < max; col++) { CellView cell = sheet.getColumnView(col); cell.setAutosize(true); sheet.setColumnView(col, cell); } } public static String trimName(String name) { if (name.length() <= 31) { return name; } else { return name.substring(0, 28) + "..."; } } }
2,398
27.223529
73
java
jkind
jkind-master/jkind-common/src/jkind/excel/ExcelCounterexampleFormatter.java
package jkind.excel; import java.io.Closeable; import java.io.File; import java.io.IOException; import java.math.BigDecimal; import java.util.List; import jkind.JKindException; import jkind.lustre.VarDecl; import jkind.lustre.values.BooleanValue; import jkind.lustre.values.EnumValue; import jkind.lustre.values.IntegerValue; import jkind.lustre.values.RealValue; import jkind.lustre.values.Value; import jkind.results.Counterexample; import jkind.results.FunctionTable; import jkind.results.FunctionTableRow; import jkind.results.Signal; import jkind.results.layout.Layout; import jkind.util.BigFraction; import jxl.Workbook; import jxl.format.CellFormat; import jxl.write.Boolean; import jxl.write.Label; import jxl.write.Number; import jxl.write.WritableCell; import jxl.write.WritableCellFeatures; import jxl.write.WritableCellFormat; import jxl.write.WritableSheet; import jxl.write.WritableWorkbook; import jxl.write.WriteException; import jxl.write.biff.RowsExceededException; public class ExcelCounterexampleFormatter implements Closeable { final private Layout layout; private WritableWorkbook workbook; private WritableSheet sheet; private int row; /* * CellFormats cannot be static, since JXL has strange results when a cell * format is reused in another workbook. See {@link * http://jexcelapi.sourceforge.net/resources/faq/}. */ private final CellFormat boldFormat = ExcelUtil.getBoldFormat(); private final CellFormat fadedFormat = ExcelUtil.getFadedFormat(); private final CellFormat defaultFormat = new WritableCellFormat(); private final CellFormat highlightFormat = ExcelUtil.getHighlightFormat(); public ExcelCounterexampleFormatter(File file, Layout layout) { this.layout = layout; try { workbook = Workbook.createWorkbook(file); } catch (IOException e) { throw new JKindException("Error writing to Excel file", e); } } public ExcelCounterexampleFormatter(WritableWorkbook workbook, Layout layout) { this.workbook = workbook; this.layout = layout; } @Override public void close() { try { if (workbook != null) { workbook.write(); workbook.close(); workbook = null; } } catch (Exception e) { throw new JKindException("Error closing Excel file", e); } } public WritableSheet writeCounterexample(String property, Counterexample cex, List<String> conflicts) { try { sheet = workbook.createSheet(ExcelUtil.trimName(property), workbook.getNumberOfSheets()); row = 0; ExcelUtil.autosize(sheet, 1); int length = cex.getLength(); writeStepsHeader(length); for (String category : layout.getCategories()) { List<Signal<Value>> signals = cex.getCategorySignals(layout, category); writeSection(category, signals, length, conflicts); } if (!cex.getFunctionTables().isEmpty()) { row++; sheet.addCell(new Label(0, row, "Functions", boldFormat)); row++; for (FunctionTable table : cex.getFunctionTables()) { writeFunction(table); } } return sheet; } catch (WriteException e) { throw new JKindException("Error writing counterexample to Excel file", e); } } private void writeStepsHeader(int k) throws WriteException, RowsExceededException { sheet.addCell(new Label(0, row, "Step", boldFormat)); for (int col = 1; col <= k; col++) { sheet.addCell(new Number(col, row, col - 1)); } row++; } private void writeSection(String category, List<Signal<Value>> signals, int k, List<String> conflicts) throws WriteException { if (!signals.isEmpty()) { row++; sheet.addCell(new Label(0, row, category, boldFormat)); row++; for (Signal<Value> signal : signals) { writeSignal(signal, k, conflicts); row++; } } } private void writeSignal(Signal<Value> signal, int k, List<String> conflicts) throws WriteException { sheet.addCell(new Label(0, row, signal.getName(), conflicts.contains(signal.getName()) ? highlightFormat : defaultFormat)); Value prev = null; for (int i = 0; i < k; i++) { Value curr = signal.getValue(i); if (curr != null) { CellFormat format = curr.equals(prev) ? fadedFormat : defaultFormat; writeValue(curr, i + 1, format); } prev = curr; } } private void writeValue(Value value, int col, CellFormat format) throws WriteException { if (value instanceof BooleanValue) { BooleanValue bv = (BooleanValue) value; sheet.addCell(new Boolean(col, row, bv.value, format)); } else if (value instanceof IntegerValue) { IntegerValue iv = (IntegerValue) value; sheet.addCell(getNumberCell(new BigFraction(iv.value), col, format)); } else if (value instanceof RealValue) { RealValue rv = (RealValue) value; sheet.addCell(getNumberCell(rv.value, col, format)); } else if (value instanceof EnumValue) { EnumValue ev = (EnumValue) value; sheet.addCell(new Label(col, row, ev.value)); } else { throw new JKindException("Unknown value type in Excel writer: " + value.getClass().getSimpleName()); } } private WritableCell getNumberCell(BigFraction value, int col, CellFormat format) { WritableCell cell = new Number(col, row, value.doubleValue(), format); // Excel displays at most a float value. We check if that display // will match the exact value. If not, we add a comment with a better // approximation (or the exact value) if (!isExactFloat(value)) { WritableCellFeatures features = new WritableCellFeatures(); features.setComment(value.toTruncatedDecimal(20, "..."), 8, 3); cell.setCellFeatures(features); } return cell; } private boolean isExactFloat(BigFraction value) { try { String str = Float.toString((float) value.doubleValue()); BigFraction approx = BigFraction.valueOf(new BigDecimal(str)); return value.equals(approx); } catch (NumberFormatException e) { return false; } } private void writeFunction(FunctionTable table) throws WriteException { if (table.getRows().isEmpty()) { return; } int col = 0; CellFormat headerFormat = ExcelUtil.addBottomBorder(defaultFormat); for (VarDecl input : table.getInputs()) { sheet.addCell(new Label(col++, row, input.id, headerFormat)); } sheet.addCell(new Label(col++, row, table.getName(), ExcelUtil.addLeftBorder(headerFormat))); row++; for (FunctionTableRow tableRow : table.getRows()) { col = 0; for (Value input : tableRow.getInputs()) { writeValue(input, col, defaultFormat); col++; } writeValue(tableRow.getOutput(), col, ExcelUtil.addLeftBorder(defaultFormat)); row++; } row++; } }
6,519
29.754717
104
java
jkind
jkind-master/jkind-common/src/jkind/excel/ExcelFormatter.java
package jkind.excel; import java.io.Closeable; import java.io.File; import java.io.IOException; import java.util.Collections; import java.util.List; import java.util.Set; import jkind.JKindException; import jkind.results.Counterexample; import jkind.results.InconsistentProperty; import jkind.results.InvalidProperty; import jkind.results.Property; import jkind.results.UnknownProperty; import jkind.results.ValidProperty; import jkind.results.layout.Layout; import jkind.util.Util; import jxl.Workbook; import jxl.format.CellFormat; import jxl.write.Label; import jxl.write.Number; import jxl.write.WritableHyperlink; import jxl.write.WritableSheet; import jxl.write.WritableWorkbook; import jxl.write.WriteException; public class ExcelFormatter implements Closeable { private WritableWorkbook workbook; private WritableSheet summarySheet; private int summaryRow; private WritableSheet currSheet; private int currRow; /* * CellFormats cannot be static, since JXL has strange results when a cell * format is reused in another workbook. See {@link * http://jexcelapi.sourceforge.net/resources/faq/}. */ private final CellFormat boldFormat = ExcelUtil.getBoldFormat(); private final ExcelCounterexampleFormatter cexFormatter; public ExcelFormatter(File file, Layout layout) { try { workbook = Workbook.createWorkbook(file); summarySheet = workbook.createSheet("Summary", workbook.getNumberOfSheets()); ExcelUtil.autosize(summarySheet, 4); summarySheet.addCell(new Label(0, 0, "Property", boldFormat)); summarySheet.addCell(new Label(1, 0, "Result", boldFormat)); summarySheet.addCell(new Label(2, 0, "Source", boldFormat)); summarySheet.addCell(new Label(3, 0, "K", boldFormat)); summarySheet.addCell(new Label(4, 0, "Runtime", boldFormat)); summarySheet.addCell(new Label(5, 0, "True For", boldFormat)); summaryRow = 1; } catch (WriteException | IOException e) { throw new JKindException("Error writing to Excel file", e); } cexFormatter = new ExcelCounterexampleFormatter(workbook, layout); } @Override public void close() { if (workbook == null) { return; } // Use two try-catch blocks to ensure workbook.close() is called even if // workbook.write() fails Exception error = null; try { workbook.write(); } catch (Exception e) { error = e; } try { workbook.close(); } catch (Exception e) { error = e; } workbook = null; if (error != null) { throw new JKindException("Error closing Excel file", error); } } public void write(List<Property> properties) { try { for (Property property : properties) { write(property); } } catch (WriteException e) { throw new JKindException("Error writing to Excel file", e); } } private void write(Property property) throws WriteException { if (property instanceof ValidProperty) { write((ValidProperty) property); } else if (property instanceof InvalidProperty) { write((InvalidProperty) property); } else if (property instanceof UnknownProperty) { write((UnknownProperty) property); } else if (property instanceof InconsistentProperty) { write((InconsistentProperty) property); } else { throw new IllegalArgumentException("Unknown property type: " + property.getClass().getSimpleName()); } } private void write(ValidProperty property) throws WriteException { String name = property.getName(); String source = property.getSource(); int k = property.getK(); List<String> invariants = property.getInvariants(); Set<String> ivc = property.getIvc(); double runtime = property.getRuntime(); summarySheet.addCell(new Label(0, summaryRow, name)); if (invariants.isEmpty() && ivc.isEmpty()) { summarySheet.addCell(new Label(1, summaryRow, "Valid")); } else { WritableSheet validSheet = writeValidSheet(name, invariants, ivc); WritableHyperlink link = new WritableHyperlink(1, summaryRow, "Valid", validSheet, 0, 0); summarySheet.addHyperlink(link); } summarySheet.addCell(new Label(2, summaryRow, source)); summarySheet.addCell(new Number(3, summaryRow, k)); summarySheet.addCell(new Number(4, summaryRow, runtime)); summaryRow++; } private WritableSheet writeValidSheet(String property, List<String> invariants, Set<String> ivc) throws WriteException { currSheet = workbook.createSheet(ExcelUtil.trimName(property), workbook.getNumberOfSheets()); currRow = 0; if (!invariants.isEmpty()) { currSheet.addCell(new Label(0, currRow, "Invariants", boldFormat)); currRow++; for (String invariant : Util.safeStringSortedSet(invariants)) { currSheet.addCell(new Label(0, currRow, invariant)); currRow++; } currRow++; } if (!ivc.isEmpty()) { currSheet.addCell(new Label(0, currRow, "Inductive Validity Core", boldFormat)); currRow++; for (String e : ivc) { currSheet.addCell(new Label(0, currRow, e)); currRow++; } } ExcelUtil.autosize(currSheet, 1); return currSheet; } private void write(InvalidProperty property) throws WriteException { String name = property.getName(); String source = property.getSource(); Counterexample cex = property.getCounterexample(); int length = cex.getLength(); double runtime = property.getRuntime(); List<String> conflicts = property.getConflicts(); WritableSheet cexSheet = writeCounterexample(name, cex, conflicts); summarySheet.addCell(new Label(0, summaryRow, name)); summarySheet.addHyperlink(new WritableHyperlink(1, summaryRow, "Invalid", cexSheet, 0, 0)); summarySheet.addCell(new Label(2, summaryRow, source)); summarySheet.addCell(new Number(3, summaryRow, length)); summarySheet.addCell(new Number(4, summaryRow, runtime)); summaryRow++; } private void write(UnknownProperty property) throws WriteException { String name = property.getName(); int trueFor = property.getTrueFor(); Counterexample cex = property.getInductiveCounterexample(); double runtime = property.getRuntime(); summarySheet.addCell(new Label(0, summaryRow, name)); if (cex == null) { summarySheet.addCell(new Label(1, summaryRow, "Unknown")); } else { WritableSheet cexSheet = writeCounterexample(name, cex, Collections.emptyList()); summarySheet.addHyperlink(new WritableHyperlink(1, summaryRow, "Unknown", cexSheet, 0, 0)); } summarySheet.addCell(new Number(4, summaryRow, runtime)); summarySheet.addCell(new Number(5, summaryRow, trueFor)); summaryRow++; } private WritableSheet writeCounterexample(String name, Counterexample cex, List<String> conflicts) { return cexFormatter.writeCounterexample(name, cex, conflicts); } private void write(InconsistentProperty property) throws WriteException { String name = property.getName(); String source = property.getSource(); int k = property.getK(); double runtime = property.getRuntime(); summarySheet.addCell(new Label(0, summaryRow, name)); summarySheet.addCell(new Label(1, summaryRow, "Inconsistent")); summarySheet.addCell(new Label(2, summaryRow, source)); summarySheet.addCell(new Number(3, summaryRow, k)); summarySheet.addCell(new Number(4, summaryRow, runtime)); summaryRow++; } }
7,149
31.5
103
java
jkind
jkind-master/jkind-common/src/jkind/util/CounterexampleFormatter.java
package jkind.util; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.function.BiFunction; import jkind.lustre.values.RealValue; import jkind.lustre.values.Value; import jkind.results.Counterexample; import jkind.results.FunctionTable; import jkind.results.FunctionTableRow; import jkind.results.Signal; import jkind.results.layout.Layout; public class CounterexampleFormatter { private static final int DECIMAL_DIGITS = 3; private static final String TRUNCATE_SUFFIX = "*"; private static final List<String> SEPARATOR = Collections.emptyList(); private static final String NEWLINE = System.lineSeparator(); private final Counterexample cex; private final Layout layout; private boolean truncated = false; public CounterexampleFormatter(Counterexample cex, Layout layout) { this.cex = cex; this.layout = layout; } @Override public String toString() { String cexTable = formatContent(getContent(), this::getCexFormatString, false); return cexTable + functions() + footer(); } private String footer() { if (truncated) { return NEWLINE + " * display value has been truncated" + NEWLINE; } else { return ""; } } private String functions() { if (cex.getFunctionTables().isEmpty()) { return ""; } List<FunctionTable> functionTables = cex.getFunctionTables(); StringBuilder sb = new StringBuilder(); sb.append(NEWLINE); sb.append("FUNCTIONS"); for (FunctionTable table : functionTables) { if (!table.getRows().isEmpty()) { sb.append(NEWLINE); sb.append(formatFunctionTable(table)); } } return sb.toString(); } private List<List<String>> getContent() { List<List<String>> content = new ArrayList<>(); content.add(getHeader()); content.add(getStepCountsRow()); for (String category : layout.getCategories()) { List<Signal<Value>> signals = cex.getCategorySignals(layout, category); content.addAll(getSectionRows(category, signals)); } return content; } private List<String> getHeader() { ArrayList<String> header = new ArrayList<>(); header.add(""); header.add("Step"); return header; } private List<String> getStepCountsRow() { List<String> row = new ArrayList<>(); row.add("variable"); for (int i = 0; i < cex.getLength(); i++) { row.add(Integer.toString(i)); } return row; } private List<List<String>> getSectionRows(String category, List<Signal<Value>> signals) { List<List<String>> rows = new ArrayList<>(); if (!signals.isEmpty()) { rows.add(SEPARATOR); rows.add(Collections.singletonList(category.toUpperCase())); for (Signal<Value> signal : signals) { rows.add(getSignalRow(signal)); } } return rows; } private List<String> getSignalRow(Signal<Value> signal) { List<String> row = new ArrayList<>(); row.add(signal.getName()); for (int i = 0; i < cex.getLength(); i++) { row.add(getString(signal.getValue(i))); } return row; } private String getString(Value value) { if (value == null) { return "-"; } else if (value instanceof RealValue) { RealValue rv = (RealValue) value; boolean negative = (rv.value.signum() == -1); BigFraction normalized = new BigFraction(rv.value.getNumerator().abs(), rv.value.getDenominator()); String text = normalized.toTruncatedDecimal(DECIMAL_DIGITS, TRUNCATE_SUFFIX); text = negative ? ("-" + text) : text; if (text.contains(TRUNCATE_SUFFIX)) { truncated = true; } return text; } else { return value.toString(); } } private String formatFunctionTable(FunctionTable table) { List<List<String>> content = new ArrayList<>(); content.add(getFunctionHeader(table)); for (FunctionTableRow row : table.getRows()) { List<String> line = new ArrayList<>(); row.getInputs().forEach(val -> line.add(getString(val))); line.add("|"); line.add(getString(row.getOutput())); content.add(line); } return formatContent(content, this::getFunctionTableFormatString, true); } private List<String> getFunctionHeader(FunctionTable table) { List<String> header = new ArrayList<>(); table.getInputs().forEach(vd -> header.add(vd.id)); header.add("|"); header.add(table.getName()); return header; } private String formatContent(List<List<String>> content, BiFunction<Integer, Integer, String> formatString, boolean headerLine) { List<Integer> minColumnWidths = computeMinimumColumnWidths(content); StringBuilder text = new StringBuilder(); for (int row = 0; row < content.size(); row++) { List<String> rowContent = content.get(row); for (int col = 0; col < rowContent.size(); col++) { String cell = rowContent.get(col); String format = formatString.apply(col, minColumnWidths.get(col)); text.append(String.format(format, cell)); } text.append(NEWLINE); if (row == 0 && headerLine) { String header = text.toString().replaceAll("\\s+$", ""); text.append(makeHeaderLine(header)); text.append(NEWLINE); } } return text.toString(); } private String getCexFormatString(int col, int minWidth) { if (col == 0) { int width = minWidth + 6; return "%-" + width + "s "; } else { int width = minWidth; return "%" + width + "s "; } } @SuppressWarnings("unused") private String getFunctionTableFormatString(int col, int minWidth) { return "%" + minWidth + "s "; } private List<Integer> computeMinimumColumnWidths(List<List<String>> content) { List<Integer> result = new ArrayList<>(); for (List<String> row : content) { for (int i = 0; i < row.size(); i++) { expandToFitElement(result, i); int curr = result.get(i); int next = Math.max(row.get(i).length(), curr); result.set(i, next); } } return result; } private void expandToFitElement(List<Integer> result, int i) { while (result.size() - 1 < i) { result.add(0); } } private String makeHeaderLine(String header) { return header.replace("|", "+").replaceAll("[^+]", "-"); } }
5,964
26.237443
108
java
jkind
jkind-master/jkind-common/src/jkind/util/DefaultValueVisitor.java
package jkind.util; import java.math.BigInteger; import jkind.lustre.ArrayType; import jkind.lustre.EnumType; import jkind.lustre.NamedType; import jkind.lustre.RecordType; import jkind.lustre.SubrangeIntType; import jkind.lustre.TupleType; import jkind.lustre.values.BooleanValue; import jkind.lustre.values.IntegerValue; import jkind.lustre.values.RealValue; import jkind.lustre.values.Value; import jkind.lustre.visitors.TypeVisitor; public class DefaultValueVisitor implements TypeVisitor<Value> { @Override public Value visit(ArrayType e) { throw new IllegalArgumentException(); } @Override public Value visit(EnumType e) { return new IntegerValue(BigInteger.ZERO); } @Override public Value visit(NamedType e) { switch (e.name) { case "bool": return BooleanValue.FALSE; case "int": return new IntegerValue(BigInteger.ZERO); case "real": return new RealValue(BigFraction.ZERO); default: throw new IllegalArgumentException("Unable to create default value for type: " + e.name); } } @Override public Value visit(RecordType e) { throw new IllegalArgumentException(); } @Override public Value visit(TupleType e) { throw new IllegalArgumentException(); } @Override public Value visit(SubrangeIntType e) { return new IntegerValue(e.low); } }
1,300
21.824561
92
java
jkind
jkind-master/jkind-common/src/jkind/util/TopologicalSorter.java
package jkind.util; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; public class TopologicalSorter<T> { private Map<String, T> valueMap = new LinkedHashMap<>(); private Map<String, Set<String>> dependencyMap = new HashMap<>(); public void put(String id, T value, Set<String> dependencies) { valueMap.put(id, value); dependencyMap.put(id, dependencies); } public List<T> getSortedValues() { List<T> result = new ArrayList<>(); for (String id : getSortedIds()) { result.add(valueMap.get(id)); } return result; } private List<String> getSortedIds() { List<String> ordered = new ArrayList<>(); for (String id : valueMap.keySet()) { addToSortedIdsList(id, ordered); } return ordered; } private void addToSortedIdsList(String id, List<String> sorted) { if (sorted.contains(id)) { return; } if (dependencyMap.containsKey(id)) { for (String dependency : dependencyMap.get(id)) { if (!sorted.contains(dependency)) { addToSortedIdsList(dependency, sorted); } } sorted.add(id); } } }
1,154
22.1
66
java
jkind
jkind-master/jkind-common/src/jkind/util/CycleFinder.java
package jkind.util; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Deque; import java.util.List; import java.util.Map; import java.util.Set; public class CycleFinder { public static List<String> findCycle(Map<String, Set<String>> dependencies) { return new CycleFinder(dependencies).findCycle(); } private final Deque<String> callStack = new ArrayDeque<>(); private final Map<String, Set<String>> dependencies; private CycleFinder(Map<String, Set<String>> dependencies) { this.dependencies = dependencies; } private List<String> findCycle() { for (String root : dependencies.keySet()) { List<String> cycle = findCycle(root); if (cycle != null) { return cycle; } } return null; } private List<String> findCycle(String curr) { if (callStack.contains(curr)) { callStack.addLast(curr); while (!curr.equals(callStack.peekFirst())) { callStack.removeFirst(); } return new ArrayList<>(callStack); } if (dependencies.containsKey(curr)) { callStack.addLast(curr); for (String next : dependencies.get(curr)) { List<String> cycle = findCycle(next); if (cycle != null) { return cycle; } } callStack.removeLast(); } return null; } }
1,244
21.232143
78
java
jkind
jkind-master/jkind-common/src/jkind/util/CurrIdExtractorVisitor.java
package jkind.util; import java.util.HashSet; import java.util.Set; import jkind.lustre.Expr; import jkind.lustre.IdExpr; import jkind.lustre.UnaryExpr; import jkind.lustre.UnaryOp; import jkind.lustre.visitors.ExprIterVisitor; public class CurrIdExtractorVisitor extends ExprIterVisitor { public static Set<String> getCurrIds(Expr expr) { CurrIdExtractorVisitor visitor = new CurrIdExtractorVisitor(); expr.accept(visitor); return visitor.set; } private Set<String> set = new HashSet<>(); @Override public Void visit(UnaryExpr e) { if (e.op == UnaryOp.PRE) { return null; } else { return super.visit(e); } } @Override public Void visit(IdExpr e) { set.add(e.id); return null; } }
718
18.972222
64
java
jkind
jkind-master/jkind-common/src/jkind/util/BigFraction.java
package jkind.util; import java.math.BigDecimal; import java.math.BigInteger; import java.math.MathContext; import jkind.JKindException; /** * An arbitrary sized fractional value * * Stored as <code>numerator</code> / <code>denominator</code> where the * fraction is in reduced form and <code>denominator</code> is always positive */ public class BigFraction implements Comparable<BigFraction> { public static final BigFraction ZERO = new BigFraction(BigInteger.ZERO); public static final BigFraction ONE = new BigFraction(BigInteger.ONE); // The numerator and denominator are always stored in reduced form with the // denominator always positive final private BigInteger num; final private BigInteger denom; public BigFraction(BigInteger num, BigInteger denom) { if (num == null || denom == null) { throw new NullPointerException(); } if (denom.equals(BigInteger.ZERO)) { throw new ArithmeticException("Divide by zero"); } BigInteger gcd = num.gcd(denom); if (denom.compareTo(BigInteger.ZERO) > 0) { this.num = num.divide(gcd); this.denom = denom.divide(gcd); } else { this.num = num.negate().divide(gcd); this.denom = denom.negate().divide(gcd); } } public BigFraction(BigInteger num) { this(num, BigInteger.ONE); } public static BigFraction valueOf(BigDecimal value) { if (value.scale() >= 0) { return new BigFraction(value.unscaledValue(), BigInteger.valueOf(10).pow(value.scale())); } else { return new BigFraction(value.unscaledValue().multiply(BigInteger.valueOf(10).pow(-value.scale()))); } } public BigInteger getNumerator() { return num; } public BigInteger getDenominator() { return denom; } public BigFraction add(BigFraction val) { return new BigFraction(num.multiply(val.denom).add(val.num.multiply(denom)), denom.multiply(val.denom)); } public BigFraction add(BigInteger val) { return add(new BigFraction(val)); } public BigFraction subtract(BigFraction val) { return new BigFraction(num.multiply(val.denom).subtract(val.num.multiply(denom)), denom.multiply(val.denom)); } public BigFraction subtract(BigInteger val) { return subtract(new BigFraction(val)); } public BigFraction multiply(BigFraction val) { return new BigFraction(num.multiply(val.num), denom.multiply(val.denom)); } public BigFraction multiply(BigInteger val) { return multiply(new BigFraction(val)); } public BigFraction divide(BigFraction val) { return new BigFraction(num.multiply(val.denom), denom.multiply(val.num)); } public BigFraction divide(BigInteger val) { return divide(new BigFraction(val)); } public BigFraction negate() { return new BigFraction(num.negate(), denom); } public int signum() { return num.signum(); } public double doubleValue() { double result = num.doubleValue() / denom.doubleValue(); if (Double.isFinite(result)) { return result; } else { BigDecimal numDec = new BigDecimal(num); BigDecimal denomDec = new BigDecimal(denom); return numDec.divide(denomDec, MathContext.DECIMAL64).doubleValue(); } } public BigInteger floor() { BigInteger divAndRem[] = num.divideAndRemainder(denom); if (num.signum() >= 0 || divAndRem[1].equals(BigInteger.ZERO)) { return divAndRem[0]; } else { return divAndRem[0].subtract(BigInteger.ONE); } } public BigDecimal toBigDecimal(int scale) { BigDecimal decNum = new BigDecimal(num).setScale(scale); BigDecimal decDenom = new BigDecimal(denom); return decNum.divide(decDenom, BigDecimal.ROUND_DOWN); } public String toTruncatedDecimal(int scale, String suffix) { if (scale <= 0) { throw new JKindException("Scale must be positive"); } BigDecimal dec = toBigDecimal(scale); if (this.equals(BigFraction.valueOf(dec))) { return Util.removeTrailingZeros(dec.toPlainString()); } else { return dec.toPlainString() + suffix; } } @Override public int compareTo(BigFraction other) { return num.multiply(other.denom).compareTo(other.num.multiply(denom)); } @Override public String toString() { if (denom.equals(BigInteger.ONE)) { return num.toString(); } else { return num + "/" + denom; } } @Override public int hashCode() { return num.hashCode() + denom.hashCode(); } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof BigFraction)) { return false; } BigFraction other = (BigFraction) obj; return num.equals(other.num) && denom.equals(other.denom); } }
4,495
25.139535
111
java
jkind
jkind-master/jkind-common/src/jkind/util/StringNaturalOrdering.java
package jkind.util; import java.math.BigInteger; import java.util.Comparator; public class StringNaturalOrdering implements Comparator<String> { @Override public int compare(String s1, String s2) { int n1 = s1.length(); int n2 = s2.length(); int min = Math.min(n1, n2); for (int i = 0; i < min; i++) { char c1 = s1.charAt(i); char c2 = s2.charAt(i); if (Character.isDigit(c1) && Character.isDigit(c2)) { int end1 = getIntEnd(s1, i); int end2 = getIntEnd(s2, i); String ss1 = s1.substring(i, end1); String ss2 = s2.substring(i, end2); BigInteger v1 = new BigInteger(ss1); BigInteger v2 = new BigInteger(ss2); if (v1.equals(v2)) { // Check leading zeros: The one with more is smaller int comp = ss1.compareTo(ss2); if (comp != 0) { return comp; } else { // Must have end1 = end2 i = end1 - 1; continue; } } else { return v1.subtract(v2).signum(); } } else if (c1 != c2) { return c1 - c2; } } return n1 - n2; } private int getIntEnd(String s, int begin) { int end = begin; while (end < s.length() && Character.isDigit(s.charAt(end))) { end++; } return end; } }
1,200
22.096154
66
java
jkind
jkind-master/jkind-common/src/jkind/util/Util.java
package jkind.util; import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toMap; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.Writer; import java.math.BigDecimal; import java.math.BigInteger; import java.text.DecimalFormat; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Queue; import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; import java.util.TreeSet; import org.w3c.dom.Element; import jkind.JKindException; import jkind.lustre.EnumType; import jkind.lustre.Equation; import jkind.lustre.Function; import jkind.lustre.IdExpr; import jkind.lustre.NamedType; import jkind.lustre.Node; import jkind.lustre.NodeCallExpr; import jkind.lustre.Program; import jkind.lustre.SubrangeIntType; import jkind.lustre.Type; import jkind.lustre.TypeDef; import jkind.lustre.VarDecl; import jkind.lustre.values.ArrayValue; import jkind.lustre.values.BooleanValue; import jkind.lustre.values.EnumValue; import jkind.lustre.values.IntegerValue; import jkind.lustre.values.RealValue; import jkind.lustre.values.Value; import jkind.lustre.visitors.AstIterVisitor; public class Util { public static Set<Node> getAllNodeDependencies(Program program) { Map<String, Node> nodeTable = getNodeTable(program.nodes); Set<Node> result = new HashSet<>(); Queue<Node> todo = new ArrayDeque<>(); todo.add(program.getMainNode()); while (!todo.isEmpty()) { Node curr = todo.remove(); if (result.add(curr)) { for (String depName : getNodeDependenciesByName(curr)) { todo.add(nodeTable.get(depName)); } } } return result; } public static Set<String> getNodeDependenciesByName(Node node) { Set<String> referenced = new HashSet<>(); node.accept(new AstIterVisitor() { @Override public Void visit(NodeCallExpr e) { referenced.add(e.node); return super.visit(e); } }); return referenced; } public static List<VarDecl> getVarDecls(Node node) { List<VarDecl> decls = new ArrayList<>(); decls.addAll(node.inputs); decls.addAll(node.outputs); decls.addAll(node.locals); return decls; } public static List<VarDecl> getVarDecls(Function function) { List<VarDecl> decls = new ArrayList<>(); decls.addAll(function.inputs); decls.addAll(function.outputs); return decls; } public static Map<String, Type> getTypeMap(Node node) { return getVarDecls(node).stream().collect(toMap(vd -> vd.id, vd -> vd.type)); } public static List<String> getIds(List<VarDecl> decls) { return decls.stream().map(decl -> decl.id).collect(toList()); } public static Map<String, Node> getNodeTable(List<Node> nodes) { return nodes.stream().collect(toMap(n -> n.id, n -> n)); } public static Map<String, Function> getFunctionTable(List<Function> functions) { return functions.stream().collect(toMap(f -> f.id, f -> f)); } /* * Get the name of the type as modeled by the SMT solvers */ public static String getName(Type type) { if (type instanceof NamedType) { NamedType namedType = (NamedType) type; return namedType.name; } else if (type instanceof SubrangeIntType || type instanceof EnumType) { return "int"; } else { throw new IllegalArgumentException("Cannot find name for type " + type); } } public static Value parseValue(String type, String value) { switch (type) { case "bool": if (value.equals("0") || value.equals("false") || value.equals("False")) { return BooleanValue.FALSE; } else if (value.equals("1") || value.equals("true") || value.equals("True")) { return BooleanValue.TRUE; } break; case "int": return new IntegerValue(new BigInteger(value)); case "real": // Sally returns real values with decimal points if(value.contains(".")) { return new RealValue(BigFraction.valueOf(new BigDecimal(value.toString()))); } String[] strs = value.split("/"); if (strs.length <= 2) { BigInteger num = new BigInteger(strs[0]); BigInteger denom = strs.length > 1 ? new BigInteger(strs[1]) : BigInteger.ONE; return new RealValue(new BigFraction(num, denom)); } break; default: if (value.isEmpty() || Character.isAlphabetic(value.charAt(0))) { return new EnumValue(value); } else { throw new IllegalArgumentException("Invalid enumeration value: " + value); } } throw new JKindException("Unable to parse " + value + " as " + type); } public static Value parseArrayValue(String type, Element arrayElement) { int size = Integer.parseInt(arrayElement.getAttribute("size")); List<Value> elements = new ArrayList<>(); for (int i = 0; i < size; i++) { Value elValue; Element arrayEl = getElement(arrayElement, "Array", i); if (arrayEl != null) { elValue = parseArrayValue(type, arrayEl); } else { arrayEl = getElement(arrayElement, "Item", i); int index = Integer.parseInt(arrayEl.getAttribute("index")); if (index != i) { throw new IllegalArgumentException("We expect array indicies to be sorted"); } elValue = parseValue(type, arrayEl.getTextContent()); } elements.add(elValue); } return new ArrayValue(elements); } public static Value promoteIfNeeded(Value value, Type type) { if (value instanceof IntegerValue && type == NamedType.REAL) { IntegerValue iv = (IntegerValue) value; return new RealValue(new BigFraction(iv.value)); } return value; } private static Element getElement(Element element, String name, int index) { return (Element) element.getElementsByTagName(name).item(index); } public static Value parseValue(Type type, String value) { return parseValue(getName(type), value); } public static Type resolveType(Type type, Map<String, Type> map) { return TypeResolver.resolve(type, map); } public static Map<String, Type> createResolvedTypeTable(List<TypeDef> defs) { Map<String, Type> resolved = new HashMap<>(); Map<String, Type> unresolved = createUnresolvedTypeTable(defs); for (TypeDef def : defs) { resolved.put(def.id, resolveType(def.type, unresolved)); } return resolved; } private static Map<String, Type> createUnresolvedTypeTable(List<TypeDef> defs) { Map<String, Type> unresolved = new HashMap<>(); for (TypeDef def : defs) { unresolved.put(def.id, def.type); } return unresolved; } public static Map<String, Set<String>> getDirectDependencies(Node node) { Map<String, Set<String>> directDepends = new HashMap<>(); for (Equation eq : node.equations) { Set<String> set = CurrIdExtractorVisitor.getCurrIds(eq.expr); for (IdExpr idExpr : eq.lhs) { directDepends.put(idExpr.id, set); } } return directDepends; } public static void writeToFile(String content, File file) throws IOException { try (Writer writer = new BufferedWriter(new FileWriter(file))) { writer.append(content); } } public static boolean isWindows() { return System.getProperty("os.name").startsWith("Windows"); } public static <T, S> List<S> castList(List<T> list, Class<S> klass) { List<S> result = new ArrayList<>(); for (T e : list) { result.add(klass.cast(e)); } return result; } /** * In SMT solvers, integer division behaves differently than in Java. In * particular, for -5 div 3 java says '-1' and SMT solvers say '-2' */ public static BigInteger smtDivide(BigInteger a, BigInteger b) { return a.subtract(a.mod(b)).divide(b); } public static <T> List<T> safeList(Collection<? extends T> original) { if (original == null) { return Collections.emptyList(); } else { return Collections.unmodifiableList(new ArrayList<>(original)); } } public static <T> List<T> safeNullableList(List<? extends T> original) { if (original == null) { return null; } else { return Collections.unmodifiableList(new ArrayList<>(original)); } } public static <T> Set<T> safeSet(Set<? extends T> original) { if (original == null) { return Collections.emptySet(); } else { return Collections.unmodifiableSet(new HashSet<>(original)); } } public static <T> SortedMap<String, T> safeStringSortedMap(Map<String, T> original) { TreeMap<String, T> map = new TreeMap<>(new StringNaturalOrdering()); if (original != null) { map.putAll(original); } return Collections.unmodifiableSortedMap(map); } public static <T> List<T> copyNullable(List<? extends T> original) { if (original == null) { return null; } return new ArrayList<>(original); } public static Set<String> safeStringSortedSet(Collection<String> original) { TreeSet<String> set = new TreeSet<>(new StringNaturalOrdering()); set.addAll(original); return Collections.unmodifiableSet(set); } public static Set<List<String>> safeStringSortedSets(Set<List<String>> original) { Set<List<String>> set = new HashSet<>(new TreeSet<>(new StringNaturalOrdering())); for (Collection<String> currentSetOriginal : original) { TreeSet<String> individualSet = new TreeSet<>(new StringNaturalOrdering()); individualSet.addAll(currentSetOriginal); set.add(safeList(individualSet)); } return Collections.unmodifiableSet(set); } public static <T> Set<T> setDifference(Collection<T> c1, Collection<T> c2) { Set<T> result = new HashSet<>(c1); result.removeAll(c2); return result; } public static List<EnumType> getEnumTypes(List<TypeDef> types) { List<EnumType> enums = new ArrayList<>(); for (TypeDef def : types) { if (def.type instanceof EnumType) { enums.add((EnumType) def.type); } } return enums; } public static Value getDefaultValue(Type type) { return type.accept(new DefaultValueVisitor()); } public static Value cast(Type type, Value value) { if (type == NamedType.REAL && value instanceof IntegerValue) { IntegerValue iv = (IntegerValue) value; return new RealValue(new BigFraction(iv.value)); } else if (type == NamedType.INT && value instanceof RealValue) { RealValue rv = (RealValue) value; return new IntegerValue(rv.value.floor()); } else { throw new IllegalArgumentException(); } } public static String removeTrailingZeros(String str) { if (!str.contains(".")) { return str; } return str.replaceFirst("\\.?0*$", ""); } public static String spaces(int n) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) { sb.append(' '); } return sb.toString(); } public static String secondsToTime(double seconds) { String result; int minutes = (int) (seconds / 60); seconds = seconds % 60; result = new DecimalFormat("#.###").format(seconds) + "s"; if (minutes == 0) { return result; } int hours = minutes / 60; minutes = minutes % 60; result = minutes + "m " + result; if (hours == 0) { return result; } int days = hours / 24; hours = hours % 24; result = hours + "h " + result; if (days == 0) { return result; } return days + "d " + result; } /** Default name for realizability query property in XML file */ public static final String REALIZABLE = "%REALIZABLE"; /** * ASCII "End of Text" character, used by JKindApi to ask JKind to terminate */ public static final int END_OF_TEXT = 0x03; public static String capitalize(String name) { return name.substring(0, 1).toUpperCase() + name.substring(1); } }
11,469
27.320988
86
java
jkind
jkind-master/jkind-common/src/jkind/util/TypeResolver.java
package jkind.util; import java.util.Map; import jkind.lustre.NamedType; import jkind.lustre.Type; import jkind.lustre.visitors.TypeMapVisitor; public class TypeResolver extends TypeMapVisitor { public static Type resolve(Type type, Map<String, Type> map) { return type.accept(new TypeResolver(map)); } public TypeResolver(Map<String, Type> map) { this.map = map; } private final Map<String, Type> map; @Override public Type visit(NamedType e) { if (e.isBuiltin()) { return e; } else { return map.get(e.name).accept(this); } } }
559
18.310345
63
java
jkind
jkind-master/jkind-common/src/jkind/translation/DistributePres.java
package jkind.translation; import static jkind.lustre.LustreUtil.arrow; import static jkind.lustre.LustreUtil.pre; import jkind.lustre.BinaryExpr; import jkind.lustre.BinaryOp; import jkind.lustre.CondactExpr; import jkind.lustre.Expr; import jkind.lustre.IdExpr; import jkind.lustre.Node; import jkind.lustre.NodeCallExpr; import jkind.lustre.UnaryExpr; import jkind.lustre.UnaryOp; import jkind.lustre.visitors.AstMapVisitor; /** * Push all instances of 'pre' operator down as far as possible. * * For example: * * <pre> * pre(x + pre(3 * z)) = pre(x) + 3 * pre(pre(z)) * </pre> * * If there are no node calls, condacts, or arrow expressions underneath 'pre' * operators, then in the result 'pre' will only be applied to variables. */ public class DistributePres extends AstMapVisitor { private int pres = 0; public static Node node(Node node) { return new DistributePres().visit(node); } private Expr applyPres(Expr e) { Expr result = e; for (int i = 0; i < pres; i++) { result = pre(result); } return result; } @Override public Expr visit(BinaryExpr e) { if (e.op == BinaryOp.ARROW) { Expr left = e.left.accept(new DistributePres()); Expr right = e.right.accept(new DistributePres()); return applyPres(arrow(left, right)); } else { return super.visit(e); } } @Override public Expr visit(CondactExpr e) { return applyPres(e); } @Override public Expr visit(IdExpr e) { return applyPres(e); } @Override public Expr visit(NodeCallExpr e) { return applyPres(e); } @Override public Expr visit(UnaryExpr e) { if (e.op == UnaryOp.PRE) { pres++; Expr result = e.expr.accept(this); pres--; return result; } else { return super.visit(e); } } }
1,738
20.469136
78
java
jkind
jkind-master/jkind-common/src/jkind/translation/InlineNodeCalls.java
package jkind.translation; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Queue; import jkind.lustre.Equation; import jkind.lustre.Expr; import jkind.lustre.IdExpr; import jkind.lustre.Node; import jkind.lustre.NodeCallExpr; import jkind.lustre.Program; import jkind.lustre.TupleExpr; import jkind.lustre.VarDecl; import jkind.lustre.builders.NodeBuilder; import jkind.lustre.builders.ProgramBuilder; import jkind.lustre.visitors.ExprMapVisitor; import jkind.util.Util; /** * Inline node calls by introducing additional local variables. Assertions * within called nodes are ignored. Properties within called nodes are lifted to * properties in the main node. */ public class InlineNodeCalls extends ExprMapVisitor { public static Program program(Program program) { InlineNodeCalls inliner = new InlineNodeCalls(Util.getNodeTable(program.nodes)); Node main = program.getMainNode(); NodeBuilder builder = new NodeBuilder(main); builder.clearAssertions().addAssertions(inliner.visitExprs(main.assertions)); builder.clearEquations().addEquations(inliner.visitEquationsQueue(main.equations)); builder.addLocals(inliner.newLocals); builder.addProperties(inliner.newProperties); builder.addIvcs(inliner.newIvc); Node inlinedMain = builder.build(); return new ProgramBuilder(program).clearNodes().addNode(inlinedMain).build(); } private final Map<String, Node> nodeTable; private final List<VarDecl> newLocals = new ArrayList<>(); private final List<String> newProperties = new ArrayList<>(); private final List<String> newIvc = new ArrayList<>(); private final Map<String, Integer> usedPrefixes = new HashMap<>(); private final Queue<Equation> queue = new ArrayDeque<>(); private final Map<String, Expr> inlinedCalls = new HashMap<>(); private InlineNodeCalls(Map<String, Node> nodeTable) { this.nodeTable = nodeTable; } public List<Equation> visitEquationsQueue(List<Equation> equations) { queue.addAll(equations); List<Equation> result = new ArrayList<>(); while (!queue.isEmpty()) { Equation eq = queue.poll(); result.add(new Equation(eq.location, eq.lhs, eq.expr.accept(this))); } return result; } @Override public Expr visit(NodeCallExpr e) { // Detect duplicate node calls to reduce code size return inlinedCalls.computeIfAbsent(getKey(e), key -> { return TupleExpr.compress(visitNodeCallExpr(e)); }); } private String getKey(NodeCallExpr e) { return new NodeCallExpr(getOriginalName(e), e.args).toString(); } private String getOriginalName(NodeCallExpr e) { return e.node.substring(e.node.lastIndexOf('.') + 1); } public List<IdExpr> visitNodeCallExpr(NodeCallExpr e) { String prefix = newPrefix(e.node); Node node = nodeTable.get(getOriginalName(e)); Map<String, IdExpr> translation = getTranslation(prefix, node); createInputEquations(node.inputs, e.args, translation); createAssignmentEquations(prefix, node.equations, translation); accumulateProperties(node.properties, translation); accumulateIvcElements(node.ivc, translation); List<IdExpr> result = new ArrayList<>(); for (VarDecl decl : node.outputs) { result.add(translation.get(decl.id)); } return result; } private Map<String, IdExpr> getTranslation(String prefix, Node node) { Map<String, IdExpr> translation = new HashMap<>(); for (VarDecl decl : Util.getVarDecls(node)) { String id = prefix + decl.id; newLocals.add(new VarDecl(id, decl.type)); translation.put(decl.id, new IdExpr(id)); } return translation; } private void createInputEquations(List<VarDecl> inputs, List<Expr> args, Map<String, IdExpr> translation) { for (int i = 0; i < inputs.size(); i++) { IdExpr idExpr = translation.get(inputs.get(i).id); Expr arg = args.get(i); queue.add(new Equation(idExpr, arg)); } } private void createAssignmentEquations(final String prefix, List<Equation> equations, Map<String, IdExpr> translation) { SubstitutionVisitor substitution = new SubstitutionVisitor(translation) { @Override public Expr visit(NodeCallExpr e) { return new NodeCallExpr(e.location, prefix + e.node, visitExprs(e.args)); } }; for (Equation eq : equations) { List<IdExpr> lhs = new ArrayList<>(); for (IdExpr idExpr : eq.lhs) { lhs.add(translation.get(idExpr.id)); } Expr expr = eq.expr.accept(substitution); queue.add(new Equation(eq.location, lhs, expr)); } } private String newPrefix(String prefix) { int i = 0; if (usedPrefixes.containsKey(prefix)) { i = usedPrefixes.get(prefix); } usedPrefixes.put(prefix, i + 1); return prefix + "~" + i + "."; } private void accumulateProperties(List<String> properties, Map<String, IdExpr> translation) { for (String property : properties) { newProperties.add(translation.get(property).id); } } private void accumulateIvcElements(List<String> ivc, Map<String, IdExpr> translation) { for (String e : ivc) { newIvc.add(translation.get(e).id); } } }
5,059
30.823899
108
java
jkind
jkind-master/jkind-common/src/jkind/translation/FlattenPres.java
package jkind.translation; import java.util.ArrayList; import java.util.List; import jkind.lustre.Equation; import jkind.lustre.Expr; import jkind.lustre.IdExpr; import jkind.lustre.Node; import jkind.lustre.Program; import jkind.lustre.UnaryExpr; import jkind.lustre.UnaryOp; import jkind.lustre.VarDecl; import jkind.lustre.builders.NodeBuilder; import jkind.lustre.visitors.TypeAwareAstMapVisitor; /** * Remove all occurrences of temporal operators ('pre' and '->') underneath * 'pre' operators. This is done by introducing new local variables. */ public class FlattenPres extends TypeAwareAstMapVisitor { public static Program program(Program program) { return new FlattenPres().visit(program); } private List<VarDecl> newLocals = new ArrayList<>(); private List<Equation> newEquations = new ArrayList<>(); private int counter = 0; @Override public Node visit(Node e) { NodeBuilder builder = new NodeBuilder(super.visit(e)); builder.addLocals(newLocals); builder.addEquations(newEquations); return builder.build(); } private IdExpr getFreshId() { return new IdExpr("~flatten" + counter++); } @Override public Expr visit(UnaryExpr e) { if (e.op == UnaryOp.PRE && ContainsTemporalOperator.check(e.expr)) { Expr nested = e.expr.accept(this); IdExpr id = getFreshId(); newLocals.add(new VarDecl(id.id, getType(e.expr))); newEquations.add(new Equation(id, nested)); return new UnaryExpr(e.op, id); } else { return super.visit(e); } } }
1,494
26.181818
75
java
jkind
jkind-master/jkind-common/src/jkind/translation/ContainsTemporalOperator.java
package jkind.translation; import jkind.lustre.BinaryExpr; import jkind.lustre.BinaryOp; import jkind.lustre.Expr; import jkind.lustre.UnaryExpr; import jkind.lustre.UnaryOp; import jkind.lustre.visitors.ExprDisjunctiveVisitor; /** * Check if an expression contains a 'pre' or '->' operator. */ public class ContainsTemporalOperator extends ExprDisjunctiveVisitor { public static boolean check(Expr e) { return e.accept(new ContainsTemporalOperator()); } @Override public Boolean visit(BinaryExpr e) { return e.op == BinaryOp.ARROW || super.visit(e); } @Override public Boolean visit(UnaryExpr e) { return e.op == UnaryOp.PRE || super.visit(e); } }
669
22.928571
70
java
jkind
jkind-master/jkind-common/src/jkind/translation/OrderEquations.java
package jkind.translation; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Set; import jkind.JKindException; import jkind.lustre.Equation; import jkind.lustre.Node; import jkind.lustre.builders.NodeBuilder; import jkind.util.CycleFinder; import jkind.util.TopologicalSorter; import jkind.util.Util; /** * Order equations in assignment-use order if possible. Throw * AlgebraicLoopException if not possible. This transformation assumes all * equations are to single variables. */ public class OrderEquations { public static Node node(Node node) { Map<String, Set<String>> dependencies = Util.getDirectDependencies(node); ensureNoCycles(dependencies); ensureAllSingleAssignment(node); NodeBuilder builder = new NodeBuilder(node); builder.clearEquations(); builder.addEquations(getSortedEquations(node.equations, dependencies)); return builder.build(); } private static void ensureNoCycles(Map<String, Set<String>> dependencies) { List<String> cycle = CycleFinder.findCycle(dependencies); if (cycle != null) { throw new AlgebraicLoopException(cycle); } } private static void ensureAllSingleAssignment(Node node) { for (Equation eq : node.equations) { if (eq.lhs.size() != 1) { throw new JKindException("OrderEquations expected single variable assignment, but found: " + eq.lhs); } } } private static Collection<Equation> getSortedEquations(List<Equation> equations, Map<String, Set<String>> dependencies) { TopologicalSorter<Equation> sorter = new TopologicalSorter<>(); for (Equation eq : equations) { String id = eq.lhs.get(0).id; sorter.put(id, eq, dependencies.get(id)); } return sorter.getSortedValues(); } public static class AlgebraicLoopException extends JKindException { private static final long serialVersionUID = 1L; public AlgebraicLoopException(List<String> cycle) { super("Algebraic loop: " + cycle); } } }
1,949
27.676471
105
java
jkind
jkind-master/jkind-common/src/jkind/translation/SubstitutionVisitor.java
package jkind.translation; import java.util.Collections; import java.util.Map; import jkind.lustre.Expr; import jkind.lustre.IdExpr; import jkind.lustre.visitors.AstMapVisitor; /** * Replace ids with expressions based on a map. This substitution is not * recursive: the newly substituted expression will not be analyzed for * additional substitutions. */ public class SubstitutionVisitor extends AstMapVisitor { private final Map<String, ? extends Expr> map; public SubstitutionVisitor(Map<String, ? extends Expr> map) { this.map = map; } public SubstitutionVisitor(String name, Expr expr) { this.map = Collections.singletonMap(name, expr); } @Override public Expr visit(IdExpr e) { if (map.containsKey(e.id)) { return map.get(e.id); } else { return e; } } }
793
21.685714
72
java
jkind
jkind-master/jkind-api/src/jkind/api/KindApi.java
package jkind.api; import java.io.File; import org.eclipse.core.runtime.IProgressMonitor; import jkind.JKindException; import jkind.api.ApiUtil.ICancellationMonitor; import jkind.api.results.JKindResult; import jkind.lustre.Program; public abstract class KindApi { protected Integer timeout = null; protected DebugLogger debug = new DebugLogger(); /** * Set a maximum run time for entire execution * * @param timeout * A positive timeout in seconds */ public void setTimeout(int timeout) { if (timeout <= 0) { throw new JKindException("Timeout must be positive"); } this.timeout = timeout; } /** * Put the KindApi into debug mode where it saves all output */ public void setApiDebug() { debug = new DebugLogger("jkind-api-debug-"); } /** * Print string to debug log (assuming setApiDebug() has been called) * * @param text * text to print to debug log */ public void apiDebug(String text) { if (debug != null) { debug.println(text); } } /** * Run Kind on a Lustre program * * @param program * Lustre program * @param result * Place to store results as they come in * @param monitor * Used to check for cancellation * @throws jkind.JKindException * @deprecated To be removed in 5.0. * Use {@link jkind.api.eclipse.KindApi.execute()} instead. */ @Deprecated public void execute(Program program, JKindResult result, IProgressMonitor monitor) { execute(program.toString(), result, new jkind.api.eclipse.ApiUtil.CancellationMonitor(monitor)); } /** * Run Kind on a Lustre program * * @param program * Lustre program * @param result * Place to store results as they come in * @param monitor * Used to check for cancellation * @throws jkind.JKindException */ public void execute(Program program, JKindResult result, ICancellationMonitor monitor) { execute(program.toString(), result, monitor); } /** * Run Kind on a Lustre program * * @param program * Lustre program as text * @param result * Place to store results as they come in * @param monitor * Used to check for cancellation * @throws jkind.JKindException * @deprecated To be removed in 5.0. * Use {@link jkind.api.eclipse.KindApi.execute()} instead. */ @Deprecated public void execute(String program, JKindResult result, IProgressMonitor monitor) { execute(program, result, new jkind.api.eclipse.ApiUtil.CancellationMonitor(monitor)); } /** * Run Kind on a Lustre program * * @param program * Lustre program as text * @param result * Place to store results as they come in * @param monitor * Used to check for cancellation * @throws jkind.JKindException */ public void execute(String program, JKindResult result, ICancellationMonitor monitor) { File lustreFile = null; try { lustreFile = ApiUtil.writeLustreFile(program); execute(lustreFile, result, monitor); } finally { debug.deleteIfUnneeded(lustreFile); } } /** * Run Kind on a Lustre program * * @param lustreFile * File containing Lustre program * @param result * Place to store results as they come in * @param monitor * Used to check for cancellation * @throws jkind.JKindException * @deprecated To be removed in 5.0. * Use {@link jkind.api.eclipse.KindApi.execute()} instead. */ @Deprecated public abstract void execute(File lustreFile, JKindResult result, IProgressMonitor monitor); /** * Run Kind on a Lustre program * * @param lustreFile * File containing Lustre program * @param result * Place to store results as they come in * @param monitor * Used to check for cancellation * @throws jkind.JKindException */ public abstract void execute(File lustreFile, JKindResult result, ICancellationMonitor monitor); /** * Check if the KindApi is available for running and throw exception if not * * @return Availability information when Kind is available * @throws java.lang.Exception * When Kind is not available */ public abstract String checkAvailable() throws Exception; }
4,276
26.06962
98
java
jkind
jkind-master/jkind-api/src/jkind/api/ApiUtil.java
package jkind.api; import static java.util.stream.Collectors.joining; import java.io.BufferedInputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.function.Function; import org.eclipse.core.runtime.IProgressMonitor; import jkind.JKindException; import jkind.api.results.JKindResult; import jkind.api.xml.JKindXmlFileInputStream; import jkind.api.xml.XmlParseThread; import jkind.util.Util; public class ApiUtil { public static interface ICancellationMonitor { /** * Check of the task being monitored has been cancelled. * @return true if the task has been marked as canceled, otherwise false */ public boolean isCanceled(); /** * Mark the task being monitored as completed */ public void done(); } public static class NullCancellationMonitor implements ICancellationMonitor { @Override public boolean isCanceled() { return false; } @Override public void done() { } } public static File writeLustreFile(String program) { return writeTempFile("jkind-api-", ".lus", program); } public static File writeTempFile(String fileName, String fileExt, String contents) { File file = null; try { file = File.createTempFile(fileName, fileExt); if (contents != null) { Util.writeToFile(contents, file); } return file; } catch (IOException e) { throw new JKindException("Cannot write to file: " + file, e); } } /** * @deprecated To be removed in 5.0. * Use {@link jkind.api.eclipse.ApiUtil.execute()} instead. */ @Deprecated public static void execute(Function<File, ProcessBuilder> runCommand, File lustreFile, JKindResult result, IProgressMonitor monitor, DebugLogger debug) { execute(runCommand, lustreFile, result, new jkind.api.eclipse.ApiUtil.CancellationMonitor(monitor), debug); } public static void execute(Function<File, ProcessBuilder> runCommand, File lustreFile, JKindResult result, ICancellationMonitor monitor, DebugLogger debug) { File xmlFile = null; try { xmlFile = getXmlFile(lustreFile); debug.println("XML results file", xmlFile); ensureDeleted(xmlFile); callJKind(runCommand, lustreFile, xmlFile, result, monitor, debug); } catch (JKindException e) { throw e; } catch (Throwable t) { throw new JKindException(result.getText(), t); } finally { debug.deleteIfUnneeded(xmlFile); debug.println(); } } private static void ensureDeleted(File file) { if (file != null && file.exists()) { file.delete(); if (file.exists()) { throw new JKindException("Unable to delete file: " + file); } } } private static File getXmlFile(File lustreFile) { return new File(lustreFile.toString() + ".xml"); } private static void callJKind(Function<File, ProcessBuilder> runCommand, File lustreFile, File xmlFile, JKindResult result, ICancellationMonitor monitor, DebugLogger debug) throws IOException, InterruptedException { ProcessBuilder builder = runCommand.apply(lustreFile); debug.println("JKind command: " + ApiUtil.getQuotedCommand(builder.command())); Process process = null; try (JKindXmlFileInputStream xmlStream = new JKindXmlFileInputStream(xmlFile)) { XmlParseThread parseThread = new XmlParseThread(xmlStream, result, Backend.JKIND); StringBuilder outputText = new StringBuilder(); StringBuilder errorText = new StringBuilder(); try { result.start(); process = builder.start(); parseThread.start(); ApiUtil.readOutputToBuilder(process, monitor, outputText, errorText); } finally { int code = 0; if (process != null) { if (monitor.isCanceled() && process.isAlive()) { // Only destroy the process if we have to since it can // change the exit code on Windows process.destroy(); } code = process.waitFor(); } xmlStream.done(); parseThread.join(); String output = outputText.toString(); String errors = errorText.toString(); result.setText(errors + output); debug.println("JKind output", debug.saveFile("jkind-output-", ".txt", errors + output)); if (monitor.isCanceled()) { result.cancel(); } else { result.done(); } monitor.done(); if (code != 0 && !monitor.isCanceled()) { throw new JKindException( "Abnormal termination, exit code " + code + System.lineSeparator() + result.getText()); } } if (parseThread.getThrowable() != null) { throw new JKindException("Error parsing XML", parseThread.getThrowable()); } } } /** * @deprecated To be removed in 5.0. * Use {@link jkind.api.eclipse.ApiUtil.readOutput()} instead. */ @Deprecated public static String readOutput(Process process, IProgressMonitor monitor) throws IOException { return jkind.api.eclipse.ApiUtil.readOutput(process, monitor); } public static String readOutput(Process process, ICancellationMonitor monitor) throws IOException { StringBuilder outputText = new StringBuilder(); StringBuilder errorText = new StringBuilder(); readOutputToBuilder(process, monitor, outputText, errorText); return errorText.toString() + outputText.toString(); } /** * @deprecated To be removed in 5.0. * Use {@link jkind.api.eclipse.ApiUtil.readOutputToBuilder()} instead. */ @Deprecated public static void readOutputToBuilder(Process process, IProgressMonitor monitor, StringBuilder outputText, StringBuilder errorText) throws IOException { jkind.api.eclipse.ApiUtil.readOutputToBuilder(process, monitor, outputText, errorText); } public static void readOutputToBuilder(Process process, ICancellationMonitor monitor, StringBuilder outputText, StringBuilder errorText) throws IOException { InputStream stream = new BufferedInputStream(process.getInputStream()); InputStream errorStream = new BufferedInputStream(process.getErrorStream()); while (true) { checkMonitor(monitor, process); while (stream.available() > 0) { int c = stream.read(); if (c == -1) { return; } outputText.append((char) c); checkMonitor(monitor, process); } while (errorStream.available() > 0) { int c = errorStream.read(); if (c == -1) { return; } errorText.append((char) c); checkMonitor(monitor, process); } if (!process.isAlive()) { return; } try { Thread.sleep(100); } catch (InterruptedException e) { } } } private static void checkMonitor(ICancellationMonitor monitor, Process process) throws IOException { if (monitor.isCanceled()) { process.getOutputStream().write(Util.END_OF_TEXT); process.getOutputStream().flush(); } } public static File findJKindJar() { /* * On Windows, invoking Process.destroy does not kill the subprocesses * of the destroyed process. If we were to run jkind.bat and kill it, * only the cmd.exe process which is running the batch file would be * killed. The underlying JKind process would continue to its natural * end. To avoid this, we search the user's path for the jkind.jar file * and invoke it directly. * * In order to support JKIND_HOME or PATH as the location for JKind, we * now search in non-windows environments too. */ File jar = findJKindJar(System.getenv("JKIND_HOME")); if (jar != null) { return jar; } jar = findJKindJar(System.getenv("PATH")); if (jar != null) { return jar; } throw new JKindException("Unable to find jkind.jar in JKIND_HOME or on system PATH"); } public static File findJKindJar(String path) { if (path == null) { return null; } for (String element : path.split(File.pathSeparator)) { File jar = new File(element, "jkind.jar"); if (jar.exists()) { return jar; } } return null; } public static String getJavaPath() { String slash = File.separator; return System.getProperty("java.home") + slash + "bin" + slash + "java"; } public static String readAll(InputStream inputStream) throws IOException { StringBuilder result = new StringBuilder(); BufferedInputStream buffered = new BufferedInputStream(inputStream); int i; while ((i = buffered.read()) != -1) { result.append((char) i); } return result.toString(); } public static String getQuotedCommand(List<String> pieces) { return pieces.stream().map(p -> p.contains(" ") ? "\"" + p + "\"" : p).collect(joining(" ")); } public static void addEnvironment(ProcessBuilder builder, Map<String, String> environment) { for (Entry<String, String> entry : environment.entrySet()) { builder.environment().put(entry.getKey(), entry.getValue()); } } }
8,642
28.298305
112
java
jkind
jkind-master/jkind-api/src/jkind/api/JLustre2ExcelApi.java
package jkind.api; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import jkind.JKindException; import jkind.lustre.Program; /** * The primary interface to JLustre2Excel. */ public class JLustre2ExcelApi { private DebugLogger debug = new DebugLogger(); private String jkindJar; /** * Put the JLustre2Excel into debug mode where it saves all output */ public void setApiDebug() { debug = new DebugLogger("jlustre2excel-api-debug-"); } /** * Print string to debug log (assuming setApiDebug() has been called) * * @param text * text to print to debug log */ public void apiDebug(String text) { if (debug != null) { debug.println(text); } } /** * Provide a fixed JKind jar file to use */ public void setJKindJar(String jkindJar) { if (!new File(jkindJar).exists()) { throw new JKindException("JKind jar file does not exist: " + jkindJar); } this.jkindJar = jkindJar; } /** * Run JLustre2Excel on a Lustre program * * @param program * Lustre program * @return Excel file * @throws jkind.JKindException */ public File execute(Program program) { return execute(program.toString()); } /** * Run JLustre2Excel on a Lustre program * * @param program * Lustre program as text * @return * @return Excel file * @throws jkind.JKindException */ public File execute(String program) { File lustreFile = null; try { lustreFile = ApiUtil.writeLustreFile(program); return execute(lustreFile); } finally { debug.deleteIfUnneeded(lustreFile); } } /** * Run JLustre2Excel on a Lustre program * * @param lustreFile * File containing Lustre program * @return Excel file * @throws jkind.JKindException */ public File execute(File lustreFile) { ProcessBuilder pb = getJLustre2ExcelProcessBuilder(lustreFile); Process process = null; try { process = pb.start(); String output = ApiUtil.readOutput(process, new ApiUtil.ICancellationMonitor() { @Override public boolean isCanceled() { return false; } @Override public void done() {} }); debug.println("JLustre2Excel output", debug.saveFile("jlustre2excel-output-", ".txt", output)); return new File(lustreFile.getPath() + ".xls"); } catch (IOException e) { throw new JKindException("Error running JLustre2Excel", e); } finally { int code = 0; if (process != null) { if (process.isAlive()) { process.destroy(); } try { code = process.waitFor(); } catch (InterruptedException e) { } if (code != 0) { throw new JKindException("Abnormal termination, exit code " + code); } } } } private ProcessBuilder getJLustre2ExcelProcessBuilder(File lustreFile) { List<String> args = new ArrayList<>(); args.addAll(Arrays.asList(getJLustre2Excel())); args.add(lustreFile.toString()); ProcessBuilder builder = new ProcessBuilder(args); builder.redirectErrorStream(true); return builder; } private String[] getJLustre2Excel() { return new String[] { ApiUtil.getJavaPath(), "-jar", getOrFindJKindJar(), "-jlustre2excel" }; } private String getOrFindJKindJar() { if (jkindJar != null) { return jkindJar; } else { return ApiUtil.findJKindJar().toString(); } } }
3,337
23.188406
98
java
jkind
jkind-master/jkind-api/src/jkind/api/JRealizabilityApi.java
package jkind.api; import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import org.eclipse.core.runtime.IProgressMonitor; import jkind.JKindException; import jkind.api.ApiUtil.ICancellationMonitor; import jkind.api.results.JRealizabilityResult; import jkind.lustre.Program; /** * The primary interface to JRealizability. */ public class JRealizabilityApi { private Integer timeout = null; private Integer n = null; private boolean extendCounterexample = false; private boolean reduce = false; private DebugLogger debug = new DebugLogger(); private List<String> vmArgs = Collections.emptyList(); private String jkindJar; private Map<String, String> environment = new HashMap<>(); /** * Set a maximum run time for entire execution * * @param timeout * A positive timeout in seconds */ public void setTimeout(int timeout) { if (timeout <= 0) { throw new JKindException("Timeout must be positive"); } this.timeout = timeout; } /** * Set a maximum path length in realizability checking algorithm * * @param n * A non-negative integer */ public void setN(int n) { if (n < 0) { throw new JKindException("n must be positive"); } this.n = n; } /** * Produce extend counterexample if realizability is 'unknown' */ public void setExtendCounterexamples() { extendCounterexample = true; } /** * Reduce conflicting properties in the case of 'unrealizable' */ public void setReduce() { reduce = true; } /** * Put the RealizabilityApi into debug mode where it saves all output */ public void setApiDebug() { debug = new DebugLogger("jrealizability-api-debug-"); } /** * Print string to debug log (assuming setApiDebug() has been called) * * @param text * text to print to debug log */ public void apiDebug(String text) { if (debug != null) { debug.println(text); } } /** * Provide a fixed JKind jar file to use */ public void setJKindJar(String jkindJar) { if (!new File(jkindJar).exists()) { throw new JKindException("JKind jar file does not exist: " + jkindJar); } this.jkindJar = jkindJar; } /** * Set an environment variable for the JRealizability process */ public void setEnvironment(String key, String value) { environment.put(key, value); } /** * Set VM args */ public void setVmArgs(List<String> args) { vmArgs = new ArrayList<>(args); } /** * Run JRealizability on a Lustre program * * @param program * Lustre program * @param result * Place to store results as they come in * @param monitor * Used to check for cancellation * @throws jkind.JKindException * @deprecated To be removed in 5.0. * Use {@link jkind.api.eclipse.JRealizabilityApi.execute()} instead. */ @Deprecated public void execute(Program program, JRealizabilityResult result, IProgressMonitor monitor) { execute(program.toString(), result, new jkind.api.eclipse.ApiUtil.CancellationMonitor(monitor)); } /** * Run JRealizability on a Lustre program * * @param program * Lustre program * @param result * Place to store results as they come in * @param monitor * Used to check for cancellation * @throws jkind.JKindException */ public void execute(Program program, JRealizabilityResult result, ICancellationMonitor monitor) { execute(program.toString(), result, monitor); } /** * Run JRealizability on a Lustre program * * @param program * Lustre program as text * @param result * Place to store results as they come in * @param monitor * Used to check for cancellation * @throws jkind.JKindException * @deprecated To be removed in 5.0. * Use {@link jkind.api.eclipse.JRealizabilityApi.execute()} instead. */ @Deprecated public void execute(String program, JRealizabilityResult result, IProgressMonitor monitor) { execute(program, result, new jkind.api.eclipse.ApiUtil.CancellationMonitor(monitor)); } /** * Run JRealizability on a Lustre program * * @param program * Lustre program as text * @param result * Place to store results as they come in * @param monitor * Used to check for cancellation * @throws jkind.JKindException */ public void execute(String program, JRealizabilityResult result, ICancellationMonitor monitor) { File lustreFile = null; try { lustreFile = ApiUtil.writeLustreFile(program); execute(lustreFile, result, monitor); } finally { debug.deleteIfUnneeded(lustreFile); } } /** * Run JRealizability on a Lustre program * * @param lustreFile * File containing Lustre program * @param result * Place to store results as they come in * @param monitor * Used to check for cancellation * @throws jkind.JKindException * @deprecated To be removed in 5.0. * Use {@link jkind.api.eclipse.JRealizabilityApi.execute()} instead. */ @Deprecated public void execute(File lustreFile, JRealizabilityResult result, IProgressMonitor monitor) { execute(lustreFile, result, new jkind.api.eclipse.ApiUtil.CancellationMonitor(monitor)); } /** * Run JRealizability on a Lustre program * * @param lustreFile * File containing Lustre program * @param result * Place to store results as they come in * @param monitor * Used to check for cancellation * @throws jkind.JKindException */ public void execute(File lustreFile, JRealizabilityResult result, ICancellationMonitor monitor) { ApiUtil.execute(this::getJRealizabilityProcessBuilder, lustreFile, result, monitor, debug); } protected ProcessBuilder getJRealizabilityProcessBuilder(File lustreFile) { List<String> args = new ArrayList<>(); args.addAll(Arrays.asList(getJRealizabilityCommand())); args.add("-xml"); if (timeout != null) { args.add("-timeout"); args.add(timeout.toString()); } if (n != null) { args.add("-n"); args.add(n.toString()); } if (extendCounterexample) { args.add("-extend_cex"); } if (reduce) { args.add("-reduce"); } args.add(lustreFile.toString()); ProcessBuilder builder = new ProcessBuilder(args); ApiUtil.addEnvironment(builder, environment); builder.redirectErrorStream(true); return builder; } private String[] getJRealizabilityCommand() { List<String> args = new ArrayList<>(); args.add(ApiUtil.getJavaPath()); args.addAll(vmArgs); args.add("-jar"); args.add(getOrFindJKindJar()); args.add("-jrealizability"); return args.toArray(new String[args.size()]); } private String getOrFindJKindJar() { if (jkindJar != null) { return jkindJar; } else { return ApiUtil.findJKindJar().toString(); } } public void checkAvailable() throws Exception { List<String> args = new ArrayList<>(); args.addAll(Arrays.asList(getJRealizabilityCommand())); args.add("-version"); ProcessBuilder builder = new ProcessBuilder(args); ApiUtil.addEnvironment(builder, environment); builder.redirectErrorStream(true); Process process = builder.start(); String output = ApiUtil.readAll(process.getInputStream()); if (process.waitFor() != 0) { throw new JKindException("Error running JRealizability: " + output); } } }
7,433
25.361702
98
java
jkind
jkind-master/jkind-api/src/jkind/api/DebugLogger.java
package jkind.api; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import jkind.JKindException; import jkind.util.Util; public class DebugLogger { private final PrintWriter debug; public DebugLogger() { debug = null; } public DebugLogger(String prefix) { try { File debugFile = File.createTempFile(prefix, ".txt"); debug = new PrintWriter(new FileWriter(debugFile), true); } catch (IOException e) { throw new JKindException("Unable to create temporary debug file", e); } } public void println() { if (debug != null) { debug.println(); } } public void println(String text) { if (debug != null) { debug.println(text); } } public void println(String text, File file) { if (debug != null) { try { debug.println(text + ": " + file.getCanonicalPath()); } catch (IOException e) { debug.println(text + ": " + file.getAbsolutePath()); } } } public File saveFile(String prefix, String suffix, String contents) { if (debug != null) { try { File file = File.createTempFile(prefix, suffix); Util.writeToFile(contents, file); return file; } catch (IOException e) { throw new JKindException("Unable to create temporary file", e); } } else { return null; } } public void deleteIfUnneeded(File file) { if (debug == null && file != null && file.exists()) { file.delete(); } } }
1,434
19.797101
72
java
jkind
jkind-master/jkind-api/src/jkind/api/Backend.java
package jkind.api; public enum Backend { JKIND, KIND2, SALLY }
65
10
21
java
jkind
jkind-master/jkind-api/src/jkind/api/JKindApi.java
package jkind.api; import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import org.eclipse.core.runtime.IProgressMonitor; import jkind.JKindException; import jkind.SolverOption; import jkind.api.ApiUtil.ICancellationMonitor; import jkind.api.results.JKindResult; /** * The primary interface to JKind. */ public class JKindApi extends KindApi { protected Integer n = null; protected boolean boundedModelChecking = true; protected boolean kInduction = true; protected boolean invariantGeneration = true; protected Integer pdrMax = null; protected boolean inductiveCounterexamples = false; protected boolean ivcReduction = false; protected boolean allIvcs = false; protected boolean smoothCounterexamples = false; protected boolean slicing = true; protected List<String> vmArgs = Collections.emptyList(); protected SolverOption solver = null; protected String jkindJar; protected Map<String, String> environment = new HashMap<>(); protected String readAdviceFileName = null; protected String writeAdviceFileName = null; /** * Set the maximum depth for BMC and k-induction * * @param n * A non-negative integer */ public void setN(int n) { if (n < 0) { throw new JKindException("n must be positive"); } this.n = n; } public void disableBoundedModelChecking() { boundedModelChecking = false; } public void disableKInduction() { kInduction = false; } public void disableInvariantGeneration() { invariantGeneration = false; } /** * Set the maximum number of PDR instances to run * * @param pdrMax * A non-negative integer */ public void setPdrMax(int pdrMax) { if (pdrMax < 0) { throw new JKindException("pdrMax must be positive"); } this.pdrMax = pdrMax; } /** * Produce inductive counterexamples for 'unknown' properties */ public void setInductiveCounterexamples() { inductiveCounterexamples = true; } /** * Set the solver to use (Yices, Z3, CVC4, ...) */ public void setSolver(SolverOption solver) { this.solver = solver; } /** * Find an inductive validity core for valid properties */ public void setIvcReduction() { ivcReduction = true; } /** * Find all inductive validity cores for valid properties */ public void setAllIvcs() { allIvcs = true; } /** * Post-process counterexamples to have minimal input value changes */ public void setSmoothCounterexamples() { smoothCounterexamples = true; } /** * Disable slicing of input model and counterexamples */ public void disableSlicing() { slicing = false; } /** * Set VM args */ public void setVmArgs(List<String> args) { vmArgs = new ArrayList<>(args); } /** * Provide a fixed JKind jar file to use */ public void setJKindJar(String jkindJar) { if (!new File(jkindJar).exists()) { throw new JKindException("JKind jar file does not exist: " + jkindJar); } this.jkindJar = jkindJar; } /** * Set an environment variable for the JKind process */ public void setEnvironment(String key, String value) { environment.put(key, value); } /* * Set the advice file to be read */ public void setReadAdviceFile(String fileName) { readAdviceFileName = fileName; } /* * Set the advice file to be written */ public void setWriteAdviceFile(String fileName) { writeAdviceFileName = fileName; } /** * Run JKind on a Lustre program * * @param lustreFile * File containing Lustre program * @param result * Place to store results as they come in * @param monitor * Used to check for cancellation * @throws jkind.JKindException * @deprecated To be removed in 5.0. * Use {@link jkind.api.eclipse.JKindApi.execute()} instead. */ @Override @Deprecated public void execute(File lustreFile, JKindResult result, IProgressMonitor monitor) { execute(lustreFile, result, new jkind.api.eclipse.ApiUtil.CancellationMonitor(monitor)); } /** * Run JKind on a Lustre program * * @param lustreFile * File containing Lustre program * @param result * Place to store results as they come in * @param monitor * Used to check for cancellation * @throws jkind.JKindException */ @Override public void execute(File lustreFile, JKindResult result, ICancellationMonitor monitor) { debug.println("Lustre file", lustreFile); ApiUtil.execute(this::getJKindProcessBuilder, lustreFile, result, monitor, debug); } private ProcessBuilder getJKindProcessBuilder(File lustreFile) { List<String> args = new ArrayList<>(); args.addAll(Arrays.asList(getJKindCommand())); args.add("-xml"); if (timeout != null) { args.add("-timeout"); args.add(timeout.toString()); } if (n != null) { args.add("-n"); args.add(n.toString()); } if (!boundedModelChecking) { args.add("-no_bmc"); } if (!kInduction) { args.add("-no_k_induction"); } if (!invariantGeneration) { args.add("-no_inv_gen"); } if (pdrMax != null) { args.add("-pdr_max"); args.add(pdrMax.toString()); } if (inductiveCounterexamples) { args.add("-induct_cex"); } if (ivcReduction) { args.add("-ivc"); } if (allIvcs) { args.add("-all_ivcs"); } if (smoothCounterexamples) { args.add("-smooth"); } if (!slicing) { args.add("-no_slicing"); } if (solver != null) { args.add("-solver"); args.add(solver.toString()); } String tempDir = System.getProperty("java.io.tmpdir"); if (readAdviceFileName != null) { args.add("-read_advice"); args.add(new File(tempDir, readAdviceFileName).getAbsolutePath()); } if (writeAdviceFileName != null) { args.add("-write_advice"); args.add(new File(tempDir, writeAdviceFileName).getAbsolutePath()); } args.add(lustreFile.toString()); ProcessBuilder builder = new ProcessBuilder(args); ApiUtil.addEnvironment(builder, environment); builder.redirectErrorStream(true); return builder; } protected String[] getJKindCommand() { List<String> args = new ArrayList<>(); args.add(ApiUtil.getJavaPath()); args.addAll(vmArgs); args.add("-jar"); args.add(getOrFindJKindJar()); args.add("-jkind"); return args.toArray(new String[args.size()]); } private String getOrFindJKindJar() { if (jkindJar != null) { return jkindJar; } else { return ApiUtil.findJKindJar().toString(); } } @Override public String checkAvailable() throws Exception { List<String> args = new ArrayList<>(); args.addAll(Arrays.asList(getJKindCommand())); args.add("-version"); ProcessBuilder builder = new ProcessBuilder(args); ApiUtil.addEnvironment(builder, environment); builder.redirectErrorStream(true); Process process = builder.start(); String output = ApiUtil.readAll(process.getInputStream()); if (process.waitFor() != 0) { throw new JKindException("Error running JKind: " + output); } return output; } }
7,017
22.709459
90
java
jkind
jkind-master/jkind-api/src/jkind/api/results/Renaming.java
package jkind.api.results; import static java.util.stream.Collectors.toList; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Map.Entry; import java.util.Set; import java.util.function.Function; import jkind.JKindException; import jkind.lustre.VarDecl; import jkind.lustre.values.EnumValue; import jkind.lustre.values.Value; import jkind.results.Counterexample; import jkind.results.FunctionTable; import jkind.results.FunctionTableRow; import jkind.results.InconsistentProperty; import jkind.results.InvalidProperty; import jkind.results.Property; import jkind.results.Signal; import jkind.results.UnknownProperty; import jkind.results.ValidProperty; /** * A class for renaming and removing variables from analysis results * * @see MapRenaming */ public abstract class Renaming { /** * Returns the new name for a given name, or null if the original name * should be hidden. This method should always return the same result when * given the same input. * * @param original * Original variable name * @return the new variable name or null if variable should be hidden */ public abstract String rename(String original); /** * Rename property and signals (if present), possibly omitting some * * @param property * Property to be renamed * @return Renamed version of the property, or <code>null</code> if there is * no renaming for the property */ public Property rename(Property property) { if (property instanceof ValidProperty) { return rename((ValidProperty) property); } else if (property instanceof InvalidProperty) { return rename((InvalidProperty) property); } else if (property instanceof UnknownProperty) { return rename((UnknownProperty) property); } else if (property instanceof InconsistentProperty) { return rename((InconsistentProperty) property); } else { return null; } } /** * Rename valid property and signals (if present), possibly omitting some * * Note: Invariants (if present) will not be renamed * * @param property * Property to be renamed * @return Renamed version of the property, or <code>null</code> if there is * no renaming for the property */ public ValidProperty rename(ValidProperty property) { String name = rename(property.getName()); if (name == null) { return null; } return new ValidProperty(name, property.getSource(), property.getK(), property.getRuntime(), property.getInvariants(), rename(this::renameIVC, property.getIvc()), property.getInvariantSets(), rename(this::renameIVC, property.getIvcSets()), property.getMivcTimedOut()); } /** * Rename invalid property and signals (if present), possibly omitting some * * @param property * Property to be renamed * @return Renamed version of the property, or <code>null</code> if there is * no renaming for the property */ public InvalidProperty rename(InvalidProperty property) { String name = rename(property.getName()); if (name == null) { return null; } return new InvalidProperty(name, property.getSource(), rename(property.getCounterexample()), rename(this::rename, property.getConflicts()), property.getRuntime(), property.getReport()); } /** * Rename unknown property and signals (if present), possibly omitting some * * @param property * Property to be renamed * @return Renamed version of the property, or <code>null</code> if there is * no renaming for the property */ public UnknownProperty rename(UnknownProperty property) { String name = rename(property.getName()); if (name == null) { return null; } return new UnknownProperty(name, property.getTrueFor(), rename(property.getInductiveCounterexample()), property.getRuntime()); } /** * Rename inconsistent property * * @param property * Property to be renamed * @return Renamed version of the property, or <code>null</code> if there is * no renaming for the property */ public InconsistentProperty rename(InconsistentProperty property) { String name = rename(property.getName()); if (name == null) { return null; } return new InconsistentProperty(name, property.getSource(), property.getK(), property.getRuntime()); } /** * Rename signals in a counterexample, possibly omitting some * * @param cex * Counterexample to be renamed * @return Renamed version of the counterexample */ protected Counterexample rename(Counterexample cex) { if (cex == null) { return null; } Counterexample result = new Counterexample(cex.getLength()); for (Signal<Value> signal : cex.getSignals()) { Signal<Value> newSignal = rename(signal); if (newSignal != null) { result.addSignal(newSignal); } } for (FunctionTable table : cex.getFunctionTables()) { FunctionTable newTable = rename(table); if (newTable != null) { result.addFunctionTable(newTable); } } return result; } protected FunctionTable rename(FunctionTable table) { String name = rename(table.getName()); if (name == null) { return null; } List<VarDecl> inputs = table.getInputs().stream().map(this::rename).collect(toList()); if (inputs.contains(null)) { return null; } VarDecl output = rename(table.getOutput()); if (output == null) { return null; } FunctionTable result = new FunctionTable(name, inputs, output); for (FunctionTableRow row : table.getRows()) { List<Value> inputValues = row.getInputs().stream().map(this::rename).collect(toList()); Value outputValue = rename(row.getOutput()); result.addRow(inputValues, outputValue); } return result; } private VarDecl rename(VarDecl vd) { String id = rename(vd.id); if (id == null) { return null; } else { return new VarDecl(id, vd.type); } } private Value rename(Value value) { if (value instanceof EnumValue) { EnumValue ev = (EnumValue) value; String renamedValue = rename(ev.value); if (renamedValue == null) { throw new JKindException("Failed when renaming enumeration value: " + ev.value); } return new EnumValue(renamedValue); } else { return value; } } /** * Rename signal * * @param <T> * * @param signal * The signal to be renamed * @return Renamed version of the signal or <code>null</code> if there is no * renaming for it */ @SuppressWarnings("unchecked") private <T extends Value> Signal<T> rename(Signal<T> signal) { String name = rename(signal.getName()); if (name == null) { return null; } Signal<T> newSignal = new Signal<>(name); for (Entry<Integer, T> entry : signal.getValues().entrySet()) { newSignal.putValue(entry.getKey(), (T) rename(entry.getValue())); } return newSignal; } /** * Rename a collection of elements, possibly omitting some * * @param es * Strings to be renamed * @return Renamed version of the conflicts */ private List<String> rename(Function<String, String> f, Collection<String> es) { List<String> updatedOrigList = new ArrayList<String>(); for (String curOrigStr : es) { String updatedName = curOrigStr; if (curOrigStr.contains(".")) { updatedName = updatedNodeElemName(curOrigStr); } updatedOrigList.add(updatedName); } List<String> renamedList = updatedOrigList.stream().map(f).filter(e -> e != null).collect(toList()); return renamedList; } private Set<List<String>> rename(Function<String, String> f, Set<List<String>> es) { Set<List<String>> set = new HashSet<List<String>>(); for (List<String> curOrigList : es) { List<String> updatedOrigList = new ArrayList<String>(); for (String curOrigStr : curOrigList) { String updatedName = curOrigStr; if (curOrigStr.contains(".")) { updatedName = updatedNodeElemName(curOrigStr); } updatedOrigList.add(updatedName); } List<String> renamedList = updatedOrigList.stream().map(f).filter(e -> e != null).collect(toList()); set.add(renamedList); } return set; } private String updatedNodeElemName(String curOrigStr) { String updatedName; String nodeName = curOrigStr.substring(0, curOrigStr.lastIndexOf('.')); String elemName = curOrigStr.substring(curOrigStr.lastIndexOf('.'), curOrigStr.length()); nodeName = nodeName.replaceAll("~([0-9]+)$", ""); updatedName = nodeName + elemName; return updatedName; } /** * Rename an IVC variable * * @param ivc * the string to be renamed * @return Renamed version of the ivc string */ public String renameIVC(String ivc) { return rename(ivc); } }
8,690
27.778146
104
java
jkind
jkind-master/jkind-api/src/jkind/api/results/Status.java
package jkind.api.results; public enum Status { WORKING, VALID, INVALID, UNKNOWN, INCONSISTENT, CANCELED, ERROR, WAITING, VALID_REFINED; @Override public String toString() { switch (this) { case WORKING: return "Working"; case VALID: return "Valid"; case INVALID: return "Invalid"; case UNKNOWN: return "Unknown"; case INCONSISTENT: return "Inconsistent"; case CANCELED: return "Canceled"; case ERROR: return "Error"; case WAITING: return "Waiting"; case VALID_REFINED: return "Valid (refined)"; default: return ""; } } }
582
17.21875
89
java
jkind
jkind-master/jkind-api/src/jkind/api/results/JKindResult.java
package jkind.api.results; import static java.util.stream.Collectors.toList; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.List; import jkind.excel.ExcelFormatter; import jkind.results.Property; import jkind.results.layout.Layout; import jkind.results.layout.SingletonLayout; /** * This class holds the results of a run of JKind. * * Each property is tracked using a {@link PropertyResult} class. * * Note on renaming: This object can be configured with a {@link Renaming} which * changes the names of properties and signals as they arrive. In this case, all * properties are added and retrieved using their original names. * * @see PropertyResult */ public class JKindResult extends AnalysisResult implements PropertyChangeListener { private String text; private final List<PropertyResult> propertyResults = new ArrayList<>(); private final MultiStatus multiStatus = new MultiStatus(); private Ticker ticker; private Renaming renaming; /** * Construct an empty JKindResult to hold the results of a run of JKind * * @param name * Name of the results */ public JKindResult(String name) { super(name); } /** * Construct a JKindResult to hold the results of a run of JKind * * @param name * Name of the results * @param properties * Property names to track */ public JKindResult(String name, List<String> properties) { super(name); addProperties(properties); } /** * Construct a JKindResult to hold the results of a run of JKind * * @param name * Name of the results * @param renaming * Renaming to apply to properties */ public JKindResult(String name, Renaming renaming) { super(name); this.renaming = renaming; } /** * Construct a JKindResult to hold the results of a run of JKind * * @param name * Name of the results * @param properties * Property names to track (pre-renaming) * @param renaming * Renaming to apply to properties */ public JKindResult(String name, List<String> properties, Renaming renaming) { super(name); this.renaming = renaming; addProperties(properties); } /** * Construct a JKindResult to hold the results of a run of JKind * * @param name * Name of the results * @param properties * Property names to track (pre-renaming) * @param invertStatus * True if the status of the property of the same index in * properties should be inverted */ public JKindResult(String name, List<String> properties, List<Boolean> invertStatus) { super(name); addProperties(properties, invertStatus); } /** * Construct a JKindResult to hold the results of a run of JKind * * @param name * Name of the results * @param properties * Property names to track (pre-renaming) * @param invertStatus * True if the status of the property of the same index in * properties should be inverted * @param renaming * Renaming to apply to properties */ public JKindResult(String name, List<String> properties, List<Boolean> invertStatus, Renaming renaming) { super(name); this.renaming = renaming; addProperties(properties, invertStatus); } private void addProperties(List<String> properties, List<Boolean> invertStatus) { int i = 0; if (properties.size() != invertStatus.size()) { throw new IllegalArgumentException("Lists have different length"); } for (String property : properties) { addProperty(property, invertStatus.get(i++)); } } /** * Add a new property to track * * @param property * Property to be tracked (pre-renaming) * @param invertStatus * True if finding a model means success. Otherwise false. * @return The PropertyResult object which will store the results of the * property */ public PropertyResult addProperty(String property, boolean invertStatus) { if (renaming != null) { property = renaming.rename(property); if (property == null) { return null; } } PropertyResult propertyResult = new PropertyResult(property, renaming, invertStatus); propertyResults.add(propertyResult); propertyResult.setParent(this); pcs.fireIndexedPropertyChange("propertyResults", propertyResults.size() - 1, null, propertyResult); addStatus(propertyResult.getStatus()); propertyResult.addPropertyChangeListener(this); return propertyResult; } /** * Add a new property to track * * @param property * Property to be tracked (pre-renaming) * @return The PropertyResult object which will store the results of the * property */ public PropertyResult addProperty(String property) { return addProperty(property, false); } /** * Add a property to track (with inverted status) * * @param property * Property to be tracked (pre-renaming) * @return The PropertyResult object which will store the results of the * property */ public PropertyResult addInvertedProperty(String property) { return addProperty(property, true); } /** * Add a new properties to track * * @param properties * Properties to be tracked (pre-renaming) * @return List of the PropertyResult objects which will store the results * of the properties */ public List<PropertyResult> addProperties(List<String> properties) { return properties.stream().map(this::addProperty).collect(toList()); } /** * Add a new properties to track (with inverted status) * * @param properties * Properties to be tracked (pre-renaming) * @return List of the PropertyResult objects which will store the results * of the properties */ public List<PropertyResult> addInvertedProperties(List<String> properties) { return properties.stream().map(this::addInvertedProperty).collect(toList()); } private void addStatus(Status other) { multiStatus.add(other); pcs.firePropertyChange("status", null, other); } /** * Get all PropertyResult objects stored in the JKindResult */ public List<PropertyResult> getPropertyResults() { return Collections.unmodifiableList(propertyResults); } /** * Get a specific PropertyResult by property name * * @param name * Name of property to retrieve (pre-renaming) * @return Property with the given name or <code>null</code> if not found */ public PropertyResult getPropertyResult(String name) { if (renaming != null) { name = renaming.rename(name); if (name == null) { return null; } } for (PropertyResult pr : propertyResults) { if (pr.getName().equals(name)) { return pr; } } return null; } public void setText(String text) { this.text = text; } public String getText() { return text; } public MultiStatus getMultiStatus() { return multiStatus; } public void start() { for (PropertyResult pr : propertyResults) { pr.start(); } ticker = new Ticker(this); ticker.start(); } public void tick() { for (PropertyResult pr : propertyResults) { pr.tick(); } } public void cancel() { for (PropertyResult pr : propertyResults) { pr.cancel(); } if (ticker != null) { ticker.done(); } } public void done() { for (PropertyResult pr : propertyResults) { pr.done(); } if (ticker != null) { ticker.done(); } } public void setBaseProgress(int k) { for (PropertyResult pr : propertyResults) { pr.setBaseProgress(k); } } /** * Convert results to an Excel spreadsheet * * Using this requires the jxl.jar file in your classpath * * @param file * File to write Excel spreadsheet to * @param layout * Layout information for counterexamples, defined over renamed * signals * @see Layout * @throws jkind.JKindException */ public void toExcel(File file, Layout layout) { try (ExcelFormatter formatter = new ExcelFormatter(file, layout)) { formatter.write(getProperties()); } } private List<Property> getProperties() { List<Property> properties = new ArrayList<>(); for (PropertyResult pr : propertyResults) { if (pr.getProperty() != null) { properties.add(pr.getProperty()); } } return properties; } /** * Convert results to an Excel spreadsheet using default layout * * Using this requires the jxl.jar file in your classpath * * @param file * File to write Excel spreadsheet to * @throws jkind.JKindException */ public void toExcel(File file) { toExcel(file, new SingletonLayout("Signals")); } /** * Discard details such as counterexamples and IVCs to save space */ public void discardDetails() { for (PropertyResult pr : propertyResults) { if (pr.getProperty() != null) { pr.getProperty().discardDetails(); } } } @Override public void propertyChange(PropertyChangeEvent evt) { // Status updates from immediate children are noted and propagated if ("status".equals(evt.getPropertyName()) && propertyResults.contains(evt.getSource())) { multiStatus.remove((Status) evt.getOldValue()); multiStatus.add((Status) evt.getNewValue()); pcs.firePropertyChange("status", evt.getOldValue(), evt.getNewValue()); } if ("multiStatus".equals(evt.getPropertyName()) && propertyResults.contains(evt.getSource())) { multiStatus.remove((MultiStatus) evt.getOldValue()); multiStatus.add((MultiStatus) evt.getNewValue()); pcs.firePropertyChange("multiStatus", evt.getOldValue(), evt.getNewValue()); } } @Override public String toString() { return name + propertyResults; } }
9,790
25.751366
106
java
jkind
jkind-master/jkind-api/src/jkind/api/results/Ticker.java
package jkind.api.results; public class Ticker extends Thread { private JKindResult result; private boolean done; public Ticker(JKindResult result) { super("Ticker"); this.result = result; this.done = false; } @Override public void run() { try { while (!done) { Thread.sleep(1000); result.tick(); } } catch (InterruptedException e) { } } public void done() { done = true; } }
417
13.928571
36
java
jkind
jkind-master/jkind-api/src/jkind/api/results/MapRenaming.java
package jkind.api.results; import java.util.Map; /** * A renaming backed by a map from strings to strings */ public class MapRenaming extends Renaming { private final Map<String, String> map; private final Mode mode; public static enum Mode { NULL, IDENTITY } public MapRenaming(Map<String, String> map, Mode mode) { super(); this.map = map; this.mode = mode; } @Override public String rename(String original) { String renamed = map.get(original); if (renamed == null && mode == Mode.IDENTITY) { return original; } else { return renamed; } } }
582
17.21875
57
java
jkind
jkind-master/jkind-api/src/jkind/api/results/MultiStatus.java
package jkind.api.results; import java.util.EnumMap; import java.util.StringJoiner; public class MultiStatus { final private EnumMap<Status, Integer> map = new EnumMap<>(Status.class); public int getCount(Status status) { if (map.containsKey(status)) { return map.get(status); } else { return 0; } } public void add(Status status) { if (status != null) { map.put(status, getCount(status) + 1); } } public void add(MultiStatus other) { if (other != null) { for (Status key : other.map.keySet()) { map.put(key, getCount(key) + other.map.get(key)); } } } public void remove(Status status) { if (status != null) { map.put(status, getCount(status) - 1); } } public void remove(MultiStatus other) { if (other != null) { for (Status key : other.map.keySet()) { map.put(key, getCount(key) - other.map.get(key)); } } } private static final Status[] PRECEDENCE = new Status[] { Status.WORKING, Status.WAITING, Status.ERROR, Status.INVALID, Status.INCONSISTENT, Status.UNKNOWN, Status.CANCELED, Status.VALID }; public Status getOverallStatus() { for (Status status : PRECEDENCE) { if (getCount(status) > 0) { return status; } } return null; } @Override public String toString() { StringJoiner text = new StringJoiner(", "); for (Status status : PRECEDENCE) { int count = getCount(status); if (count > 0) { text.add(count + " " + status); } } return text.toString(); } }
1,481
20.171429
104
java
jkind
jkind-master/jkind-api/src/jkind/api/results/ResultsUtil.java
package jkind.api.results; public class ResultsUtil { public static MultiStatus getMultiStatus(AnalysisResult result) { if (result instanceof CompositeAnalysisResult) { return ((CompositeAnalysisResult) result).getMultiStatus(); } else if (result instanceof JKindResult) { return ((JKindResult) result).getMultiStatus(); } else { return null; } } }
369
25.428571
66
java
jkind
jkind-master/jkind-api/src/jkind/api/results/PropertyResult.java
package jkind.api.results; import jkind.JKindException; import jkind.results.InconsistentProperty; import jkind.results.InvalidProperty; import jkind.results.Property; import jkind.results.UnknownProperty; import jkind.results.ValidProperty; public class PropertyResult extends AnalysisResult { private Property property; private final Renaming renaming; private boolean invertStatus = false; private boolean invalidInPast = false; private int elapsed; private int baseProgress; private Status status; public PropertyResult(String name, Renaming renaming, boolean invertStatus) { this(name, renaming); this.invertStatus = invertStatus; } public PropertyResult(String name, Renaming renaming) { super(name); this.elapsed = 0; this.status = Status.WAITING; this.property = null; this.renaming = renaming; } public Property getProperty() { return property; } public int getElapsed() { return elapsed; } public int getBaseProgress() { return baseProgress; } public Status getStatus() { return status; } public boolean isInverted() { return invertStatus; } public void setProperty(Property original) { if (renaming == null) { property = original; } else { property = renaming.rename(original); } if (property instanceof ValidProperty) { if (invalidInPast) { if (invertStatus) { throw new JKindException("Refinement not supported for inverted property"); } setStatus(Status.VALID_REFINED); } else { setStatus(invertStatus ? Status.INVALID : Status.VALID); } } else if (property instanceof InvalidProperty) { setStatus(invertStatus ? Status.VALID : Status.INVALID); } else if (property instanceof UnknownProperty) { setStatus(Status.UNKNOWN); } else if (property instanceof InconsistentProperty) { setStatus(Status.INCONSISTENT); } } public void start() { setStatus(Status.WORKING); } public void tick() { if (status == Status.WORKING) { pcs.firePropertyChange("elapased", elapsed, ++elapsed); } } public void cancel() { if (status == Status.WORKING || status == Status.WAITING) { setStatus(Status.CANCELED); } } public void done() { if (status == Status.WORKING || status == Status.WAITING) { setStatus(Status.ERROR); } } public void setBaseProgress(int k) { if (status == Status.WORKING) { pcs.firePropertyChange("progress", baseProgress, baseProgress = k); } } private void setStatus(Status status) { if (this.status == Status.INVALID) { invalidInPast = true; } pcs.firePropertyChange("status", this.status, this.status = status); } @Override public String toString() { return name + " - " + status; } }
2,683
21.745763
80
java
jkind
jkind-master/jkind-api/src/jkind/api/results/CompositeAnalysisResult.java
package jkind.api.results; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.ArrayList; import java.util.Collections; import java.util.List; public class CompositeAnalysisResult extends AnalysisResult implements PropertyChangeListener { final private List<AnalysisResult> children = new ArrayList<>(); final private MultiStatus multiStatus = new MultiStatus(); public CompositeAnalysisResult(String name) { super(name); } public void addChild(AnalysisResult child) { children.add(child); child.setParent(this); pcs.fireIndexedPropertyChange("children", children.size() - 1, null, child); addMultiStatus(ResultsUtil.getMultiStatus(child)); child.addPropertyChangeListener(this); } private void addMultiStatus(MultiStatus other) { multiStatus.add(other); pcs.firePropertyChange("multiStatus", null, other); } public List<AnalysisResult> getChildren() { return Collections.unmodifiableList(children); } public MultiStatus getMultiStatus() { return multiStatus; } @Override public void propertyChange(PropertyChangeEvent evt) { // Status updates from immediate children are noted and propagated if ("status".equals(evt.getPropertyName()) && children.contains(evt.getSource())) { multiStatus.remove((Status) evt.getOldValue()); multiStatus.add((Status) evt.getNewValue()); pcs.firePropertyChange("status", evt.getOldValue(), evt.getNewValue()); } if ("multiStatus".equals(evt.getPropertyName()) && children.contains(evt.getSource())) { multiStatus.remove((MultiStatus) evt.getOldValue()); multiStatus.add((MultiStatus) evt.getNewValue()); pcs.firePropertyChange("multiStatus", evt.getOldValue(), evt.getNewValue()); } } @Override public String toString() { return name + children; } }
1,806
29.627119
95
java
jkind
jkind-master/jkind-api/src/jkind/api/results/JRealizabilityResult.java
package jkind.api.results; import java.util.Collections; import jkind.util.Util; /** * This class holds the results of a run of JRealizability. * Note on renaming: This object can be configured with a {@link Renaming} which * changes the names of properties and signals as they arrive. In this case, all * properties are added and retrieved using their original names. * * @see PropertyResult */ public class JRealizabilityResult extends JKindResult { /** * Construct a JRealizabilityResult to hold the results of a run of JRealizability * * @param name * Name of the results */ public JRealizabilityResult(String name) { super(name, Collections.singletonList(Util.REALIZABLE)); } /** * Construct a JRealizabilityResult to hold the results of a run of JRealizability * * @param name * Name of the results * @param renaming * Renaming to apply to apply properties */ public JRealizabilityResult(String name, Renaming renaming) { super(name, Collections.singletonList(Util.REALIZABLE), renaming); } /** * Get the PropertyResult for realizability */ public PropertyResult getPropertyResult() { return getPropertyResult(Util.REALIZABLE); } }
1,232
25.804348
83
java
jkind
jkind-master/jkind-api/src/jkind/api/results/AnalysisResult.java
package jkind.api.results; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; public abstract class AnalysisResult { protected final String name; protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this); protected AnalysisResult parent; public AnalysisResult(String name) { this.name = name; } public String getName() { return name; } public void setParent(AnalysisResult parent) { pcs.firePropertyChange("parent", this.parent, this.parent = parent); } public AnalysisResult getParent() { return parent; } public void addPropertyChangeListener(PropertyChangeListener listener) { pcs.addPropertyChangeListener(listener); } public void removePropertyChangeListener(PropertyChangeListener listener) { pcs.removePropertyChangeListener(listener); } }
832
22.8
77
java
jkind
jkind-master/jkind-api/src/jkind/api/xml/JKindXmlFileInputStream.java
package jkind.api.xml; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; public class JKindXmlFileInputStream extends InputStream { private final File xmlFile; private InputStream stream; private volatile boolean done; private static final int POLL_INTERVAL = 100; public JKindXmlFileInputStream(File xmlFile) { this.xmlFile = xmlFile; this.stream = null; this.done = false; } @Override public int read() throws IOException { if (!getStream()) { return -1; } int c; try { while ((c = stream.read()) == -1 && !done) { Thread.sleep(POLL_INTERVAL); } } catch (InterruptedException e) { return -1; } return c; } private boolean getStream() { if (stream == null) { try { while (!xmlFile.exists() && !done) { Thread.sleep(POLL_INTERVAL); } } catch (InterruptedException e) { return false; } try { stream = new BufferedInputStream(new FileInputStream(xmlFile)); } catch (FileNotFoundException e) { // File deleted before we could open it return false; } } return true; } public void done() { done = true; } @Override public void close() throws IOException { if (stream != null) { stream.close(); stream = null; } } }
1,371
17.794521
67
java
jkind
jkind-master/jkind-api/src/jkind/api/xml/XmlParseThread.java
package jkind.api.xml; import java.io.InputStream; import java.io.StringReader; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; import jkind.JKindException; import jkind.api.Backend; import jkind.api.results.JKindResult; import jkind.api.results.PropertyResult; import jkind.lustre.NamedType; import jkind.lustre.Type; import jkind.lustre.VarDecl; import jkind.lustre.values.Value; import jkind.results.Counterexample; import jkind.results.FunctionTable; import jkind.results.InconsistentProperty; import jkind.results.InvalidProperty; import jkind.results.Property; import jkind.results.Signal; import jkind.results.UnknownProperty; import jkind.results.ValidProperty; import jkind.util.Util; public class XmlParseThread extends Thread { private final InputStream xmlStream; private final JKindResult result; private final Backend backend; private final DocumentBuilderFactory factory; private volatile Throwable throwable; private Map<String, List<PropertyResult>> analysisToProps = new HashMap<>(); public XmlParseThread(InputStream xmlStream, JKindResult result, Backend backend) { super("Xml Parse"); this.xmlStream = xmlStream; this.result = result; this.backend = backend; this.factory = DocumentBuilderFactory.newInstance(); } @Override public void run() { /* * XML parsers buffer their input which conflicts with the way we are * streaming data from the XML file as it is written. This results in * data in the XML not being acted upon until more content is written to * the XML file which causes the buffer to fill. Instead, we read the * XML file ourselves and give relevant pieces of it to the parser as * they are ready. * * The downside is we assume the <Property ...> and </Property> tags are * on their own lines. */ try (LineInputStream lines = new LineInputStream(xmlStream)) { StringBuilder buffer = null; String line; String analysis = null; while ((line = lines.readLine()) != null) { boolean beginProperty = line.contains("<Property "); boolean endProperty = line.contains("</Property>"); boolean beginProgress = line.contains("<Progress "); boolean endProgress = line.contains("</Progress>"); boolean beginAnalysis = line.contains("<AnalysisStart"); boolean endAnalysis = line.contains("<AnalysisStop"); if (beginProgress && endProgress) { // Kind 2 progress format uses a single line parseKind2ProgressXml(line, analysis); } else if (beginProgress || beginProperty) { buffer = new StringBuilder(); buffer.append(line); if (endProperty) { parsePropertyXML(buffer.toString(), analysis); buffer = null; } } else if (endProperty) { buffer.append(line); parsePropertyXML(buffer.toString(), analysis); buffer = null; } else if (endProgress) { buffer.append(line); parseJKindProgressXml(buffer.toString()); buffer = null; } else if (beginAnalysis) { analysis = parseKind2AnalysisXml(line); } else if (endAnalysis) { analysis = null; } else if (buffer != null) { buffer.append(line); } } } catch (Throwable t) { throwable = t; } } private String parseKind2AnalysisXml(String line) { Element progressElement = parseXml(line); String analysis = progressElement.getAttribute("top"); analysisToProps.putIfAbsent(analysis, new ArrayList<>()); return analysis; } private Element parseXml(String xml) { try { DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(new InputSource(new StringReader(xml))); return doc.getDocumentElement(); } catch (Exception e) { throw new JKindException("Error parsing: " + xml, e); } } private void parseKind2ProgressXml(String progressXml, String analysis) { Element progressElement = parseXml(progressXml); String source = progressElement.getAttribute("source"); if ("bmc".equals(source)) { int k = Integer.parseInt(progressElement.getTextContent()); for (PropertyResult pr : analysisToProps.get(analysis)) { pr.setBaseProgress(k); } } } private void parseJKindProgressXml(String progressXml) { Element progressElement = parseXml(progressXml); String source = progressElement.getAttribute("source"); if ("bmc".equals(source)) { int trueFor = Integer.parseInt(progressElement.getAttribute("trueFor")); for (Element propertyElement : getElements(progressElement, "PropertyProgress")) { String prop = propertyElement.getAttribute("name"); PropertyResult pr = result.getPropertyResult(prop); if (pr != null) { pr.setBaseProgress(trueFor); } } } } public void parsePropertyXML(String propertyXml, String analysis) { Property prop = getProperty(parseXml(propertyXml)); String propName = prop.getName(); PropertyResult pr = getOrAddProperty(analysis, propName); if (pr != null) { pr.setProperty(prop); if (analysis != null) { analysisToProps.get(analysis).add(pr); } } } private PropertyResult getOrAddProperty(String analysis, String propName) { PropertyResult pr = result.getPropertyResult(propName); if (pr == null && analysis != null) { propName = analysis + propName; pr = result.getPropertyResult(propName); } if (pr == null) { pr = result.addProperty(propName); } return pr; } private Property getProperty(Element propertyElement) { String name = propertyElement.getAttribute("name"); double runtime = getRuntime(getElement(propertyElement, "Runtime")); int trueFor = getTrueFor(getElement(propertyElement, "TrueFor")); int k = getK(getElement(propertyElement, "K")); String answer = getAnswer(getElement(propertyElement, "Answer")); String source = getSource(getElement(propertyElement, "Answer")); int numOfIVCs = getNumOfIVCs(getElement(propertyElement, "NumberOfIVCs")); boolean mivcTimedOut = getTimedOutInfo(getElement(propertyElement, "TimedoutLoop")); List<String> invariants = getStringList(getElements(propertyElement, "Invariant")); List<String> ivc = getStringList(getElements(propertyElement, "Ivc")); Set<List<String>> invarantSets = new HashSet<List<String>>(); Set<List<String>> ivcSets = new HashSet<List<String>>(); List<String> conflicts = getConflicts(getElement(propertyElement, "Conflicts")); Counterexample cex = getCounterexample(getElement(propertyElement, getCounterexampleTag()), k); String reportFile = getReportFile(propertyElement); if (numOfIVCs == 0) { List<String> curInvariants = getStringList(getElements(propertyElement, "Invariant")); List<String> curIvc = getStringList(getElements(propertyElement, "Ivc")); invarantSets.add(curInvariants); ivcSets.add(curIvc); } else { for (int i = 0; i < numOfIVCs; i++) { Element ivcSetElem = (Element) propertyElement.getElementsByTagName("IvcSet").item(i); List<String> curInvariants = getStringList(getElements(ivcSetElem, "Invariant")); List<String> curIvc = getStringList(getElements(ivcSetElem, "Ivc")); invarantSets.add(curInvariants); ivcSets.add(curIvc); } } switch (answer) { case "valid": return new ValidProperty(name, source, k, runtime, invariants, ivc, invarantSets, ivcSets, mivcTimedOut); case "falsifiable": return new InvalidProperty(name, source, cex, conflicts, runtime, reportFile); case "unknown": return new UnknownProperty(name, trueFor, cex, runtime); case "inconsistent": return new InconsistentProperty(name, source, k, runtime); default: throw new JKindException("Unknown property answer in XML file: " + answer); } } private String getReportFile(Element propertyElement) { switch(backend) { case SALLY: return propertyElement.getAttribute("report"); default: return null; } } private double getRuntime(Node runtimeNode) { if (runtimeNode == null) { return 0; } return Double.parseDouble(runtimeNode.getTextContent()); } private int getTrueFor(Node trueForNode) { if (trueForNode == null) { return 0; } return Integer.parseInt(trueForNode.getTextContent()); } private int getK(Node kNode) { if (kNode == null) { return 0; } int k = Integer.parseInt(kNode.getTextContent()); switch (backend) { case JKIND: case SALLY: return k; case KIND2: return k + 1; default: throw new IllegalArgumentException(); } } private int getNumOfIVCs(Node numOfIVCNode) { if (numOfIVCNode == null) { return 0; } int num = Integer.parseInt(numOfIVCNode.getTextContent()); return num; } private boolean getTimedOutInfo(Node timedOutLoopNode) { if (timedOutLoopNode == null) { return false; } String timedOutInfo = timedOutLoopNode.getTextContent(); return timedOutInfo.equals("yes"); } private String getAnswer(Node answerNode) { return answerNode.getTextContent(); } private String getSource(Element answerNode) { return answerNode.getAttribute("source"); } private List<String> getStringList(List<Element> elements) { List<String> result = new ArrayList<>(); for (Element e : elements) { result.add(e.getTextContent()); } return result; } private List<String> getConflicts(Element conflictsElement) { if (conflictsElement == null) { return Collections.emptyList(); } List<String> conflicts = new ArrayList<>(); for (Element conflictElement : getElements(conflictsElement, "Conflict")) { conflicts.add(conflictElement.getTextContent()); } return conflicts; } private Counterexample getCounterexample(Element cexElement, Integer k) { if (cexElement == null) { return null; } Counterexample cex = new Counterexample(k); for (Element signalElement : getElements(cexElement, getSignalTag())) { cex.addSignal(getSignal(signalElement)); } for (Element functionElement : getElements(cexElement, "Function")) { cex.addFunctionTable(getFunction(functionElement)); } return cex; } protected String getCounterexampleTag() { switch (backend) { case JKIND: return "Counterexample"; case KIND2: case SALLY: return "CounterExample"; default: throw new IllegalArgumentException(); } } protected String getSignalTag() { switch (backend) { case JKIND: return "Signal"; case KIND2: case SALLY: return "Stream"; default: throw new IllegalArgumentException(); } } private Signal<Value> getSignal(Element signalElement) { String name = signalElement.getAttribute("name"); String type = signalElement.getAttribute("type"); if (type.contains("subrange ")) { type = "int"; } Signal<Value> signal = new Signal<>(name); for (Element valueElement : getElements(signalElement, "Value")) { int time = Integer.parseInt(valueElement.getAttribute(getTimeAttribute())); signal.putValue(time, getValue(valueElement, type)); } return signal; } protected String getTimeAttribute() { switch (backend) { case JKIND: return "time"; case KIND2: case SALLY: return "instant"; default: throw new IllegalArgumentException(); } } private Value getValue(Element valueElement, String type) { if (type.startsWith("array of")) { type = type.replaceAll("array of ", ""); return Util.parseArrayValue(type, getElement(valueElement, "Array")); } return Util.parseValue(type, valueElement.getTextContent()); } private FunctionTable getFunction(Element functionElement) { String name = functionElement.getAttribute("name"); List<VarDecl> inputs = new ArrayList<>(); for (Element inputElement : getElements(functionElement, "Input")) { inputs.add(getVarDecl(inputElement)); } VarDecl output = getVarDecl(getElement(functionElement, "Output")); FunctionTable table = new FunctionTable(name, inputs, output); for (Element fvElement : getElements(functionElement, "FunctionValue")) { List<Value> inputValues = new ArrayList<>(); List<Element> ivElements = getElements(fvElement, "InputValue"); for (int i = 0; i < inputs.size(); i++) { inputValues.add(Util.parseValue(inputs.get(i).type, ivElements.get(i).getTextContent())); } Value outputValue = Util.parseValue(output.type, getElement(fvElement, "OutputValue").getTextContent()); table.addRow(inputValues, outputValue); } return table; } private VarDecl getVarDecl(Element element) { String name = element.getAttribute("name"); Type type = NamedType.get(element.getAttribute("type")); return new VarDecl(name, type); } private Element getElement(Element element, String name) { return (Element) element.getElementsByTagName(name).item(0); } private List<Element> getElements(Element element, String name) { List<Element> elements = new ArrayList<>(); NodeList nodeList = element.getElementsByTagName(name); for (int i = 0; i < nodeList.getLength(); i++) { elements.add((Element) nodeList.item(i)); } return elements; } public Throwable getThrowable() { return throwable; } }
13,258
29.550691
108
java
jkind
jkind-master/jkind-api/src/jkind/api/xml/LineInputStream.java
package jkind.api.xml; import java.io.IOException; import java.io.InputStream; import jkind.JKindException; public class LineInputStream implements AutoCloseable { private final InputStream source; public LineInputStream(InputStream source) { this.source = source; } public String readLine() throws IOException { StringBuilder buffer = new StringBuilder(); int c; while ((c = source.read()) != -1) { buffer.append((char) c); if (c == '\n') { return buffer.toString(); } } if (buffer.length() == 0) { source.close(); return null; } else { return buffer.toString(); } } @Override public void close() { try { source.close(); } catch (IOException e) { throw new JKindException("Error closing input stream", e); } } }
779
17.139535
61
java
jkind
jkind-master/jkind-api/src/jkind/api/ui/counterexample/SignalGrouper.java
package jkind.api.ui.counterexample; import java.util.Collection; import java.util.LinkedHashMap; import java.util.Map; import jkind.lustre.values.Value; import jkind.results.Signal; public class SignalGrouper { public static Collection<SignalGroup> group(SignalGroup parent, Collection<Signal<Value>> signals) { Map<String, SignalGroup> groups = new LinkedHashMap<>(); for (Signal<Value> signal : signals) { String[] split = splitName(signal.getName()); String groupName = split[0]; String subName = split[1]; SignalGroup group = groups.get(groupName); if (group == null) { group = new SignalGroup(parent, groupName); groups.put(groupName, group); } group.addSignal(signal.rename(subName)); } return groups.values(); } private static String[] splitName(String name) { int dotIndex = name.indexOf("."); int arrayIndex = name.indexOf("[", 1); if (0 <= dotIndex && (dotIndex < arrayIndex || arrayIndex == -1)) { return new String[] { name.substring(0, dotIndex), name.substring(dotIndex + 1, name.length()) }; } if (0 <= arrayIndex && (arrayIndex < dotIndex || dotIndex == -1)) { return new String[] { name.substring(0, arrayIndex), name.substring(arrayIndex, name.length()) }; } return new String[] { name, "" }; } }
1,287
27.622222
101
java
jkind
jkind-master/jkind-api/src/jkind/api/ui/counterexample/Spacer.java
package jkind.api.ui.counterexample; public class Spacer { }
63
9.666667
36
java
jkind
jkind-master/jkind-api/src/jkind/api/ui/counterexample/SignalGroup.java
package jkind.api.ui.counterexample; import java.util.ArrayList; import java.util.Collections; import java.util.List; import jkind.lustre.values.Value; import jkind.results.Signal; public class SignalGroup { private final SignalGroup parent; private final String name; private final List<Signal<Value>> signals = new ArrayList<>(); public SignalGroup(SignalGroup parent, String name) { this.parent = parent; this.name = name; } public String getName() { return name; } public List<Signal<Value>> getSignals() { return Collections.unmodifiableList(signals); } public void addSignal(Signal<Value> signal) { signals.add(signal); } public boolean isSingleton() { return signals.size() == 1 && signals.get(0).getName().equals(""); } public SignalGroup getParent() { return parent; } }
818
19.475
68
java
jkind
jkind-master/jkind-api/src/jkind/api/eclipse/KindApi.java
package jkind.api.eclipse; import org.eclipse.core.runtime.IProgressMonitor; import jkind.api.results.JKindResult; import jkind.lustre.Program; public abstract class KindApi extends jkind.api.KindApi { /** * Run Kind on a Lustre program * * @param program * Lustre program * @param result * Place to store results as they come in * @param monitor * Used to check for cancellation * @throws jkind.JKindException */ @Override public void execute(Program program, JKindResult result, IProgressMonitor monitor) { execute(program.toString(), result, new jkind.api.eclipse.ApiUtil.CancellationMonitor(monitor)); } /** * Run Kind on a Lustre program * * @param program * Lustre program as text * @param result * Place to store results as they come in * @param monitor * Used to check for cancellation * @throws jkind.JKindException */ @Override public void execute(String program, JKindResult result, IProgressMonitor monitor) { execute(program, result, new jkind.api.eclipse.ApiUtil.CancellationMonitor(monitor)); } }
1,136
25.44186
98
java
jkind
jkind-master/jkind-api/src/jkind/api/eclipse/ApiUtil.java
package jkind.api.eclipse; import java.io.File; import java.io.IOException; import java.util.function.Function; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import jkind.api.DebugLogger; import jkind.api.results.JKindResult; public class ApiUtil extends jkind.api.ApiUtil { /** * An implementation of an (@link jkind.api.ApiUtil.ICancellationMonitor) based on using * an Eclipse IProgressMonitor. */ public static class CancellationMonitor implements jkind.api.ApiUtil.ICancellationMonitor { private IProgressMonitor monitor; public CancellationMonitor(IProgressMonitor monitor) { this.monitor = monitor; } public CancellationMonitor() { this(new NullProgressMonitor()); } @Override public boolean isCanceled() { return monitor.isCanceled(); } @Override public void done() { monitor.done(); } } public static void execute(Function<File, ProcessBuilder> runCommand, File lustreFile, JKindResult result, IProgressMonitor monitor, DebugLogger debug) { execute(runCommand, lustreFile, result, new CancellationMonitor(monitor), debug); } public static String readOutput(Process process, IProgressMonitor monitor) throws IOException { return readOutput(process, new CancellationMonitor(monitor)); } public static void readOutputToBuilder(Process process, IProgressMonitor monitor, StringBuilder outputText, StringBuilder errorText) throws IOException { readOutputToBuilder(process, new CancellationMonitor(monitor), outputText, errorText); } }
1,570
27.053571
108
java