Skip to main content



      Home
Home » Modeling » TMF (Xtext) » How xtext Lexer and Parser works?
How xtext Lexer and Parser works? [message #892816] Fri, 29 June 2012 16:56 Go to next message
Eclipse UserFriend
Hello!

Where can I find the information, how xtext Lexer and Parser works?

I have wrote some xtext grammars, but I still don't understand, what's under the hood.
Re: How xtext Lexer and Parser works? [message #892845 is a reply to message #892816] Sat, 30 June 2012 07:32 Go to previous message
Eclipse UserFriend
Hi,

ANTLR is under the hood

so let us take the sample grammar

Model:
	greetings+=Greeting*;
	
Greeting:
	'Hello' name=ID '!';


and the sample file

Hello Me!
Hello You!


the lexer divides the file into a token stream

Keyword:"Hello" ID Keyword:"!"
Keyword:"Hello" ID Keyword:"!"


and the parser then assembles the ast based on the rules in the grammar

-Model
--Greeting(name=Me)
--Greeting(name=You)

Maybe some basic reading on formal languages and parsing helps

~Christian
Previous Topic:mwe2 with resources from different projects
Next Topic:extraneous input '}' expecting EOF
Goto Forum:
  


Current Time: Sun Jul 13 20:31:23 EDT 2025

Powered by FUDForum. Page generated in 0.03749 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top