lexeme default vs. :default and :lexeme

27 views
Skip to first unread message

Ruslan Shvedov

unread,
Feb 25, 2014, 11:25:30 AM2/25/14
to marpa-...@googlegroups.com
Just caught myself thinking that 

:default ::= action => [name, values] 
:lexeme default ::= latm => 1

looks like a bit more consistent (well, for some definitions of consistency at least) syntax than the current

:default ::= action => [name, values] 
lexeme default = latm => 1

:default ::= ... and :lexeme ~ ... are pseudo-rules, but lexeme default = ... is a statement. This is by design, so I'd appreciate any information from those in the know.

Jeffrey Kegler

unread,
Feb 25, 2014, 1:11:50 PM2/25/14
to marpa-...@googlegroups.com
The "logic" goes like this.  Note the "=" instead of "::=".  This signals that the statement is not a rule, and is non-lexical -- it's location in the file does not matter.  Since it's not a rule, it does not take the form LHS ::= RHS2 ...

The initial colon was for pseudo-symbols.  Since the lexeme default statement is not a rule, it does not have a LHS, so what appears before the equal sign ("=") is not considered symbol, pseudo- or otherwise.

I am, frankly, less than 100% happy with this "logic" and my design choices, but there they are.

In an ironic way, it does show Marpa's strength.  Because it allows and exploits ambiguity, I can "unpaint myself out of the corner", by introducing new statements and syntax.  Languages based on other parsers cannot evolve in that way.

-- jeffrey

--
You received this message because you are subscribed to the Google Groups "marpa parser" group.
To unsubscribe from this group and stop receiving emails from it, send an email to marpa-parser...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ruslan Shvedov

unread,
Feb 25, 2014, 2:44:16 PM2/25/14
to marpa-...@googlegroups.com
Thanks for explaining. 

The thing was I thought if SLIF DSL could benefit from less diverse/more strict — (pseudo-)rule/adverbs only — syntax and model, where

lexeme default statement becomes :lexeme default ::= pseudo rule

inaccessible statement becomes an adverb of 
:default and/or :lexeme default pseudo-rules, e.g. 

:default action => [name, values] inaccessible => ok

and

named event statement — event ( 'name' | name ) = ( completed | nulled | predicted ) symbol — becomes an adverb of the rule whose LHS symbol is, e.g. 

                event subtext = completed <subtext>
                event 'A[]' = nulled <A>
                event '^a' = predicted A

become

                subtext ::= ... event completed => subtext
                <A> ::= ... event nulled => 'A[]'
                A ::= ... event predicted => '^a'

Heretic as it is, but I thought I'd better braindump it. :)

What do you think?

Jeffrey Kegler

unread,
Feb 25, 2014, 3:10:39 PM2/25/14
to marpa-...@googlegroups.com
There's been talk of alternative interfaces to Libmarpa, and multiple interfaces are the real solution here.  In fact, the SLIF only exists because Peter Stuifzand decided my ways of interfacing Libmarpa in my public examples weren't good enough, and took it upon himself to write his own.   Once he'd done so, I saw that Peter was right -- and the SLIF is a direct descendant of Peter's interface.  [ Though any feature of it you don't like is probably my idea. :-) ]

-- jeffrey

Ruslan Shvedov

unread,
Feb 25, 2014, 3:15:45 PM2/25/14
to marpa-...@googlegroups.com
Well, what can I say? Fair enough. :)
Reply all
Reply to author
Forward
0 new messages