Package org.metricshub.jawk.frontend
Class AwkParser
java.lang.Object
org.metricshub.jawk.frontend.AwkParser
Converts the AWK script into a syntax tree,
which is useful the backend that either compiles or interprets the script.
It contains the internal state of the parser and the lexer.
- Author:
- Danny Daglas
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionparse(List<ScriptSource> localScriptSources) Parse the script streamed by script_reader.parseExpression(ScriptSource expressionSource) Parse a single AWK expression and return the corresponding AST.voidAdds {varName -> offset} mappings to the tuples so that global variables can be set by the interpreter while processing filename and name=value entries from the command-line.
-
Constructor Details
-
AwkParser
Constructor for AwkParser.
- Parameters:
extensions- aMapobject
-
-
Method Details
-
parse
Parse the script streamed by script_reader. Build and return the root of the abstract syntax tree which represents the Jawk script.- Parameters:
localScriptSources- List of script sources- Returns:
- The abstract syntax tree of this script.
- Throws:
IOException- upon an IO error.
-
parseExpression
Parse a single AWK expression and return the corresponding AST.- Parameters:
expressionSource- The expression to parse (not a statement or rule, just an expression)- Returns:
- tuples representing the expression
- Throws:
IOException- upon an IO error or parsing error
-
populateGlobalVariableNameToOffsetMappings
Adds {varName -> offset} mappings to the tuples so that global variables can be set by the interpreter while processing filename and name=value entries from the command-line. Also sends function names to the tuples, to provide the back end with names to invalidate if name=value assignments are passed in via the -v or ARGV arguments.- Parameters:
tuples- The tuples to add the mapping to.
-