Class StreamParser
java.lang.Object
org.infosmid.stream.dsl.AppParser
org.infosmid.stream.dsl.StreamParser
Parser for stream DSL that generates
StreamNode.-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a defaultStreamParser.StreamParser(String dsl) Construct aStreamParserwithout supplying the stream name up front.StreamParser(String name, String description, String dsl) Construct aStreamParserfor a stream with the provided name. -
Method Summary
Modifier and TypeMethodDescriptioneatAppList(boolean preceedingSourceChannelSpecified) Return a list ofAppNodestarting from the current token position.protected DestinationNodeeatDestinationReference(boolean canDefault) Return aDestinationNodefor the token at the current position.protected SinkDestinationNodeIf the current token position contains a sink destination, return aSinkDestinationNodeand advance the token position; otherwise returnnull.protected SourceDestinationNodeIf the current token position contains a source destination, return aSourceDestinationNodeand advance the token position; otherwise returnnull.protected StreamNodeReturn aStreamNodebased on the tokens resulting from the parsed DSL.protected StringIf a stream name is present, return it and advance the token position - otherwise returnnull.protected StringgetTokenData(Token token) protected booleanReturntrueif the current token position appears to be pointing at a destination.protected booleanlooksLikeDestination(int position) Returntrueif the indicated position appears to be pointing at a destination.protected DestinationNodemakeDestinationNode(int startpos, int endPos, String destinationName, ArgumentNode[] argumentNodes) protected StreamNodemakeStreamNode(String streamText, String streamName, String streamDescription, List<AppNode> appNodes, SourceDestinationNode sourceDestinationNode, SinkDestinationNode sinkDestinationNode) protected booleanReturntrueif no more pipes are present from the current token position.protected booleannoMorePipes(int position) Returntrueif no more pipes are present from the given position.parse()Parse a stream definition.Parse a stream definition with the provided name and DSL.protected TokentoString()Methods inherited from class AppParser
eatApp, eatAppArgs, eatArgValue, eatDottedName, getTokens, isValidName, makeAppNode, toData, tokenListToStringList, toLabelNode, toString
-
Constructor Details
-
StreamParser
public StreamParser()Construct a defaultStreamParser. -
StreamParser
Construct aStreamParserwithout supplying the stream name up front. The stream name may be embedded in the definition; for example:mystream = http | file.- Parameters:
dsl- the stream definition DSL text
-
StreamParser
-
-
Method Details
-
parse
Parse a stream definition with the provided name and DSL.- Parameters:
name- stream namedsl- stream DSL text- Returns:
- the AST for the parsed stream
- Throws:
ParseException- thrown if expression fails parsing.
-
parse
Parse a stream definition.- Returns:
- the AST for the parsed stream
- Throws:
ParseException- thrown if expression fails parsing.
-
eatStreamName
If a stream name is present, return it and advance the token position - otherwise returnnull.Expected format:
name =- Returns:
- stream name if present
-
eatStream
Return aStreamNodebased on the tokens resulting from the parsed DSL.Expected format:
stream: (streamName) (sourceDestination) appList (sinkDestination)- Returns:
StreamNodebased on parsed DSL
-
noMorePipes
protected boolean noMorePipes()Returntrueif no more pipes are present from the current token position.- Returns:
trueif no more pipes are present from the current token position
-
noMorePipes
protected boolean noMorePipes(int position) Returntrueif no more pipes are present from the given position.- Parameters:
position- token position from which to check for the presence of pipes- Returns:
trueif no more pipes are present from the given position
-
looksLikeDestination
protected boolean looksLikeDestination()Returntrueif the current token position appears to be pointing at a destination.- Returns:
trueif the current token position appears to be pointing at a destination
-
looksLikeDestination
protected boolean looksLikeDestination(int position) Returntrueif the indicated position appears to be pointing at a destination.- Parameters:
position- token position to check- Returns:
trueif the indicated position appears to be pointing at a destination.
-
eatSourceDestination
If the current token position contains a source destination, return aSourceDestinationNodeand advance the token position; otherwise returnnull.Expected format:
':' identifier >':' identifier '.' identifier >- Returns:
- a
SourceDestinationNodeornullif the token position is not pointing at a source destination
-
eatSinkDestination
If the current token position contains a sink destination, return aSinkDestinationNodeand advance the token position; otherwise returnnull.Expected format:
'>' ':' identifier- Returns:
- a
SinkDestinationNodeornullif the token position is not pointing at a sink destination
-
peekDestinationComponentToken
-
getTokenData
-
eatDestinationReference
Return aDestinationNodefor the token at the current position.A destination reference is the label component when referencing a specific app/label in a stream definition.
Expected format:
':' identifier [ '.' identifier ]*- Parameters:
canDefault- allows the user to peek ahead to parse a reference when working with colons in the syntax.- Returns:
DestinationNoderepresenting the destination reference
-
eatAppList
Return a list ofAppNodestarting from the current token position.Expected formats:
appList: app (| app)*A stream may end in an app (if it is a sink) or be followed by a sink destination.- Parameters:
preceedingSourceChannelSpecified- indicator to parser about state of stream.- Returns:
- a list of
AppNode
-
toString
-
makeDestinationNode
protected DestinationNode makeDestinationNode(int startpos, int endPos, String destinationName, ArgumentNode[] argumentNodes) -
makeStreamNode
protected StreamNode makeStreamNode(String streamText, String streamName, String streamDescription, List<AppNode> appNodes, SourceDestinationNode sourceDestinationNode, SinkDestinationNode sinkDestinationNode)
-