Skip to content

Commit

Permalink
[ agda ] Fix AST creation
Browse files Browse the repository at this point in the history
  • Loading branch information
ice1000 committed May 16, 2019
1 parent d3c1267 commit 4dac717
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/org/ice1000/tt/psi/agda/parser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class AgdaTokenType(debugName: String) : IElementType(debugName, AgdaLanguage.IN
@JvmField val IDENTIFIERS = TokenSet.create(AgdaTypes.IDENTIFIER)

fun fromText(text: String, project: Project) = PsiFileFactory.getInstance(project).createFileFromText(AgdaLanguage.INSTANCE, text)?.firstChild
fun createSignature(text: String, project: Project) = fromText(text, project) as? AgdaSignature
fun createLayout(text: String, project: Project) = fromText(text, project) as? AgdaLayout
fun createSignature(text: String, project: Project) = createLayout(text, project)?.firstChild as? AgdaSignature
fun createExp(text: String, project: Project) = createSignature("f : $text", project)?.exp
fun createStr(text: String, project: Project) = createExp(text, project) as? AgdaString
}
Expand Down
2 changes: 1 addition & 1 deletion src/org/ice1000/tt/psi/layout.kt
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class LayoutLexer(
when (state) {
WaitingForLayout -> {
if (token.isCode && token.column > indentStack.peek()) {
tokens.add(i, virtualToken(layoutStart, tokens[i - 1]))
tokens.add(i, virtualToken(layoutStart, tokens[(i - 1).coerceAtLeast(0)]))
i++
indentStack.push(token.column)
if (token.elementType !in layoutCreatingTokens) state = Normal
Expand Down

0 comments on commit 4dac717

Please sign in to comment.