OMetaJS String Matching Syntax
OMeta can parse more than just text streams. It can operate on typed objects that the host language understands. That's why we have different string matching syntax for different purposes.
#abcor ``abc` => match the string object 'abc'
'abc'=> match the string object 'abc'
'c'=> match the string object 'c'
orseq("abc")` => match the sequence of string objects 'a', 'b', 'c'
"abc"=> match token('abc')
When matching single string characters use
'a'. When parsing text streams, it is capturing on a per character basis. When it takes each character, it's trying to compare it against
'abc', then of course it doesn't work. For
'abc' to actually work, the object it captured must actually be
'abc' as well, and that can only happen if you say passed in a typed string object!
When matching a word or phrase, use
"while I say this". You can use whitespace including newlines in between the words/phrases, but you cannot start with spaces or newlines. For example, this does not work:
When matching a literal sequence of characters or special characters use the
seq higher order rule, or use the ```literalsequence''
. For example: this one seq("\n\n")` matches 2 newlines.
However none of this applies to string parameters that are passed into higher order rules. All string parameters will be considered string literals. Therefore there is no difference between