class KeywordBasedParser extends Parser
A StructureParser reads MMT declarations (but not objects) and defers to continuation functions for the found StructuralElement, ParsingUnits, and SourceErrors.
This class provides 3 things
1) High-level read methods that read MMT-related entities from a stream, which implementing classes can use. These methods throw do not read more than necessary from the stream and throw SourceError where appropriate.
2) It is stateless and maintains the parse state via an implicit argument of type ParserState in most functions.
3) It leaves processing of MMT entities application-independently via high-level continuation functions.
- Source
- StructureParser.scala
- Alphabetic
- By Inheritance
- KeywordBasedParser
- Parser
- LeveledExtension
- ObjectParser
- StructureParser
- FormatBasedExtension
- Extension
- Logger
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new KeywordBasedParser(objectParser: ObjectParser)
Type Members
-
case class
LocalError(s: String) extends ExtensionError with Product with Serializable
a custom error class for this extension
a custom error class for this extension
- Definition Classes
- Extension
-
class
Features extends AnyRef
holds the structural features and patterns that are available during parsing
holds the structural features and patterns that are available during parsing
- Attributes
- protected
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
apply(ps: ParsingStream)(implicit cont: StructureParserContinuations): StructuralElement
the main interface function: parses a stream and registers all elements (usually a single document) in it
the main interface function: parses a stream and registers all elements (usually a single document) in it
- ps
the encapsulated input stream
- cont
continuations for errors and parsed elements
- returns
the element into which the stream was parsed (of the type corresponding to ps.parentInfo)
- Definition Classes
- KeywordBasedParser → StructureParser
-
def
apply(pu: ParsingUnit)(implicit errorCont: ErrorHandler): ParseResult
relegates to objectParser
relegates to objectParser
- Definition Classes
- Parser → ObjectParser
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
asInterpreter: OneStepInterpreter
an interpreter that does not check
an interpreter that does not check
- Definition Classes
- Parser
-
def
catchErrors[A](msg: String, recoverWith: ⇒ A)(code: ⇒ A): A
like its partner but with return value
like its partner but with return value
- Attributes
- protected
- Definition Classes
- Extension
-
def
catchErrors(msg: String)(code: ⇒ Unit): Unit
convenience method for wrapping code in error handler that throws LocalError
convenience method for wrapping code in error handler that throws LocalError
- Attributes
- protected
- Definition Classes
- Extension
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
val
controller: Controller
the controller that this extension is added to; only valid after creation of the extension, i.e., will return null if used in a non-lazy val-field
the controller that this extension is added to; only valid after creation of the extension, i.e., will return null if used in a non-lazy val-field
- Attributes
- protected
- Definition Classes
- Extension
-
def
currentSourceRegion(implicit state: ParserState): SourceRegion
the region from the start of the current structural element to the current position
the region from the start of the current structural element to the current position
- Attributes
- protected
-
lazy val
defaultPrefix: String
- Definition Classes
- Extension
-
def
destroy: Unit
extension-specific cleanup (override as needed, empty by default)
extension-specific cleanup (override as needed, empty by default)
Extensions may create persistent data structures and threads, but they must clean up after themselves in this method
- Definition Classes
- LeveledExtension → Extension
-
def
destroyWhenRemainingTasksFinished: Unit
convenience for calling waitUntilRemainingTasksFinished and then destroy
convenience for calling waitUntilRemainingTasksFinished and then destroy
- Definition Classes
- Extension
-
def
end(s: ContainerElement[_])(implicit state: ParserState): Unit
called at the end of a document or module, does common bureaucracy
called at the end of a document or module, does common bureaucracy
- Attributes
- protected
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
errorCont(e: ⇒ SourceError)(implicit state: ParserState): Unit
A continuation function called on every error that occurred
A continuation function called on every error that occurred
- Attributes
- protected
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
val
format: String
- Definition Classes
- KeywordBasedParser → Parser
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
getFeatures(cont: Context): Features
- Attributes
- protected
-
def
getFeatures(mp: MPath): Features
auxiliary function to collect all structural feature rules in a given context
auxiliary function to collect all structural feature rules in a given context
- Attributes
- protected
-
def
getFromFirstArgOrEnvvar(args: List[String], name: String, default: String = ""): String
- Attributes
- protected
- Definition Classes
- Extension
-
def
getParseExt(se: StructuralElement, key: String): Option[ParserExtension]
allow to control certain parser extensions i.e.
allow to control certain parser extensions i.e. those with side effects like RuleConstantParser
- Attributes
- protected
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
init(controller: Controller): Unit
MMT initialization (idempotent)
MMT initialization (idempotent)
- Definition Classes
- LeveledExtension → Extension
-
def
initOther(e: Extension): Unit
any extension can initialize other extensions if those are not meant to be added to the ExtensionManager
any extension can initialize other extensions if those are not meant to be added to the ExtensionManager
- Attributes
- protected
- Definition Classes
- Extension
-
def
isApplicable(s: String): Boolean
- returns
true if this extension is applicable
- Definition Classes
- Parser → FormatBasedExtension
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
log(e: Error): Unit
logs an error - always logged
logs an error - always logged
- Attributes
- protected
- Definition Classes
- Logger
-
def
log(s: ⇒ String, subgroup: Option[String] = None): Unit
logs a message with this logger's logprefix
logs a message with this logger's logprefix
- Attributes
- protected
- Definition Classes
- Logger
-
def
logError(s: ⇒ String): Unit
log as an error message
log as an error message
- Attributes
- protected
- Definition Classes
- Logger
-
def
logGroup[A](a: ⇒ A): A
wraps around a group to create nested logging
wraps around a group to create nested logging
- Attributes
- protected
- Definition Classes
- Logger
-
val
logPrefix: String
the prefix used to identify this extension for logging, by default the class name
the prefix used to identify this extension for logging, by default the class name
- Definition Classes
- KeywordBasedParser → Extension → Logger
-
def
logTemp(s: ⇒ String): Unit
temporary logging - always logged
temporary logging - always logged
- Attributes
- protected
- Definition Classes
- Logger
-
def
makeError(reg: SourceRegion, s: String, causedBy: Option[Exception] = None)(implicit state: ParserState): SourceError
convenience function to create SourceError's
convenience function to create SourceError's
- Attributes
- protected
-
def
makeErrorThrower(msg: String): ErrorHandler
an ErrorHandler that wraps an error in a LocalError and throws it
an ErrorHandler that wraps an error in a LocalError and throws it
- Attributes
- protected
- Definition Classes
- Extension
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- val noFeatures: Features
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
val
objectLevel: ObjectParser
- Definition Classes
- Parser → LeveledExtension
-
def
readDPath(implicit state: ParserState): DPath
read a DPath from the stream throws SourceError iff ill-formed or empty
-
def
readDelimiter(delims: String*)(implicit state: ParserState): String
reads one out of a list of permitted delimiters
reads one out of a list of permitted delimiters
- delims
the permitted delimiter
- returns
the read delimiter throws SourceError iff anything else found
-
def
readInModule(mod: ModuleOrLink, context: Context, features: Features)(state: ParserState): Unit
the main loop for reading declarations that can occur in a theory
the main loop for reading declarations that can occur in a theory
- mod
the containing module (added already)
- context
the context (including the containing module)
- features
the patterns and structural features of the meta-theory (precomputed in readInDocument) this function handles one declaration if possible, then calls itself recursively
-
def
readMPath(newBase: Path)(implicit state: ParserState): (SourceRef, MPath)
read a MPath from the stream throws SourceError iff ill-formed or empty
-
def
readName(implicit state: ParserState): LocalName
read a LocalName from the stream throws SourceError iff ill-formed or empty
-
def
readParsedObject(context: Context, topRule: Option[ParsingRule] = None)(implicit state: ParserState): (String, SourceRegion, ParseResult)
reads until the object delimiter and parses the found string
reads until the object delimiter and parses the found string
- returns
the raw string, the region, and the parsed term
-
def
readSPath(newBase: Path)(implicit state: ParserState): GlobalName
read a GlobalName from the stream throws SourceError iff ill-formed or empty
- val report: Report
-
def
resolveDeclarationName[A <: Declaration](cls: Class[A], parent: ModuleOrLink, name: LocalName)(implicit state: ParserState): LocalName
resolve a name in a realized theory (e.g, the domain of a link) and report error on failure
resolve a name in a realized theory (e.g, the domain of a link) and report error on failure
- Attributes
- protected
-
def
seCont(se: StructuralElement)(implicit state: ParserState): Unit
A continuation function called on every StructuralElement that was found
A continuation function called on every StructuralElement that was found
For container elements (documents, modules with body), this must be called on the empty element first and then on each child, finally end(se) must be called on the container element. This holds accordingly for nested declared modules.
- Attributes
- protected
-
def
start(args: List[String]): Unit
extension-specific initialization (override as needed, empty by default)
extension-specific initialization (override as needed, empty by default)
- Definition Classes
- Extension
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
waitUntilRemainingTasksFinished: Unit
extensions that process tasks in separate threads should override this and wait until those threads are done
extensions that process tasks in separate threads should override this and wait until those threads are done
- Definition Classes
- Extension