Skip to content

Commit

Permalink
Merge pull request #37 from pherrymason/0.0.7
Browse files Browse the repository at this point in the history
v0.0.7
  • Loading branch information
pherrymason authored Aug 2, 2024
2 parents 3c2634b + 021ad78 commit a6fd018
Show file tree
Hide file tree
Showing 16 changed files with 1,571 additions and 45 deletions.
43 changes: 37 additions & 6 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,50 @@ on:
branches: [ "main" ]

jobs:

build:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: '1.21'

- name: Build
run: cd server/cmd/lsp && go build -v

- name: Test
run: cd server && go test -v ./...
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4

-
name: Set up Go
uses: actions/setup-go@v5

-
name: Build
uses: crazy-max/ghaction-xgo@v3
with:
xgo_version: latest
go_version: 1.21
dest: /home/runner/work/repo-name/builds
prefix: c3-lsp
targets: windows/amd64,linux/amd64,linux/arm64,darwin/arm64
v: true
x: false
race: false
ldflags: -s -w
buildmode: default
pkg: cmd/lsp
working_dir: server
trimpath: true

-
name: Upload assets
uses: actions/upload-artifact@v4
with:
name: c3-lsp
path: /home/runner/work/repo-name/builds/*
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
*.log
assets
tree-sitter-c3
parser/target
server/bin
parser/chumsky
server/internal/parser
server/bin
dist/
4 changes: 4 additions & 0 deletions client/vscode/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ module.exports = {
args.push('--log-path '+config.get('log.path'));
}

if (config.get('c3.version')) {
args.push('--lang-version '+config.get('c3.version'));
}

const serverOptions = {
run: {
command: executable,
Expand Down
7 changes: 6 additions & 1 deletion client/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "c3-lsp-client",
"displayName": "C3 Language Server client",
"description": "Language Server client for C3. Download C3 server from https://github.com/pherrymason/c3-lsp",
"version": "0.0.2",
"version": "0.0.3",
"publisher": "rferras",
"engines": {
"vscode": "^1.40.0"
Expand Down Expand Up @@ -53,6 +53,11 @@
"type": "boolean",
"default": false,
"markdownDescription": "Sends crash reports to server to help fixing bugs."
},
"c3lspclient.lsp.c3.version": {
"type": "string",
"default": null,
"markdownDescription": "Specify C3 language version. If omited, LSP will use the last version it supports."
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion server/cmd/lsp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

const version = "0.0.7"
const prerelease = true
const prerelease = false
const appName = "C3-LSP"

func getVersion() string {
Expand Down
36 changes: 34 additions & 2 deletions server/internal/lsp/ast/ast.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package ast

import sitter "github.com/smacker/go-tree-sitter"
import (
"github.com/pherrymason/c3-lsp/pkg/option"
sitter "github.com/smacker/go-tree-sitter"
)

type Position struct {
Line, Column uint
Expand Down Expand Up @@ -84,6 +87,30 @@ type PropertyValue struct {
Value Expression
}

const (
StructTypeNormal = iota
StructTypeUnion
StructTypeBitStruct
)

type StructType int

type StructDecl struct {
ASTNodeBase
Name string
BackingType option.Option[TypeInfo]
Members []StructMemberDecl
StructType StructType
Implements []string
}

type StructMemberDecl struct {
ASTNodeBase
Names []Identifier
Type TypeInfo
BitRange option.Option[[2]uint]
}

type FunctionDecl struct {
ASTNodeBase
Name *Identifier
Expand All @@ -104,7 +131,7 @@ type FunctionCall struct {
type TypeInfo struct {
ASTNodeBase
ResolveStatus int
Name string
Identifier Identifier
Pointer uint
Optional bool
BuiltIn bool
Expand All @@ -114,6 +141,7 @@ type TypeInfo struct {
type Identifier struct {
ASTNodeBase
Name string
Path string
}

type Expression interface {
Expand All @@ -124,6 +152,10 @@ type Literal struct {
ASTNodeBase
Value string
}
type NumberLiteral struct {
ASTNodeBase
Value uint
}

type BoolLiteral struct {
ASTNodeBase
Expand Down
38 changes: 38 additions & 0 deletions server/internal/lsp/ast/ast_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,41 @@ func (d *ASTBaseNodeBuilder) WithStartEnd(startRow uint, startCol uint, endRow u
d.bn.EndPos = Position{endRow, endCol}
return d
}

type IdentifierBuilder struct {
bi Identifier
bn ASTBaseNodeBuilder
}

func NewIdentifierBuilder() *IdentifierBuilder {
return &IdentifierBuilder{
bi: Identifier{},
bn: *NewBaseNodeBuilder(),
}
}

func (i *IdentifierBuilder) WithName(name string) *IdentifierBuilder {
i.bi.Name = name
return i
}
func (i *IdentifierBuilder) WithPath(path string) *IdentifierBuilder {
i.bi.Path = path
return i
}

func (i *IdentifierBuilder) WithSitterPos(node *sitter.Node) *IdentifierBuilder {
i.bn.WithSitterPosRange(node.StartPoint(), node.EndPoint())
return i
}

func (i *IdentifierBuilder) WithStartEnd(startRow uint, startCol uint, endRow uint, endCol uint) *IdentifierBuilder {
i.bn.WithStartEnd(startRow, startCol, endRow, endCol)
return i
}

func (i *IdentifierBuilder) Build() Identifier {
ident := i.bi
ident.ASTNodeBase = i.bn.Build()

return ident
}
Loading

0 comments on commit a6fd018

Please sign in to comment.