Class Parser
java.lang.Object
org.jfuncmachine.sexprlang.parser.Parser
A simple S-expression parser
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic SexprItemParses a file and returns the first S-expressionstatic SexprItemParses a file and returns either the first or all S-expressions in itstatic SexprItemparseFile(String filename, boolean parseMultipleSexprs, SymbolMatcher symbolMatcher) Parses S-expressions from a file using the specified matcher to identify symbolsstatic SexprItemparseFile(String filename, SymbolMatcher symbolMatcher) Parses an S-expression from a file using the specified matcher to identify symbolsstatic SexprItemparseString(String str) Parses an S-expression from a Stringstatic SexprItemparseString(String str, boolean parseMultipleSexprs) Parses an S-expression from a Stringstatic SexprItemparseString(String str, boolean parseMultipleSexprs, String filename) Parses an S-expression from a Stringstatic SexprItemparseString(String str, String filename) Parses an S-expression from a Stringstatic SexprItemparseString(String str, String filename, boolean parseMultipleSexprs, SymbolMatcher symbolMatcher) Parses an S-expression from a string using the specified matcher to identify symbolsstatic SexprItemparseString(String str, String filename, SymbolMatcher symbolMatcher) Parses an S-expression from a string using the specified matcher to identify symbols
-
Method Details
-
parseFile
Parses a file and returns the first S-expression- Parameters:
filename- The file to parse- Returns:
- The first S-expression in the file
- Throws:
IOException- If there is an error reading or parsing the file
-
parseFile
Parses a file and returns either the first or all S-expressions in it- Parameters:
filename- The file to parseparseMultipleSexprs- True if the parser should return all S-expressions instead of just the first- Returns:
- Either the first or all the S-expressions in the file
- Throws:
IOException- If there is an error reading or parsing the file
-
parseString
Parses an S-expression from a String- Parameters:
str- The string to parse- Returns:
- The first S-expression in the string
- Throws:
IOException- If there is an error parsing the string
-
parseString
Parses an S-expression from a String- Parameters:
str- The string to parseparseMultipleSexprs- If true, all S-expressions in the file are parsed, not just the first- Returns:
- The first S-expression in the string
- Throws:
IOException- If there is an error parsing the string
-
parseString
Parses an S-expression from a String- Parameters:
str- The string to parsefilename- The filename to use as the filename in the generated S-expressions- Returns:
- The first S-expression in the string
- Throws:
IOException- If there is an error parsing the string
-
parseString
public static SexprItem parseString(String str, boolean parseMultipleSexprs, String filename) throws IOException Parses an S-expression from a String- Parameters:
str- The string to parseparseMultipleSexprs- If true, all S-expressions in the file are parsed, not just the firstfilename- The filename to use as the filename in the generated S-expressions- Returns:
- The first S-expression in the string
- Throws:
IOException- If there is an error parsing the string
-
parseFile
Parses an S-expression from a file using the specified matcher to identify symbols- Parameters:
filename- The file to parsesymbolMatcher- The matcher that determines if a character is part of a symbol- Returns:
- The first S-expression matched
- Throws:
IOException- If there is an error reading or parsing the file
-
parseFile
public static SexprItem parseFile(String filename, boolean parseMultipleSexprs, SymbolMatcher symbolMatcher) throws IOException Parses S-expressions from a file using the specified matcher to identify symbols- Parameters:
filename- The file to parseparseMultipleSexprs- If true, all S-expressions in the file are parsed, not just the firstsymbolMatcher- The matcher that determines if a character is part of a symbol- Returns:
- The first S-expression matched
- Throws:
IOException- If there is an error reading or parsing the file
-
parseString
public static SexprItem parseString(String str, String filename, SymbolMatcher symbolMatcher) throws IOException Parses an S-expression from a string using the specified matcher to identify symbols- Parameters:
str- The string to parsefilename- The filename to use as the filename in the generated S-expression itemssymbolMatcher- The matcher that determines if a character is part of a symbol- Returns:
- The first S-expression matched
- Throws:
IOException- If there is an error parsing the string
-
parseString
public static SexprItem parseString(String str, String filename, boolean parseMultipleSexprs, SymbolMatcher symbolMatcher) throws IOException Parses an S-expression from a string using the specified matcher to identify symbols- Parameters:
str- The string to parsefilename- The filename to use as the filename in the generated S-expression itemsparseMultipleSexprs- If true, all S-expressions in the file are parsed, not just the firstsymbolMatcher- The matcher that determines if a character is part of a symbol- Returns:
- The first S-expression matched
- Throws:
IOException- If there is an error parsing the string
-