/* * Copyright (c) 2013 Patrick Scheibe * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package de.halirutan.mathematica.parsing.prattparser; import com.intellij.lang.ASTNode; import com.intellij.lang.ParserDefinition; import com.intellij.lang.PsiParser; import com.intellij.lexer.Lexer; import com.intellij.openapi.project.Project; import com.intellij.psi.FileViewProvider; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.tree.IFileElementType; import com.intellij.psi.tree.TokenSet; import de.halirutan.mathematica.lexer.MathematicaLexer; import de.halirutan.mathematica.parsing.MathematicaElementTypes; import de.halirutan.mathematica.parsing.psi.impl.MathematicaPsiFileImpl; import org.jetbrains.annotations.NotNull; /** * @author patrick (3/27/13) */ public class MathematicaParserDefinition implements ParserDefinition { @NotNull @Override public Lexer createLexer(Project project) { return new MathematicaLexer(); } @Override public PsiParser createParser(Project project) { return new MathematicaParser(); } @Override public IFileElementType getFileNodeType() { return MathematicaElementTypes.FILE; } @NotNull @Override public TokenSet getWhitespaceTokens() { return MathematicaElementTypes.WHITE_SPACES; } @NotNull @Override public TokenSet getCommentTokens() { return MathematicaElementTypes.COMMENTS; } @NotNull @Override public TokenSet getStringLiteralElements() { return MathematicaElementTypes.STRING_LITERALS; } @NotNull @Override public PsiElement createElement(ASTNode node) { return MathematicaElementTypes.Factory.create(node); } @Override public PsiFile createFile(FileViewProvider viewProvider) { return new MathematicaPsiFileImpl(viewProvider); } @Override public SpaceRequirements spaceExistanceTypeBetweenTokens(ASTNode left, ASTNode right) { return SpaceRequirements.MAY; } }